import { Box, Text } from "@prismicio/editor-ui"; import type { FC } from "react"; import { toast } from "react-toastify"; import { LabsListItem } from "./LabsListItem"; import { useLab, type UseLabArgs, type UseLabReturnType } from "./useLab"; export const LabsList: FC = () => { const [legacySliceUpgraderLab, setLegacySliceUpgraderLab] = useLabWithToast( "legacySliceUpgrader", "Legacy Slice Upgrader", ); return (
Slice Machine Labs gives you early access to new features before they're widely released. Experimental features are works-in-progress and potentially unstable, so you may find some bugs and breaking changes along the way.
void setLegacySliceUpgraderLab(enabled)} > The Legacy Slice Upgrader allows you to convert old slices (legacy and composite slices) to slices managed by Slice Machine (shared slices). This feature is experimental, and we strongly recommend that you test it with a{" "} Prismic environment {" "} or you'll be at risk of losing past content.
); }; function useLabWithToast(key: UseLabArgs, name: string): UseLabReturnType { const [lab, setLab] = useLab(key); const setLabWithToast = async (enabled: boolean) => { try { await setLab(enabled); toast.success( enabled ? `Labs: enabled ${name}` : `Labs: disabled ${name}`, ); } catch (error) { console.error(error); toast.error( enabled ? `Labs: failed to enable ${name}` : `Labs: failed to disable ${name}`, ); } }; return [lab, setLabWithToast]; }