-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1854 from chirino/ui-fflags
ui: don’t show security group fields when that feature flag is off
- Loading branch information
Showing
13 changed files
with
243 additions
and
161 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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,42 @@ | ||
import { | ||
useState, | ||
createContext, | ||
useEffect, | ||
PropsWithChildren, | ||
ReactNode, | ||
useContext, | ||
} from "react"; | ||
import { dataProvider } from "../DataProvider"; | ||
import { useGetIdentity } from "react-admin"; | ||
|
||
const FlagsContext = createContext( | ||
{} as { | ||
[index: string]: boolean; | ||
}, | ||
); | ||
|
||
export function FlagsProvider(props: PropsWithChildren<{}>) { | ||
const { data, isLoading } = useGetIdentity(); | ||
const [flags, setFlags] = useState({} as { [index: string]: boolean }); | ||
useEffect(() => { | ||
isLoading || | ||
(async () => { | ||
try { | ||
const flags = await dataProvider.getFlags(); | ||
setFlags(flags); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
})(); | ||
}, [data]); // we can only fetch flags after we have logged in | ||
|
||
return ( | ||
<FlagsContext.Provider value={flags}> | ||
{props.children} | ||
</FlagsContext.Provider> | ||
); | ||
} | ||
|
||
export const useFlags = () => { | ||
return useContext(FlagsContext); | ||
}; |
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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
import { Layout, LayoutProps } from "react-admin"; | ||
import AppBar from "./AppBar"; | ||
import { FlagsProvider } from "../common/FlagsContext"; | ||
|
||
export default (props: LayoutProps) => { | ||
return <Layout {...props} appBar={AppBar} />; | ||
return ( | ||
<FlagsProvider> | ||
<Layout {...props} appBar={AppBar} /> | ||
</FlagsProvider> | ||
); | ||
}; |
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
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
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
Oops, something went wrong.