mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-22 00:35:22 +00:00
♻️ update
This commit is contained in:
@@ -40,6 +40,8 @@ import { orgQueries, resourceQueries } from "@app/lib/queries";
|
|||||||
import { ResourcePolicyProvider } from "@app/providers/ResourcePolicyProvider";
|
import { ResourcePolicyProvider } from "@app/providers/ResourcePolicyProvider";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { CaretSortIcon } from "@radix-ui/react-icons";
|
import { CaretSortIcon } from "@radix-ui/react-icons";
|
||||||
|
import { build } from "@server/build";
|
||||||
|
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
||||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import { ArrowRightIcon, CheckIcon, ShieldAlertIcon } from "lucide-react";
|
import { ArrowRightIcon, CheckIcon, ShieldAlertIcon } from "lucide-react";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
@@ -73,8 +75,6 @@ export default function ResourceAuthenticationPage() {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
|
|
||||||
const { isPaidUser } = usePaidStatus();
|
|
||||||
|
|
||||||
const { data: policies, isLoading: isLoadingPolicies } = useQuery(
|
const { data: policies, isLoading: isLoadingPolicies } = useQuery(
|
||||||
resourceQueries.policies({
|
resourceQueries.policies({
|
||||||
resourceId: resource.resourceId
|
resourceId: resource.resourceId
|
||||||
@@ -84,7 +84,10 @@ export default function ResourceAuthenticationPage() {
|
|||||||
const form = useForm({
|
const form = useForm({
|
||||||
resolver: zodResolver(resourceTypeSchema),
|
resolver: zodResolver(resourceTypeSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
type: resource.resourcePolicyId ? "shared" : "inline"
|
type:
|
||||||
|
build !== "oss" && resource.resourcePolicyId
|
||||||
|
? "shared"
|
||||||
|
: "inline"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -185,6 +188,7 @@ export default function ResourceAuthenticationPage() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SettingsContainer>
|
<SettingsContainer>
|
||||||
|
{build !== "oss" && (
|
||||||
<SettingsSection>
|
<SettingsSection>
|
||||||
<SettingsSectionHeader>
|
<SettingsSectionHeader>
|
||||||
<SettingsSectionTitle>
|
<SettingsSectionTitle>
|
||||||
@@ -225,27 +229,34 @@ export default function ResourceAuthenticationPage() {
|
|||||||
<Command shouldFilter={false}>
|
<Command shouldFilter={false}>
|
||||||
<CommandInput
|
<CommandInput
|
||||||
placeholder={t("siteSearch")}
|
placeholder={t("siteSearch")}
|
||||||
value={resourcePolicysearchQuery}
|
value={
|
||||||
|
resourcePolicysearchQuery
|
||||||
|
}
|
||||||
onValueChange={
|
onValueChange={
|
||||||
setResourcePolicySearchQuery
|
setResourcePolicySearchQuery
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<CommandList>
|
<CommandList>
|
||||||
<CommandEmpty>
|
<CommandEmpty>
|
||||||
{t("resourcePolicyNotFound")}
|
{t(
|
||||||
|
"resourcePolicyNotFound"
|
||||||
|
)}
|
||||||
</CommandEmpty>
|
</CommandEmpty>
|
||||||
<CommandGroup>
|
<CommandGroup>
|
||||||
{policiesList.map((policy) => (
|
{policiesList.map(
|
||||||
|
(policy) => (
|
||||||
<CommandItem
|
<CommandItem
|
||||||
key={
|
key={
|
||||||
policy.resourcePolicyId
|
policy.resourcePolicyId
|
||||||
}
|
}
|
||||||
value={policy.resourcePolicyId.toString()}
|
value={policy.resourcePolicyId.toString()}
|
||||||
onSelect={() =>
|
onSelect={() =>
|
||||||
setSelectedPolicy({
|
setSelectedPolicy(
|
||||||
|
{
|
||||||
id: policy.resourcePolicyId,
|
id: policy.resourcePolicyId,
|
||||||
name: policy.name
|
name: policy.name
|
||||||
})
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<CheckIcon
|
<CheckIcon
|
||||||
@@ -259,7 +270,8 @@ export default function ResourceAuthenticationPage() {
|
|||||||
/>
|
/>
|
||||||
{policy.name}
|
{policy.name}
|
||||||
</CommandItem>
|
</CommandItem>
|
||||||
))}
|
)
|
||||||
|
)}
|
||||||
</CommandGroup>
|
</CommandGroup>
|
||||||
</CommandList>
|
</CommandList>
|
||||||
</Command>
|
</Command>
|
||||||
@@ -270,7 +282,9 @@ export default function ResourceAuthenticationPage() {
|
|||||||
<SettingsSectionFooter className="justify-start">
|
<SettingsSectionFooter className="justify-start">
|
||||||
<Button
|
<Button
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
startTransition(handleSaveResourcePolicyType)
|
startTransition(
|
||||||
|
handleSaveResourcePolicyType
|
||||||
|
)
|
||||||
}
|
}
|
||||||
loading={isUpdatingResource}
|
loading={isUpdatingResource}
|
||||||
>
|
>
|
||||||
@@ -278,6 +292,8 @@ export default function ResourceAuthenticationPage() {
|
|||||||
</Button>
|
</Button>
|
||||||
</SettingsSectionFooter>
|
</SettingsSectionFooter>
|
||||||
</SettingsSection>
|
</SettingsSection>
|
||||||
|
)}
|
||||||
|
|
||||||
{selectedResourceType === "inline" ? (
|
{selectedResourceType === "inline" ? (
|
||||||
<ResourcePolicyProvider policy={policies.defaultPolicy}>
|
<ResourcePolicyProvider policy={policies.defaultPolicy}>
|
||||||
<EditPolicyForm hidePolicyNameForm />
|
<EditPolicyForm hidePolicyNameForm />
|
||||||
|
|||||||
Reference in New Issue
Block a user