Skip to content

Commit e97603f

Browse files
authored
fix: fix bugs (#4047)
1 parent 6706e61 commit e97603f

File tree

13 files changed

+121
-25
lines changed

13 files changed

+121
-25
lines changed

shell/app/App-vite.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// external modules
1515
import React from 'react';
1616
import ReactDOM from 'react-dom';
17-
import { get } from 'lodash';
17+
import { get, merge } from 'lodash';
1818
import moment from 'moment';
1919
import 'moment/dist/locale/zh-cn';
2020
import { ConfigProvider as AntConfigProvider, message } from 'antd';
@@ -41,7 +41,7 @@ import userStore from './user/stores';
4141
import permStore from 'user/stores/permission';
4242
import { getJoinedOrgs, getOrgByDomain } from 'app/org-home/services/org';
4343
import orgStore, { isAdminRoute } from 'app/org-home/stores/org';
44-
import setAntdDefault from './antd-default-props';
44+
import { setAntdDefault, antdZhCNExtra } from './antd-default-props';
4545
import './styles/antd-extension.scss';
4646
import './styles/app.scss';
4747
import '@erda-ui/dashboard-configurator/dist/index.css';
@@ -122,7 +122,7 @@ const start = (userData: ILoginUser, orgs: ORG.IOrg[]) => {
122122
<AntConfigProvider
123123
autoInsertSpaceInButton={false}
124124
renderEmpty={EmptyListHolder}
125-
locale={isZh() ? antd_zhCN : antd_enUS}
125+
locale={isZh() ? merge(antdZhCNExtra, antd_zhCN) : antd_enUS}
126126
>
127127
<ConfigProvider locale={isZh() ? zhCN : enUS}>
128128
<App />

shell/app/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// external modules
1515
import React from 'react';
1616
import ReactDOM from 'react-dom';
17-
import { get } from 'lodash';
17+
import { get, merge } from 'lodash';
1818
import moment from 'moment';
1919
import 'moment/locale/zh-cn';
2020
import { message, ConfigProvider as AntConfigProvider } from 'antd';
@@ -39,7 +39,7 @@ import userStore from './user/stores';
3939
import announcementStore from 'org/stores/announcement';
4040
import layoutStore from 'layout/stores/layout';
4141
import orgStore from 'app/org-home/stores/org';
42-
import setAntdDefault from './antd-default-props';
42+
import { setAntdDefault, antdZhCNExtra } from './antd-default-props';
4343
import './styles/antd-extension.scss';
4444
import './styles/app.scss';
4545
import '@erda-ui/dashboard-configurator/dist/index.css';
@@ -148,7 +148,7 @@ const start = (userData: ILoginUser, orgs: ORG.IOrg[], curOrg: ORG.IOrg, orgAcce
148148
<AntConfigProvider
149149
autoInsertSpaceInButton={false}
150150
renderEmpty={EmptyListHolder}
151-
locale={isZh() ? antd_zhCN : antd_enUS}
151+
locale={isZh() ? merge(antdZhCNExtra, antd_zhCN) : antd_enUS}
152152
>
153153
<ConfigProvider locale={isZh() ? zhCN : enUS}>
154154
<App dynamicModules={dynamicModules} />

shell/app/antd-default-props.tsx

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
import React from 'react';
1515
import { Pagination, Modal, Spin } from 'antd';
1616
import { Loading } from 'common';
17-
import { isZh } from 'i18n';
17+
import i18n, { isZh } from 'i18n';
1818
import { PAGINATION } from './constants';
1919

20-
const setAntdDefault = () => {
20+
export const setAntdDefault = () => {
2121
Pagination.defaultProps = {
2222
showSizeChanger: false,
2323
...Pagination.defaultProps,
@@ -39,4 +39,32 @@ const setAntdDefault = () => {
3939
Spin.setDefaultIndicator(<Loading />);
4040
};
4141

42-
export default setAntdDefault;
42+
export const antdZhCNExtra = {
43+
DatePicker: {
44+
lang: {
45+
shortWeekDays: [
46+
i18n.t('Sun'),
47+
i18n.t('Mon'),
48+
i18n.t('Tue'),
49+
i18n.t('Wed'),
50+
i18n.t('Thu'),
51+
i18n.t('Fri'),
52+
i18n.t('Sat'),
53+
],
54+
shortMonths: [
55+
i18n.t('January'),
56+
i18n.t('February'),
57+
i18n.t('March'),
58+
i18n.t('April'),
59+
i18n.t('May'),
60+
i18n.t('June'),
61+
i18n.t('July'),
62+
i18n.t('August'),
63+
i18n.t('September'),
64+
i18n.t('October'),
65+
i18n.t('November'),
66+
i18n.t('December'),
67+
],
68+
},
69+
},
70+
};

shell/app/config-page/components/api-editor/api-editor.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,21 @@
267267
}
268268
}
269269
}
270+
271+
.file-editor-container {
272+
.ace_static_highlight {
273+
.ace_line {
274+
line-height: 21px;
275+
}
276+
277+
.ace_gutter {
278+
width: 48px;
279+
padding-right: 13px;
280+
padding-left: 19px;
281+
}
282+
283+
&.ace_show_gutter .ace_line {
284+
padding-left: 52px;
285+
}
286+
}
287+
}

shell/app/config-page/components/table/render-types.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export const getRender = (val: any, record: CP_TABLE.RowData, extra: any) => {
256256
return (
257257
<span key={idx}>
258258
{val.showIcon === false ? null : (
259-
<Avatar src={cU.avatar} size="small">
259+
<Avatar src={cU.avatar || undefined} size="small">
260260
{cU.nick ? getAvatarChars(cU.nick) : i18n.t('None')}
261261
</Avatar>
262262
)}
@@ -289,7 +289,7 @@ export const getRender = (val: any, record: CP_TABLE.RowData, extra: any) => {
289289
const { avatar, nick, name, id } = item;
290290
return (
291291
<div key={id} className="flex-h-center pr-3">
292-
<Avatar src={avatar} size="small">
292+
<Avatar src={avatar || undefined} size="small">
293293
{nick ? getAvatarChars(nick) : i18n.t('None')}
294294
</Avatar>
295295
<span className="ml-2" title={name}>

shell/app/layout/pages/page-container/components/chat-GPT/index.tsx

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
// You should have received a copy of the GNU Affero General Public License
1212
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1313

14-
import React, { useState } from 'react';
14+
import React, { useState, useRef } from 'react';
1515
import { Modal, Tabs } from 'antd';
1616
import i18n from 'i18n';
1717
import { ErdaIcon as CustomIcon } from 'common';
1818
import routeInfoStore from 'core/stores/route';
19+
import { useEffectOnce } from 'react-use';
1920
import Chat from './chat';
2021
import FunctionalTestCases from './functional-test-cases';
2122
import KnowledgeBase from './knowledge-base';
@@ -25,12 +26,42 @@ import './index.scss';
2526
const ChatGPT = () => {
2627
const { projectId } = routeInfoStore.useStore((s) => s.params);
2728
const [visible, setVisible] = useState(false);
29+
const divRef = useRef<HTMLDivElement>(null);
30+
const activeRef = useRef(false);
31+
const [bottom, setBottom] = useState(64);
32+
33+
useEffectOnce(() => {
34+
const onDown = () => {
35+
activeRef.current = true;
36+
};
37+
const onUp = () => {
38+
activeRef.current = false;
39+
};
40+
const onMove = (e: MouseEvent) => {
41+
if (activeRef.current) {
42+
setBottom(window.innerHeight - (e.clientY + 20));
43+
}
44+
};
45+
if (divRef.current) {
46+
divRef.current.addEventListener('mousedown', onDown);
47+
document.addEventListener('mousemove', onMove);
48+
document.addEventListener('mouseup', onUp);
49+
}
50+
51+
return () => {
52+
divRef.current?.removeEventListener('mousedown', onDown);
53+
document.removeEventListener('mousemove', onMove);
54+
document.removeEventListener('mouseup', onUp);
55+
};
56+
});
2857

2958
return (
3059
<>
3160
<div
32-
className="fixed bottom-16 right-[8px] shadow-card p-2 rounded-[10px] bg-white cursor-pointer w-[40px] text-center z-[2050]"
61+
ref={divRef}
62+
className="fixed right-[8px] shadow-card p-2 rounded-[10px] bg-white cursor-pointer w-[40px] text-center z-[2050]"
3363
onClick={() => setVisible(true)}
64+
style={{ bottom }}
3465
>
3566
<CustomIcon type="ai" className="text-xl mr-0" />
3667
</div>

shell/app/layout/stores/layout.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,20 @@ const layout = createStore({
201201
if (!features) {
202202
return;
203203
}
204+
204205
if (features.length) {
205206
if (/\/:orgName\//.test(path)) {
206207
const isMatch = features.some((feature) => {
207208
const regexStr = feature.replace(/\*/g, '.+');
208209
const regex = new RegExp('^' + regexStr + '$');
209-
const remainingStr = path.replace(/^\/:orgName\//, '');
210-
return regex.test(remainingStr);
210+
let remainingStr = path.replace(/^\/:orgName\//, '');
211+
if (!remainingStr.includes('/')) {
212+
remainingStr = `${remainingStr}/*`;
213+
}
214+
if (feature) {
215+
return regex.test(remainingStr);
216+
}
217+
return false;
211218
});
212219
if (!isMatch) {
213220
goTo(goTo.pages.noAuth);

shell/app/modules/application/common/components/create-add-on.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ interface IAddOnProps {
6060
const getGroupData = (props: any) => {
6161
const { addOn } = props;
6262
if (!addOn) return null;
63-
const splits = addOn.plan.split(':');
63+
const splits = addOn.plan?.split(':') || [];
6464
const config = splits[1];
65-
let addonName = splits[0];
65+
let addonName = splits[0] || '';
6666

6767
if (addonName === 'zookeeper') {
6868
addonName = 'terminus-zookeeper';

shell/app/modules/application/services/repo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export const getAddonInstanceList = (): DEPLOY.ExtensionAction[] => {
162162
};
163163

164164
export const getAddonVersions = ({ addonName }: { addonName: string }): DEPLOY.ActionConfig[] => {
165-
return agent.get(`/api/extensions/${addonName}?all=true`).then((response: any) => response.body);
165+
return agent.get(`/api/extensions/${addonName}`).then((response: any) => response.body);
166166
};
167167

168168
export const getTags = ({ repoPrefix, ...rest }: { repoPrefix: string; findTags?: string }): REPOSITORY.ITag[] => {

shell/app/modules/dcos/services/service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ export const getServiceList = ({
5959
}
6060
}
6161

62+
if (!clusterName) {
63+
return Promise.resolve([]) as any;
64+
}
65+
6266
return agent
6367
.get(`/api/cmdb/clusters/${clusterName}/instances-usage`)
6468
.query(query)

0 commit comments

Comments
 (0)