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

Hide specific features from nav is dashboard tenant #51103

Merged
merged 1 commit into from
Jan 16, 2025
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
1 change: 1 addition & 0 deletions web/packages/teleport/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import generateResourcePath from './generateResourcePath';
import type { MfaChallengeResponse } from './services/mfa';
import { KindAuthConnectors } from './services/resources';

export type Cfg = typeof cfg;
const cfg = {
/** @deprecated Use cfg.edition instead. */
isEnterprise: false,
Expand Down
17 changes: 12 additions & 5 deletions web/packages/teleport/src/features.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
} from 'design/Icon';

import { IntegrationEnroll } from '@gravitational/teleport/src/Integrations/Enroll';
import cfg from 'teleport/config';
import cfg, { Cfg } from 'teleport/config';
import { IntegrationStatus } from 'teleport/Integrations/IntegrationStatus';
import {
ManagementSection,
Expand Down Expand Up @@ -67,6 +67,13 @@ import { NavTitle, type FeatureFlags, type TeleportFeature } from './types';
import { UnifiedResources } from './UnifiedResources';
import { Users } from './Users';

// to promote feature discoverability, most features should be visible in the navigation even if a user doesnt have access.
// However, there are some cases where hiding the feature is explicitly requested. Use this as a backdoor to hide the features that
// are usually "always visible"
export function shouldHideFromNavigation(cfg: Cfg) {
return cfg.isDashboard || cfg.hideInaccessibleFeatures;
}

class AccessRequests implements TeleportFeature {
category = NavigationCategory.Resources;
sideNavCategory = SideNavigationCategory.Resources;
Expand Down Expand Up @@ -243,7 +250,7 @@ export class FeatureBots implements TeleportFeature {
hasAccess(flags: FeatureFlags) {
// if feature hiding is enabled, only show
// if the user has access
if (cfg.hideInaccessibleFeatures) {
if (shouldHideFromNavigation(cfg)) {
return flags.listBots;
}
return true;
Expand Down Expand Up @@ -435,7 +442,7 @@ export class FeatureIntegrations implements TeleportFeature {
hasAccess(flags: FeatureFlags) {
// if feature hiding is enabled, only show
// if the user has access
if (cfg.hideInaccessibleFeatures) {
if (shouldHideFromNavigation(cfg)) {
return flags.integrations;
}
return true;
Expand Down Expand Up @@ -476,7 +483,7 @@ export class FeatureIntegrationEnroll implements TeleportFeature {
};

hasAccess(flags: FeatureFlags) {
if (cfg.hideInaccessibleFeatures) {
if (shouldHideFromNavigation(cfg)) {
return flags.enrollIntegrations;
}
return true;
Expand Down Expand Up @@ -622,7 +629,7 @@ class FeatureDeviceTrust implements TeleportFeature {
};

hasAccess(flags: FeatureFlags) {
if (cfg.hideInaccessibleFeatures) {
if (shouldHideFromNavigation(cfg)) {
return flags.deviceTrust;
}
return true;
Expand Down
Loading