chore: logs
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
// columns.ts
|
||||
import AutoTooltip from '@/components/auto-tooltip';
|
||||
import DropdownButtons from '@/components/drop-down-buttons';
|
||||
import icons from '@/components/icon-font/icons';
|
||||
import StatusTag from '@/components/status-tag';
|
||||
import { tableSorter } from '@/config/settings';
|
||||
import { useIntl } from '@umijs/max';
|
||||
@@ -10,25 +8,10 @@ import { ColumnsType } from 'antd/es/table';
|
||||
import dayjs from 'dayjs';
|
||||
import _ from 'lodash';
|
||||
import { useMemo } from 'react';
|
||||
import RowActions from '../components/row-actions';
|
||||
import { BenchmarkStatus, BenchmarkStatusLabelMap } from '../config';
|
||||
import { BenchmarkListItem as ListItem } from '../config/types';
|
||||
|
||||
const actionList = [
|
||||
{
|
||||
key: 'edit',
|
||||
label: 'common.button.edit',
|
||||
icon: icons.EditOutlined
|
||||
},
|
||||
{
|
||||
key: 'delete',
|
||||
label: 'common.button.delete',
|
||||
icon: icons.DeleteOutlined,
|
||||
props: {
|
||||
danger: true
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
const useBenchmarkColumns = (
|
||||
sortOrder: string[],
|
||||
handleSelect: (val: string, record: ListItem) => void,
|
||||
@@ -174,10 +157,7 @@ const useBenchmarkColumns = (
|
||||
showTitle: false
|
||||
},
|
||||
render: (value: string, record: ListItem) => (
|
||||
<DropdownButtons
|
||||
items={actionList}
|
||||
onSelect={(val) => handleSelect(val, record)}
|
||||
></DropdownButtons>
|
||||
<RowActions record={record} handleSelect={handleSelect}></RowActions>
|
||||
)
|
||||
}
|
||||
];
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import { useState } from 'react';
|
||||
import { BENCHMARKS_API } from '../apis';
|
||||
import { BenchmarkListItem as ListItem } from '../config/types';
|
||||
|
||||
const useViewLogs = () => {
|
||||
const [openModalStatus, setOpenModalStatus] = useState<{
|
||||
open: boolean;
|
||||
url: string;
|
||||
tail?: number;
|
||||
status?: string;
|
||||
}>({
|
||||
open: false,
|
||||
url: '',
|
||||
tail: 1000,
|
||||
status: undefined
|
||||
});
|
||||
|
||||
const openModal = (row?: ListItem) => {
|
||||
setOpenModalStatus({
|
||||
open: true,
|
||||
url: `${BENCHMARKS_API}/${row?.id}/logs`,
|
||||
tail: 1000,
|
||||
status: row?.state || undefined
|
||||
});
|
||||
};
|
||||
|
||||
const closeModal = () => {
|
||||
setOpenModalStatus({
|
||||
open: false,
|
||||
url: '',
|
||||
tail: 1000,
|
||||
status: undefined
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
openViewLogsModalStatus: openModalStatus,
|
||||
setOpenViewLogsModalStatus: setOpenModalStatus,
|
||||
openViewLogsModal: openModal,
|
||||
closeViewLogsModal: closeModal
|
||||
};
|
||||
};
|
||||
|
||||
export default useViewLogs;
|
||||
Reference in New Issue
Block a user