diff --git a/src/App.less b/src/App.less index 11813ab0b..5356ab6e5 100644 --- a/src/App.less +++ b/src/App.less @@ -381,26 +381,6 @@ input::placeholder { } } -// antd表格排序icon特殊处理 -.ant-table-column-has-sorters .ant-table-column-sorter-inner { - .ant-table-column-sorter-up, - .ant-table-column-sorter-down { - transition: all 0.2s; - } - - &:has(.ant-table-column-sorter-up.active) { - .ant-table-column-sorter-down { - opacity: 0; - } - } - - &:has(.ant-table-column-sorter-down.active) { - .ant-table-column-sorter-up { - opacity: 0; - } - } -} - .theme-light.theme-light-gold { .login-main.integration { .ant-btn-primary { diff --git a/src/components/TableActionDropdown/index.tsx b/src/components/TableActionDropdown/index.tsx new file mode 100644 index 000000000..6d1c2112a --- /dev/null +++ b/src/components/TableActionDropdown/index.tsx @@ -0,0 +1,79 @@ +import React from 'react'; +import { Button } from 'antd'; +import type { ButtonProps } from 'antd/lib/button'; +import { + CheckCircle, + Copy, + ExternalLink, + Eye, + Link as LinkIcon, + MoreVertical, + Network, + Pencil, + Play, + Search, + Settings, + ShieldCheck, + Sparkles, + Trash2, +} from 'lucide-react'; +import classNames from 'classnames'; +import { Link, LinkProps } from 'react-router-dom'; + +import './style.less'; + +const tableActionIconMap = { + default: CheckCircle, + edit: Pencil, + view: Eye, + settings: Settings, + access: Network, + permission: ShieldCheck, + copy: Copy, + delete: Trash2, + run: Play, + search: Search, + open: ExternalLink, + link: LinkIcon, + ai: Sparkles, +}; + +export type TableActionIconName = keyof typeof tableActionIconMap; + +export function TableActionIcon({ name }: { name: TableActionIconName }) { + const Icon = tableActionIconMap[name]; + return ; +} + +interface TableActionButtonProps extends Omit { + actionIcon?: TableActionIconName; + icon?: React.ReactNode; +} + +export function TableActionButton({ actionIcon, icon, className, type = 'link', ...rest }: TableActionButtonProps) { + return ( + + )} + {(IS_PLUS || !_.includes(['firemap', 'northstar'], record?.rule_prod)) && } - + } > - - {record.cate === 'prometheus' && anomalyEnabled === true && ( -
- {t('brain_result_btn')} -
- )} - + onCancel() {}, + }); + }} + > + {t('common:btn.delete')} + + + + } + > + + ); }, }, diff --git a/src/pages/alertRules/List/constants.ts b/src/pages/alertRules/List/constants.ts index dac1b27d8..24196474d 100644 --- a/src/pages/alertRules/List/constants.ts +++ b/src/pages/alertRules/List/constants.ts @@ -24,16 +24,6 @@ export const defaultColumnsConfigs = [ i18nKey: 'table.status', visible: true, }, - { - name: 'cate', - i18nKey: 'table.cate', - visible: true, - }, - { - name: 'datasource_ids', - i18nKey: 'table.datasource_ids', - visible: false, - }, { name: 'name', i18nKey: 'table.name', @@ -44,6 +34,11 @@ export const defaultColumnsConfigs = [ i18nKey: 'table.severity', visible: false, }, + { + name: 'datasource_ids', + i18nKey: 'table.datasource_ids', + visible: false, + }, { name: 'append_tags', i18nKey: 'table.append_tags', @@ -69,11 +64,6 @@ export const defaultColumnsConfigs = [ i18nKey: 'common:table.username', visible: true, }, - { - name: 'update_by_nickname', - i18nKey: 'common:table.nickname', - visible: true, - }, { name: 'disabled', i18nKey: 'table.disabled', diff --git a/src/pages/alertRules/List/index.tsx b/src/pages/alertRules/List/index.tsx index 245500e5f..45a7c4ef9 100644 --- a/src/pages/alertRules/List/index.tsx +++ b/src/pages/alertRules/List/index.tsx @@ -95,7 +95,7 @@ export default function List(props: ListProps) { }, [gids, refreshFlag]); return ( -
+
{ prod: string; severities: number[]; update_at: number; - update_by: number; + update_by: string; + update_by_nickname?: string; cur_event_count: number; } diff --git a/src/pages/builtInComponents/AlertRules/index.tsx b/src/pages/builtInComponents/AlertRules/index.tsx index 35de800e2..fa8f7353f 100644 --- a/src/pages/builtInComponents/AlertRules/index.tsx +++ b/src/pages/builtInComponents/AlertRules/index.tsx @@ -1,7 +1,7 @@ import React, { useState, useRef, useContext, useEffect } from 'react'; import _ from 'lodash'; import { Table, Space, Button, Input, Select, Dropdown, Menu, Modal, Tag, message } from 'antd'; -import { SearchOutlined, MoreOutlined } from '@ant-design/icons'; +import { SearchOutlined } from '@ant-design/icons'; import { useTranslation } from 'react-i18next'; import { Link } from 'react-router-dom'; import { useDebounceEffect } from 'ahooks'; @@ -10,6 +10,8 @@ import Export from '@/pages/dashboard/List/Export'; import AuthorizationWrapper from '@/components/AuthorizationWrapper'; import { CommonStateContext } from '@/App'; import { HelpLink } from '@/components/pageLayout'; +import { TableActionButton, TableActionTrigger } from '@/components/TableActionDropdown'; +import Tags from '@/components/TableTags/Tags'; import { RuleType } from './types'; import Import from './Import'; import { getPayloads, deletePayloads, getCates } from '../services'; @@ -205,29 +207,17 @@ export default function index(props: Props) { render: (val) => { const tags = _.compact(_.split(val, ' ')); return ( - - {_.map(tags, (tag, idx) => { - return ( - { - const queryItem = _.compact(_.split(filter.query, ' ')); - if (_.includes(queryItem, tag)) return; - setFilter((filter) => { - return { - ...filter, - query: filter.query ? filter.query + ' ' + tag : tag, - }; - }); - }} - > - {tag} - - ); - })} - + { + const queryItem = _.compact(_.split(filter.query, ' ')); + if (_.includes(queryItem, tag)) return; + setFilter((filter) => ({ + ...filter, + query: filter.query ? filter.query + ' ' + tag : tag, + })); + }} + /> ); }, }, @@ -245,14 +235,19 @@ export default function index(props: Props) { }, { title: t('common:table.operations'), - width: 100, + width: 64, + fixed: 'right' as const, render: (record) => { return ( - { Import({ data: formatBeautifyJson(record.content), @@ -264,10 +259,11 @@ export default function index(props: Props) { }} > {t('import_to_buisGroup')} - + - { Export({ data: formatBeautifyJson(record.content, 'array'), @@ -275,12 +271,13 @@ export default function index(props: Props) { }} > {t('common:btn.export')} - + {record.updated_by !== 'system' && ( - { PayloadFormModal({ darkMode, @@ -297,38 +294,40 @@ export default function index(props: Props) { }} > {t('common:btn.edit')} - + )} {record.updated_by !== 'system' && ( - - - + <> + + + { + Modal.confirm({ + title: t('common:confirm.delete'), + onOk() { + deletePayloads([record.id]).then(() => { + fetchData(); + fetchCates(); + }); + }, + }); + }} + > + {t('common:btn.delete')} + + + )} } > - - + <> + + + { + Modal.confirm({ + title: t('common:confirm.delete'), + onOk() { + deletePayloads([record.id]).then(() => { + fetchData(); + fetchCates(); + }); + }, + }); + }} + > + {t('common:btn.delete')} + + + )} } > - - + <> + + + { + Modal.confirm({ + title: t('common:confirm.delete'), + onOk() { + deletePayloads([record.id]).then(() => { + fetchData(); + }); + }, + }); + }} + > + {t('common:btn.delete')} + + + )} } > - - + <> + + + { + Modal.confirm({ + title: t('common:confirm.delete'), + onOk() { + deleteMetrics([record.id]).then(() => { + message.success(t('common:success.delete')); + setRefreshFlag(_.uniqueId('refreshFlag_')); + }); + }, + }); + }} + > + {t('common:btn.delete')} + + + )} } > - - - )} - {gids && gids !== '-1' && ( - - - - )} + }, + { + title: t('common:table.operations'), + width: 64, + fixed: 'right' as const, + render: (text: string, record: DashboardType) => { + return ( + + {gids !== '-1' && ( - + {t('common:btn.clone')} + - {gids !== '-1' && ( + )} + + { + const exportData = await getDashboard(record.id); + Export({ + data: exportDataStringify(exportData), + }); + }} + > + {t('common:btn.export')} + + + {gids !== '-1' && ( + <> + - + - )} - - } - > - - )} - - {record.plugin_type === 'cloudwatch' && ( - + }} + > + {record.status === 'enabled' ? t('disable') : t('enable')} + + + {record.plugin_type === 'cloudwatch' && ( + + + + )} + {record.status === 'disabled' && ( + <> + - + { + Modal.confirm({ + title: t('common:confirm.delete'), + onOk() { + deleteDataSourceById(record.id).then(() => { + message.success(t('common:success.delete')); + setRefresh((oldVal) => !oldVal); + }); + }, + }); + }} + > + {t('common:btn.delete')} + - - } - > - + )} + - + } > - + )} + - + } > -