Skip to content
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
3 changes: 2 additions & 1 deletion src/components/TenantNameWrapper/TenantNameWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {DefinitionList, Flex} from '@gravity-ui/uikit';
import {getTenantPath} from '../../containers/Tenant/TenantPages';
import type {PreparedTenant} from '../../store/reducers/tenants/types';
import type {AdditionalTenantsProps} from '../../types/additionalProps';
import {uiFactory} from '../../uiFactory/uiFactory';
import {getDatabaseLinks} from '../../utils/additionalProps';
import {useIsUserAllowedToMakeChanges} from '../../utils/hooks/useIsUserAllowedToMakeChanges';
import {EntityStatus} from '../EntityStatus/EntityStatus';
Expand Down Expand Up @@ -63,7 +64,7 @@ export function TenantNameWrapper({tenant, additionalTenantsProps}: TenantNameWr
hasClipboardButton
path={getTenantPath(
{
database: tenant.Name,
database: uiFactory.useDatabaseId ? tenant.Id : tenant.Name,
backend,
},
{withBasename: isExternalLink},
Expand Down
7 changes: 5 additions & 2 deletions src/containers/Header/breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
TENANT_PAGE,
TENANT_PAGES_IDS,
} from '../../store/reducers/tenant/constants';
import {uiFactory} from '../../uiFactory/uiFactory';
import {CLUSTER_DEFAULT_TITLE, getTabletLabel} from '../../utils/constants';
import {getClusterPath} from '../Cluster/utils';
import {getDefaultNodePath} from '../Node/NodePages';
Expand Down Expand Up @@ -84,12 +85,14 @@ const getClusterBreadcrumbs: GetBreadcrumbs<ClusterBreadcrumbsOptions> = (option
};

const getTenantBreadcrumbs: GetBreadcrumbs<TenantBreadcrumbsOptions> = (options, query = {}) => {
const {tenantName} = options;
const {tenantName, tenantId} = options;

const breadcrumbs = getClusterBreadcrumbs(options, query);

const text = tenantName || headerKeyset('breadcrumbs.tenant');
const link = tenantName ? getTenantPath({...query, database: tenantName}) : undefined;
const link = tenantName
? getTenantPath({...query, database: uiFactory.useDatabaseId ? tenantId : tenantName})
: undefined;

const lastItem = {text, link, icon: <DatabaseIcon />};
breadcrumbs.push(lastItem);
Expand Down
6 changes: 3 additions & 3 deletions src/containers/Tenant/Tenant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function Tenant(props: TenantProps) {

const {database, schema} = useTenantQueryParams();

const {controlPlane, name} = useTenantBaseInfo(database ?? '');
const {controlPlane, name, id} = useTenantBaseInfo(database ?? '');

if (!database) {
throw new Error('Tenant name is not defined');
Expand Down Expand Up @@ -88,8 +88,8 @@ export function Tenant(props: TenantProps) {

const dispatch = useTypedDispatch();
React.useEffect(() => {
dispatch(setHeaderBreadcrumbs('tenant', {tenantName: databaseName}));
}, [databaseName, dispatch]);
dispatch(setHeaderBreadcrumbs('tenant', {tenantName: databaseName, tenantId: id}));
}, [databaseName, id, dispatch]);

const preloadedData = useTypedSelector((state) =>
selectSchemaObjectData(state, path, database),
Expand Down
1 change: 1 addition & 0 deletions src/store/reducers/header/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface ClusterBreadcrumbsOptions extends ClustersBreadcrumbsOptions {

export interface TenantBreadcrumbsOptions extends ClusterBreadcrumbsOptions {
tenantName?: string;
tenantId?: string;
}

export interface StorageGroupBreadcrumbsOptions extends ClusterBreadcrumbsOptions {
Expand Down
3 changes: 2 additions & 1 deletion src/store/reducers/tenant/tenant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@ export function useTenantBaseInfo(path: string) {
{skip: !path},
);

const {ControlPlane, Name} = currentData || {};
const {ControlPlane, Name, Id} = currentData || {};

return {
controlPlane: ControlPlane,
name: Name,
id: Id,
};
}
2 changes: 2 additions & 0 deletions src/uiFactory/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export interface UIFactory<H extends string = CommonIssueType> {
};
hasAccess?: boolean;
yaMetricaMap?: Record<string, number>;

useDatabaseId?: boolean;
}

export type HandleCreateDB = (params: {clusterName: string}) => Promise<boolean>;
Expand Down
1 change: 1 addition & 0 deletions src/uiFactory/uiFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const uiFactoryBase: UIFactory = {
countHealthcheckIssuesByType,
},
hasAccess: true,
useDatabaseId: false,
};

export function configureUIFactory<H extends string>(overrides: Partial<UIFactory<H>>) {
Expand Down
Loading