Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+21
-13
@@ -1,10 +1,15 @@
|
||||
import { ActionFunctionArgs, LoaderFunction, MetaFunction, useLoaderData } from "react-router";
|
||||
import { ActionFunctionArgs, LoaderFunction, useActionData, useLoaderData } from "react-router";
|
||||
import { FeatureFlag } from "@hivegrid/db/prisma-browser";
|
||||
import { FeatureFlagWithEvents, getFeatureFlag, getFeatureFlagsWithEvents, updateFeatureFlag } from "~/modules/featureFlags/db/featureFlags.db.server";
|
||||
import {
|
||||
FeatureFlagWithEventCount,
|
||||
getFeatureFlag,
|
||||
getLegacyFeatureFlagsWithEventCounts,
|
||||
updateFeatureFlag,
|
||||
} from "~/modules/featureFlags/db/featureFlags.db.server";
|
||||
import SimpleBadge from "~/components/ui/badges/SimpleBadge";
|
||||
import { Colors } from "~/application/enums/shared/Colors";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link, Outlet, useSearchParams, useSubmit } from "react-router";
|
||||
import { Outlet, useSearchParams, useSubmit } from "react-router";
|
||||
import TabsWithIcons from "~/components/ui/tabs/TabsWithIcons";
|
||||
import ButtonPrimary from "~/components/ui/buttons/ButtonPrimary";
|
||||
import PlusIcon from "~/components/ui/icons/PlusIcon";
|
||||
@@ -14,28 +19,28 @@ import InputCheckbox from "~/components/ui/input/InputCheckbox";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import DateCell from "~/components/ui/dates/DateCell";
|
||||
import { v2MetaFunction } from "~/utils/compat/v2MetaFunction";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import { validateCSRFToken } from "~/utils/session.server";
|
||||
import { appendCSRFToken } from "~/utils/csrf";
|
||||
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
|
||||
import { useSaveToast } from "~/hooks/use-save-toast";
|
||||
|
||||
type LoaderData = {
|
||||
title: string;
|
||||
items: FeatureFlagWithEvents[];
|
||||
items: FeatureFlagWithEventCount[];
|
||||
};
|
||||
type ActionData = { intent: "toggle"; errorKey?: string };
|
||||
export const loader: LoaderFunction = async ({ request }) => {
|
||||
await verifyUserHasPermission(request, "admin.featureFlags.view");
|
||||
const { t } = await getTranslations(request);
|
||||
const data: LoaderData = {
|
||||
title: `${t("featureFlags.title")} | ${process.env.APP_NAME}`,
|
||||
items: await getFeatureFlagsWithEvents({ enabled: undefined }),
|
||||
items: await getLegacyFeatureFlagsWithEventCounts({ enabled: undefined }),
|
||||
};
|
||||
return Response.json(data);
|
||||
};
|
||||
|
||||
export const action = async ({ request, params }: ActionFunctionArgs) => {
|
||||
export const action = async ({ request, params: _params }: ActionFunctionArgs) => {
|
||||
await verifyUserHasPermission(request, "admin.featureFlags.manage");
|
||||
const { t } = await getTranslations(request);
|
||||
await validateCSRFToken(request);
|
||||
const form = await request.formData();
|
||||
const action = form.get("action")?.toString();
|
||||
@@ -46,16 +51,16 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
|
||||
|
||||
const flag = await getFeatureFlag({ id });
|
||||
if (!flag) {
|
||||
return Response.json({ error: t("shared.notFound") }, { status: 400 });
|
||||
return Response.json({ intent: "toggle", errorKey: "shared.notFound" } satisfies ActionData, { status: 400 });
|
||||
}
|
||||
|
||||
await updateFeatureFlag(id, {
|
||||
enabled,
|
||||
});
|
||||
|
||||
return Response.json({ success: t("shared.success") });
|
||||
return Response.json({ intent: "toggle" } satisfies ActionData);
|
||||
} else {
|
||||
return Response.json({ error: t("shared.invalidForm") }, { status: 400 });
|
||||
return Response.json({ intent: "toggle", errorKey: "shared.invalidForm" } satisfies ActionData, { status: 400 });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -64,8 +69,11 @@ export const meta: v2MetaFunction<LoaderData> = ({ data }) => [{ title: data?.ti
|
||||
export default function CampaignsListRoute() {
|
||||
const { t } = useTranslation();
|
||||
const data = useLoaderData<LoaderData>();
|
||||
const actionData = useActionData<ActionData>();
|
||||
const submit = useSubmit();
|
||||
|
||||
useSaveToast(actionData);
|
||||
|
||||
const [searchParams] = useSearchParams();
|
||||
|
||||
function countStatus(enabled?: boolean) {
|
||||
@@ -94,7 +102,7 @@ export default function CampaignsListRoute() {
|
||||
return data.items;
|
||||
}
|
||||
return (
|
||||
<div className="mx-auto mb-12 max-w-5xl space-y-5 px-4 py-4 sm:px-6 lg:px-8 xl:max-w-7xl">
|
||||
<div className="mb-12 w-full space-y-5 px-6 py-6 mobile:px-4">
|
||||
<div className="flex items-center justify-between space-x-2">
|
||||
<div className="flex-grow">
|
||||
<TabsWithIcons
|
||||
@@ -155,7 +163,7 @@ export default function CampaignsListRoute() {
|
||||
</div>
|
||||
<div className="text-muted-foreground flex items-center space-x-2 text-sm">
|
||||
<span className="lowercase">
|
||||
{i.events.length} {t("featureFlags.triggers")}
|
||||
{i._count.events} {t("featureFlags.triggers")}
|
||||
</span>
|
||||
<div>•</div>
|
||||
<div>
|
||||
|
||||
Reference in new issue
Block a user