MCPcopy Index your code
hub / github.com/coder/coder / getFeatureVisibility

Function getFeatureVisibility

site/src/modules/dashboard/entitlements.ts:8–24  ·  view source on GitHub ↗
(
	hasLicense: boolean,
	features: Record<string, Feature>,
)

Source from the content-addressed store, hash-verified

6 * @returns record from feature name whether to show the feature
7 */
8export const getFeatureVisibility = (
9 hasLicense: boolean,
10 features: Record<string, Feature>,
11): Record<string, boolean> => {
12 if (!hasLicense) {
13 return {};
14 }
15
16 const permissionPairs = Object.entries(features).map(
17 ([feature, { entitlement, limit, actual, enabled }]) => {
18 const entitled = ["entitled", "grace_period"].includes(entitlement);
19 const limitCompliant = limit && actual ? limit >= actual : true;
20 return [feature, entitled && limitCompliant && enabled];
21 },
22 );
23 return Object.fromEntries(permissionPairs);
24};
25
26export const selectFeatureVisibility = (
27 entitlements: Entitlements,

Callers 2

selectFeatureVisibilityFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected