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 bugs #4047

Merged
merged 1 commit into from
Jun 21, 2024
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: 3 additions & 3 deletions shell/app/App-vite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// external modules
import React from 'react';
import ReactDOM from 'react-dom';
import { get } from 'lodash';
import { get, merge } from 'lodash';
import moment from 'moment';
import 'moment/dist/locale/zh-cn';
import { ConfigProvider as AntConfigProvider, message } from 'antd';
Expand All @@ -41,7 +41,7 @@ import userStore from './user/stores';
import permStore from 'user/stores/permission';
import { getJoinedOrgs, getOrgByDomain } from 'app/org-home/services/org';
import orgStore, { isAdminRoute } from 'app/org-home/stores/org';
import setAntdDefault from './antd-default-props';
import { setAntdDefault, antdZhCNExtra } from './antd-default-props';
import './styles/antd-extension.scss';
import './styles/app.scss';
import '@erda-ui/dashboard-configurator/dist/index.css';
Expand Down Expand Up @@ -122,7 +122,7 @@ const start = (userData: ILoginUser, orgs: ORG.IOrg[]) => {
<AntConfigProvider
autoInsertSpaceInButton={false}
renderEmpty={EmptyListHolder}
locale={isZh() ? antd_zhCN : antd_enUS}
locale={isZh() ? merge(antdZhCNExtra, antd_zhCN) : antd_enUS}
>
<ConfigProvider locale={isZh() ? zhCN : enUS}>
<App />
Expand Down
6 changes: 3 additions & 3 deletions shell/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// external modules
import React from 'react';
import ReactDOM from 'react-dom';
import { get } from 'lodash';
import { get, merge } from 'lodash';
import moment from 'moment';
import 'moment/locale/zh-cn';
import { message, ConfigProvider as AntConfigProvider } from 'antd';
Expand All @@ -39,7 +39,7 @@ import userStore from './user/stores';
import announcementStore from 'org/stores/announcement';
import layoutStore from 'layout/stores/layout';
import orgStore from 'app/org-home/stores/org';
import setAntdDefault from './antd-default-props';
import { setAntdDefault, antdZhCNExtra } from './antd-default-props';
import './styles/antd-extension.scss';
import './styles/app.scss';
import '@erda-ui/dashboard-configurator/dist/index.css';
Expand Down Expand Up @@ -148,7 +148,7 @@ const start = (userData: ILoginUser, orgs: ORG.IOrg[], curOrg: ORG.IOrg, orgAcce
<AntConfigProvider
autoInsertSpaceInButton={false}
renderEmpty={EmptyListHolder}
locale={isZh() ? antd_zhCN : antd_enUS}
locale={isZh() ? merge(antdZhCNExtra, antd_zhCN) : antd_enUS}
>
<ConfigProvider locale={isZh() ? zhCN : enUS}>
<App dynamicModules={dynamicModules} />
Expand Down
34 changes: 31 additions & 3 deletions shell/app/antd-default-props.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
import React from 'react';
import { Pagination, Modal, Spin } from 'antd';
import { Loading } from 'common';
import { isZh } from 'i18n';
import i18n, { isZh } from 'i18n';
import { PAGINATION } from './constants';

const setAntdDefault = () => {
export const setAntdDefault = () => {
Pagination.defaultProps = {
showSizeChanger: false,
...Pagination.defaultProps,
Expand All @@ -39,4 +39,32 @@ const setAntdDefault = () => {
Spin.setDefaultIndicator(<Loading />);
};

export default setAntdDefault;
export const antdZhCNExtra = {
DatePicker: {
lang: {
shortWeekDays: [
i18n.t('Sun'),
i18n.t('Mon'),
i18n.t('Tue'),
i18n.t('Wed'),
i18n.t('Thu'),
i18n.t('Fri'),
i18n.t('Sat'),
],
shortMonths: [
i18n.t('January'),
i18n.t('February'),
i18n.t('March'),
i18n.t('April'),
i18n.t('May'),
i18n.t('June'),
i18n.t('July'),
i18n.t('August'),
i18n.t('September'),
i18n.t('October'),
i18n.t('November'),
i18n.t('December'),
],
},
},
};
18 changes: 18 additions & 0 deletions shell/app/config-page/components/api-editor/api-editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,21 @@
}
}
}

.file-editor-container {
.ace_static_highlight {
.ace_line {
line-height: 21px;
}

.ace_gutter {
width: 48px;
padding-right: 13px;
padding-left: 19px;
}

&.ace_show_gutter .ace_line {
padding-left: 52px;
}
}
}
4 changes: 2 additions & 2 deletions shell/app/config-page/components/table/render-types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export const getRender = (val: any, record: CP_TABLE.RowData, extra: any) => {
return (
<span key={idx}>
{val.showIcon === false ? null : (
<Avatar src={cU.avatar} size="small">
<Avatar src={cU.avatar || undefined} size="small">
{cU.nick ? getAvatarChars(cU.nick) : i18n.t('None')}
</Avatar>
)}
Expand Down Expand Up @@ -289,7 +289,7 @@ export const getRender = (val: any, record: CP_TABLE.RowData, extra: any) => {
const { avatar, nick, name, id } = item;
return (
<div key={id} className="flex-h-center pr-3">
<Avatar src={avatar} size="small">
<Avatar src={avatar || undefined} size="small">
{nick ? getAvatarChars(nick) : i18n.t('None')}
</Avatar>
<span className="ml-2" title={name}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React, { useState } from 'react';
import React, { useState, useRef } from 'react';
import { Modal, Tabs } from 'antd';
import i18n from 'i18n';
import { ErdaIcon as CustomIcon } from 'common';
import routeInfoStore from 'core/stores/route';
import { useEffectOnce } from 'react-use';
import Chat from './chat';
import FunctionalTestCases from './functional-test-cases';
import KnowledgeBase from './knowledge-base';
Expand All @@ -25,12 +26,42 @@ import './index.scss';
const ChatGPT = () => {
const { projectId } = routeInfoStore.useStore((s) => s.params);
const [visible, setVisible] = useState(false);
const divRef = useRef<HTMLDivElement>(null);
const activeRef = useRef(false);
const [bottom, setBottom] = useState(64);

useEffectOnce(() => {
const onDown = () => {
activeRef.current = true;
};
const onUp = () => {
activeRef.current = false;
};
const onMove = (e: MouseEvent) => {
if (activeRef.current) {
setBottom(window.innerHeight - (e.clientY + 20));
}
};
if (divRef.current) {
divRef.current.addEventListener('mousedown', onDown);
document.addEventListener('mousemove', onMove);
document.addEventListener('mouseup', onUp);
}

return () => {
divRef.current?.removeEventListener('mousedown', onDown);
document.removeEventListener('mousemove', onMove);
document.removeEventListener('mouseup', onUp);
};
});

return (
<>
<div
className="fixed bottom-16 right-[8px] shadow-card p-2 rounded-[10px] bg-white cursor-pointer w-[40px] text-center z-[2050]"
ref={divRef}
className="fixed right-[8px] shadow-card p-2 rounded-[10px] bg-white cursor-pointer w-[40px] text-center z-[2050]"
onClick={() => setVisible(true)}
style={{ bottom }}
>
<CustomIcon type="ai" className="text-xl mr-0" />
</div>
Expand Down
11 changes: 9 additions & 2 deletions shell/app/layout/stores/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,20 @@ const layout = createStore({
if (!features) {
return;
}

if (features.length) {
if (/\/:orgName\//.test(path)) {
const isMatch = features.some((feature) => {
const regexStr = feature.replace(/\*/g, '.+');
const regex = new RegExp('^' + regexStr + '$');
const remainingStr = path.replace(/^\/:orgName\//, '');
return regex.test(remainingStr);
let remainingStr = path.replace(/^\/:orgName\//, '');
if (!remainingStr.includes('/')) {
remainingStr = `${remainingStr}/*`;
}
if (feature) {
return regex.test(remainingStr);
}
return false;
});
if (!isMatch) {
goTo(goTo.pages.noAuth);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ interface IAddOnProps {
const getGroupData = (props: any) => {
const { addOn } = props;
if (!addOn) return null;
const splits = addOn.plan.split(':');
const splits = addOn.plan?.split(':') || [];
const config = splits[1];
let addonName = splits[0];
let addonName = splits[0] || '';

if (addonName === 'zookeeper') {
addonName = 'terminus-zookeeper';
Expand Down
2 changes: 1 addition & 1 deletion shell/app/modules/application/services/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const getAddonInstanceList = (): DEPLOY.ExtensionAction[] => {
};

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

export const getTags = ({ repoPrefix, ...rest }: { repoPrefix: string; findTags?: string }): REPOSITORY.ITag[] => {
Expand Down
4 changes: 4 additions & 0 deletions shell/app/modules/dcos/services/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export const getServiceList = ({
}
}

if (!clusterName) {
return Promise.resolve([]) as any;
}

return agent
.get(`/api/cmdb/clusters/${clusterName}/instances-usage`)
.query(query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import serviceAnalyticsStore from 'msp/stores/service-analytics';
import NoServicesHolder from 'msp/env-overview/service-list/pages/no-services-holder';
import DiceConfigPage from 'config-page';
import routeInfoStore from 'core/stores/route';
import { transformRange } from 'common/components/time-select/utils';
// import { transformRange } from 'common/components/time-select/utils';
import moment from 'moment';
import { useUpdate } from 'common/use-hooks';
import './transaction.scss';
Expand Down Expand Up @@ -132,21 +132,21 @@ const Transaction = () => {

const handleChangeType = React.useCallback(
(type: string) => {
const { date } = transformRange(rangeData);
// const { date } = transformRange(rangeData);
update({
transactionType: type,
analysisParams: getTimeParams(date[0].valueOf(), date[1].valueOf()),
// analysisParams: getTimeParams(date[0].valueOf(), date[1].valueOf()),
});
},
[rangeData],
);

const openDetail = (item: IState['recordItem']) => {
const { date } = transformRange(rangeData);
// const { date } = transformRange(rangeData);
update({
visible: true,
recordItem: item,
detailParams: getTimeParams(date[0].valueOf(), date[1].valueOf()),
// detailParams: getTimeParams(date[0].valueOf(), date[1].valueOf()),
});
};

Expand Down
8 changes: 7 additions & 1 deletion shell/app/modules/project/pages/test-plan/plan-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { map } from 'lodash';
import i18n from 'i18n';
import React from 'react';
import { FormModal, MemberSelector } from 'common';
import { goTo } from 'common/utils';
import routeInfoStore from 'core/stores/route';
import testPlanStore from 'project/stores/test-plan';
import iterationStore from 'project/stores/iteration';
Expand Down Expand Up @@ -55,7 +56,12 @@ const TestPlanModal = (props: IProps) => {
if (mode === 'edit') {
updateTestPlan({ ...copy, id: testPlanId, status: planItem.status }).then(close);
} else {
addTestPlan(copy).then(close);
addTestPlan(copy).then((d) => {
close();
if (d) {
goTo(`../${d}`);
}
});
}
};

Expand Down
4 changes: 3 additions & 1 deletion shell/app/modules/project/stores/test-plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ const testPlan = createStore({
},
async addTestPlan({ call, getParams }, payload: TEST_PLAN.PlanSubmitBody) {
const { projectId } = getParams();
await call(addTestPlan, { ...payload, projectID: +projectId });

const res = await call(addTestPlan, { ...payload, projectID: +projectId });
return res;
},
async updateTestPlan({ call, getParams }, payload: TEST_PLAN.PlanSubmitBody) {
const { testPlanId } = getParams();
Expand Down
Loading