Skip to content

Commit f2a330e

Browse files
authored
Merge branch 'main' into astandrik.popup-closes-on-context-menu-copy-1452
2 parents c6cdae4 + e452f15 commit f2a330e

File tree

11 files changed

+62
-67
lines changed

11 files changed

+62
-67
lines changed

package-lock.json

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,13 @@
112112
"^@gravity-ui/uikit/toaster-singleton-react-18$": "@gravity-ui/uikit/build/cjs/toaster-singleton-react-18.js"
113113
}
114114
},
115-
"browserslist": {
116-
"production": [
117-
">0.2%",
118-
"not dead",
119-
"not op_mini all"
120-
],
121-
"development": [
122-
"last 1 chrome version",
123-
"last 1 firefox version",
124-
"last 1 safari version"
125-
]
126-
},
115+
"browserslist": [
116+
"extends @gravity-ui/browserslist-config"
117+
],
127118
"devDependencies": {
128119
"@commitlint/cli": "^19.3.0",
129120
"@commitlint/config-conventional": "^19.2.2",
121+
"@gravity-ui/browserslist-config": "^4.3.0",
130122
"@gravity-ui/eslint-config": "^3.2.0",
131123
"@gravity-ui/prettier-config": "^1.1.0",
132124
"@gravity-ui/stylelint-config": "^4.0.1",

src/containers/Cluster/Cluster.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {InternalLink} from '../../components/InternalLink';
1111
import routes, {getLocationObjectFromHref} from '../../routes';
1212
import {
1313
clusterApi,
14+
selectClusterTabletsWithFqdn,
1415
selectClusterTitle,
1516
updateDefaultClusterTab,
1617
} from '../../store/reducers/cluster/cluster';
@@ -74,6 +75,10 @@ export function Cluster({
7475

7576
const clusterError = error && typeof error === 'object' ? error : undefined;
7677

78+
const clusterTablets = useTypedSelector((state) =>
79+
selectClusterTabletsWithFqdn(state, clusterName ?? undefined),
80+
);
81+
7782
React.useEffect(() => {
7883
dispatch(setHeaderBreadcrumbs('cluster', {}));
7984
}, [dispatch]);
@@ -162,7 +167,8 @@ export function Cluster({
162167
<div className={b('tablets')}>
163168
<div className={b('fake-block')} />
164169
<TabletsTable
165-
tablets={cluster.SystemTablets ?? []}
170+
loading={infoLoading}
171+
tablets={clusterTablets}
166172
className={b('tablets-table')}
167173
/>
168174
</div>

src/containers/Header/breadcrumbs.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,11 @@ const getStorageGroupBreadcrumbs: GetBreadcrumbs<StorageGroupBreadcrumbsOptions>
178178
};
179179

180180
const getTabletBreadcrumbs: GetBreadcrumbs<TabletBreadcrumbsOptions> = (options, query = {}) => {
181-
const {tabletId, tabletType, nodeId, nodeRole, nodeActiveTab = TABLETS, tenantName} = options;
181+
const {tabletId, tabletType, tenantName} = options;
182182

183-
const breadcrumbs = getNodeBreadcrumbs({nodeId, nodeRole, nodeActiveTab, tenantName}, query);
183+
const breadcrumbs = tenantName
184+
? getTenantBreadcrumbs(options, query)
185+
: getClusterBreadcrumbs(options, query);
184186

185187
const lastItem = {
186188
text: tabletId || headerKeyset('breadcrumbs.tablet'),

src/containers/Tablet/Tablet.tsx

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ import {PageMetaWithAutorefresh} from '../../components/PageMeta/PageMeta';
1616
import {getTabletPagePath} from '../../routes';
1717
import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication';
1818
import {setHeaderBreadcrumbs} from '../../store/reducers/header/header';
19-
import {nodeApi} from '../../store/reducers/node/node';
2019
import {tabletApi} from '../../store/reducers/tablet';
2120
import {EFlag} from '../../types/api/enums';
2221
import type {TTabletStateInfo} from '../../types/api/tablet';
23-
import {EType} from '../../types/api/tablet';
2422
import type {ITabletPreparedHistoryItem} from '../../types/store/tablet';
2523
import {cn} from '../../utils/cn';
2624
import {CLUSTER_DEFAULT_TITLE} from '../../utils/constants';
@@ -59,12 +57,9 @@ const TABLET_PAGE_TABS = [
5957
];
6058

6159
const tabletTabSchema = z.nativeEnum(TABLET_TABS_IDS).catch(TABLET_TABS_IDS.history);
62-
const eTypeSchema = z.nativeEnum(EType).or(z.undefined()).catch(undefined);
6360

6461
const tabletQueryParams = {
65-
nodeId: StringParam,
6662
tenantName: StringParam,
67-
type: StringParam,
6863
clusterName: StringParam,
6964
activeTab: StringParam,
7065
};
@@ -74,18 +69,12 @@ export function Tablet() {
7469

7570
const {id} = useParams<{id: string}>();
7671

77-
const [
78-
{
79-
nodeId: queryNodeId,
80-
tenantName: queryDatabase,
81-
type: queryTabletType,
82-
clusterName: queryClusterName,
83-
},
84-
] = useQueryParams(tabletQueryParams);
72+
const [{tenantName: queryDatabase, clusterName: queryClusterName}] =
73+
useQueryParams(tabletQueryParams);
8574

8675
const [autoRefreshInterval] = useAutoRefreshInterval();
8776
const {currentData, isFetching, error} = tabletApi.useGetTabletQuery(
88-
{id, database: queryDatabase ?? undefined, nodeId: queryNodeId ?? undefined},
77+
{id, database: queryDatabase ?? undefined},
8978
{pollingInterval: autoRefreshInterval},
9079
);
9180

@@ -96,24 +85,19 @@ export function Tablet() {
9685
tablet.TenantId ? {tenantId: tablet.TenantId} : skipToken,
9786
);
9887

99-
const nodeId = tablet.NodeId ?? queryNodeId ?? undefined;
10088
const database = (tenantPath || queryDatabase) ?? undefined;
10189

102-
const nodeRole = useNodeRole(nodeId?.toString());
103-
104-
const tabletType = tablet.Type || eTypeSchema.parse(queryTabletType);
90+
const tabletType = tablet.Type;
10591

10692
React.useEffect(() => {
10793
dispatch(
10894
setHeaderBreadcrumbs('tablet', {
109-
nodeId,
110-
nodeRole,
11195
tenantName: queryDatabase ?? undefined,
11296
tabletId: id,
11397
tabletType,
11498
}),
11599
);
116-
}, [dispatch, queryDatabase, id, nodeId, nodeRole, tabletType]);
100+
}, [dispatch, queryDatabase, id, tabletType]);
117101

118102
const {Leader, Type} = tablet;
119103
const metaItems: string[] = [];
@@ -246,17 +230,3 @@ function Channels({id, hiveId}: {id: string; hiveId: string}) {
246230
</LoaderWrapper>
247231
);
248232
}
249-
250-
function useNodeRole(nodeId: string | undefined) {
251-
const {currentData: node} = nodeApi.useGetNodeInfoQuery(nodeId ? {nodeId} : skipToken);
252-
253-
let nodeRole: 'Storage' | 'Compute' | undefined;
254-
255-
if (node) {
256-
// Compute nodes have tenantName, storage nodes doesn't
257-
const isStorage = !node?.Tenants?.[0];
258-
nodeRole = isStorage ? 'Storage' : 'Compute';
259-
}
260-
261-
return nodeRole;
262-
}

src/containers/Tablets/Tablets.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {skipToken} from '@reduxjs/toolkit/query';
22

33
import {ResponseError} from '../../components/Errors/ResponseError';
4-
import {TableSkeleton} from '../../components/TableSkeleton/TableSkeleton';
54
import {selectTabletsWithFqdn, tabletsApi} from '../../store/reducers/tablets';
65
import type {TabletsApiRequestParams} from '../../types/store/tablets';
76
import {cn} from '../../utils/cn';
@@ -38,14 +37,12 @@ export function Tablets({nodeId, path, database, className}: TabletsProps) {
3837
const loading = isFetching && currentData === undefined;
3938
const tablets = useTypedSelector((state) => selectTabletsWithFqdn(state, params));
4039

41-
if (loading) {
42-
return <TableSkeleton />;
43-
}
44-
4540
return (
4641
<div className={b(null, className)}>
4742
{error ? <ResponseError error={error} /> : null}
48-
{currentData ? <TabletsTable tablets={tablets} database={database} /> : null}
43+
{currentData || loading ? (
44+
<TabletsTable tablets={tablets} database={database} loading={loading} />
45+
) : null}
4946
</div>
5047
);
5148
}

src/containers/Tablets/TabletsTable.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {DeveloperUILinkButton} from '../../components/DeveloperUILinkButton/Deve
77
import {EntityStatus} from '../../components/EntityStatus/EntityStatus';
88
import {InternalLink} from '../../components/InternalLink';
99
import {ResizeableDataTable} from '../../components/ResizeableDataTable/ResizeableDataTable';
10+
import {TableSkeleton} from '../../components/TableSkeleton/TableSkeleton';
1011
import {TabletState} from '../../components/TabletState/TabletState';
1112
import {getTabletPagePath} from '../../routes';
1213
import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication';
@@ -50,8 +51,6 @@ function getColumns({database}: {database?: string}) {
5051
}
5152

5253
const tabletPath = getTabletPagePath(row.TabletId, {
53-
nodeId: row.NodeId,
54-
type: row.Type,
5554
tenantName: database,
5655
});
5756

@@ -168,9 +167,13 @@ interface TabletsTableProps {
168167
fqdn?: string;
169168
})[];
170169
className?: string;
170+
loading?: boolean;
171171
}
172172

173-
export function TabletsTable({database, tablets, className}: TabletsTableProps) {
173+
export function TabletsTable({database, tablets, className, loading}: TabletsTableProps) {
174+
if (loading) {
175+
return <TableSkeleton />;
176+
}
174177
return (
175178
<ResizeableDataTable
176179
wrapperClassName={className}

src/services/api.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,15 +467,14 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
467467
);
468468
}
469469
getTablet(
470-
{id, database, nodeId}: {id: string; database?: string; nodeId?: string},
470+
{id, database}: {id: string; database?: string},
471471
{concurrentId, signal}: AxiosOptions = {},
472472
) {
473473
return this.get<TEvTabletStateResponse>(
474474
this.getPath('/viewer/json/tabletinfo'),
475475
{
476476
enums: true,
477477
database,
478-
node_id: nodeId,
479478
filter: `(TabletId=${id})`,
480479
},
481480
{
@@ -485,7 +484,7 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
485484
);
486485
}
487486
getTabletHistory(
488-
{id, database, nodeId}: {id: string; database?: string; nodeId?: string},
487+
{id, database}: {id: string; database?: string},
489488
{concurrentId, signal}: AxiosOptions = {},
490489
) {
491490
return this.get<UnmergedTEvTabletStateResponse>(
@@ -494,7 +493,6 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
494493
enums: true,
495494
merge: false,
496495
database,
497-
node_id: nodeId,
498496
filter: `(TabletId=${id})`,
499497
},
500498
{

src/store/reducers/cluster/cluster.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import {clusterTabsIds, isClusterTab} from '../../../containers/Cluster/utils';
88
import {parseTraceFields} from '../../../services/parsers/parseMetaCluster';
99
import {isClusterInfoV2} from '../../../types/api/cluster';
1010
import type {TClusterInfo} from '../../../types/api/cluster';
11+
import type {TTabletStateInfo} from '../../../types/api/tablet';
1112
import {CLUSTER_DEFAULT_TITLE, DEFAULT_CLUSTER_TAB_KEY} from '../../../utils/constants';
1213
import {isQueryErrorResponse} from '../../../utils/query';
1314
import type {RootState} from '../../defaultStore';
1415
import {api} from '../api';
16+
import {selectNodeHostsMap} from '../nodesList';
1517

1618
import type {ClusterGroupsStats, ClusterState} from './types';
1719
import {
@@ -169,3 +171,21 @@ export const selectClusterTitle = createSelector(
169171
return Name || clusterName || normalizeDomain(Domain) || CLUSTER_DEFAULT_TITLE;
170172
},
171173
);
174+
175+
export const selectClusterTabletsWithFqdn = createSelector(
176+
(state: RootState, clusterName?: string) => selectClusterInfo(state, clusterName),
177+
(state: RootState) => selectNodeHostsMap(state),
178+
(data, nodeHostsMap): (TTabletStateInfo & {fqdn?: string})[] => {
179+
const tablets = data?.clusterData?.SystemTablets;
180+
if (!tablets) {
181+
return [];
182+
}
183+
if (!nodeHostsMap) {
184+
return tablets;
185+
}
186+
return tablets.map((tablet) => {
187+
const fqdn = tablet.NodeId === undefined ? undefined : nodeHostsMap.get(tablet.NodeId);
188+
return {...tablet, fqdn};
189+
});
190+
},
191+
);

src/store/reducers/header/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface VDiskBreadcrumbsOptions extends PDiskBreadcrumbsOptions {
4141
vDiskSlotId?: string | number;
4242
}
4343

44-
export interface TabletBreadcrumbsOptions extends NodeBreadcrumbsOptions {
44+
export interface TabletBreadcrumbsOptions extends TenantBreadcrumbsOptions {
4545
tabletId?: string;
4646
tabletType?: EType;
4747
}

0 commit comments

Comments
 (0)