Skip to content

Commit c9accba

Browse files
committed
fix: optional viewContext
1 parent ad8b74a commit c9accba

File tree

8 files changed

+25
-24
lines changed

8 files changed

+25
-24
lines changed

src/containers/Storage/PaginatedStorage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ export const PaginatedStorage = (props: PaginatedStorageProps) => {
2525
if (isNodes) {
2626
return (
2727
<PaginatedStorageNodes
28-
initialEntitiesCount={getStorageNodesInitialEntitiesCount(props.viewContext ?? {})}
28+
initialEntitiesCount={getStorageNodesInitialEntitiesCount(props.viewContext)}
2929
{...props}
3030
/>
3131
);
3232
}
3333

3434
return (
3535
<PaginatedStorageGroups
36-
initialEntitiesCount={getStorageGroupsInitialEntitiesCount(props.viewContext ?? {})}
36+
initialEntitiesCount={getStorageGroupsInitialEntitiesCount(props.viewContext)}
3737
{...props}
3838
/>
3939
);

src/containers/Storage/PaginatedStorageGroups.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function StorageGroupsComponent({
6464

6565
const {columnsToShow, columnsToSelect, setColumns} = useStorageGroupsSelectedColumns({
6666
visibleEntities,
67-
viewContext: viewContext ?? {},
67+
viewContext,
6868
});
6969

7070
const renderControls: RenderControls = ({totalEntities, foundEntities, inited}) => {
@@ -113,7 +113,7 @@ function GroupedStorageGroupsComponent({
113113

114114
const {columnsToShow, columnsToSelect, setColumns} = useStorageGroupsSelectedColumns({
115115
visibleEntities,
116-
viewContext: viewContext ?? {},
116+
viewContext,
117117
});
118118

119119
const {currentData, isFetching, error} = storageApi.useGetStorageGroupsInfoQuery(

src/containers/Storage/PaginatedStorageNodes.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function StorageNodesComponent({
7171

7272
const {columnsToShow, columnsToSelect, setColumns} = useStorageNodesColumnsToSelect({
7373
database,
74-
viewContext: viewContext ?? {},
74+
viewContext,
7575
});
7676

7777
const renderControls: RenderControls = ({totalEntities, foundEntities, inited}) => {
@@ -119,7 +119,7 @@ function GroupedStorageNodesComponent({
119119

120120
const {columnsToShow, columnsToSelect, setColumns} = useStorageNodesColumnsToSelect({
121121
database,
122-
viewContext: viewContext ?? {},
122+
viewContext,
123123
});
124124

125125
const {currentData, isFetching, error} = storageApi.useGetStorageNodesInfoQuery(
@@ -218,6 +218,6 @@ function useStorageNodesColumnsToSelect({
218218
additionalNodesProps,
219219
visibleEntities,
220220
database,
221-
viewContext: viewContext ?? {},
221+
viewContext,
222222
});
223223
}

src/containers/Storage/StorageGroups/columns/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from './constants';
1515
import type {GetStorageGroupsColumnsParams} from './types';
1616

17-
export function useGetStorageGroupsColumns(viewContext: StorageViewContext) {
17+
export function useGetStorageGroupsColumns(viewContext?: StorageViewContext) {
1818
return React.useMemo(() => {
1919
return getStorageGroupsColumns({viewContext});
2020
}, [viewContext]);

src/containers/Storage/StorageGroups/columns/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import type {StorageViewContext} from '../../types';
55
export type StorageGroupsColumn = Column<PreparedStorageGroup>;
66

77
export interface GetStorageColumnsData {
8-
viewContext: StorageViewContext;
8+
viewContext?: StorageViewContext;
99
}
1010

1111
export interface GetStorageGroupsColumnsParams {
1212
visibleEntities?: VisibleEntities;
13-
viewContext: StorageViewContext;
13+
viewContext?: StorageViewContext;
1414
}
1515

1616
export type StorageColumnsGetter = (data?: GetStorageColumnsData) => StorageGroupsColumn[];

src/containers/Storage/StorageNodes/columns/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ export interface GetStorageNodesColumnsParams {
99
additionalNodesProps?: AdditionalNodesProps | undefined;
1010
visibleEntities?: VisibleEntities;
1111
database?: string;
12-
viewContext: StorageViewContext;
12+
viewContext?: StorageViewContext;
1313
}

src/containers/Storage/utils/index.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,14 @@ const DEFAULT_ENTITIES_COUNT = 10;
8989
// GroupPage - DEFAULT_ENTITIES_COUNT nodes
9090
// PDiskPage - 1 node
9191
// VDiskPage - 1 node
92-
export function getStorageNodesInitialEntitiesCount({
93-
nodeId,
94-
pDiskId,
95-
vDiskSlotId,
96-
}: StorageViewContext): number | undefined {
97-
if (valueIsDefined(nodeId) || valueIsDefined(pDiskId) || valueIsDefined(vDiskSlotId)) {
92+
export function getStorageNodesInitialEntitiesCount(
93+
context?: StorageViewContext,
94+
): number | undefined {
95+
if (
96+
valueIsDefined(context?.nodeId) ||
97+
valueIsDefined(context?.pDiskId) ||
98+
valueIsDefined(context?.vDiskSlotId)
99+
) {
98100
return 1;
99101
}
100102

@@ -105,14 +107,13 @@ export function getStorageNodesInitialEntitiesCount({
105107
// GroupPage - 1 group
106108
// PDiskPage - DEFAULT_ENTITIES_COUNT groups
107109
// VDiskPage - 1 group
108-
export function getStorageGroupsInitialEntitiesCount({
109-
vDiskSlotId,
110-
groupId,
111-
}: StorageViewContext): number | undefined {
112-
if (valueIsDefined(groupId)) {
110+
export function getStorageGroupsInitialEntitiesCount(
111+
context?: StorageViewContext,
112+
): number | undefined {
113+
if (valueIsDefined(context?.groupId)) {
113114
return 1;
114115
}
115-
if (valueIsDefined(vDiskSlotId)) {
116+
if (valueIsDefined(context?.vDiskSlotId)) {
116117
return 1;
117118
}
118119

tests/suites/paginatedTable/paginatedTable.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ test.describe('PaginatedTable', () => {
4646
}
4747
});
4848

49-
test.only('loads data when scrolling to middle of table', async ({page}) => {
49+
test('loads data when scrolling to middle of table', async ({page}) => {
5050
// Setup mocks with large dataset
5151
await setupLargeNodesMock(page);
5252
await setupSettingsMock(page);

0 commit comments

Comments
 (0)