61 lines
2.2 KiB
TypeScript
61 lines
2.2 KiB
TypeScript
import { LoaderFunctionArgs, MetaFunction, Outlet } from "react-router";
|
|
import { useTranslation } from "react-i18next";
|
|
import IncreaseIcon from "~/components/ui/icons/crm/IncreaseIcon";
|
|
import IncreaseIconFilled from "~/components/ui/icons/crm/IncreaseIconFilled";
|
|
import SettingsIcon from "~/components/ui/icons/crm/SettingsIcon";
|
|
import SettingsIconFilled from "~/components/ui/icons/crm/SettingsIconFilled";
|
|
import ToggleOffIcon from "~/components/ui/icons/featureFlags/ToggleOffIcon";
|
|
import ToggleOnIcon from "~/components/ui/icons/featureFlags/ToggleOnIcon";
|
|
import SidebarIconsLayout from "~/components/ui/layouts/SidebarIconsLayout";
|
|
import { getTranslations } from "~/locale/i18next.server";
|
|
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
|
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
|
|
|
|
type LoaderData = {
|
|
title: string;
|
|
};
|
|
|
|
export const loader = async ({ request }: LoaderFunctionArgs) => {
|
|
await verifyUserHasPermission(request, "admin.featureFlags.view");
|
|
const { t } = await getTranslations(request);
|
|
const data: LoaderData = {
|
|
title: `${t("featureFlags.title")} | ${process.env.APP_NAME}`,
|
|
};
|
|
return data;
|
|
};
|
|
|
|
export const meta: MetaFunction<typeof loader> = ({ data }) => [{ title: data?.title }];
|
|
|
|
export default () => {
|
|
const { t } = useTranslation();
|
|
return (
|
|
<SidebarIconsLayout
|
|
label={{ align: "right" }}
|
|
items={[
|
|
{
|
|
name: t("shared.overview"),
|
|
href: adminPath("feature-flags", { mode: "host-aware" }),
|
|
icon: <IncreaseIcon className="h-5 w-5" />,
|
|
iconSelected: <IncreaseIconFilled className="h-5 w-5" />,
|
|
exact: true,
|
|
},
|
|
{
|
|
name: t("featureFlags.plural"),
|
|
href: adminPath("feature-flags/flags", { mode: "host-aware" }),
|
|
icon: <ToggleOffIcon className="h-5 w-5" />,
|
|
iconSelected: <ToggleOnIcon className="h-5 w-5" />,
|
|
},
|
|
{
|
|
name: t("shared.settings"),
|
|
href: adminPath("feature-flags/settings", { mode: "host-aware" }),
|
|
icon: <SettingsIcon className="h-5 w-5" />,
|
|
iconSelected: <SettingsIconFilled className="h-5 w-5" />,
|
|
bottom: true,
|
|
},
|
|
]}
|
|
>
|
|
<Outlet />
|
|
</SidebarIconsLayout>
|
|
);
|
|
};
|