Skip to content

Commit 2c1ab79

Browse files
authored
Merge branch 'main' into astandrik.stash-multipart
2 parents e3e2fc5 + c28ade6 commit 2c1ab79

File tree

12 files changed

+63
-36
lines changed

12 files changed

+63
-36
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.scss

+15
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,19 @@
6262
&__more-badge {
6363
margin-left: var(--g-spacing-1);
6464
}
65+
&__key-icon {
66+
position: absolute;
67+
top: 3.5px;
68+
69+
margin-left: var(--g-spacing-half);
70+
71+
vertical-align: baseline;
72+
}
73+
&__id-wrapper {
74+
position: relative;
75+
76+
display: inline-block;
77+
78+
padding-right: var(--g-spacing-1);
79+
}
6580
}

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/Schema/SchemaViewer/columns.tsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import DataTable from '@gravity-ui/react-data-table';
2+
import {Icon} from '@gravity-ui/uikit';
23

34
import {getColumnWidth} from '../../../../utils/getColumnWidth';
45

56
import i18n from './i18n';
7+
import {b} from './shared';
68
import type {SchemaColumn, SchemaData} from './types';
79

10+
import KeyIcon from '@gravity-ui/icons/svgs/key.svg';
11+
812
export const SCHEMA_COLUMNS_WIDTH_LS_KEY = 'schemaTableColumnsWidth';
913

1014
const SCHEMA_TABLE_COLUMS_IDS = {
@@ -26,7 +30,16 @@ const idColumn: SchemaColumn = {
2630
return i18n('column-title.id');
2731
},
2832
width: 60,
29-
render: ({row}) => row.id,
33+
align: DataTable.RIGHT,
34+
render: ({row}) => {
35+
const keyIcon = <Icon className={b('key-icon')} size={12} data={KeyIcon} />;
36+
return (
37+
<span className={b('id-wrapper')}>
38+
{row.id}
39+
{row.keyColumnIndex === undefined || row.keyColumnIndex === -1 ? null : keyIcon}
40+
</span>
41+
);
42+
},
3043
};
3144
const nameColumn: SchemaColumn = {
3245
name: SCHEMA_TABLE_COLUMS_IDS.name,

src/containers/Tenant/Schema/SchemaViewer/prepareData.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@ function prepareRowTableSchema(data: TTableDescription = {}): SchemaData[] {
7070
columnCodec,
7171
};
7272
});
73-
const keyColumns = preparedColumns?.filter((column) => column.keyColumnIndex !== -1) || [];
74-
const otherColumns = preparedColumns?.filter((column) => column.keyColumnIndex === -1) || [];
7573

76-
return [...keyColumns, ...otherColumns];
74+
return preparedColumns ?? [];
7775
}
7876

7977
function prepareExternalTableSchema(data: TExternalTableDescription = {}): SchemaData[] {

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)