Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix the issue of checking licenses in ks #4302

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
Loading