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;