Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: [M3-7770] - isFeatureEnabledV2 to check for feature flag AND account capability #10371

Merged
merged 5 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tech Stories
---

isFeatureEnabledV2 to check for feature flag AND account capability ([#10371](https://github.com/linode/manager/pull/10371))
hana-akamai marked this conversation as resolved.
Show resolved Hide resolved
20 changes: 20 additions & 0 deletions packages/manager/src/utilities/accountCapabilities.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
import type { AccountCapability } from '@linode/api-v4';

/**
* Determines if a feature should be enabled.
*
* @returns true if the feature is returned from account.capabilities AND if it is explicitly enabled
* by a feature flag
*
* If you need to launch a production feature, but have it be gated,
* you would turn the flag *off* for that environment, but have the API return
hana-akamai marked this conversation as resolved.
Show resolved Hide resolved
* the account capability.
hana-akamai marked this conversation as resolved.
Show resolved Hide resolved
*/
export const isFeatureEnabledV2 = (
featureName: AccountCapability,
isFeatureFlagEnabled: boolean,
capabilities: AccountCapability[]
) => {
return isFeatureFlagEnabled && capabilities.includes(featureName);
};

/**
* DEPRECATED USE isFeatureEnabledV2
hana-akamai marked this conversation as resolved.
Show resolved Hide resolved
*
* Determines if a feature should be enabled.
*
* @returns true if the feature is returned from account.capabilities **or** if it is explicitly enabled
Expand Down
Loading