From c3532f74fdddd998fd5060954cfc8f1d7ad732da Mon Sep 17 00:00:00 2001 From: donniean Date: Thu, 19 Sep 2024 11:57:24 +0800 Subject: [PATCH] fix: fix the issue of checking licenses in ks Signed-off-by: donniean --- packages/bootstrap/webpack/webpack.base.conf.js | 4 ++++ .../components/Layouts/NavMenu/NavItem/index.tsx | 13 +++++++++---- packages/shared/src/constants/env.ts | 2 ++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/bootstrap/webpack/webpack.base.conf.js b/packages/bootstrap/webpack/webpack.base.conf.js index 86606012a9e..71140ae6028 100644 --- a/packages/bootstrap/webpack/webpack.base.conf.js +++ b/packages/bootstrap/webpack/webpack.base.conf.js @@ -5,6 +5,7 @@ const fs = require('fs-extra'); const { config, systemImports } = require('./config'); +const webpack = require('webpack'); const WebpackBar = require('webpackbar'); const { merge } = require('webpack-merge'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -87,6 +88,9 @@ const webpackBaseConfig = merge(configs, { ], }, plugins: [ + new webpack.DefinePlugin({ + 'process.env.KUBESPHERE_EDITION': JSON.stringify('ks'), + }), new ForkTsCheckerWebpackPlugin(), new CopyWebpackPlugin({ patterns: [ diff --git a/packages/shared/src/components/Layouts/NavMenu/NavItem/index.tsx b/packages/shared/src/components/Layouts/NavMenu/NavItem/index.tsx index 398f2d8f04b..c8d1e222c3a 100644 --- a/packages/shared/src/components/Layouts/NavMenu/NavItem/index.tsx +++ b/packages/shared/src/components/Layouts/NavMenu/NavItem/index.tsx @@ -9,6 +9,7 @@ import { Link } from 'react-router-dom'; import { ChevronDown } from '@kubed/icons'; import type { LicenseAuthorizationStatus } from '../../../../types/license'; +import { ENV } from '../../../../constants'; import { LicenseErrorTip } from '../../../../index'; import Icon from '../../../Icon'; @@ -56,6 +57,8 @@ interface NavItemProps { disabled?: boolean; } +const isCheckLicense = ENV.isKseEdition; + const NavItem = ({ item, onOpen, isOpen, pathArr, prefix, disabled }: NavItemProps) => { const handleToggle = () => { onOpen(item?.name || ''); @@ -73,9 +76,10 @@ const NavItem = ({ item, onOpen, isOpen, pathArr, prefix, disabled }: NavItemPro return pathArr.includes(navItem.name); }; - const isItemDisabled = item?.isLicenseError ? true : disabled && !item?.showInDisable; + const isItemDisabled = + isCheckLicense && item?.isLicenseError ? true : disabled && !item?.showInDisable; - const itemLicenseErrorTipWrapper = item?.isLicenseError && ( + const itemLicenseErrorTipWrapper = isCheckLicense && item?.isLicenseError && ( @@ -102,7 +106,8 @@ const NavItem = ({ item, onOpen, isOpen, pathArr, prefix, disabled }: NavItemPro {item?.children.map((child: NavMenuItem) => { - const isChildDisabled = child.isLicenseError ? true : disabled && !child.showInDisable; + const isChildDisabled = + isCheckLicense && child.isLicenseError ? true : disabled && !child.showInDisable; return ( {t(child.title)} )} - {child.isLicenseError && ( + {isCheckLicense && child.isLicenseError && ( diff --git a/packages/shared/src/constants/env.ts b/packages/shared/src/constants/env.ts index e48491bd026..b1f221835e4 100644 --- a/packages/shared/src/constants/env.ts +++ b/packages/shared/src/constants/env.ts @@ -6,3 +6,5 @@ export const isDevelopment = process.env.NODE_ENV === 'development'; export const isProduction = process.env.NODE_ENV === 'production'; + +export const isKseEdition = process.env.KUBESPHERE_EDITION === 'kse';