mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-17 06:24:32 +00:00
♻️ refactor
This commit is contained in:
@@ -660,6 +660,7 @@
|
|||||||
"policyErrorUpdateMessageDescription": "An unexpected error occurred",
|
"policyErrorUpdateMessageDescription": "An unexpected error occurred",
|
||||||
"policyCreatedSuccess": "Resource policy succesfully created",
|
"policyCreatedSuccess": "Resource policy succesfully created",
|
||||||
"policyUpdatedSuccess": "Resource policy succesfully updated",
|
"policyUpdatedSuccess": "Resource policy succesfully updated",
|
||||||
|
"authMethodsSave": "Save auth methods",
|
||||||
"resourceErrorCreate": "Error creating resource",
|
"resourceErrorCreate": "Error creating resource",
|
||||||
"resourceErrorCreateDescription": "An error occurred when creating the resource",
|
"resourceErrorCreateDescription": "An error occurred when creating the resource",
|
||||||
"resourceErrorCreateMessage": "Error creating resource:",
|
"resourceErrorCreateMessage": "Error creating resource:",
|
||||||
|
|||||||
@@ -118,7 +118,10 @@ async function query(params: z.infer<typeof getResourcePolicySchema>) {
|
|||||||
.where(eq(rolePolicies.resourcePolicyId, res.resourcePolicyId));
|
.where(eq(rolePolicies.resourcePolicyId, res.resourcePolicyId));
|
||||||
|
|
||||||
const policyEmailWhiteList = await db
|
const policyEmailWhiteList = await db
|
||||||
.select()
|
.select({
|
||||||
|
whiteListId: resourcePolicyWhiteList.whitelistId,
|
||||||
|
email: resourcePolicyWhiteList.email
|
||||||
|
})
|
||||||
.from(resourcePolicyWhiteList)
|
.from(resourcePolicyWhiteList)
|
||||||
.where(
|
.where(
|
||||||
eq(resourcePolicyWhiteList.resourcePolicyId, res.resourcePolicyId)
|
eq(resourcePolicyWhiteList.resourcePolicyId, res.resourcePolicyId)
|
||||||
|
|||||||
@@ -646,7 +646,7 @@ export function EditPolicyAuthMethodsSectionForm() {
|
|||||||
loading={isSubmitting}
|
loading={isSubmitting}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
>
|
>
|
||||||
{t("saveSettings")}
|
{t("authMethodsSave")}
|
||||||
</Button>
|
</Button>
|
||||||
</SettingsSectionFooter>
|
</SettingsSectionFooter>
|
||||||
</SettingsSection>
|
</SettingsSection>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import { EditPolicyAuthMethodsSectionForm } from "./EditPolicyAuthMethodsSection
|
|||||||
import { EditPolicyNameSectionForm } from "./EditPolicyNameSectionForm";
|
import { EditPolicyNameSectionForm } from "./EditPolicyNameSectionForm";
|
||||||
import { EditPolicyUsersRolesSectionForm } from "./EditPolicyUserRolesSectionForm";
|
import { EditPolicyUsersRolesSectionForm } from "./EditPolicyUserRolesSectionForm";
|
||||||
import { EditPolicyOtpEmailSectionForm } from "./EditPolicyOtpEmailSectionForm";
|
import { EditPolicyOtpEmailSectionForm } from "./EditPolicyOtpEmailSectionForm";
|
||||||
|
import { EditPolicyRulesSectionForm } from "./EditPolicyRulesSectionForm";
|
||||||
|
|
||||||
// ─── EditPolicyForm ─────────────────────────────────────────────────────────
|
// ─── EditPolicyForm ─────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -112,12 +113,10 @@ export function EditPolicyForm({ hidePolicyNameForm }: EditPolicyFormProps) {
|
|||||||
emailEnabled={env.email.emailEnabled}
|
emailEnabled={env.email.emailEnabled}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/*
|
<EditPolicyRulesSectionForm
|
||||||
<PolicyRulesSection
|
isMaxmindAvailable={isMaxmindAvailable}
|
||||||
form={form}
|
isMaxmindAsnAvailable={isMaxmindASNAvailable}
|
||||||
isMaxmindAvailable={isMaxmindAvailable}
|
/>
|
||||||
isMaxmindAsnAvailable={isMaxmindASNAvailable}
|
|
||||||
/> */}
|
|
||||||
</SettingsContainer>
|
</SettingsContainer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +1,22 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
SettingsContainer,
|
|
||||||
SettingsSection,
|
SettingsSection,
|
||||||
SettingsSectionBody,
|
SettingsSectionBody,
|
||||||
SettingsSectionDescription,
|
SettingsSectionDescription,
|
||||||
SettingsSectionForm,
|
|
||||||
SettingsSectionHeader,
|
SettingsSectionHeader,
|
||||||
SettingsSectionTitle
|
SettingsSectionTitle
|
||||||
} from "@app/components/Settings";
|
} from "@app/components/Settings";
|
||||||
|
|
||||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
|
||||||
import { useOrgContext } from "@app/hooks/useOrgContext";
|
|
||||||
import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
|
||||||
|
|
||||||
import { getUserDisplayName } from "@app/lib/getUserDisplayName";
|
|
||||||
import { orgQueries } from "@app/lib/queries";
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { build } from "@server/build";
|
|
||||||
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
|
||||||
import { UserType } from "@server/types/UserTypes";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
|
||||||
import z from "zod";
|
import z from "zod";
|
||||||
|
|
||||||
import { type PolicyFormValues, createPolicySchema } from ".";
|
|
||||||
import { toast } from "@app/hooks/useToast";
|
import { toast } from "@app/hooks/useToast";
|
||||||
import { createApiClient, formatAxiosError } from "@app/lib/api";
|
import { createPolicySchema, type PolicyFormValues } from ".";
|
||||||
import { orgs, type ResourcePolicy } from "@server/db";
|
|
||||||
import type { AxiosResponse } from "axios";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
|
|
||||||
import { SwitchInput } from "@app/components/SwitchInput";
|
import { SwitchInput } from "@app/components/SwitchInput";
|
||||||
import { Tag, TagInput } from "@app/components/tags/tag-input";
|
|
||||||
import { Alert, AlertDescription, AlertTitle } from "@app/components/ui/alert";
|
|
||||||
import { Button } from "@app/components/ui/button";
|
import { Button } from "@app/components/ui/button";
|
||||||
import {
|
import {
|
||||||
Command,
|
Command,
|
||||||
@@ -47,7 +29,6 @@ import {
|
|||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
FormDescription,
|
|
||||||
FormField,
|
FormField,
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
@@ -76,21 +57,6 @@ import {
|
|||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow
|
TableRow
|
||||||
} from "@app/components/ui/table";
|
} from "@app/components/ui/table";
|
||||||
import {
|
|
||||||
Credenza,
|
|
||||||
CredenzaBody,
|
|
||||||
CredenzaClose,
|
|
||||||
CredenzaContent,
|
|
||||||
CredenzaDescription,
|
|
||||||
CredenzaFooter,
|
|
||||||
CredenzaHeader,
|
|
||||||
CredenzaTitle
|
|
||||||
} from "@app/components/Credenza";
|
|
||||||
import {
|
|
||||||
InputOTP,
|
|
||||||
InputOTPGroup,
|
|
||||||
InputOTPSlot
|
|
||||||
} from "@app/components/ui/input-otp";
|
|
||||||
|
|
||||||
import { MAJOR_ASNS } from "@server/db/asns";
|
import { MAJOR_ASNS } from "@server/db/asns";
|
||||||
import { COUNTRIES } from "@server/db/countries";
|
import { COUNTRIES } from "@server/db/countries";
|
||||||
@@ -108,21 +74,10 @@ import {
|
|||||||
getSortedRowModel,
|
getSortedRowModel,
|
||||||
useReactTable
|
useReactTable
|
||||||
} from "@tanstack/react-table";
|
} from "@tanstack/react-table";
|
||||||
import {
|
import { ArrowUpDown, Check, ChevronsUpDown, Plus } from "lucide-react";
|
||||||
ArrowUpDown,
|
|
||||||
Binary,
|
|
||||||
Bot,
|
|
||||||
Check,
|
|
||||||
ChevronsUpDown,
|
|
||||||
InfoIcon,
|
|
||||||
Key,
|
|
||||||
Plus
|
|
||||||
} from "lucide-react";
|
|
||||||
|
|
||||||
import { useCallback, useMemo, useState, useActionState } from "react";
|
import { useCallback, useMemo, useState } from "react";
|
||||||
import { UseFormReturn, useForm, useWatch } from "react-hook-form";
|
import { UseFormReturn, useForm } from "react-hook-form";
|
||||||
import { useResourcePolicyContext } from "@app/providers/ResourcePolicyProvider";
|
|
||||||
import { cn } from "@app/lib/cn";
|
|
||||||
|
|
||||||
// ─── PolicyRulesSection ───────────────────────────────────────────────────────
|
// ─── PolicyRulesSection ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -145,17 +100,24 @@ type LocalRule = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type PolicyRulesSectionProps = {
|
type PolicyRulesSectionProps = {
|
||||||
form: UseFormReturn<PolicyFormValues, any, any>;
|
|
||||||
isMaxmindAvailable: boolean;
|
isMaxmindAvailable: boolean;
|
||||||
isMaxmindAsnAvailable: boolean;
|
isMaxmindAsnAvailable: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function PolicyRulesSection({
|
export function EditPolicyRulesSectionForm({
|
||||||
form,
|
|
||||||
isMaxmindAvailable,
|
isMaxmindAvailable,
|
||||||
isMaxmindAsnAvailable
|
isMaxmindAsnAvailable
|
||||||
}: PolicyRulesSectionProps) {
|
}: PolicyRulesSectionProps) {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
|
|
||||||
|
const form = useForm({
|
||||||
|
resolver: zodResolver(
|
||||||
|
createPolicySchema.pick({
|
||||||
|
rules: true,
|
||||||
|
applyRules: true
|
||||||
|
})
|
||||||
|
)
|
||||||
|
});
|
||||||
const [isExpanded, setIsExpanded] = useState(false);
|
const [isExpanded, setIsExpanded] = useState(false);
|
||||||
const [rules, setRules] = useState<LocalRule[]>([]);
|
const [rules, setRules] = useState<LocalRule[]>([]);
|
||||||
const [rulesEnabled, setRulesEnabled] = useState(false);
|
const [rulesEnabled, setRulesEnabled] = useState(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user