Skip to content

Commit

Permalink
Hide specific features from nav is dashboard tenant (#51118)
Browse files Browse the repository at this point in the history
This PR makes an update to our logic to the "backdoor" that would keep
things hidden after making updates to show most of the features to
promote discoverability. Currently, we only continued to hide them if
their license specified it, but this incorrectly ignored dashboard,
usage based, and team tenants as well.
  • Loading branch information
avatus authored Jan 16, 2025
1 parent 7ca4e53 commit d81e278
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions web/packages/teleport/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import type { YamlSupportedResourceKind } from 'teleport/services/yaml/types';
import { defaultEntitlements } from './entitlement';
import generateResourcePath from './generateResourcePath';

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

0 comments on commit d81e278

Please sign in to comment.