Skip to content

Commit

Permalink
chore(routes): add helper for create tablet page path
Browse files Browse the repository at this point in the history
  • Loading branch information
Raubzeug committed Aug 16, 2024
1 parent d938728 commit f28a7e1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/containers/Heatmap/HeatmapCanvas/HeatmapCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import throttle from 'lodash/throttle';
import PropTypes from 'prop-types';

import routes, {createHref} from '../../../routes';
import {getTabletPagePath} from '../../../routes';
import {basename as appBasename} from '../../../store/index';
import {cn} from '../../../utils/cn';

Expand Down Expand Up @@ -90,7 +90,7 @@ export const HeatmapCanvas = (props) => {
const generateTabletExternalLink = (tablet) => {
const {TabletId: id} = tablet;
const hostname = window.location.hostname;
const path = createHref(routes.tablet, {id});
const path = getTabletPagePath(id);
const protocol = 'https://';
const href = [hostname, appBasename, path]
.map((item) => (item.startsWith('/') ? item.slice(1) : item))
Expand Down
11 changes: 5 additions & 6 deletions src/containers/Tablets/Tablets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {ResponseError} from '../../components/Errors/ResponseError';
import {InternalLink} from '../../components/InternalLink';
import {ResizeableDataTable} from '../../components/ResizeableDataTable/ResizeableDataTable';
import {TableSkeleton} from '../../components/TableSkeleton/TableSkeleton';
import routes, {createHref} from '../../routes';
import {getTabletPagePath} from '../../routes';
import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication';
import {selectTabletsWithFqdn, tabletsApi} from '../../store/reducers/tablets';
import {ETabletState} from '../../types/api/tablet';
Expand Down Expand Up @@ -54,11 +54,10 @@ const columns: DataTableColumn<TTabletStateInfo & {fqdn?: string}>[] = [
return EMPTY_DATA_PLACEHOLDER;
}

const tabletPath = createHref(
routes.tablet,
{id: row.TabletId},
{nodeId: row.NodeId, type: row.Type},
);
const tabletPath = getTabletPagePath(row.TabletId, {
nodeId: row.NodeId,
type: row.Type,
});

return (
<EntityStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {EntityStatus} from '../../../../components/EntityStatus/EntityStatus';
import {InternalLink} from '../../../../components/InternalLink';
import {LinkToSchemaObject} from '../../../../components/LinkToSchemaObject/LinkToSchemaObject';
import {UsageLabel} from '../../../../components/UsageLabel/UsageLabel';
import routes, {createHref} from '../../../../routes';
import {getTabletPagePath} from '../../../../routes';
import {getLoadSeverityForShard} from '../../../../store/reducers/tenantOverview/topShards/utils';
import type {KeyValueRow} from '../../../../types/api/query';
import type {ValueOf} from '../../../../types/common';
Expand Down Expand Up @@ -88,7 +88,7 @@ const tabletIdColumn: Column<KeyValueRow> = {
return (
<EntityStatus
name={row.TabletId?.toString()}
path={createHref(routes.tablet, {id: row.TabletId})}
path={getTabletPagePath(row.TabletId)}
hasClipboardButton
showStatus={false}
additionalControls={
Expand Down
4 changes: 4 additions & 0 deletions src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,7 @@ export function getVDiskPagePath(
) {
return createHref(routes.vDisk, undefined, {...query, nodeId, pDiskId, vDiskSlotId});
}

export function getTabletPagePath(tabletId: string | number, query: Query = {}) {
return createHref(routes.tablet, {id: tabletId}, {...query});
}

0 comments on commit f28a7e1

Please sign in to comment.