MCPcopy
hub / github.com/TaskingAI/TaskingAI / ModalTable

Function ModalTable

frontend/src/components/modalTable/index.tsx:13–456  ·  view source on GitHub ↗
({ columns, ifAllowNew,title, hangleFilterData,isShowNewCreateButton=true, ifOnlyId, defaultSelectedRowKeys, updatePrevButton,ifHideLeftHeader, ifHideFooter=false, dataSource, mode, ifSelect, onChildEvent, id, hasMore, onOpenDrawer, name, handleRecordsSelected }: TableProps)

Source from the content-addressed store, hash-verified

11import NoProject from '../../assets/img/NO_PROJECT.svg?react'
12import { TableProps } from '../../constant/index'
13function ModalTable({ columns, ifAllowNew,title, hangleFilterData,isShowNewCreateButton=true, ifOnlyId, defaultSelectedRowKeys, updatePrevButton,ifHideLeftHeader, ifHideFooter=false, dataSource, mode, ifSelect, onChildEvent, id, hasMore, onOpenDrawer, name, handleRecordsSelected }: TableProps) {
14 const [selectedValue, setSelectedValue] = useState('id_search')
15 const [inputValue, setInputValue] = useState('')
16 const [scroll, setScroll] = useState({ x: 0, y: 0 });
17 const [ifClickPageSizeLimit, setIfClickPageSizeLimit] = useState(false)
18 const [flagPrev, setFlagPrev] = useState(false)
19 const [originalDataSource, setOriginalDataSource] = useState<any[]>([]);
20 const [flagNext, setFlagNext] = useState(false)
21 const [nextButtonDisabled, setNextButtonDisabled] = useState(false)
22 const [previousButtonDisabled, setPrevButtonDisabled] = useState(true)
23 const [isFirstRender, setIsFirstRender] = useState(true);
24 const [_filterConfig, setFilterConfig] = useState<any>({
25 limit: 20,
26 sort_field: 'created_timestamp',
27 })
28 const [enterPlaceHolder, setEnterPlaceHolder] = useState('Enter Name')
29 const empty: Record<string, any> = {
30 ['API Key']: <NoApikey style={{ width: '158px', height: '100px' }} />,
31 assistant: <NoAssistant style={{ width: '158px', height: '100px' }} />,
32 collection: <NoCollection style={{ width: '158px', height: '100px' }} />,
33 model: <NoModel style={{ width: '158px', height: '100px' }} />,
34 record: <NoRecord style={{ width: '158px', height: '100px' }} />,
35 action: <NoTool style={{ width: '158px', height: '100px' }} />,
36 plugin: <NoTool style={{ width: '158px', height: '100px' }} />,
37 Invoice: <NoRecord style={{ width: '158px', height: '100px' }} />,
38 project: <NoProject style={{ width: '158px', height: '100px' }} />,
39 }
40 const [selectedRowKeys, setSelectedRowKeys] = useState((defaultSelectedRowKeys && defaultSelectedRowKeys.length) ? defaultSelectedRowKeys : []);
41 useEffect(() => {
42 const updateScroll = () => {
43 let tableContainer: HTMLElement | null = document.querySelector('.ant-table-container .ant-table-body table');
44 let tableContainerH: HTMLElement | null = document.querySelector('.ant-table-container');
45 let modalInnerTable: HTMLElement | null = document.querySelector('.modal-inner-table');
46 let modalOpen = true;
47 if (modalInnerTable) {
48 modalOpen = getComputedStyle(modalInnerTable).display === 'none'
49 }
50 let elementsWithPrefix: any = document.querySelectorAll('[class*="_drawer-inner-table"]');
51 let elementsWithPrefix1: any = document.querySelectorAll('[class*="_drawer-inner-chunk"]');
52 let containerWidth = 0;
53 let containerHeight = 0;
54 if (!modalInnerTable && elementsWithPrefix.length === 0 && elementsWithPrefix1.length === 0) {
55 setTimeout(() => {
56 if (!tableContainer) {
57 return
58 }
59 containerWidth = tableContainer.offsetWidth;
60
61 containerHeight = tableContainerH?.offsetHeight as any;
62 setScroll({
63 x: containerWidth,
64 y: containerHeight - 61
65 });
66 }, 0)
67 } else if (elementsWithPrefix.length !== 0 && elementsWithPrefix1.length === 0 && modalOpen) {
68
69 setTimeout(() => {
70 let firstElement = elementsWithPrefix[0];

Callers

nothing calls this directly

Calls 3

updateScrollFunction · 0.85
handleRowClickFunction · 0.85
popMethod · 0.45

Tested by

no test coverage detected