Skip to content

Commit

Permalink
Merge pull request #1206 from redpanda-data/fix/hide-quotas-from-the-…
Browse files Browse the repository at this point in the history
…menu-if-not-supported

Hide Quotas from the menu if it's not supported
  • Loading branch information
jvorcak authored Apr 5, 2024
2 parents 437d45e + 447690f commit 6836b21
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 7 additions & 3 deletions frontend/src/components/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import SchemaDetailsView from './pages/schemas/Schema.Details';
import AclList from './pages/acls/Acl.List';
import { HomeIcon, CogIcon, CollectionIcon, CubeTransparentIcon, FilterIcon, ShieldCheckIcon, LinkIcon, ScaleIcon, BeakerIcon } from '@heroicons/react/outline';
import ReassignPartitions from './pages/reassign-partitions/ReassignPartitions';
import { Feature, FeatureEntry, isSupported } from '../state/supportedFeatures';
import { Feature, FeatureEntry, isSupported, shouldHideIfNotSupported } from '../state/supportedFeatures';
import { UserPermissions } from '../state/restInterfaces';
import KafkaConnectOverview from './pages/connect/Overview';
import KafkaConnectorDetails from './pages/connect/Connector.Details';
Expand Down Expand Up @@ -181,15 +181,19 @@ function routeVisibility(
requiredAppFeatures?: AppFeature[],
): () => MenuItemState {
return () => {
const v = typeof visible === 'boolean'
let v = typeof visible === 'boolean'
? visible
: visible();

const disabledReasons: DisabledReasons[] = [];
if (requiredFeatures)
for (const f of requiredFeatures) {
if (!isSupported(f)) {
disabledReasons.push(DisabledReasons.notSupported);
if (shouldHideIfNotSupported(f)) {
v = false
} else {
disabledReasons.push(DisabledReasons.notSupported);
}
break;
}
}
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/state/supportedFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ export function isSupported(f: FeatureEntry): boolean {
return false;
}

/**
* A list of features we should hide instead of showing a disabled message.
*/
const HIDE_IF_NOT_SUPPORTED_FEATURES = [Feature.GetQuotas]
export function shouldHideIfNotSupported(f: FeatureEntry): boolean {
return HIDE_IF_NOT_SUPPORTED_FEATURES.includes(f)
}

class SupportedFeatures {
@computed get clusterConfig(): boolean { return isSupported(Feature.ClusterConfig); }
@computed get consumerGroups(): boolean { return isSupported(Feature.ConsumerGroups); }
Expand Down

0 comments on commit 6836b21

Please sign in to comment.