Skip to content

Commit

Permalink
Add userCannotModify field to flag control (#2966)
Browse files Browse the repository at this point in the history
  • Loading branch information
allisonking authored Apr 4, 2023
1 parent 428ed42 commit 94d41f1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The types of changes are:

### Added
* Access support for Shippo [#2484](https://github.com/ethyca/fides/pull/2484)
* Feature flags can be set such that they cannot be modified by the user [#2966](https://github.com/ethyca/fides/pull/2966)

## [2.10.0](https://github.com/ethyca/fides/compare/2.9.2...2.10.0)

Expand Down
2 changes: 2 additions & 0 deletions clients/admin-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ running the app, for example:

Or you can configure the environment using `env.local` as described by the [Next.js docs](https://nextjs.org/docs/basic-features/environment-variables#loading-environment-variables).

In addition, you can mark a flag as `userCannotModify: true` in `flags.json`. This will prevent the user from seeing that flag as an override-able option in the Beta Features section. However, the values given to the various environments will still be in effect. Therefore, you can still control the flag with the same level of granularity via the `flags.json` file, but not via the UI.

## Preparing for production

To view a production version of this site, including the backend:
Expand Down
5 changes: 5 additions & 0 deletions clients/admin-ui/src/features/common/features/FlagControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export const FlagControl = ({
);
}

// Do not render a toggle if the flag is marked as not able to be modified by the user
if (FLAG_CONFIG[flag].userCannotModify) {
return null;
}

return (
<FormControl display="contents">
<Box justifySelf="center">
Expand Down
4 changes: 4 additions & 0 deletions clients/admin-ui/src/features/common/features/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export type FlagEnvs<Value> = {
test: Value;
production: Value;
description?: string;
/**
* If true, this flag will not show up in the UI as a toggle
*/
userCannotModify?: boolean;
};

/**
Expand Down

0 comments on commit 94d41f1

Please sign in to comment.