Skip to content

Commit 7cd0064

Browse files
fix(ObjectSummary): refresh tabs with tree refresh, disable autorefresh
1 parent 5683cfd commit 7cd0064

File tree

9 files changed

+33
-32
lines changed

9 files changed

+33
-32
lines changed

src/containers/Tenant/ObjectSummary/ObjectSummary.tsx

+5-11
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
formatNumber,
2525
formatSecondsToHours,
2626
} from '../../../utils/dataFormatters/dataFormatters';
27-
import {useAutoRefreshInterval, useTypedDispatch, useTypedSelector} from '../../../utils/hooks';
27+
import {useTypedDispatch, useTypedSelector} from '../../../utils/hooks';
2828
import {Acl} from '../Acl/Acl';
2929
import {EntityTitle} from '../EntityTitle/EntityTitle';
3030
import {SchemaViewer} from '../Schema/SchemaViewer/SchemaViewer';
@@ -76,7 +76,6 @@ export function ObjectSummary({
7676
onExpandSummary,
7777
isCollapsed,
7878
}: ObjectSummaryProps) {
79-
const [autoRefreshInterval] = useAutoRefreshInterval();
8079
const dispatch = useTypedDispatch();
8180
const [, setCurrentPath] = useQueryParam('schema', StringParam);
8281
const [commonInfoVisibilityState, dispatchCommonInfoVisibilityState] = React.useReducer(
@@ -95,15 +94,10 @@ export function ObjectSummary({
9594
ignoreQueryPrefix: true,
9695
});
9796

98-
const {currentData: currentObjectData} = overviewApi.useGetOverviewQuery(
99-
{
100-
path,
101-
database: tenantName,
102-
},
103-
{
104-
pollingInterval: autoRefreshInterval,
105-
},
106-
);
97+
const {currentData: currentObjectData} = overviewApi.useGetOverviewQuery({
98+
path,
99+
database: tenantName,
100+
});
107101
const currentSchemaData = currentObjectData?.PathDescription?.Self;
108102

109103
React.useEffect(() => {

src/containers/Tenant/ObjectSummary/SchemaTree/RefreshTreeButton.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@ import {ArrowsRotateLeft} from '@gravity-ui/icons';
22
import {ActionTooltip, Button, Icon} from '@gravity-ui/uikit';
33
import {nanoid} from '@reduxjs/toolkit';
44

5+
import {api} from '../../../../store/reducers/api';
6+
import {useTypedDispatch} from '../../../../utils/hooks';
57
import {useDispatchTreeKey} from '../UpdateTreeContext';
68
import {b} from '../shared';
79

810
export function RefreshTreeButton() {
911
const updateTreeKey = useDispatchTreeKey();
12+
const dispatch = useTypedDispatch();
13+
1014
return (
1115
<ActionTooltip title="Refresh">
1216
<Button
1317
className={b('refresh-button')}
1418
view="flat-secondary"
1519
onClick={() => {
1620
updateTreeKey(nanoid());
21+
dispatch(api.util.invalidateTags(['SchemaTree']));
1722
}}
1823
>
1924
<Icon data={ArrowsRotateLeft} />

src/containers/Tenant/Schema/SchemaViewer/SchemaViewer.tsx

+7-8
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,19 @@ interface SchemaViewerProps {
3838

3939
export const SchemaViewer = ({type, path, tenantName, extended = false}: SchemaViewerProps) => {
4040
const [autoRefreshInterval] = useAutoRefreshInterval();
41+
42+
// Refresh table only in Diagnostics
43+
const pollingInterval = extended ? autoRefreshInterval : undefined;
44+
4145
const {currentData: schemaData, isLoading: loading} = overviewApi.useGetOverviewQuery(
42-
{
43-
path,
44-
database: tenantName,
45-
},
46-
{
47-
pollingInterval: autoRefreshInterval,
48-
},
46+
{path, database: tenantName},
47+
{pollingInterval},
4948
);
5049

5150
const viewSchemaRequestParams = isViewType(type) ? {path, database: tenantName} : skipToken;
5251

5352
const {data: viewColumnsData, isLoading: isViewSchemaLoading} =
54-
viewSchemaApi.useGetViewSchemaQuery(viewSchemaRequestParams);
53+
viewSchemaApi.useGetViewSchemaQuery(viewSchemaRequestParams, {pollingInterval});
5554

5655
const tableData = React.useMemo(() => {
5756
if (isViewType(type)) {

src/containers/Tenant/Tenant.tsx

+2-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {selectSchemaObjectData} from '../../store/reducers/schema/schema';
1212
import type {AdditionalNodesProps, AdditionalTenantsProps} from '../../types/additionalProps';
1313
import {cn} from '../../utils/cn';
1414
import {DEFAULT_IS_TENANT_SUMMARY_COLLAPSED, DEFAULT_SIZE_TENANT_KEY} from '../../utils/constants';
15-
import {useAutoRefreshInterval, useTypedDispatch, useTypedSelector} from '../../utils/hooks';
15+
import {useTypedDispatch, useTypedSelector} from '../../utils/hooks';
1616
import {isAccessError} from '../../utils/response';
1717

1818
import ObjectGeneral from './ObjectGeneral/ObjectGeneral';
@@ -43,7 +43,6 @@ interface TenantProps {
4343
}
4444

4545
export function Tenant(props: TenantProps) {
46-
const [autoRefreshInterval] = useAutoRefreshInterval();
4746
const [summaryVisibilityState, dispatchSummaryVisibilityAction] = React.useReducer(
4847
paneVisibilityToggleReducerCreator(DEFAULT_IS_TENANT_SUMMARY_COLLAPSED),
4948
undefined,
@@ -95,12 +94,7 @@ export function Tenant(props: TenantProps) {
9594
currentData: currentItem,
9695
error,
9796
isLoading,
98-
} = overviewApi.useGetOverviewQuery(
99-
{path, database: tenantName},
100-
{
101-
pollingInterval: autoRefreshInterval,
102-
},
103-
);
97+
} = overviewApi.useGetOverviewQuery({path, database: tenantName});
10498

10599
const preloadedData = useTypedSelector((state) =>
106100
selectSchemaObjectData(state, path, tenantName),

src/store/reducers/api.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ export const api = createApi({
99
*/
1010
endpoints: () => ({}),
1111
invalidationBehavior: 'immediately',
12-
tagTypes: ['All', 'PDiskData', 'PreviewData', 'StorageData', 'Tablet', 'UserData', 'VDiskData'],
12+
tagTypes: [
13+
'All',
14+
'PDiskData',
15+
'PreviewData',
16+
'SchemaTree',
17+
'StorageData',
18+
'Tablet',
19+
'UserData',
20+
'VDiskData',
21+
],
1322
});
1423

1524
export const _NEVER = Symbol();

src/store/reducers/overview/overview.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const overviewApi = api.injectEndpoints({
5151
}
5252
},
5353
keepUnusedDataFor: 0,
54-
providesTags: ['All'],
54+
providesTags: ['All', 'SchemaTree'],
5555
}),
5656
}),
5757
});

src/store/reducers/preview.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const previewApi = api.injectEndpoints({
2929
return {error: error || new Error('Unauthorized')};
3030
}
3131
},
32-
providesTags: ['All', 'PreviewData'],
32+
providesTags: ['PreviewData'],
3333
}),
3434
}),
3535
overrideExisting: 'throw',

src/store/reducers/schemaAcl/schemaAcl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const schemaAclApi = api.injectEndpoints({
1818
return {error};
1919
}
2020
},
21-
providesTags: ['All'],
21+
providesTags: ['SchemaTree'],
2222
}),
2323
}),
2424
overrideExisting: 'throw',

src/store/reducers/viewSchema/viewSchema.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const viewSchemaApi = api.injectEndpoints({
3737
return {error: error};
3838
}
3939
},
40-
providesTags: ['All'],
40+
providesTags: ['All', 'SchemaTree'],
4141
}),
4242
}),
4343
overrideExisting: 'throw',

0 commit comments

Comments
 (0)