From 5429b8ab3126bfbe2cab228a0d6c70c0061f74f7 Mon Sep 17 00:00:00 2001 From: Michael Myers Date: Thu, 16 Jan 2025 08:49:36 -0600 Subject: [PATCH] Hide specific features from nav is dashboard tenant 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. --- web/packages/teleport/src/config.ts | 1 + web/packages/teleport/src/features.tsx | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/web/packages/teleport/src/config.ts b/web/packages/teleport/src/config.ts index e8de4ef2ccb70..b3fcb9242997e 100644 --- a/web/packages/teleport/src/config.ts +++ b/web/packages/teleport/src/config.ts @@ -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, diff --git a/web/packages/teleport/src/features.tsx b/web/packages/teleport/src/features.tsx index 38157579634a9..8fc4dde759296 100644 --- a/web/packages/teleport/src/features.tsx +++ b/web/packages/teleport/src/features.tsx @@ -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, @@ -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; @@ -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; @@ -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; @@ -476,7 +483,7 @@ export class FeatureIntegrationEnroll implements TeleportFeature { }; hasAccess(flags: FeatureFlags) { - if (cfg.hideInaccessibleFeatures) { + if (shouldHideFromNavigation(cfg)) { return flags.enrollIntegrations; } return true; @@ -622,7 +629,7 @@ class FeatureDeviceTrust implements TeleportFeature { }; hasAccess(flags: FeatureFlags) { - if (cfg.hideInaccessibleFeatures) { + if (shouldHideFromNavigation(cfg)) { return flags.deviceTrust; } return true;