This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
forked from HHS/simpler-grants-gov
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
93 additions
and
97 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
frontend/src/app/[locale]/dev/feature-flags/FeatureFlagsTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
"use client"; | ||
import { useFeatureFlags } from "src/hooks/useFeatureFlags"; | ||
|
||
import React from "react"; | ||
import { Button, Table } from "@trussworks/react-uswds"; | ||
|
||
/** | ||
* View for managing feature flags | ||
*/ | ||
export default function FeatureFlagsTable() { | ||
const { featureFlagsManager, mounted, setFeatureFlag } = useFeatureFlags(); | ||
|
||
if (!mounted) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Table> | ||
<thead> | ||
<tr> | ||
<th scope="col">Status</th> | ||
<th scope="col">Feature Flag</th> | ||
<th scope="col">Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{Object.entries(featureFlagsManager.featureFlags).map( | ||
([featureName, enabled]) => ( | ||
<tr key={featureName}> | ||
<td | ||
data-testid={`${featureName}-status`} | ||
style={{ background: enabled ? "#81cc81" : "#fc6a6a" }} | ||
> | ||
{enabled ? "Enabled" : "Disabled"} | ||
</td> | ||
<th scope="row">{featureName}</th> | ||
<td> | ||
<Button | ||
data-testid={`enable-${featureName}`} | ||
disabled={enabled} | ||
onClick={() => setFeatureFlag(featureName, true)} | ||
type="button" | ||
> | ||
Enable | ||
</Button> | ||
<Button | ||
data-testid={`disable-${featureName}`} | ||
disabled={!enabled} | ||
onClick={() => setFeatureFlag(featureName, false)} | ||
type="button" | ||
> | ||
Disable | ||
</Button> | ||
</td> | ||
</tr> | ||
), | ||
)} | ||
</tbody> | ||
</Table> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Metadata } from "next"; | ||
|
||
import Head from "next/head"; | ||
import React from "react"; | ||
import FeatureFlagsTable from "./FeatureFlagsTable"; | ||
|
||
export function generateMetadata() { | ||
const meta: Metadata = { | ||
title: "Feature flag manager", | ||
}; | ||
|
||
return meta; | ||
} | ||
|
||
/** | ||
* View for managing feature flags | ||
*/ | ||
export default function FeatureFlags() { | ||
return ( | ||
<> | ||
<Head> | ||
<title>Manage Feature Flags</title> | ||
</Head> | ||
<div> | ||
<h1>Manage Feature Flags</h1> | ||
<FeatureFlagsTable /> | ||
</div> | ||
</> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters