mirror of
https://github.com/Infisical/infisical.git
synced 2026-01-09 15:38:03 -05:00
feat(pam): request access modal callout
This commit is contained in:
@@ -6,7 +6,7 @@ import { cva, type VariantProps } from "cva";
|
|||||||
import { cn } from "../../utils";
|
import { cn } from "../../utils";
|
||||||
|
|
||||||
const alertVariants = cva(
|
const alertVariants = cva(
|
||||||
"relative w-full border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",
|
"relative w-full border px-4 rounded-md py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",
|
||||||
{
|
{
|
||||||
variants: {
|
variants: {
|
||||||
variant: {
|
variant: {
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|||||||
import { useNavigate, useSearch } from "@tanstack/react-router";
|
import { useNavigate, useSearch } from "@tanstack/react-router";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
|
||||||
import { ProjectPermissionCan } from "@app/components/permissions";
|
import { ProjectPermissionCan } from "@app/components/permissions";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@@ -251,13 +250,8 @@ export const PamAccountsTable = ({ projectId }: Props) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (requiresApproval) {
|
if (requiresApproval) {
|
||||||
createNotification({
|
|
||||||
text: "This account is protected by an approval policy, you must request access",
|
|
||||||
type: "info"
|
|
||||||
});
|
|
||||||
|
|
||||||
// Open request access modal with pre-populated path
|
// Open request access modal with pre-populated path
|
||||||
handlePopUpOpen("requestAccount", { accountPath: fullAccountPath });
|
handlePopUpOpen("requestAccount", { accountPath: fullAccountPath, accountAccessed: true });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,6 +554,7 @@ export const PamAccountsTable = ({ projectId }: Props) => {
|
|||||||
isOpen={popUp.requestAccount.isOpen}
|
isOpen={popUp.requestAccount.isOpen}
|
||||||
onOpenChange={(isOpen) => handlePopUpToggle("requestAccount", isOpen)}
|
onOpenChange={(isOpen) => handlePopUpToggle("requestAccount", isOpen)}
|
||||||
accountPath={popUp.requestAccount.data?.accountPath}
|
accountPath={popUp.requestAccount.data?.accountPath}
|
||||||
|
accountAccessed={popUp.requestAccount.data?.accountAccessed}
|
||||||
/>
|
/>
|
||||||
<PamDeleteAccountModal
|
<PamDeleteAccountModal
|
||||||
isOpen={popUp.deleteAccount.isOpen}
|
isOpen={popUp.deleteAccount.isOpen}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Controller, useForm } from "react-hook-form";
|
import { Controller, useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import { InfoIcon } from "lucide-react";
|
||||||
import ms from "ms";
|
import ms from "ms";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
@@ -17,9 +18,11 @@ import {
|
|||||||
import { useProject } from "@app/context";
|
import { useProject } from "@app/context";
|
||||||
import { ApprovalPolicyType } from "@app/hooks/api/approvalPolicies";
|
import { ApprovalPolicyType } from "@app/hooks/api/approvalPolicies";
|
||||||
import { useCreateApprovalRequest } from "@app/hooks/api/approvalRequests/mutations";
|
import { useCreateApprovalRequest } from "@app/hooks/api/approvalRequests/mutations";
|
||||||
|
import { UnstableAlert, UnstableAlertDescription, UnstableAlertTitle } from "@app/components/v3";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
accountPath?: string;
|
accountPath?: string;
|
||||||
|
accountAccessed?: boolean;
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onOpenChange: (isOpen: boolean) => void;
|
onOpenChange: (isOpen: boolean) => void;
|
||||||
};
|
};
|
||||||
@@ -45,7 +48,7 @@ const formSchema = z.object({
|
|||||||
|
|
||||||
type FormData = z.infer<typeof formSchema>;
|
type FormData = z.infer<typeof formSchema>;
|
||||||
|
|
||||||
const Content = ({ onOpenChange, accountPath }: Props) => {
|
const Content = ({ onOpenChange, accountPath, accountAccessed }: Props) => {
|
||||||
const { projectId } = useProject();
|
const { projectId } = useProject();
|
||||||
const { mutateAsync: createApprovalRequest, isPending: isSubmitting } =
|
const { mutateAsync: createApprovalRequest, isPending: isSubmitting } =
|
||||||
useCreateApprovalRequest();
|
useCreateApprovalRequest();
|
||||||
@@ -94,6 +97,15 @@ const Content = ({ onOpenChange, accountPath }: Props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit(onSubmit)}>
|
<form onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
{accountAccessed && (
|
||||||
|
<UnstableAlert variant="info" className="mb-3">
|
||||||
|
<InfoIcon />
|
||||||
|
<UnstableAlertTitle>This account is protected by an approval policy</UnstableAlertTitle>
|
||||||
|
<UnstableAlertDescription>
|
||||||
|
You must request access by filling out the fields below.
|
||||||
|
</UnstableAlertDescription>
|
||||||
|
</UnstableAlert>
|
||||||
|
)}
|
||||||
<Controller
|
<Controller
|
||||||
name="accountPath"
|
name="accountPath"
|
||||||
control={control}
|
control={control}
|
||||||
|
|||||||
Reference in New Issue
Block a user