diff --git a/src/components/PaginatedTable/TableChunk.tsx b/src/components/PaginatedTable/TableChunk.tsx index 7fd2124b4..75fc2a5c2 100644 --- a/src/components/PaginatedTable/TableChunk.tsx +++ b/src/components/PaginatedTable/TableChunk.tsx @@ -47,12 +47,15 @@ export const TableChunk = ({ const [isTimeoutActive, setIsTimeoutActive] = React.useState(true); const [autoRefreshInterval] = useAutoRefreshInterval(); + const columnsIds = columns.map((column) => column.name); + const queryParams = { offset: id * limit, limit, fetchData: fetchData as FetchData, filters, sortParams, + columnsIds, tableName, }; diff --git a/src/components/PaginatedTable/types.ts b/src/components/PaginatedTable/types.ts index 4d496a7e5..4e4092e7f 100644 --- a/src/components/PaginatedTable/types.ts +++ b/src/components/PaginatedTable/types.ts @@ -47,6 +47,7 @@ type FetchDataParams = { offset: number; filters?: F; sortParams?: SortParams; + columnsIds: string[]; signal?: AbortSignal; } & E; diff --git a/src/components/nodesColumns/columns.tsx b/src/components/nodesColumns/columns.tsx index 1b1175a58..68e0fac85 100644 --- a/src/components/nodesColumns/columns.tsx +++ b/src/components/nodesColumns/columns.tsx @@ -7,6 +7,7 @@ import {valueIsDefined} from '../../utils'; import {EMPTY_DATA_PLACEHOLDER} from '../../utils/constants'; import {formatStorageValuesToGb} from '../../utils/dataFormatters/dataFormatters'; import {getSpaceUsageSeverity} from '../../utils/storage'; +import type {Column} from '../../utils/tableUtils/types'; import {CellWithPopover} from '../CellWithPopover/CellWithPopover'; import {NodeHostWrapper} from '../NodeHostWrapper/NodeHostWrapper'; import type {NodeHostData} from '../NodeHostWrapper/NodeHostWrapper'; @@ -16,7 +17,7 @@ import {TabletsStatistic} from '../TabletsStatistic'; import {UsageLabel} from '../UsageLabel/UsageLabel'; import {NODES_COLUMNS_IDS, NODES_COLUMNS_TITLES} from './constants'; -import type {Column, GetNodesColumnsParams} from './types'; +import type {GetNodesColumnsParams} from './types'; export function getNodeIdColumn(): Column { return { diff --git a/src/components/nodesColumns/constants.ts b/src/components/nodesColumns/constants.ts index e66c24212..97813b90f 100644 --- a/src/components/nodesColumns/constants.ts +++ b/src/components/nodesColumns/constants.ts @@ -1,3 +1,4 @@ +import type {NodesRequiredField} from '../../types/api/nodes'; import type {ValueOf} from '../../types/common'; import i18n from './i18n'; @@ -21,6 +22,7 @@ export const NODES_COLUMNS_IDS = { TotalSessions: 'TotalSessions', Missing: 'Missing', Tablets: 'Tablets', + PDisks: 'PDisks', } as const; export type NodesColumnId = ValueOf; @@ -76,4 +78,29 @@ export const NODES_COLUMNS_TITLES = { get Tablets() { return i18n('tablets'); }, + get PDisks() { + return i18n('pdisks'); + }, } as const satisfies Record; + +// Although columns ids mostly similar to backend fields, there might be some difference +// Also for some columns we may use more than one field +export const NODES_COLUMNS_TO_DATA_FIELDS: Record = { + NodeId: ['NodeId'], + Host: ['Host', 'Rack', 'Database', 'SystemState'], + NodeName: ['NodeName'], + DC: ['DC'], + Rack: ['Rack'], + Version: ['Version'], + Uptime: ['Uptime'], + Memory: ['Memory'], + CPU: ['CPU'], + LoadAverage: ['LoadAverage'], + Load: ['LoadAverage'], + DiskSpaceUsage: ['DiskSpaceUsage'], + SharedCacheUsage: ['SystemState'], + TotalSessions: ['SystemState'], + Missing: ['Missing'], + Tablets: ['Tablets', 'Database'], + PDisks: ['PDisks'], +}; diff --git a/src/components/nodesColumns/i18n/en.json b/src/components/nodesColumns/i18n/en.json index 5b6f99f95..0638d8ea5 100644 --- a/src/components/nodesColumns/i18n/en.json +++ b/src/components/nodesColumns/i18n/en.json @@ -14,5 +14,6 @@ "load": "Load", "caches": "Caches", "sessions": "Sessions", - "missing": "Missing" + "missing": "Missing", + "pdisks": "PDisks" } diff --git a/src/components/nodesColumns/types.ts b/src/components/nodesColumns/types.ts index 8bf42cd9e..f09990a20 100644 --- a/src/components/nodesColumns/types.ts +++ b/src/components/nodesColumns/types.ts @@ -1,9 +1,4 @@ -import type {Column as DataTableColumn} from '@gravity-ui/react-data-table'; - import type {GetNodeRefFunc} from '../../types/additionalProps'; -import type {Column as PaginatedTableColumn} from '../PaginatedTable'; - -export type Column = PaginatedTableColumn & DataTableColumn; export interface GetNodesColumnsParams { getNodeRef?: GetNodeRefFunc; diff --git a/src/containers/Nodes/columns/columns.tsx b/src/containers/Nodes/columns/columns.tsx index d81ef4057..8041fa647 100644 --- a/src/containers/Nodes/columns/columns.tsx +++ b/src/containers/Nodes/columns/columns.tsx @@ -11,9 +11,10 @@ import { getUptimeColumn, getVersionColumn, } from '../../../components/nodesColumns/columns'; -import type {Column, GetNodesColumnsParams} from '../../../components/nodesColumns/types'; +import type {GetNodesColumnsParams} from '../../../components/nodesColumns/types'; import type {NodesPreparedEntity} from '../../../store/reducers/nodes/types'; import {isSortableNodesProperty} from '../../../utils/nodes'; +import type {Column} from '../../../utils/tableUtils/types'; export function getNodesColumns(params: GetNodesColumnsParams): Column[] { const columns = [ diff --git a/src/containers/Nodes/getNodes.ts b/src/containers/Nodes/getNodes.ts index 340fd3a2a..7fd7a11ef 100644 --- a/src/containers/Nodes/getNodes.ts +++ b/src/containers/Nodes/getNodes.ts @@ -1,4 +1,5 @@ import type {FetchData} from '../../components/PaginatedTable'; +import {NODES_COLUMNS_TO_DATA_FIELDS} from '../../components/nodesColumns/constants'; import type {NodesFilters, NodesPreparedEntity} from '../../store/reducers/nodes/types'; import {prepareNodesData} from '../../store/reducers/nodes/utils'; import type {NodesRequestParams} from '../../types/api/nodes'; @@ -8,6 +9,7 @@ import { getUptimeParamValue, isSortableNodesProperty, } from '../../utils/nodes'; +import {getRequiredDataFields} from '../../utils/tableUtils/getRequiredDataFields'; const getConcurrentId = (limit?: number, offset?: number) => { return `getNodes|offset${offset}|limit${limit}`; @@ -26,6 +28,7 @@ export const getNodes: FetchData< offset, sortParams, filters, + columnsIds, } = params; const {sortOrder, columnId} = sortParams ?? {}; @@ -35,6 +38,8 @@ export const getNodes: FetchData< ? prepareSortValue(columnId, sortOrder) : undefined; + const dataFieldsRequired = getRequiredDataFields(columnsIds, NODES_COLUMNS_TO_DATA_FIELDS); + const response = await window.api.getNodes( { type, @@ -48,6 +53,7 @@ export const getNodes: FetchData< filter: searchValue, problems_only: getProblemParamValue(problemFilter), uptime: getUptimeParamValue(uptimeFilter), + fieldsRequired: dataFieldsRequired, }, {concurrentId: getConcurrentId(limit, offset), signal: params.signal}, ); diff --git a/src/containers/Storage/StorageGroups/columns/constants.ts b/src/containers/Storage/StorageGroups/columns/constants.ts index d084adada..b6862fbad 100644 --- a/src/containers/Storage/StorageGroups/columns/constants.ts +++ b/src/containers/Storage/StorageGroups/columns/constants.ts @@ -1,7 +1,7 @@ import type {SelectOption} from '@gravity-ui/uikit'; import {z} from 'zod'; -import type {GroupsGroupByField} from '../../../../types/api/storage'; +import type {GroupsGroupByField, GroupsRequiredField} from '../../../../types/api/storage'; import type {ValueOf} from '../../../../types/common'; import i18n from './i18n'; @@ -31,7 +31,7 @@ export const STORAGE_GROUPS_COLUMNS_IDS = { State: 'State', } as const; -type StorageGroupsColumnId = ValueOf; +export type StorageGroupsColumnId = ValueOf; export const DEFAULT_STORAGE_GROUPS_COLUMNS: StorageGroupsColumnId[] = [ 'GroupId', @@ -136,3 +136,29 @@ export const storageGroupsGroupByParamSchema = z GroupsGroupByField | undefined >((value) => STORAGE_GROUPS_GROUP_BY_PARAMS.includes(value)) .catch(undefined); + +// Although columns ids mostly similar to backend fields, there might be some difference +// Also for some columns we may use more than one field +export const GROUPS_COLUMNS_TO_DATA_FIELDS: Record = { + GroupId: ['GroupId'], + PoolName: ['PoolName'], + // We display MediaType and Encryption in one Type column + MediaType: ['MediaType', 'Encryption'], + Encryption: ['Encryption'], + Erasure: ['Erasure'], + Used: ['Used'], + Limit: ['Limit'], + Usage: ['Usage'], + DiskSpaceUsage: ['DiskSpaceUsage'], + DiskSpace: ['State'], + Read: ['Read'], + Write: ['Write'], + Latency: ['Latency'], + AllocationUnits: ['AllocationUnits'], + // Read and Write fields make backend to return Whiteboard data + VDisks: ['VDisk', 'PDisk', 'Read', 'Write'], + VDisksPDisks: ['VDisk', 'PDisk', 'Read', 'Write'], + MissingDisks: ['MissingDisks'], + Degraded: ['MissingDisks'], + State: ['State'], +}; diff --git a/src/containers/Storage/StorageGroups/columns/types.ts b/src/containers/Storage/StorageGroups/columns/types.ts index 8697d4423..03c615cd6 100644 --- a/src/containers/Storage/StorageGroups/columns/types.ts +++ b/src/containers/Storage/StorageGroups/columns/types.ts @@ -1,11 +1,8 @@ -import type {Column as DataTableColumn} from '@gravity-ui/react-data-table'; - -import type {Column as PaginatedTableColumn} from '../../../../components/PaginatedTable'; import type {PreparedStorageGroup, VisibleEntities} from '../../../../store/reducers/storage/types'; +import type {Column} from '../../../../utils/tableUtils/types'; import type {StorageViewContext} from '../../types'; -export type StorageGroupsColumn = PaginatedTableColumn & - DataTableColumn; +export type StorageGroupsColumn = Column; export interface GetStorageColumnsData { viewContext: StorageViewContext; diff --git a/src/containers/Storage/StorageGroups/getGroups.ts b/src/containers/Storage/StorageGroups/getGroups.ts index 11f496453..d4e39de90 100644 --- a/src/containers/Storage/StorageGroups/getGroups.ts +++ b/src/containers/Storage/StorageGroups/getGroups.ts @@ -8,13 +8,16 @@ import type { } from '../../../store/reducers/storage/types'; import {prepareSortValue} from '../../../utils/filters'; import {isSortableStorageProperty} from '../../../utils/storage'; +import {getRequiredDataFields} from '../../../utils/tableUtils/getRequiredDataFields'; + +import {GROUPS_COLUMNS_TO_DATA_FIELDS} from './columns/constants'; type GetStorageGroups = FetchData; export function useGroupsGetter(shouldUseGroupsHandler: boolean) { const fetchData: GetStorageGroups = React.useCallback( async (params) => { - const {limit, offset, sortParams, filters} = params; + const {limit, offset, sortParams, filters, columnsIds} = params; const {sortOrder, columnId} = sortParams ?? {}; const { searchValue, @@ -31,6 +34,11 @@ export function useGroupsGetter(shouldUseGroupsHandler: boolean) { ? prepareSortValue(columnId, sortOrder) : undefined; + const dataFieldsRequired = getRequiredDataFields( + columnsIds, + GROUPS_COLUMNS_TO_DATA_FIELDS, + ); + const {groups, found, total} = await requestStorageData({ limit, offset, @@ -43,6 +51,7 @@ export function useGroupsGetter(shouldUseGroupsHandler: boolean) { pDiskId, filter_group: filterGroup, filter_group_by: filterGroupBy, + fieldsRequired: dataFieldsRequired, shouldUseGroupsHandler, }); diff --git a/src/containers/Storage/StorageNodes/columns/columns.tsx b/src/containers/Storage/StorageNodes/columns/columns.tsx index 8368df464..5f72e4123 100644 --- a/src/containers/Storage/StorageNodes/columns/columns.tsx +++ b/src/containers/Storage/StorageNodes/columns/columns.tsx @@ -13,12 +13,15 @@ import { getUptimeColumn, getVersionColumn, } from '../../../../components/nodesColumns/columns'; +import { + NODES_COLUMNS_IDS, + NODES_COLUMNS_TITLES, +} from '../../../../components/nodesColumns/constants'; import type {PreparedStorageNode} from '../../../../store/reducers/storage/types'; import {cn} from '../../../../utils/cn'; import {isSortableNodesProperty} from '../../../../utils/nodes'; import {PDisk} from '../../PDisk/PDisk'; -import {STORAGE_NODES_COLUMNS_IDS, STORAGE_NODES_COLUMNS_TITLES} from './constants'; import type {GetStorageNodesColumnsParams, StorageNodesColumn} from './types'; import './StorageNodesColumns.scss'; @@ -27,8 +30,8 @@ const b = cn('ydb-storage-nodes-columns'); const getPDisksColumn = ({viewContext}: GetStorageNodesColumnsParams): StorageNodesColumn => { return { - name: STORAGE_NODES_COLUMNS_IDS.PDisks, - header: STORAGE_NODES_COLUMNS_TITLES.PDisks, + name: NODES_COLUMNS_IDS.PDisks, + header: NODES_COLUMNS_TITLES.PDisks, className: b('pdisks-column'), render: ({row}) => { return ( diff --git a/src/containers/Storage/StorageNodes/columns/constants.ts b/src/containers/Storage/StorageNodes/columns/constants.ts index dbf89c581..30e81ca73 100644 --- a/src/containers/Storage/StorageNodes/columns/constants.ts +++ b/src/containers/Storage/StorageNodes/columns/constants.ts @@ -1,26 +1,14 @@ import type {SelectOption} from '@gravity-ui/uikit'; import {z} from 'zod'; -import { - NODES_COLUMNS_IDS as BASE_NODES_COLUMNS_IDS, - NODES_COLUMNS_TITLES as BASE_NODES_COLUMNS_TITLES, -} from '../../../../components/nodesColumns/constants'; +import type {NodesColumnId} from '../../../../components/nodesColumns/constants'; +import {NODES_COLUMNS_TITLES} from '../../../../components/nodesColumns/constants'; import type {NodesGroupByField} from '../../../../types/api/nodes'; -import type {ValueOf} from '../../../../types/common'; - -import i18n from './i18n'; export const STORAGE_NODES_COLUMNS_WIDTH_LS_KEY = 'storageNodesColumnsWidth'; export const STORAGE_NODES_SELECTED_COLUMNS_LS_KEY = 'storageNodesSelectedColumns'; -export const STORAGE_NODES_COLUMNS_IDS = { - ...BASE_NODES_COLUMNS_IDS, - PDisks: 'PDisks', -} as const; - -type StorageNodesColumnId = ValueOf; - -export const DEFAULT_STORAGE_NODES_COLUMNS: StorageNodesColumnId[] = [ +export const DEFAULT_STORAGE_NODES_COLUMNS: NodesColumnId[] = [ 'NodeId', 'Host', 'DC', @@ -29,16 +17,7 @@ export const DEFAULT_STORAGE_NODES_COLUMNS: StorageNodesColumnId[] = [ 'Uptime', 'PDisks', ]; -export const REQUIRED_STORAGE_NODES_COLUMNS: StorageNodesColumnId[] = ['NodeId']; - -// This code is running when module is initialized and correct language may not be set yet -// get functions guarantee that i18n fields will be inited on render with current render language -export const STORAGE_NODES_COLUMNS_TITLES = { - ...BASE_NODES_COLUMNS_TITLES, - get PDisks() { - return i18n('pdisks'); - }, -} as const satisfies Record; +export const REQUIRED_STORAGE_NODES_COLUMNS: NodesColumnId[] = ['NodeId']; const STORAGE_NODES_GROUP_BY_PARAMS = [ 'Host', @@ -54,7 +33,7 @@ export const STORAGE_NODES_GROUP_BY_OPTIONS: SelectOption[] = STORAGE_NODES_GROU (param) => { return { value: param, - content: STORAGE_NODES_COLUMNS_TITLES[param], + content: NODES_COLUMNS_TITLES[param], }; }, ); diff --git a/src/containers/Storage/StorageNodes/columns/hooks.ts b/src/containers/Storage/StorageNodes/columns/hooks.ts index 694238e1e..9f05a4aa3 100644 --- a/src/containers/Storage/StorageNodes/columns/hooks.ts +++ b/src/containers/Storage/StorageNodes/columns/hooks.ts @@ -1,5 +1,9 @@ import React from 'react'; +import { + NODES_COLUMNS_IDS, + NODES_COLUMNS_TITLES, +} from '../../../../components/nodesColumns/constants'; import {VISIBLE_ENTITIES} from '../../../../store/reducers/storage/constants'; import {useSelectedColumns} from '../../../../utils/hooks/useSelectedColumns'; @@ -7,8 +11,6 @@ import {getStorageNodesColumns} from './columns'; import { DEFAULT_STORAGE_NODES_COLUMNS, REQUIRED_STORAGE_NODES_COLUMNS, - STORAGE_NODES_COLUMNS_IDS, - STORAGE_NODES_COLUMNS_TITLES, STORAGE_NODES_SELECTED_COLUMNS_LS_KEY, } from './constants'; import type {GetStorageNodesColumnsParams} from './types'; @@ -25,7 +27,7 @@ export function useStorageNodesSelectedColumns({ const requiredColumns = React.useMemo(() => { if (visibleEntities === VISIBLE_ENTITIES.missing) { - return [...REQUIRED_STORAGE_NODES_COLUMNS, STORAGE_NODES_COLUMNS_IDS.Missing]; + return [...REQUIRED_STORAGE_NODES_COLUMNS, NODES_COLUMNS_IDS.Missing]; } return REQUIRED_STORAGE_NODES_COLUMNS; }, [visibleEntities]); @@ -33,7 +35,7 @@ export function useStorageNodesSelectedColumns({ return useSelectedColumns( columns, STORAGE_NODES_SELECTED_COLUMNS_LS_KEY, - STORAGE_NODES_COLUMNS_TITLES, + NODES_COLUMNS_TITLES, DEFAULT_STORAGE_NODES_COLUMNS, requiredColumns, ); diff --git a/src/containers/Storage/StorageNodes/columns/i18n/en.json b/src/containers/Storage/StorageNodes/columns/i18n/en.json deleted file mode 100644 index ce968874b..000000000 --- a/src/containers/Storage/StorageNodes/columns/i18n/en.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "pdisks": "PDisks" -} diff --git a/src/containers/Storage/StorageNodes/columns/i18n/index.ts b/src/containers/Storage/StorageNodes/columns/i18n/index.ts deleted file mode 100644 index a40213682..000000000 --- a/src/containers/Storage/StorageNodes/columns/i18n/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import {registerKeysets} from '../../../../../utils/i18n'; - -import en from './en.json'; - -const COMPONENT = 'ydb-storage-nodes-columns'; - -export default registerKeysets(COMPONENT, {en}); diff --git a/src/containers/Storage/StorageNodes/columns/types.ts b/src/containers/Storage/StorageNodes/columns/types.ts index 960a33799..049f17a9b 100644 --- a/src/containers/Storage/StorageNodes/columns/types.ts +++ b/src/containers/Storage/StorageNodes/columns/types.ts @@ -1,6 +1,6 @@ -import type {Column} from '../../../../components/nodesColumns/types'; import type {PreparedStorageNode, VisibleEntities} from '../../../../store/reducers/storage/types'; import type {AdditionalNodesProps} from '../../../../types/additionalProps'; +import type {Column} from '../../../../utils/tableUtils/types'; import type {StorageViewContext} from '../../types'; export type StorageNodesColumn = Column; diff --git a/src/containers/Storage/StorageNodes/getNodes.ts b/src/containers/Storage/StorageNodes/getNodes.ts index 8efd58a91..86ca308b5 100644 --- a/src/containers/Storage/StorageNodes/getNodes.ts +++ b/src/containers/Storage/StorageNodes/getNodes.ts @@ -1,4 +1,5 @@ import type {FetchData} from '../../../components/PaginatedTable'; +import {NODES_COLUMNS_TO_DATA_FIELDS} from '../../../components/nodesColumns/constants'; import type { PreparedStorageNode, PreparedStorageNodeFilters, @@ -7,13 +8,22 @@ import {prepareStorageNodesResponse} from '../../../store/reducers/storage/utils import type {NodesRequestParams} from '../../../types/api/nodes'; import {prepareSortValue} from '../../../utils/filters'; import {getUptimeParamValue, isSortableNodesProperty} from '../../../utils/nodes'; +import {getRequiredDataFields} from '../../../utils/tableUtils/getRequiredDataFields'; export const getStorageNodes: FetchData< PreparedStorageNode, PreparedStorageNodeFilters, Pick > = async (params) => { - const {type = 'static', storage = true, limit, offset, sortParams, filters} = params; + const { + type = 'static', + storage = true, + limit, + offset, + sortParams, + filters, + columnsIds, + } = params; const { searchValue, nodesUptimeFilter, @@ -30,6 +40,8 @@ export const getStorageNodes: FetchData< ? prepareSortValue(columnId, sortOrder) : undefined; + const dataFieldsRequired = getRequiredDataFields(columnsIds, NODES_COLUMNS_TO_DATA_FIELDS); + const response = await window.api.getNodes({ type, storage, @@ -44,6 +56,7 @@ export const getStorageNodes: FetchData< group_id: groupId, filter_group: filterGroup, filter_group_by: filterGroupBy, + fieldsRequired: dataFieldsRequired, }); const preparedResponse = prepareStorageNodesResponse(response); return { diff --git a/src/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TopNodesByLoad.tsx b/src/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TopNodesByLoad.tsx index 4d4a030e7..dafab258a 100644 --- a/src/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TopNodesByLoad.tsx +++ b/src/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TopNodesByLoad.tsx @@ -1,3 +1,5 @@ +import type {Column} from '@gravity-ui/react-data-table'; + import { getHostColumn, getLoadColumn, @@ -5,7 +7,7 @@ import { getVersionColumn, } from '../../../../../components/nodesColumns/columns'; import {NODES_COLUMNS_WIDTH_LS_KEY} from '../../../../../components/nodesColumns/constants'; -import type {Column, GetNodesColumnsParams} from '../../../../../components/nodesColumns/types'; +import type {GetNodesColumnsParams} from '../../../../../components/nodesColumns/types'; import {nodesApi} from '../../../../../store/reducers/nodes/nodes'; import type {NodesPreparedEntity} from '../../../../../store/reducers/nodes/types'; import {TENANT_DIAGNOSTICS_TABS_IDS} from '../../../../../store/reducers/tenant/constants'; diff --git a/src/store/reducers/tableData.ts b/src/store/reducers/tableData.ts index 8797d35c6..a22379f32 100644 --- a/src/store/reducers/tableData.ts +++ b/src/store/reducers/tableData.ts @@ -10,19 +10,24 @@ interface PaginatedTableParams { filters: F; limit: number; sortParams?: SortParams; + columnsIds: string[]; tableName: string; } function endpoints(build: EndpointBuilder) { return { fetchTableChunk: build.query, PaginatedTableParams>({ - queryFn: async ({offset, limit, sortParams, filters, fetchData}, {signal}) => { + queryFn: async ( + {offset, limit, sortParams, filters, columnsIds, fetchData}, + {signal}, + ) => { try { const response = await fetchData({ limit, offset, filters, sortParams, + columnsIds, signal, }); return {data: response}; diff --git a/src/types/api/storage.ts b/src/types/api/storage.ts index 21a92353f..c9d346224 100644 --- a/src/types/api/storage.ts +++ b/src/types/api/storage.ts @@ -284,7 +284,6 @@ export type GroupsRequiredField = | 'MissingDisks' | 'Degraded' | 'State' - | 'Usage' | 'Used' | 'Limit' | 'Usage' diff --git a/src/utils/tableUtils/getRequiredDataFields.ts b/src/utils/tableUtils/getRequiredDataFields.ts new file mode 100644 index 000000000..8659bba84 --- /dev/null +++ b/src/utils/tableUtils/getRequiredDataFields.ts @@ -0,0 +1,15 @@ +export function getRequiredDataFields( + columns: string[], + columnsToFields: Record, +) { + const requiredFieldsSet = columns.reduce((fields, column) => { + const columnFields = columnsToFields[column as ColumnId]; + columnFields.forEach((field) => { + fields.add(field); + }); + + return fields; + }, new Set()); + + return Array.from(requiredFieldsSet); +} diff --git a/src/utils/tableUtils/types.ts b/src/utils/tableUtils/types.ts new file mode 100644 index 000000000..23d4d7f7f --- /dev/null +++ b/src/utils/tableUtils/types.ts @@ -0,0 +1,5 @@ +import type {Column as DataTableColumn} from '@gravity-ui/react-data-table'; + +import type {Column as PaginatedTableColumn} from '../../components/PaginatedTable'; + +export type Column = PaginatedTableColumn & DataTableColumn;