Skip to content

Commit

Permalink
[INLONG-11197][Dashboard] Add delete button to cluster management and…
Browse files Browse the repository at this point in the history
… template management (apache#11198)
  • Loading branch information
wohainilaodou authored Sep 26, 2024
1 parent b670373 commit e0d7f8d
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
28 changes: 26 additions & 2 deletions inlong-dashboard/src/ui/pages/GroupDataTemplate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
*/

import React, { useCallback, useMemo, useState } from 'react';
import { Button } from 'antd';
import { Button, message, Modal } from 'antd';
import i18n from '@/i18n';
import HighTable from '@/ui/components/HighTable';
import { PageContainer } from '@/ui/components/PageContainer';
import { defaultSize } from '@/configs/pagination';
import { useRequest } from '@/ui/hooks';
import CreateModal from './CreateModal';
import { timestampFormat } from '@/core/utils';
import request from '@/core/utils/request';

const Comp: React.FC = () => {
const [options, setOptions] = useState({
Expand Down Expand Up @@ -101,6 +102,26 @@ const Comp: React.FC = () => {
],
[],
);
const onDelete = useCallback(
record => {
console.log(record);
Modal.confirm({
title: i18n.t('basic.DeleteConfirm'),
onOk: async () => {
await request({
url: `/template/delete`,
method: 'DELETE',
params: {
templateName: record.name,
},
});
await getList();
message.success(i18n.t('basic.DeleteSuccess'));
},
});
},
[getList],
);
const entityColumns = useMemo(() => {
return [
{
Expand Down Expand Up @@ -157,12 +178,15 @@ const Comp: React.FC = () => {
{
title: i18n.t('basic.Operating'),
dataIndex: 'action',
width: 100,
width: 150,
render: (text, record) => (
<>
<Button type="link" onClick={() => onEdit(record)}>
{i18n.t('basic.Edit')}
</Button>
<Button type="link" onClick={() => onDelete(record)}>
{i18n.t('basic.Delete')}
</Button>
</>
),
} as any,
Expand Down
6 changes: 5 additions & 1 deletion inlong-dashboard/src/ui/pages/TenantManagement/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const getFilterFormContent = () => [
},
];

export const getColumns = ({ onEdit }) => {
export const getColumns = ({ onEdit, onDelete }) => {
return [
{
title: i18n.t('pages.Tenant.config.Name'),
Expand Down Expand Up @@ -70,11 +70,15 @@ export const getColumns = ({ onEdit }) => {
{
title: i18n.t('basic.Operating'),
dataIndex: 'action',
width: 150,
render: (text, record) => (
<>
<Button type="link" onClick={() => onEdit(record)}>
{i18n.t('basic.Edit')}
</Button>
<Button type="link" onClick={() => onDelete(record)}>
{i18n.t('basic.Delete')}
</Button>
</>
),
},
Expand Down
25 changes: 21 additions & 4 deletions inlong-dashboard/src/ui/pages/TenantManagement/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@
* under the License.
*/

import React, { useEffect, useState } from 'react';
import { Button, Card } from 'antd';
import React, { useCallback, useEffect, useState } from 'react';
import { Button, Card, message, Modal } from 'antd';
import { PageContainer, Container } from '@/ui/components/PageContainer';
import HighTable from '@/ui/components/HighTable';
import { useRequest } from '@/ui/hooks';
import { useTranslation } from 'react-i18next';
import { defaultSize } from '@/configs/pagination';
import DetailModal from './DetailModal';
import { getFilterFormContent, getColumns } from './config';
import i18n from 'i18next';
import request from '@/core/utils/request';

const Comp: React.FC = () => {
const { t } = useTranslation();
Expand Down Expand Up @@ -114,7 +116,22 @@ const Comp: React.FC = () => {
current: options.pageNum,
total: data?.total,
};

const onDelete = useCallback(
({ id }) => {
Modal.confirm({
title: i18n.t('basic.DeleteConfirm'),
onOk: async () => {
await request({
url: `/role/tenant/delete/${id}`,
method: 'DELETE',
});
await getList();
message.success(i18n.t('basic.DeleteSuccess'));
},
});
},
[getList],
);
return (
<PageContainer useDefaultBreadcrumb={false} useDefaultContainer={false}>
<Container>
Expand All @@ -130,7 +147,7 @@ const Comp: React.FC = () => {
onFilter,
}}
table={{
columns: getColumns({ onEdit }),
columns: getColumns({ onEdit, onDelete }),
rowKey: 'id',
dataSource: data?.list,
pagination,
Expand Down

0 comments on commit e0d7f8d

Please sign in to comment.