MCPcopy
hub / github.com/Tencent/CodeAnalysis / ToolLibs

Function ToolLibs

web/packages/tca-layout/src/modules/tool-libs/index.tsx:21–82  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19import { useOrgAdminPerm } from '@src/utils/hooks';
20
21export const ToolLibs = () => {
22 const { orgSid }: any = useParams();
23 // 弹框
24 const [modalData, setModalData] = useState({
25 visible: false,
26 libId: null,
27 });
28 // 是否可编辑
29 const [editable, , isSuperuser] = useOrgAdminPerm();
30 // 数据源
31 const { filter, currentPage, pageSize, searchParams } = useURLParams(filterFields);
32 const [{ data, isLoading }, reload] = useFetch(getToolLibs, [orgSid, filter]);
33 const { results: listData = [], count = 0 } = data || {};
34
35 return (
36 <>
37 <PageHeader title={t('工具依赖')} description={t('工具最小单元,用于组合工具')} action={
38 editable && (
39 <Button
40 theme='primary'
41 onClick={() => setModalData({
42 visible: true,
43 libId: null,
44 })}
45 >
46 {t('添加依赖')}
47 </Button>
48 )
49 } />
50 <Search
51 searchParams={searchParams}
52 fields={TOOLLIB_SEARCH_FIELDS}
53 />
54 <div className='tca-px-lg'>
55 <Table loading={isLoading} dataSource={listData}
56 opCell={row => <Space>
57 <Button variant='text' theme='primary' onClick={() => setModalData({ visible: true, libId: row.id })} >{t('编辑')}</Button>
58 </Space>}
59 pagination={{
60 current: currentPage,
61 total: count,
62 pageSize,
63 }} />
64 </div>
65 {
66 editable && (
67 <CreateToollibs
68 orgSid={orgSid}
69 isSuperuser={isSuperuser}
70 visible={modalData.visible}
71 libId={modalData.libId}
72 onClose={() => setModalData({
73 visible: false,
74 libId: null,
75 })}
76 callback={() => reload()}
77 />
78 )

Callers

nothing calls this directly

Calls 4

useOrgAdminPermFunction · 0.90
useURLParamsFunction · 0.90
useFetchFunction · 0.90
reloadFunction · 0.85

Tested by

no test coverage detected