From 1b7fbfbc67a0268110a84e6b1e981ae4e641a350 Mon Sep 17 00:00:00 2001 From: TomNewChao Date: Fri, 26 Jan 2024 11:49:05 +0800 Subject: [PATCH] fix review about mgr/dashboard/frontend:Ceph dashboard supports multiple languages 1.Set the default value of DASHBOARD_FRONTEND_LANGS to 'ALL'. 2.Fix bug about receive the `"ALL"` or `'ALL'`from process.env.DASHBOARD_FRONTEND_LANGS that is not equal 'ALL' in cd.js. 3.When we use the make-dist script to build the front-end UI to release the ceph, we should add DASHBOARD_FRONTEND_LANGS="ALL" to support multiple languages. Signed-off-by: TomNewChao (cherry picked from commit 913b52d6eefc1c1c763c03f2e6e54cceae5601ff) --- CMakeLists.txt | 2 +- ceph.spec.in | 10 ---------- make-dist | 2 +- src/pybind/mgr/dashboard/frontend/cd.js | 1 + .../frontend/cypress/e2e/ui/language.e2e-spec.ts | 2 +- 5 files changed, 4 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d70d471ab81..ab453b66a6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -728,7 +728,7 @@ if(WITH_SYSTEM_NPM) message(FATAL_ERROR "Can't find npm.") endif() endif() -set(DASHBOARD_FRONTEND_LANGS "" CACHE STRING +set(DASHBOARD_FRONTEND_LANGS "ALL" CACHE STRING "List of comma separated ceph-dashboard frontend languages to build. \ Use value `ALL` to build all languages") CMAKE_DEPENDENT_OPTION(WITH_MGR_ROOK_CLIENT "Enable the mgr's Rook support" ON diff --git a/ceph.spec.in b/ceph.spec.in index 89f5cc5823c..ed367465527 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -23,7 +23,6 @@ %bcond_with make_check %bcond_with cmake_verbose_logging %bcond_without ceph_test_package -%bcond_without mgr_dashboard_frontend_support_multi_language %ifarch s390 %bcond_with tcmalloc %else @@ -479,9 +478,6 @@ BuildRequires: libnuma-devel %if 0%{?rhel} >= 8 BuildRequires: /usr/bin/pathfix.py %endif -%if 0%{with mgr_dashboard_frontend_support_multi_language} -BuildRequires: npm -%endif %description Ceph is a massively scalable, open-source, distributed storage system that runs @@ -1386,13 +1382,7 @@ cmake .. \ -DSYSTEMD_SYSTEM_UNIT_DIR:PATH=%{_unitdir} \ -DWITH_MANPAGE:BOOL=ON \ -DWITH_PYTHON3:STRING=%{python3_version} \ -%if 0%{with mgr_dashboard_frontend_support_multi_language} - -DWITH_MGR_DASHBOARD_FRONTEND:BOOL=ON \ - -DDASHBOARD_FRONTEND_LANGS:STRING="cs,de,es,fr,id,it,ja,ko,pl,zh-Hans,zh-Hant,pt" \ - -DWITH_SYSTEM_NPM:BOOL=ON \ -%else -DWITH_MGR_DASHBOARD_FRONTEND:BOOL=OFF \ -%endif %if 0%{?suse_version} -DWITH_RADOSGW_SELECT_PARQUET:BOOL=OFF \ %endif diff --git a/make-dist b/make-dist index 41cee50a6d3..388fae8a2a7 100755 --- a/make-dist +++ b/make-dist @@ -140,7 +140,7 @@ build_dashboard_frontend() { echo "Building ceph-dashboard frontend with build:localize script"; # we need to use "--" because so that "--configuration production" # survives accross all scripts redirections inside package.json - npm run build:localize -- --configuration production + DASHBOARD_FRONTEND_LANGS="ALL" npm run build:localize -- --configuration production deactivate cd $CURR_DIR rm -rf $TEMP_DIR diff --git a/src/pybind/mgr/dashboard/frontend/cd.js b/src/pybind/mgr/dashboard/frontend/cd.js index 34d0ce29f2d..db92308d585 100755 --- a/src/pybind/mgr/dashboard/frontend/cd.js +++ b/src/pybind/mgr/dashboard/frontend/cd.js @@ -46,6 +46,7 @@ function prepareLocales() { } let langs = process.env.DASHBOARD_FRONTEND_LANGS || ''; + langs = langs.replace(/\"\'/g, '') if (langs == 'ALL') { logger(`Preparing build of all languages.`); return; diff --git a/src/pybind/mgr/dashboard/frontend/cypress/e2e/ui/language.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/cypress/e2e/ui/language.e2e-spec.ts index fa20f0be542..86b170d4320 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/e2e/ui/language.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/e2e/ui/language.e2e-spec.ts @@ -14,6 +14,6 @@ describe('Shared pages', () => { it('should check all available languages', () => { language.getLanguageBtn().click(); - language.getAllLanguages().should('have.length', 1).should('contain.text', 'English'); + language.getAllLanguages().should('have.length', 13).should('contain.text', 'English'); }); }); -- 2.39.5