|
1 | 1 | /* eslint-disable @typescript-eslint/no-explicit-any */ |
2 | | -import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; |
3 | 2 | import { MUIDataTableColumn, MUIDataTableMeta } from 'mui-datatables'; |
4 | 3 | import React, { useState } from 'react'; |
5 | | -import { Accordion, AccordionDetails, AccordionSummary, Box, Typography } from '../../base'; |
| 4 | +import { Box, Typography } from '../../base'; |
6 | 5 | import { DeleteIcon, EnvironmentIcon, ViewIcon } from '../../icons'; |
7 | 6 | import { useTheme } from '../../theme'; |
8 | 7 | import { NameDiv } from '../CatalogDesignTable/style'; |
@@ -77,23 +76,25 @@ const WorkspaceViewsTable: React.FC<ViewsTableProps> = ({ |
77 | 76 | handleShowDetails |
78 | 77 | }) => { |
79 | 78 | const theme = useTheme(); |
80 | | - const [expanded, setExpanded] = useState<boolean>(true); |
81 | | - const handleAccordionChange = () => { |
82 | | - setExpanded(!expanded); |
83 | | - }; |
| 79 | + |
84 | 80 | const [search, setSearch] = useState(''); |
85 | 81 | const [isSearchExpanded, setIsSearchExpanded] = useState(false); |
86 | 82 | const [page, setPage] = useState<number>(0); |
87 | 83 | const [pageSize, setPageSize] = useState<number>(10); |
88 | 84 | const [sortOrder, setSortOrder] = useState<string>('updated_at desc'); |
89 | | - const { data: viewsOfWorkspace } = useGetViewsOfWorkspaceQuery({ |
90 | | - workspaceId, |
91 | | - page: page, |
92 | | - pageSize: pageSize, |
93 | | - search: search, |
94 | | - order: sortOrder, |
95 | | - expandUser: true |
96 | | - }); |
| 85 | + const { data: viewsOfWorkspace } = useGetViewsOfWorkspaceQuery( |
| 86 | + { |
| 87 | + workspaceId, |
| 88 | + page: page, |
| 89 | + pageSize: pageSize, |
| 90 | + search: search, |
| 91 | + order: sortOrder, |
| 92 | + expandUser: true |
| 93 | + }, |
| 94 | + { |
| 95 | + skip: !workspaceId |
| 96 | + } |
| 97 | + ); |
97 | 98 | const { width } = useWindowDimensions(); |
98 | 99 | const [unassignviewFromWorkspace] = useUnassignViewFromWorkspaceMutation(); |
99 | 100 | const columns: MUIDataTableColumn[] = [ |
@@ -305,60 +306,50 @@ const WorkspaceViewsTable: React.FC<ViewsTableProps> = ({ |
305 | 306 |
|
306 | 307 | return ( |
307 | 308 | <> |
308 | | - <Accordion expanded={expanded} onChange={handleAccordionChange} style={{ margin: 0 }}> |
309 | | - <AccordionSummary |
310 | | - expandIcon={<ExpandMoreIcon />} |
311 | | - sx={{ |
312 | | - backgroundColor: 'background.paper' |
313 | | - }} |
314 | | - > |
315 | | - <TableHeader> |
316 | | - <Box display={'flex'} alignItems="center" gap={1} width="100%"> |
317 | | - <ViewIcon height="1.5rem" width="1.5rem" fill={theme.palette.icon.brand} /> |
318 | | - <Typography variant="body1" fontWeight={'bold'}> |
319 | | - Assigned Views |
320 | | - </Typography> |
321 | | - </Box> |
322 | | - <TableRightActionHeader> |
323 | | - <SearchBar |
324 | | - onSearch={(value) => { |
325 | | - setSearch(value); |
326 | | - }} |
327 | | - onClear={() => { |
328 | | - setSearch(''); |
329 | | - }} |
330 | | - expanded={isSearchExpanded} |
331 | | - setExpanded={setIsSearchExpanded} |
332 | | - placeholder="Search workspaces..." |
333 | | - /> |
334 | | - <CustomColumnVisibilityControl |
335 | | - columns={columns} |
336 | | - customToolsProps={{ |
337 | | - columnVisibility, |
338 | | - setColumnVisibility |
339 | | - }} |
340 | | - id={'views-table'} |
341 | | - /> |
342 | | - <L5EditIcon |
343 | | - onClick={viewAssignment.handleAssignModal} |
344 | | - disabled={!isAssignAllowed} |
345 | | - title="Assign Views" |
346 | | - /> |
347 | | - </TableRightActionHeader> |
348 | | - </TableHeader> |
349 | | - </AccordionSummary> |
350 | | - <AccordionDetails style={{ padding: 0 }}> |
351 | | - <ResponsiveDataTable |
| 309 | + <TableHeader style={{ padding: '1rem' }}> |
| 310 | + <Box display={'flex'} alignItems="center" gap={1} width="100%"> |
| 311 | + <ViewIcon height="1.5rem" width="1.5rem" fill={theme.palette.icon.brand} /> |
| 312 | + <Typography variant="body1" fontWeight={'bold'}> |
| 313 | + Assigned Views |
| 314 | + </Typography> |
| 315 | + </Box> |
| 316 | + <TableRightActionHeader style={{ marginRight: '0rem' }}> |
| 317 | + <SearchBar |
| 318 | + onSearch={(value) => { |
| 319 | + setSearch(value); |
| 320 | + }} |
| 321 | + onClear={() => { |
| 322 | + setSearch(''); |
| 323 | + }} |
| 324 | + expanded={isSearchExpanded} |
| 325 | + setExpanded={setIsSearchExpanded} |
| 326 | + placeholder="Search workspaces..." |
| 327 | + /> |
| 328 | + <CustomColumnVisibilityControl |
352 | 329 | columns={columns} |
353 | | - data={viewsOfWorkspace?.views} |
354 | | - options={options} |
355 | | - colViews={colViews} |
356 | | - tableCols={tableCols} |
357 | | - updateCols={updateCols} |
358 | | - columnVisibility={columnVisibility} |
| 330 | + customToolsProps={{ |
| 331 | + columnVisibility, |
| 332 | + setColumnVisibility |
| 333 | + }} |
| 334 | + id={'views-table'} |
| 335 | + /> |
| 336 | + <L5EditIcon |
| 337 | + onClick={viewAssignment.handleAssignModal} |
| 338 | + disabled={!isAssignAllowed} |
| 339 | + title="Assign Views" |
359 | 340 | /> |
360 | | - </AccordionDetails> |
361 | | - </Accordion> |
| 341 | + </TableRightActionHeader> |
| 342 | + </TableHeader> |
| 343 | + |
| 344 | + <ResponsiveDataTable |
| 345 | + columns={columns} |
| 346 | + data={viewsOfWorkspace?.views} |
| 347 | + options={options} |
| 348 | + colViews={colViews} |
| 349 | + tableCols={tableCols} |
| 350 | + updateCols={updateCols} |
| 351 | + columnVisibility={columnVisibility} |
| 352 | + /> |
362 | 353 |
|
363 | 354 | <AssignmentModal |
364 | 355 | open={viewAssignment.assignModal} |
|
0 commit comments