1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00

chore: don't hide columns in connected instances table (#6264)

Don't hide anything yet, so remove related code. Plus other code we
don't need has been removed.
This commit is contained in:
Thomas Heartman 2024-02-19 14:37:13 +08:00 committed by GitHub
parent 0e9102fb22
commit bd907244c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 58 deletions

View File

@ -26,28 +26,17 @@ export const ConnectedInstances = () => {
); );
}, [application]); }, [application]);
const { const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } =
getTableProps, useConnectedInstancesTable(tableData);
getTableBodyProps,
headerGroups,
rows,
prepareRow,
state: { globalFilter },
setHiddenColumns,
columns,
} = useConnectedInstancesTable(tableData);
return ( return (
<ConnectedInstancesTable <ConnectedInstancesTable
loading={false} loading={false}
headerGroups={headerGroups} headerGroups={headerGroups}
setHiddenColumns={setHiddenColumns}
prepareRow={prepareRow} prepareRow={prepareRow}
getTableBodyProps={getTableBodyProps} getTableBodyProps={getTableBodyProps}
getTableProps={getTableProps} getTableProps={getTableProps}
rows={rows} rows={rows}
columns={columns}
globalFilter={globalFilter}
/> />
); );
}; };

View File

@ -11,27 +11,11 @@ import {
TableCell, TableCell,
TablePlaceholder, TablePlaceholder,
} from 'component/common/Table'; } from 'component/common/Table';
import { import { Box, Table, TableBody, TableRow } from '@mui/material';
Box,
styled,
Table,
TableBody,
TableRow,
useMediaQuery,
} from '@mui/material';
import theme from 'themes/theme';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { useConditionallyHiddenColumns } from 'hooks/useConditionallyHiddenColumns';
const hiddenColumnsSmall = ['ip', 'sdkVersion'];
const hiddenColumnsCompact = ['ip', 'sdkVersion', 'lastSeen'];
type ConnectedInstancesTableProps = { type ConnectedInstancesTableProps = {
compact?: boolean;
loading: boolean; loading: boolean;
setHiddenColumns: (param: any) => void;
columns: any[];
rows: Row<object>[]; rows: Row<object>[];
prepareRow: (row: Row<object>) => void; prepareRow: (row: Row<object>) => void;
getTableProps: ( getTableProps: (
@ -41,37 +25,15 @@ type ConnectedInstancesTableProps = {
propGetter?: TableBodyPropGetter<object> | undefined, propGetter?: TableBodyPropGetter<object> | undefined,
) => TableBodyProps; ) => TableBodyProps;
headerGroups: HeaderGroup<object>[]; headerGroups: HeaderGroup<object>[];
globalFilter: any;
}; };
export const ConnectedInstancesTable = ({ export const ConnectedInstancesTable = ({
compact = false,
setHiddenColumns,
columns,
loading, loading,
rows, rows,
getTableProps, getTableProps,
getTableBodyProps, getTableBodyProps,
headerGroups, headerGroups,
globalFilter,
prepareRow, prepareRow,
}: ConnectedInstancesTableProps) => { }: ConnectedInstancesTableProps) => {
const isSmallScreen = useMediaQuery(theme.breakpoints.down('md'));
useConditionallyHiddenColumns(
[
{
condition: isSmallScreen,
columns: hiddenColumnsSmall,
},
{
condition: compact,
columns: hiddenColumnsCompact,
},
],
setHiddenColumns,
columns,
);
return ( return (
<> <>
<Box sx={{ overflowX: 'auto' }}> <Box sx={{ overflowX: 'auto' }}>

View File

@ -1,13 +1,7 @@
import { useMemo } from 'react'; import { useMemo } from 'react';
import { IApiToken } from 'hooks/api/getters/useApiTokens/useApiTokens';
import { DateCell } from 'component/common/Table/cells/DateCell/DateCell';
import { HighlightCell } from 'component/common/Table/cells/HighlightCell/HighlightCell'; import { HighlightCell } from 'component/common/Table/cells/HighlightCell/HighlightCell';
import { IconCell } from 'component/common/Table/cells/IconCell/IconCell';
import { TimeAgoCell } from 'component/common/Table/cells/TimeAgoCell/TimeAgoCell';
import { useTable, useGlobalFilter, useSortBy } from 'react-table'; import { useTable, useGlobalFilter, useSortBy } from 'react-table';
import { sortTypes } from 'utils/sortTypes'; import { sortTypes } from 'utils/sortTypes';
import { ProjectsList } from 'component/admin/apiToken/ProjectsList/ProjectsList';
import { Key } from '@mui/icons-material';
type ConnectedInstancesTableData = { type ConnectedInstancesTableData = {
instanceId: string; instanceId: string;