Skip to content

Commit

Permalink
fix: fix the issue of checking licenses in ks (#4303)
Browse files Browse the repository at this point in the history
Signed-off-by: donniean <[email protected]>
  • Loading branch information
donniean authored Sep 19, 2024
1 parent b73e1bd commit 04d220f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/bootstrap/webpack/webpack.base.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -87,6 +88,9 @@ const webpackBaseConfig = merge(configs, {
],
},
plugins: [
new webpack.DefinePlugin({
'process.env.KUBESPHERE_EDITION': JSON.stringify('ks'),
}),
new ForkTsCheckerWebpackPlugin(),
new CopyWebpackPlugin({
patterns: [
Expand Down
13 changes: 9 additions & 4 deletions packages/shared/src/components/Layouts/NavMenu/NavItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 || '');
Expand All @@ -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 && (
<LicenseErrorTipWrapper>
<LicenseErrorTip authorizationStatus={item?.licenseAuthorizationStatus} />
</LicenseErrorTipWrapper>
Expand All @@ -102,7 +106,8 @@ const NavItem = ({ item, onOpen, isOpen, pathArr, prefix, disabled }: NavItemPro
</TitleWrapper>
<InnerNav className="inner-nav">
{item?.children.map((child: NavMenuItem) => {
const isChildDisabled = child.isLicenseError ? true : disabled && !child.showInDisable;
const isChildDisabled =
isCheckLicense && child.isLicenseError ? true : disabled && !child.showInDisable;

return (
<InnerItem
Expand All @@ -117,7 +122,7 @@ const NavItem = ({ item, onOpen, isOpen, pathArr, prefix, disabled }: NavItemPro
) : (
<Link to={`${prefix}/${child.name}`}>{t(child.title)}</Link>
)}
{child.isLicenseError && (
{isCheckLicense && child.isLicenseError && (
<LicenseErrorTipWrapper>
<LicenseErrorTip authorizationStatus={child.licenseAuthorizationStatus} />
</LicenseErrorTipWrapper>
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/constants/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit 04d220f

Please sign in to comment.