Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(routes): add helper for create tablet page path #1178

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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});
}
Loading