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: plugin path change #1455

Merged
merged 2 commits into from
Jan 10, 2025
Merged
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
6 changes: 4 additions & 2 deletions src/common/appMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,17 @@ function menuData(teamName, regionName, appID, permissionsInfo,pluginList) {
authority: ['admin', 'user']
});
}
if (PluginUtil.isInstallEnterprisePlugin(pluginList)) {
const showAppBackup = PluginUtil.isInstallPlugin(pluginList, 'rainbond-bill');

if (PluginUtil.isInstallEnterprisePlugin(pluginList) && !showAppBackup) {
addMenuArr({
name: formatMessage({ id: 'menu.app.backup' }),
icon: getMenuSvg.getSvg('backup'),
path: `team/${teamName}/region/${regionName}/apps/${appID}/backup`,
authority: ['admin', 'user']
});
}
if (isAppResources) {
if (isAppResources && !showAppBackup) {
addMenuArr({
name: formatMessage({ id: 'menu.app.k8s' }),
icon: getMenuSvg.getSvg('kubenetes'),
Expand Down
48 changes: 38 additions & 10 deletions src/common/enterpriseMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { isUrl } from '../utils/utils';
import getMenuSvg from './getMenuSvg';
import PluginUtil from '../utils/pulginUtils'

function menuData(eid, currentUser, enterprise, pluginList,clusterList) {
function menuData(eid, currentUser, enterprise, pluginList, clusterList) {
const adminer = userUtil.isCompanyAdmin(currentUser);
const menuArr = [
{
Expand Down Expand Up @@ -36,6 +36,35 @@ function menuData(eid, currentUser, enterprise, pluginList,clusterList) {
path: `/enterprise/${eid}/teams`,
authority: ['admin', 'user']
});

const billPlugin = PluginUtil.getPluginInfo(pluginList, 'rainbond-bill');
if (billPlugin && Object.keys(billPlugin).length === 1) {
Object.entries(billPlugin).forEach(([regionName, plugins]) => {
menuArr.push({
name: '计量计费',
icon: getMenuSvg.getSvg('bill'),
path: `/enterprise/${eid}/plugins/rainbond-bill?regionName=${regionName}`,
authority: ['admin', 'user']
});
});
} else if (billPlugin && Object.keys(billPlugin).length > 1) {
const billPluginChildren = []
Object.entries(billPlugin).forEach(([regionName, plugins]) => {
billPluginChildren.push({
name: regionName,
icon: getMenuSvg.getSvg('clusters'),
path: `rainbond-bill?regionName=${regionName}`,
authority: ['admin', 'user']
});
});
menuArr.push({
name: '计量计费',
icon: getMenuSvg.getSvg('bill'),
path: `/enterprise/${eid}/plugins`,
authority: ['admin', 'user'],
children: billPluginChildren,
});
}
if (adminer) {
menuArr.push(
{
Expand Down Expand Up @@ -82,23 +111,22 @@ function menuData(eid, currentUser, enterprise, pluginList,clusterList) {
}
});
}

if (pluginObj && Object.keys(pluginObj).length > 0) {
const pluginChildren = [];

Object.entries(pluginObj).forEach(([regionName, plugins]) => {
const regionPluginChildren = plugins.map(val => ({
name: val.display_name,
icon: getMenuSvg.getSvg('plugin'),
path: pluginObj && Object.keys(pluginObj).length === 1
path: pluginObj && Object.keys(pluginObj).length === 1
? `${val.name}?regionName=${regionName}`
: val.name,
authority: ['admin', 'user']
}));

if (Object.keys(pluginObj).length > 1) {
pluginChildren.push({
name: getRegionDispalyName(clusterList,regionName),
name: getRegionDispalyName(clusterList, regionName),
icon: getMenuSvg.getSvg('clusters'),
path: regionName,
authority: ['admin', 'user'],
Expand All @@ -108,7 +136,7 @@ function menuData(eid, currentUser, enterprise, pluginList,clusterList) {
pluginChildren.push(...regionPluginChildren);
}
});

menuArr.push({
name: '插件列表',
icon: getMenuSvg.getSvg('plugin'),
Expand All @@ -117,12 +145,12 @@ function menuData(eid, currentUser, enterprise, pluginList,clusterList) {
children: pluginChildren,
});
}

return menuArr;
}

function getRegionDispalyName (list,name){
const display_name = (list||[]).filter(item => item.region_name == name)
function getRegionDispalyName(list, name) {
const display_name = (list || []).filter(item => item.region_name == name)
return display_name[0].region_alias || name
}

Expand Down
7 changes: 6 additions & 1 deletion src/common/getMenuSvg.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 41 additions & 35 deletions src/components/CreateAppModels/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,24 @@ import {
} from 'antd';
import { connect } from 'dva';
import React, { Fragment, PureComponent } from 'react';
import { formatMessage, FormattedMessage } from 'umi-plugin-locale';
import { formatMessage, FormattedMessage } from 'umi-plugin-locale';
import apiconfig from '../../../config/api.config';
import { fetchAppModelsTags, fetchOrganizations } from '../../services/market';
import cookie from '../../utils/cookie';
import userUtil from '../../utils/user';
import pluginUtils from '../../utils/pulginUtils';
import styles from '../CreateTeam/index.less';

const FormItem = Form.Item;
const { Option } = Select;
const { TextArea } = Input;

@Form.create()
@connect(({ user, global, teamControl }) => ({
@connect(({ user, global, teamControl, rbdPlugin }) => ({
user: user.currentUser,
rainbondInfo: global.rainbondInfo,
currentTeam: teamControl.currentTeam
currentTeam: teamControl.currentTeam,
pluginList: rbdPlugin.pluginList,
}))
class CreateAppModels extends PureComponent {
constructor(props) {
Expand All @@ -54,7 +56,8 @@ class CreateAppModels extends PureComponent {
tagLoading: true,
isAddLicense: false,
enterpriseTeamsLoading: true,
language: cookie.get('language') === 'zh-CN' ? true : false
language: cookie.get('language') === 'zh-CN' ? true : false,
showPublish: pluginUtils.isInstallPlugin(this.props?.pluginList, 'rainbond-bill'),

};
}
Expand Down Expand Up @@ -340,8 +343,8 @@ class CreateAppModels extends PureComponent {
}
this.handleSubmitLoading(false);
},
handleError: err =>{
notification.error({message: err?.data?.msg || formatMessage({id:'notification.error.setUp'})})
handleError: err => {
notification.error({ message: err?.data?.msg || formatMessage({ id: 'notification.error.setUp' }) })
this.handleSubmitLoading(false);
}
});
Expand Down Expand Up @@ -371,8 +374,8 @@ class CreateAppModels extends PureComponent {
}
this.handleSubmitLoading(false);
},
handleError: err =>{
notification.error({message: err?.data?.msg || formatMessage({id:'notification.error.setUp'})})
handleError: err => {
notification.error({ message: err?.data?.msg || formatMessage({ id: 'notification.error.setUp' }) })
this.handleSubmitLoading(false);
}
});
Expand Down Expand Up @@ -422,7 +425,8 @@ class CreateAppModels extends PureComponent {
organizationsLoading,
organizations,
submitLoading,
language
language,
showPublish
} = this.state;

const formItemLayout = {
Expand Down Expand Up @@ -468,7 +472,7 @@ class CreateAppModels extends PureComponent {
const uploadButton = (
<div>
<Icon type={loading ? 'loading' : 'plus'} />
<div className="ant-upload-text">{formatMessage({id:'appPublish.btn.record.creactAppModel.pages.uploadIcon'})}</div>
<div className="ant-upload-text">{formatMessage({ id: 'appPublish.btn.record.creactAppModel.pages.uploadIcon' })}</div>
</div>
);

Expand All @@ -490,44 +494,44 @@ class CreateAppModels extends PureComponent {
onCancel={onCancel}
footer={
<Fragment>
<Button onClick={onCancel}> {formatMessage({id:'popover.cancel'})} </Button>
<Button onClick={onCancel}> {formatMessage({ id: 'popover.cancel' })} </Button>
<Button
type="primary"
disabled={organizationsLoading || tagLoading}
onClick={this.handleSubmit}
loading={submitLoading}
>
{formatMessage({id:'popover.confirm'})}
{formatMessage({ id: 'popover.confirm' })}
</Button>
</Fragment>
}
>
<Spin spinning={organizationsLoading || tagLoading}>
<Form onSubmit={this.handleSubmit} layout="horizontal">
<FormItem {...is_formItemLayout} label={formatMessage({id:'appPublish.btn.record.creactAppModel.pages.label.name'})}>
<FormItem {...is_formItemLayout} label={formatMessage({ id: 'appPublish.btn.record.creactAppModel.pages.label.name' })}>
{getFieldDecorator('name', {
initialValue: appName || (appInfo ? appInfo.app_name : ''),
rules: [
{
required: true,
message: formatMessage({id:'placeholder.appShare.appPublish.name'})
message: formatMessage({ id: 'placeholder.appShare.appPublish.name' })
},
{
max: 32,
message: formatMessage({id:'placeholder.max32'})
message: formatMessage({ id: 'placeholder.max32' })
},
{
pattern: /^[a-z0-9A-Z\u4e00-\u9fa5]([a-zA-Z0-9_\-\u4e00-\u9fa5]*[a-z0-9A-Z\u4e00-\u9fa5])?$/,
message: formatMessage({id:'placeholder.nameSpaceReg'})
message: formatMessage({ id: 'placeholder.nameSpaceReg' })
}
]
})(<Input placeholder={formatMessage({id:'placeholder.appShare.appPublish.name'})} />)}
})(<Input placeholder={formatMessage({ id: 'placeholder.appShare.appPublish.name' })} />)}
<div className={styles.conformDesc}>
{formatMessage({id:'appPublish.btn.record.creactAppModel.pages.label.max32'})}
{formatMessage({ id: 'appPublish.btn.record.creactAppModel.pages.label.max32' })}
</div>
</FormItem>
{!marketId && (
<FormItem {...is_formItemLayout} label={formatMessage({id:'appPublish.btn.record.creactAppModel.pages.label.scope'})}>
<FormItem {...is_formItemLayout} label={formatMessage({ id: 'appPublish.btn.record.creactAppModel.pages.label.scope' })}>
{getFieldDecorator('scope', {
initialValue: appInfo
? isShared && appInfo.scope && appInfo.scope === 'team'
Expand All @@ -537,7 +541,7 @@ class CreateAppModels extends PureComponent {
rules: [
{
required: true,
message: formatMessage({id:'placeholder.appShare.appPublish.name'})
message: formatMessage({ id: 'placeholder.appShare.appPublish.name' })
}
]
})(
Expand All @@ -546,7 +550,7 @@ class CreateAppModels extends PureComponent {
getPopupContainer={triggerNode =>
triggerNode.parentNode
}
placeholder={formatMessage({id:'placeholder.appShare.scopePublish'})}
placeholder={formatMessage({ id: 'placeholder.appShare.scopePublish' })}
dropdownRender={menu => (
<div>
{menu}
Expand All @@ -566,7 +570,7 @@ class CreateAppModels extends PureComponent {
this.addTeams();
}}
>
<Icon type="plus" /> {formatMessage({id:'appPublish.btn.record.creactAppModel.pages.label.loadingMore'})}
<Icon type="plus" /> {formatMessage({ id: 'appPublish.btn.record.creactAppModel.pages.label.loadingMore' })}
</div>
)}
</div>
Expand All @@ -576,7 +580,7 @@ class CreateAppModels extends PureComponent {
>
<Option value="enterprise" key="enterprise">
<div style={{ borderBottom: '1px solid #ccc' }}>
{formatMessage({id:'appPublish.btn.record.creactAppModel.pages.label.present_enterprise'})}
{formatMessage({ id: 'appPublish.btn.record.creactAppModel.pages.label.present_enterprise' })}
</div>
</Option>

Expand All @@ -594,25 +598,27 @@ class CreateAppModels extends PureComponent {
</Select>
) : (
<Radio.Group name="scope">
<Radio value="team">{formatMessage({id:'appPublish.btn.record.creactAppModel.pages.label.present_team'})}</Radio>
<Radio value="enterprise">{formatMessage({id:'appPublish.btn.record.creactAppModel.pages.label.enterprise'})}</Radio>
<Radio value="team">{formatMessage({ id: 'appPublish.btn.record.creactAppModel.pages.label.present_team' })}</Radio>
{!showPublish && (
<Radio value="enterprise">{formatMessage({ id: 'appPublish.btn.record.creactAppModel.pages.label.enterprise' })}</Radio>
)}
</Radio.Group>
)
)}
<div className={styles.conformDesc}>{formatMessage({id:'appPublish.btn.record.creactAppModel.pages.label.scope_Publish'})}</div>
<div className={styles.conformDesc}>{formatMessage({ id: 'appPublish.btn.record.creactAppModel.pages.label.scope_Publish' })}</div>
</FormItem>
)}
{marketId && marketVersion && marketVersion === '2.0' && (
<FormItem {...is_formItemLayout} label={formatMessage({id:'appPublish.btn.record.creactAppModel.pages.label.org_id'})}>
<FormItem {...is_formItemLayout} label={formatMessage({ id: 'appPublish.btn.record.creactAppModel.pages.label.org_id' })}>
{getFieldDecorator('org_id', {
rules: [
{
required: true,
message: formatMessage({id:'placeholder.appShare.org_id'})
message: formatMessage({ id: 'placeholder.appShare.org_id' })
}
]
})(
<Select placeholder={formatMessage({id:'placeholder.appShare.org_id'})}>
<Select placeholder={formatMessage({ id: 'placeholder.appShare.org_id' })}>
{organizations &&
organizations.length > 0 &&
organizations.map(item => {
Expand All @@ -624,29 +630,29 @@ class CreateAppModels extends PureComponent {
)}
</FormItem>
)}
<FormItem {...is_formItemLayout} label={formatMessage({id:'appPublish.btn.record.creactAppModel.pages.label.describe'})}>
<FormItem {...is_formItemLayout} label={formatMessage({ id: 'appPublish.btn.record.creactAppModel.pages.label.describe' })}>
{getFieldDecorator('describe', {
initialValue: appInfo
? appInfo.describe || appInfo.app_describe
: '',
rules: [
{
required: false,
message: formatMessage({id:'placeholder.appShare.describe'})
message: formatMessage({ id: 'placeholder.appShare.describe' })
}
]
})(<TextArea placeholder={formatMessage({id:'placeholder.appShare.describe'})} />)}
})(<TextArea placeholder={formatMessage({ id: 'placeholder.appShare.describe' })} />)}
<div className={styles.conformDesc}>
{formatMessage({id:'appPublish.btn.record.creactAppModel.pages.label.model_intro'})}
{formatMessage({ id: 'appPublish.btn.record.creactAppModel.pages.label.model_intro' })}
</div>
</FormItem>
<Form.Item {...is_formItemLayout} label={formatMessage({id:'appPublish.btn.record.creactAppModel.pages.label.logo'})}>
<Form.Item {...is_formItemLayout} label={formatMessage({ id: 'appPublish.btn.record.creactAppModel.pages.label.logo' })}>
{getFieldDecorator('pic', {
initialValue: appInfo ? appInfo.pic : '',
rules: [
{
required: false,
message: formatMessage({id:'placeholder.appShare.picLogo'})
message: formatMessage({ id: 'placeholder.appShare.picLogo' })
}
]
})(
Expand Down
Loading
Loading