Something went wrong. Try again.
A self-hosted web platform for applications & services with design based on Google's Material 3 Expressive. (Work In Progress)
Something went wrong. Try again.
onlineworkspace applications uk.ewsgit.settings web pages instance components FeatureFlags FeatureFlags.tsx
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859import UKStack from "@ewsgit/uikit-solid/src/components/stack/UKStack.tsx";import UKStackItem from "@ewsgit/uikit-solid/src/components/stack/UKStackItem.tsx";import UKStackLabel from "@ewsgit/uikit-solid/src/components/stack/UKStackLabel.tsx";import UKSwitch from "@ewsgit/uikit-solid/src/components/switch/UKSwitch.tsx";import { type Component, createResource, For, Suspense } from "solid-js";import trpc from "../../../../lib/trpc";import styles from "./FeatureFlags.module.scss";
const FeatureFlags: Component = () => { const [features, { mutate: mutateFeatures }] = createResource(() => trpc.instance.getFeatures.query());
return ( <> <UKStackLabel>Feature Flags</UKStackLabel> <UKStack> <Suspense> <For each={features()}> {(feature) => { return ( <UKStackItem labelText={`${feature.name} ('${feature.id}')`} supportingText={`${feature.description !== undefined ? `${feature.description}` : ""}`} inlineComponent={ <UKSwitch class={styles.switch} value={feature.enabled} onValueChange={async (val) => { await trpc.instance.setFeature.mutate({ id: feature.id, value: val, }); mutateFeatures((feats) => feats !== undefined ? feats.map((f) => { if (f.id === feature.id) return { ...f, enabled: val, };
return f; }) : undefined, ); }} /> } /> ); }} </For> </Suspense> </UKStack> </> );};
export default FeatureFlags;