Skip to content

Commit b0d31ac

Browse files
fix(breadcrumbs): update tenant and tablet params (#443)
* fix(TabletsFilters): fix filters on empty values * fix(Tablet): delete type and state from breadcrumbs params
1 parent a9e8cb7 commit b0d31ac

File tree

5 files changed

+34
-35
lines changed

5 files changed

+34
-35
lines changed

src/components/Tablet/Tablet.tsx

+2-13
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,10 @@ interface TabletProps {
1818
}
1919

2020
export const Tablet = ({tablet = {}, tenantName}: TabletProps) => {
21-
const {TabletId: id, NodeId, Type, State} = tablet;
21+
const {TabletId: id, NodeId} = tablet;
2222
const status = tablet.Overall?.toLowerCase();
2323

24-
const tabletPath =
25-
id &&
26-
createHref(
27-
routes.tablet,
28-
{id},
29-
{
30-
nodeId: NodeId,
31-
type: Type,
32-
state: State,
33-
tenantName,
34-
},
35-
);
24+
const tabletPath = id && createHref(routes.tablet, {id}, {nodeId: NodeId, tenantName});
3625

3726
return (
3827
<ContentWithPopup

src/containers/Header/breadcrumbs.ts

+22-6
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ import type {
1010
TabletsBreadcrumbsOptions,
1111
TenantBreadcrumbsOptions,
1212
} from '../../store/reducers/header/types';
13+
import {
14+
TENANT_DIAGNOSTICS_TABS_IDS,
15+
TENANT_PAGE,
16+
TENANT_PAGES_IDS,
17+
} from '../../store/reducers/tenant/constants';
1318
import routes, {createHref} from '../../routes';
1419

1520
import {getClusterPath} from '../Cluster/utils';
16-
import {getTenantPath} from '../Tenant/TenantPages';
21+
import {TenantTabsGroups, getTenantPath} from '../Tenant/TenantPages';
1722
import {getDefaultNodePath} from '../Node/NodePages';
1823

1924
const prepareTenantName = (tenantName: string) => {
@@ -61,10 +66,16 @@ const getNodeBreadcrumbs = (options: NodeBreadcrumbsOptions, query = {}): RawBre
6166
// Compute nodes have tenantName, storage nodes doesn't
6267
const isStorageNode = !tenantName;
6368

69+
const newQuery = {
70+
...query,
71+
[TENANT_PAGE]: TENANT_PAGES_IDS.diagnostics,
72+
[TenantTabsGroups.diagnosticsTab]: TENANT_DIAGNOSTICS_TABS_IDS.nodes,
73+
};
74+
6475
if (isStorageNode) {
6576
breadcrumbs = getClusterBreadcrumbs(options, query);
6677
} else {
67-
breadcrumbs = getTenantBreadcrumbs(options, query);
78+
breadcrumbs = getTenantBreadcrumbs(options, newQuery);
6879
}
6980

7081
const text = nodeId ? `Node ${nodeId}` : 'Node';
@@ -79,21 +90,26 @@ const getTabletsBreadcrubms = (
7990
options: TabletsBreadcrumbsOptions,
8091
query = {},
8192
): RawBreadcrumbItem[] => {
82-
const {tenantName, nodeIds, state, type} = options;
93+
const {tenantName, nodeIds} = options;
94+
95+
const newQuery = {
96+
...query,
97+
[TENANT_PAGE]: TENANT_PAGES_IDS.diagnostics,
98+
[TenantTabsGroups.diagnosticsTab]: TENANT_DIAGNOSTICS_TABS_IDS.tablets,
99+
};
83100

84101
let breadcrumbs: RawBreadcrumbItem[];
85102

86103
// Cluster system tablets don't have tenantName
87104
if (tenantName) {
88-
breadcrumbs = getTenantBreadcrumbs(options, query);
105+
breadcrumbs = getTenantBreadcrumbs(options, newQuery);
89106
} else {
90107
breadcrumbs = getClusterBreadcrumbs(options, query);
91108
}
92109

93110
const link = createHref(routes.tabletsFilters, undefined, {
111+
...query,
94112
nodeIds,
95-
state,
96-
type,
97113
path: tenantName,
98114
});
99115

src/containers/Tablet/Tablet.tsx

+2-11
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,9 @@ export const Tablet = () => {
4848
error,
4949
} = useTypedSelector((state) => state.tablet);
5050

51-
const {
52-
nodeId: queryNodeId,
53-
type: queryType,
54-
state: queryState,
55-
tenantName: queryTenantName,
56-
} = parseQuery(location);
51+
const {nodeId: queryNodeId, tenantName: queryTenantName} = parseQuery(location);
5752

5853
const nodeId = tablet.NodeId?.toString() || queryNodeId?.toString();
59-
const tabletState = tablet.State || queryState?.toString();
60-
const tabletType = tablet.Type || queryType?.toString();
6154
const tenantName = tenantPath || queryTenantName?.toString();
6255

6356
// NOTE: should be reviewed when migrating to React 18
@@ -84,13 +77,11 @@ export const Tablet = () => {
8477
dispatch(
8578
setHeaderBreadcrumbs('tablet', {
8679
nodeIds: nodeId ? [nodeId] : [],
87-
state: tabletState,
88-
type: tabletType,
8980
tenantName,
9081
tabletId: id,
9182
}),
9283
);
93-
}, [dispatch, tenantName, id, nodeId, tabletState, tabletType]);
84+
}, [dispatch, tenantName, id, nodeId]);
9485

9586
const renderExternalLinks = (link: {name: string; path: string}, index: number) => {
9687
return (

src/containers/TabletsFilters/TabletsFilters.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,15 @@ class TabletsFilters extends React.Component {
8181
});
8282
const {nodeIds, type, path, state} = queryParams;
8383
const nodes = TabletsFilters.parseNodes(nodeIds);
84-
const stateFilter = TabletsFilters.getStateFiltersFromColor(state);
8584

86-
setStateFilter(stateFilter);
87-
setTypeFilter([type]);
85+
if (state) {
86+
const stateFilter = TabletsFilters.getStateFiltersFromColor(state);
87+
setStateFilter(stateFilter);
88+
}
89+
90+
if (type) {
91+
setTypeFilter([type]);
92+
}
8893

8994
this.setState({nodeFilter: nodes, tenantPath: path}, () => {
9095
this.makeRequest();

src/store/reducers/header/types.ts

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ export interface NodeBreadcrumbsOptions extends TenantBreadcrumbsOptions {
1919

2020
export interface TabletsBreadcrumbsOptions extends TenantBreadcrumbsOptions {
2121
nodeIds?: string[] | number[];
22-
state?: string;
23-
type?: string;
2422
}
2523

2624
export interface TabletBreadcrumbsOptions extends TabletsBreadcrumbsOptions {

0 commit comments

Comments
 (0)