From a19f7c12c45c657dbf8f43649f7cc926141e9240 Mon Sep 17 00:00:00 2001 From: Gowtham Shanmugasundaram Date: Tue, 2 Aug 2022 21:31:55 +0530 Subject: [PATCH] Fix Overview tab is present under Storage section Signed-off-by: Gowtham Shanmugasundaram --- .gitignore | 6 + Dockerfile | 2 +- Dockerfile.ci | 4 +- Dockerfile.mco.ci | 5 +- Dockerfile.prod | 4 +- package.json | 50 ++----- packages/odf/features.ts | 7 - plugins/mco/console-extensions.json | 83 ++++++++++++ plugins/mco/console-plugin.json | 15 +++ .../odf/console-extensions.json | 126 +----------------- plugins/odf/console-plugin.json | 27 ++++ scripts/generatePluginPackage.ts | 7 + webpack.config.ts | 21 +-- 13 files changed, 168 insertions(+), 189 deletions(-) create mode 100644 plugins/mco/console-extensions.json create mode 100644 plugins/mco/console-plugin.json rename console-extensions.json => plugins/odf/console-extensions.json (72%) create mode 100644 plugins/odf/console-plugin.json create mode 100644 scripts/generatePluginPackage.ts diff --git a/.gitignore b/.gitignore index 730ad1d09..cbe246232 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,9 @@ node_modules dist .cache-loader cypress/cypress-a11y-report.json +plugins/odf/package.json +plugins/odf/dist +plugins/odf/.cache-loader +plugins/mco/package.json +plugins/mco/dist +plugins/mco/.cache-loader diff --git a/Dockerfile b/Dockerfile index 6df4cfed0..0e71be455 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ RUN yarn global add http-server RUN export PATH="$(yarn global bin):$PATH" FROM serverpackage -COPY --from=builder /app/dist /app +COPY --from=builder /app/plugins/odf/dist /app COPY --from=builder /app/http-server.sh . ENTRYPOINT [ "./http-server.sh", "./app" ] diff --git a/Dockerfile.ci b/Dockerfile.ci index 954d4a0ef..742be7a64 100644 --- a/Dockerfile.ci +++ b/Dockerfile.ci @@ -10,7 +10,7 @@ RUN yarn global add http-server RUN export PATH="$(yarn global bin):$PATH" FROM serverpackage -COPY --from=builder /app/dist /app -COPY --from=builder /app/dist /app/compatibility +COPY --from=builder /app/plugins/odf/dist /app +COPY --from=builder /app/plugins/odf/dist /app/compatibility COPY --from=builder /app/http-server.sh . ENTRYPOINT [ "./http-server.sh", "./app" ] diff --git a/Dockerfile.mco.ci b/Dockerfile.mco.ci index fef94e5ae..6e35ff86e 100644 --- a/Dockerfile.mco.ci +++ b/Dockerfile.mco.ci @@ -1,7 +1,6 @@ FROM node:15 AS builder WORKDIR /app COPY . /app -RUN sed -i "s/\"name\": \"odf-console\"/\"name\": \"odf-multicluster-console\"/" package.json RUN yarn install RUN yarn build-mco @@ -11,7 +10,7 @@ RUN yarn global add http-server RUN export PATH="$(yarn global bin):$PATH" FROM serverpackage -COPY --from=builder /app/dist /app -COPY --from=builder /app/dist /app/compatibility +COPY --from=builder /app/plugins/mco/dist /app +COPY --from=builder /app/plugins/mco/dist /app/compatibility COPY --from=builder /app/http-server.sh . ENTRYPOINT [ "./http-server.sh", "./app" ] diff --git a/Dockerfile.prod b/Dockerfile.prod index 79155796c..6e10113ca 100644 --- a/Dockerfile.prod +++ b/Dockerfile.prod @@ -8,12 +8,12 @@ RUN git fetch origin ${TARGET_BRANCH} && git checkout origin/${TARGET_BRANCH} RUN yarn install --prod=false RUN yarn build -RUN mv ./dist ../app +RUN mv ./plugins/odf/dist ../app RUN git fetch origin ${TARGET_BRANCH}-compatibility && git checkout origin/${TARGET_BRANCH}-compatibility RUN yarn install RUN yarn build -RUN mv ./dist ../compatibility +RUN mv ./plugins/odf/dist ../compatibility FROM registry.access.redhat.com/ubi8/nginx-118 ADD default.conf "${NGINX_CONFIGURATION_PATH}" diff --git a/package.json b/package.json index 6c85c1b82..d83574048 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "odf-console", + "name": "odf-plugin", "version": "0.0.0", - "description": "ODF console", + "description": "ODF plugin", "license": "MIT", "private": true, "workspaces": [ @@ -9,17 +9,21 @@ ], "repository": "git@github.com:red-hat-storage/odf-console.git", "scripts": { - "clean": "rm -rf ./dist", + "clean": "yarn clean-mco && yarn clean-odf", + "clean-mco": "cd plugins/mco && rm -rf ./dist", + "clean-odf": "cd plugins/odf && rm -rf ./dist", "cypress-merge": "mochawesome-merge ./gui-test-screenshots/cypress_report*.json > ./gui-test-screenshots/cypress.json", "cypress-generate": "marge -o ./gui-test-screenshots/ -f cypress-report -t 'OpenShift Console Cypress Test Results' -p 'OpenShift Cypress Test Results' --showPassed false --assetsDir ./gui-test-screenshots/cypress/assets ./gui-test-screenshots/cypress.json", "cypress-postreport": "yarn cypress-merge && yarn cypress-generate", "test-cypress": "node_modules/.bin/cypress open --config-file ./cypress/cypress.json --env openshift=true", "test-cypress-headless": "node --max-old-space-size=4096 node_modules/.bin/cypress run --config-file ./cypress/cypress.json --env openshift=true --browser ${BRIDGE_E2E_BROWSER_NAME:=chrome} --headless", - "build": "yarn clean && NODE_ENV=production I8N_NS=plugin__odf-console yarn ts-node ./node_modules/.bin/webpack", - "build-mco": "yarn clean && NODE_ENV=production MODE=MCO I8N_NS=plugin__odf-multicluster-console yarn ts-node ./node_modules/.bin/webpack", - "build-dev": "yarn clean && yarn ts-node ./node_modules/.bin/webpack", - "dev": "yarn clean && I8N_NS=plugin__odf-console yarn ts-node ./node_modules/.bin/webpack serve --progress", - "dev-mco": "yarn clean && MODE=MCO I8N_NS=plugin__odf-multicluster-console yarn ts-node ./node_modules/.bin/webpack serve", + "build:plugin": "yarn clean-${PLUGIN} && cd plugins/${PLUGIN} && ts-node ../../scripts/generatePluginPackage.ts && NODE_ENV=${NODE_ENV} I8N_NS=${I8N_NS} yarn ts-node ../../node_modules/.bin/webpack -c ../../webpack.config.ts", + "build": "NODE_ENV=production PLUGIN=odf I8N_NS=plugin__odf-console yarn build:plugin", + "build-mco": "NODE_ENV=production PLUGIN=mco I8N_NS=plugin__odf-multicluster-console yarn build:plugin", + "build-dev": "NODE_ENV=development PLUGIN=odf I8N_NS=plugin__odf-console yarn build:plugin", + "server:plugin": "yarn clean-${PLUGIN} && cd plugins/${PLUGIN} && ts-node ../../scripts/generatePluginPackage.ts && NODE_ENV=development I8N_NS=${I8N_NS} yarn ts-node ../../node_modules/.bin/webpack serve -c ../../webpack.config.ts --progress", + "dev": "PLUGIN=odf I8N_NS=plugin__odf-console yarn server:plugin", + "dev-mco": "PLUGIN=mco I8N_NS=plugin__odf-multicluster-console yarn server:plugin", "http-server": "./http-server.sh ./dist", "ts-node": "ts-node -O '{\"module\":\"commonjs\"}' -I '/node_modules/(?!(@odf)/)/'", "lint-css": "yarn stylelint packages/**/**/*.scss", @@ -112,35 +116,5 @@ "webpack": "5.64.4", "webpack-cli": "4.5.x", "webpack-dev-server": "^4.9.2" - }, - "consolePlugin": { - "name": "odf-console", - "version": "0.0.0", - "displayName": "ODF(OpenShift Data Foundation) Plugin", - "description": "Console plugin for ODF", - "dependencies": { - "@console/pluginAPI": "*" - }, - "exposedModules": { - "dashboard": "@odf/core/components/odf-dashboard/dashboard", - "features": "@odf/core/features", - "wizard": "@odf/core/components/create-storage-system/create-storage-system", - "dataPolicies": "@odf/mco/components/data-policies/data-policies-list", - "createDataPolicy": "@odf/mco/components/data-policies/create-dr-policy/create-dr-policy", - "obc": "@odf/core/components/mcg/ObjectBucketClaim", - "createOBC": "@odf/core/components/mcg/CreateObjectBucketClaim", - "ob": "@odf/core/components/mcg/ObjectBucket", - "ocs": "@odf/ocs/dashboards/odf-system-dashboard", - "blockPoolDetailsPage": "@odf/ocs/block-pool/BlockPoolDetailsPage", - "createBlockPools": "@odf/ocs/block-pool/CreateBlockPool", - "bsCreate": "@odf/core/components/create-bs/create-bs-page", - "mcoDashboard": "@odf/mco/components/mco-dashboard/dashboard", - "nsCreate": "@odf/core/components/namespace-store/create-namespace-store", - "bcCreate": "@odf/core/components/bucket-class/create-bc", - "bsDetails": "@odf/core/components/resource-pages/BackingStoreDetailsPage", - "bcDetails": "@odf/core/components/resource-pages/BucketClassDetailsPage", - "nsDetails": "@odf/core/components/resource-pages/NamespaceStoreDetailsPage", - "editPage": "@odf/core/components/ResourceEditor/GenericResourceEditor" - } } } diff --git a/packages/odf/features.ts b/packages/odf/features.ts index a2883f523..3bead1dea 100644 --- a/packages/odf/features.ts +++ b/packages/odf/features.ts @@ -45,10 +45,6 @@ export const CEPH_FLAG = 'CEPH'; // Based on the existence of StorageCluster export const OCS_FLAG = 'OCS'; -export const MCO_MODE_FLAG = 'MCO'; - -export const isMCO = process.env.MODE === 'MCO'; - export enum FEATURES { // Flag names to be prefixed with "OCS_" so as to seperate from console flags OCS_MULTUS = 'OCS_MULTUS', @@ -106,9 +102,6 @@ const setOCSFlagsFalse = (setFlag: SetFeatureFlag) => { export const setODFFlag = (setFlag: SetFeatureFlag) => setFlag(ODF_MODEL_FLAG, true); -export const setMCOFlag = (setFlag: SetFeatureFlag) => - setFlag(MCO_MODE_FLAG, isMCO); - export const setOCSFlags = async (setFlag: SetFeatureFlag) => { let ocsIntervalId = null; // to prevent unnecessary re-render every 15 sec diff --git a/plugins/mco/console-extensions.json b/plugins/mco/console-extensions.json new file mode 100644 index 000000000..51186ab60 --- /dev/null +++ b/plugins/mco/console-extensions.json @@ -0,0 +1,83 @@ +[ + { + "type": "console.flag/model", + "properties": { + "model": { + "group": "ramendr.openshift.io", + "version": "v1alpha1", + "kind": "DRPolicy" + }, + "flag": "ODR_MODEL" + } + }, + { + "type": "console.navigation/section", + "properties": { + "id": "mco-data-services", + "perspective": "acm", + "name": "%plugin__odf-multicluster-console~Data Services%", + "insertBefore": "acm-applications" + } + }, + { + "type": "console.navigation/href", + "properties": { + "id": "mco-data-policies", + "perspective": "acm", + "section": "mco-data-services", + "name": "%plugin__odf-multicluster-console~Data policies%", + "href": "/multicloud/data-services/data-policies" + }, + "flags": { + "required": ["ODR_MODEL"] + } + }, + { + "type": "console.page/route", + "properties": { + "path": "/multicloud/data-services/data-policies", + "exact": true, + "component": { "$codeRef": "dataPolicies.DataPoliciesList" } + } + }, + { + "type": "console.page/route", + "properties": { + "path": "/multicloud/data-services/data-policies/ramendr.openshift.io~v1alpha1~DRPolicy/~new", + "exact": true, + "component": { "$codeRef": "createDataPolicy.CreateDRPolicy" } + } + }, + { + "type": "console.navigation/href", + "properties": { + "id": "mcodashboard", + "perspective": "acm", + "insertAfter": "mco-data-policies", + "section": "mco-data-services", + "name": "%plugin__odf-plugin~Storage System%", + "href": "/multicloud/data-services/storagesystem" + } + }, + { + "type": "console.page/route", + "properties": { + "path": "/multicloud/data-services/storagesystem", + "exact": false, + "component": { "$codeRef": "mcoDashboard.default" } + } + }, + { + "type": "console.page/route", + "properties": { + "path": [ + "/odf/edit/:cluster/ns/:namespace/:kind/:name/yaml", + "/odf/edit/:cluster/cluster/:kind/:name/yaml" + ], + "exact": true, + "component": { + "$codeRef": "editPage.default" + } + } + } +] diff --git a/plugins/mco/console-plugin.json b/plugins/mco/console-plugin.json new file mode 100644 index 000000000..5a55def20 --- /dev/null +++ b/plugins/mco/console-plugin.json @@ -0,0 +1,15 @@ +{ + "name": "odf-multicluster-console", + "version": "0.0.0", + "displayName": "ODF MCO(ODF Multicluster Orchestartor) Plugin", + "description": "Console plugin for ODF and DR", + "dependencies": { + "@console/pluginAPI": "*" + }, + "exposedModules": { + "dataPolicies": "@odf/mco/components/data-policies/data-policies-list", + "createDataPolicy": "@odf/mco/components/data-policies/create-dr-policy/create-dr-policy", + "mcoDashboard": "@odf/mco/components/mco-dashboard/dashboard", + "editPage": "@odf/core/components/ResourceEditor/GenericResourceEditor" + } +} diff --git a/console-extensions.json b/plugins/odf/console-extensions.json similarity index 72% rename from console-extensions.json rename to plugins/odf/console-extensions.json index 65391b457..136b96c1b 100644 --- a/console-extensions.json +++ b/plugins/odf/console-extensions.json @@ -15,14 +15,6 @@ } } }, - { - "type": "console.flag", - "properties": { - "handler": { - "$codeRef": "features.setMCOFlag" - } - } - }, { "type": "console.flag", "properties": { @@ -55,17 +47,6 @@ } } }, - { - "type": "console.flag/model", - "properties": { - "model": { - "group": "ramendr.openshift.io", - "version": "v1alpha1", - "kind": "DRPolicy" - }, - "flag": "ODR_MODEL" - } - }, { "type": "console.navigation/resource-cluster", "properties": { @@ -83,7 +64,6 @@ "required": ["MCG"] } }, - /* Activates when RGW is present without MCG */ { "type": "console.navigation/resource-cluster", "properties": { @@ -119,7 +99,6 @@ "required": ["MCG"] } }, - /* Activates when RGW is present without MCG */ { "type": "console.navigation/resource-ns", "properties": { @@ -148,8 +127,7 @@ "href": "/odf/cluster" }, "flags": { - "required": ["ODF_MODEL"], - "disallowed": ["MCO"] + "required": ["ODF_MODEL"] } }, { @@ -160,8 +138,7 @@ "component": { "$codeRef": "dashboard.default" } }, "flags": { - "required": ["ODF_MODEL"], - "disallowed": ["MCO"] + "required": ["ODF_MODEL"] } }, { @@ -172,8 +149,7 @@ "component": { "$codeRef": "dashboard.Reroute" } }, "flags": { - "required": ["ODF_MODEL"], - "disallowed": ["MCO"] + "required": ["ODF_MODEL"] } }, { @@ -184,8 +160,7 @@ "component": { "$codeRef": "dashboard.RerouteResource" } }, "flags": { - "required": ["ODF_MODEL"], - "disallowed": ["MCO"] + "required": ["ODF_MODEL"] } }, { @@ -199,78 +174,6 @@ "component": { "$codeRef": "wizard.default" } } }, - { - "type": "console.navigation/section", - "properties": { - "id": "mco-data-services", - "perspective": "acm", - "name": "%plugin__odf-plugin~Data Services%", - "insertBefore": "acm-applications" - }, - "flags": { - "required": ["MCO"] - } - }, - { - "type": "console.navigation/href", - "properties": { - "id": "mco-data-policies", - "perspective": "acm", - "section": "mco-data-services", - "name": "%plugin__odf-plugin~Data policies%", - "href": "/multicloud/data-services/data-policies" - }, - "flags": { - "required": ["MCO", "ODR_MODEL"] - } - }, - { - "type": "console.page/route", - "properties": { - "path": "/multicloud/data-services/data-policies", - "exact": true, - "component": { "$codeRef": "dataPolicies.DataPoliciesList" } - }, - "flags": { - "required": ["MCO"] - } - }, - { - "type": "console.page/route", - "properties": { - "path": "/multicloud/data-services/data-policies/ramendr.openshift.io~v1alpha1~DRPolicy/~new", - "exact": true, - "component": { "$codeRef": "createDataPolicy.CreateDRPolicy" } - }, - "flags": { - "required": ["MCO"] - } - }, - { - "type": "console.navigation/href", - "properties": { - "id": "mcodashboard", - "perspective": "acm", - "insertAfter": "mco-data-policies", - "section": "mco-data-services", - "name": "%plugin__odf-plugin~Storage System%", - "href": "/multicloud/data-services/storagesystem" - }, - "flags": { - "required": ["MCO"] - } - }, - { - "type": "console.page/route", - "properties": { - "path": "/multicloud/data-services/storagesystem", - "exact": false, - "component": { "$codeRef": "mcoDashboard.default" } - }, - "flags": { - "required": ["MCO"] - } - }, { "type": "console.page/resource/list", "properties": { @@ -280,9 +183,6 @@ "version": "v1alpha1" }, "component": { "$codeRef": "obc.OBCListPage" } - }, - "flags": { - "disallowed": ["MCO"] } }, { @@ -294,9 +194,6 @@ "version": "v1alpha1" }, "component": { "$codeRef": "obc.OBCDetailsPage" } - }, - "flags": { - "disallowed": ["MCO"] } }, { @@ -309,8 +206,7 @@ } }, "flags": { - "required": ["OCS"], - "disallowed": ["MCO"] + "required": ["OCS"] } }, { @@ -322,9 +218,6 @@ "version": "v1alpha1" }, "component": { "$codeRef": "ob.OBDetailsPage" } - }, - "flags": { - "disallowed": ["MCO"] } }, { @@ -336,9 +229,6 @@ "version": "v1alpha1" }, "component": { "$codeRef": "ob.ObjectBucketListPage" } - }, - "flags": { - "disallowed": ["MCO"] } }, { @@ -359,9 +249,6 @@ "component": { "$codeRef": "blockPoolDetailsPage.default" } - }, - "flags": { - "disallowed": ["MCO"] } }, { @@ -432,9 +319,6 @@ "component": { "$codeRef": "ocs.default" } - }, - "flags": { - "disallowed": ["MCO"] } }, { diff --git a/plugins/odf/console-plugin.json b/plugins/odf/console-plugin.json new file mode 100644 index 000000000..18c9703ba --- /dev/null +++ b/plugins/odf/console-plugin.json @@ -0,0 +1,27 @@ +{ + "name": "odf-console", + "version": "0.0.0", + "displayName": "ODF(OpenShift Data Foundation) Plugin", + "description": "Console plugin for ODF", + "dependencies": { + "@console/pluginAPI": "*" + }, + "exposedModules": { + "dashboard": "@odf/core/components/odf-dashboard/dashboard", + "features": "@odf/core/features", + "wizard": "@odf/core/components/create-storage-system/create-storage-system", + "obc": "@odf/core/components/mcg/ObjectBucketClaim", + "createOBC": "@odf/core/components/mcg/CreateObjectBucketClaim", + "ob": "@odf/core/components/mcg/ObjectBucket", + "ocs": "@odf/ocs/dashboards/odf-system-dashboard", + "blockPoolDetailsPage": "@odf/ocs/block-pool/BlockPoolDetailsPage", + "createBlockPools": "@odf/ocs/block-pool/CreateBlockPool", + "bsCreate": "@odf/core/components/create-bs/create-bs-page", + "nsCreate": "@odf/core/components/namespace-store/create-namespace-store", + "bcCreate": "@odf/core/components/bucket-class/create-bc", + "bsDetails": "@odf/core/components/resource-pages/BackingStoreDetailsPage", + "bcDetails": "@odf/core/components/resource-pages/BucketClassDetailsPage", + "nsDetails": "@odf/core/components/resource-pages/NamespaceStoreDetailsPage", + "editPage": "@odf/core/components/ResourceEditor/GenericResourceEditor" + } +} diff --git a/scripts/generatePluginPackage.ts b/scripts/generatePluginPackage.ts new file mode 100644 index 000000000..fc642803d --- /dev/null +++ b/scripts/generatePluginPackage.ts @@ -0,0 +1,7 @@ +const fs = require('fs'); + +const frontendPackage = JSON.parse(fs.readFileSync('../../package.json')); +frontendPackage.consolePlugin = JSON.parse( + fs.readFileSync('./console-plugin.json') +); +fs.writeFileSync('./package.json', JSON.stringify(frontendPackage)); diff --git a/webpack.config.ts b/webpack.config.ts index 4228ec96f..968a8382f 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -8,22 +8,16 @@ import type { Configuration as DevServerConfiguration } from 'webpack-dev-server const LANGUAGES = ['en', 'ja', 'ko', 'zh']; const resolveLocale = (dirName: string, ns: string) => - LANGUAGES.reduce( - (acc, lang) => [ - ...acc, - { - from: path.resolve(dirName, `locales/${lang}/plugin__*.json`), - to: `locales/${lang}/${ns}.[ext]`, - }, - ], - [] - ); + LANGUAGES.map((lang) => ({ + from: path.resolve(dirName, `locales/${lang}/plugin__*.json`), + to: `locales/${lang}/${ns}.[ext]`, + })); const config: webpack.Configuration & DevServerConfiguration = { mode: 'development', entry: {}, output: { - path: path.resolve(__dirname, 'dist'), + path: path.resolve('./dist'), filename: '[name]-bundle.js', chunkFilename: '[name]-chunk.js', }, @@ -101,10 +95,7 @@ const config: webpack.Configuration & DevServerConfiguration = { plugins: [ new ConsoleRemotePlugin(), new CopyWebpackPlugin({ - patterns: [...resolveLocale(__dirname, process.env.I8N_NS)], - }), - new webpack.DefinePlugin({ - 'process.env.MODE': JSON.stringify(process.env.MODE), + patterns: [...resolveLocale(__dirname, process.env.I8N_NS || '')], }), new webpack.DefinePlugin({ 'process.env.I8N_NS': JSON.stringify(process.env.I8N_NS),