diff --git a/frontend/src/views/Org/IdentityPage/components/IdentityDetailsSection.tsx b/frontend/src/views/Org/IdentityPage/components/IdentityDetailsSection.tsx index aa7536bb8..223f4c9a0 100644 --- a/frontend/src/views/Org/IdentityPage/components/IdentityDetailsSection.tsx +++ b/frontend/src/views/Org/IdentityPage/components/IdentityDetailsSection.tsx @@ -25,7 +25,7 @@ export const IdentityDetailsSection = ({ identityId, handlePopUpOpen }: Props) = return data ? (
-

Details

+

Identity Details

{(isAllowed) => { return ( diff --git a/frontend/src/views/Org/IdentityPage/components/IdentityProjectsSection/IdentityProjectRow.tsx b/frontend/src/views/Org/IdentityPage/components/IdentityProjectsSection/IdentityProjectRow.tsx index 70a3c998b..0a9301d56 100644 --- a/frontend/src/views/Org/IdentityPage/components/IdentityProjectsSection/IdentityProjectRow.tsx +++ b/frontend/src/views/Org/IdentityPage/components/IdentityProjectsSection/IdentityProjectRow.tsx @@ -48,7 +48,7 @@ export const IdentityProjectRow = ({ return ( { if (isAccessible) { diff --git a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx index 094de7a5e..9d23a6d71 100644 --- a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx +++ b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx @@ -86,7 +86,7 @@ export const IdentityTable = ({ handlePopUpOpen }: Props) => { data?.map(({ identity: { id, name }, role, customRole }) => { return ( router.push(`/org/${orgId}/identities/${id}`)} > diff --git a/frontend/src/views/Org/MembersPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx b/frontend/src/views/Org/MembersPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx index 304b104a7..6c0c7566a 100644 --- a/frontend/src/views/Org/MembersPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx +++ b/frontend/src/views/Org/MembersPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx @@ -184,7 +184,7 @@ export const OrgMembersTable = ({ handlePopUpOpen, setCompleteInviteLink }: Prop return ( router.push(`/org/${orgId}/memberships/${orgMembershipId}`)} > {name} diff --git a/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleTable.tsx b/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleTable.tsx index 0fce9f06b..f9b15cb1f 100644 --- a/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleTable.tsx +++ b/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleTable.tsx @@ -93,7 +93,7 @@ export const OrgRoleTable = () => { return ( router.push(`/org/${orgId}/roles/${id}`)} > {name} diff --git a/frontend/src/views/Org/RolePage/components/RoleDetailsSection.tsx b/frontend/src/views/Org/RolePage/components/RoleDetailsSection.tsx index 6497f5ba6..bab0ca525 100644 --- a/frontend/src/views/Org/RolePage/components/RoleDetailsSection.tsx +++ b/frontend/src/views/Org/RolePage/components/RoleDetailsSection.tsx @@ -26,7 +26,7 @@ export const RoleDetailsSection = ({ roleId, handlePopUpOpen }: Props) => { return data ? (
-

Details

+

Org Role Details

{isCustomRole && ( {(isAllowed) => { diff --git a/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionRow.tsx b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionRow.tsx index bbd9b8457..6f4cc7c88 100644 --- a/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionRow.tsx +++ b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionRow.tsx @@ -150,7 +150,7 @@ export const RolePermissionRow = ({ isEditable, title, formName, control, setVal return ( <> setIsRowExpanded.toggle()} > diff --git a/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx index 747ae016a..fe19620f5 100644 --- a/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx +++ b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx @@ -16,23 +16,23 @@ import { RolePermissionRow } from "./RolePermissionRow"; const SIMPLE_PERMISSION_OPTIONS = [ { - title: "User management", + title: "User Management", formName: "member" }, { - title: "Group management", + title: "Group Management", formName: "groups" }, { - title: "Machine identity management", + title: "Machine Identity Management", formName: "identity" }, { - title: "Billing & usage", + title: "Usage & Billing", formName: "billing" }, { - title: "Role management", + title: "Role Management", formName: "role" }, { @@ -40,7 +40,7 @@ const SIMPLE_PERMISSION_OPTIONS = [ formName: "incident-contact" }, { - title: "Organization profile", + title: "Organization Profile", formName: "settings" }, { diff --git a/frontend/src/views/Org/UserPage/components/UserDetailsSection.tsx b/frontend/src/views/Org/UserPage/components/UserDetailsSection.tsx index 00c605f05..4311a48bb 100644 --- a/frontend/src/views/Org/UserPage/components/UserDetailsSection.tsx +++ b/frontend/src/views/Org/UserPage/components/UserDetailsSection.tsx @@ -3,7 +3,8 @@ import { faCheckCircle, faCircleXmark, faCopy, - faPencil} from "@fortawesome/free-solid-svg-icons"; + faPencil +} from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { createNotification } from "@app/components/notifications"; @@ -82,7 +83,7 @@ export const UserDetailsSection = ({ membershipId, handlePopUpOpen }: Props) => return membership ? (
-

Details

+

User Details

{userId !== membership.user.id && ( {(isAllowed) => { diff --git a/frontend/src/views/Org/UserPage/components/UserProjectsSection/UserProjectRow.tsx b/frontend/src/views/Org/UserPage/components/UserProjectsSection/UserProjectRow.tsx index 68a974a4b..fff2007ef 100644 --- a/frontend/src/views/Org/UserPage/components/UserProjectsSection/UserProjectRow.tsx +++ b/frontend/src/views/Org/UserPage/components/UserProjectsSection/UserProjectRow.tsx @@ -44,7 +44,7 @@ export const UserProjectRow = ({ return ( { if (isAccessible) { diff --git a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleList/ProjectRoleList.tsx b/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleList/ProjectRoleList.tsx index 59a13c67f..658a75b57 100644 --- a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleList/ProjectRoleList.tsx +++ b/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleList/ProjectRoleList.tsx @@ -92,7 +92,7 @@ export const ProjectRoleList = () => { return ( router.push(`/project/${projectId}/roles/${slug}`)} > {name} diff --git a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/MultiEnvProjectPermission.tsx b/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/MultiEnvProjectPermission.tsx deleted file mode 100644 index 40b841e0f..000000000 --- a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/MultiEnvProjectPermission.tsx +++ /dev/null @@ -1,258 +0,0 @@ -import { useMemo } from "react"; -import { Control, Controller, UseFormGetValues, UseFormSetValue, useWatch } from "react-hook-form"; -import { IconProp } from "@fortawesome/fontawesome-svg-core"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { motion } from "framer-motion"; -import { twMerge } from "tailwind-merge"; - -import GlobPatternExamples from "@app/components/basic/popups/GlobPatternExamples"; -import { - Checkbox, - FormControl, - Input, - Select, - SelectItem, - Table, - TableContainer, - TBody, - Td, - Th, - THead, - Tr -} from "@app/components/v2"; -import { useWorkspace } from "@app/context"; - -import { TFormSchema } from "./ProjectRoleModifySection.utils"; - -type Props = { - formName: "secrets"; - isNonEditable?: boolean; - setValue: UseFormSetValue; - getValue: UseFormGetValues; - control: Control; - title: string; - subtitle: string; - icon: IconProp; -}; - -enum Permission { - NoAccess = "no-access", - ReadOnly = "read-only", - FullAccess = "full-acess", - Custom = "custom" -} - -export const MultiEnvProjectPermission = ({ - isNonEditable, - setValue, - getValue, - control, - formName, - title, - subtitle, - icon -}: Props) => { - const { currentWorkspace } = useWorkspace(); - - const environments = currentWorkspace?.environments || []; - const customRule = useWatch({ - control, - name: `permissions.${formName}.custom` - }); - const isCustom = Boolean(customRule); - const allRule = useWatch({ control, name: `permissions.${formName}.all` }); - - const selectedPermissionCategory = useMemo(() => { - const { read, delete: del, edit, create } = allRule || {}; - if (read && del && edit && create) return Permission.FullAccess; - if (read) return Permission.ReadOnly; - return Permission.NoAccess; - }, [allRule]); - - const handlePermissionChange = (val: Permission) => { - if(!val) return - switch (val) { - case Permission.NoAccess: { - const permissions = getValue("permissions"); - if (permissions) delete permissions[formName]; - setValue("permissions", permissions, { shouldDirty: true }); - break; - } - case Permission.FullAccess: - setValue( - `permissions.${formName}`, - { all: { read: true, edit: true, create: true, delete: true } }, - { shouldDirty: true } - ); - break; - case Permission.ReadOnly: - setValue( - `permissions.${formName}`, - { all: { read: true, edit: false, create: false, delete: false } }, - { shouldDirty: true } - ); - break; - default: - setValue( - `permissions.${formName}`, - { custom: { read: false, edit: false, create: false, delete: false } }, - { shouldDirty: true } - ); - break; - } - }; - - return ( -
-
-
- -
-
-
{title}
-
{subtitle}
-
-
- -
-
- - - - - - - - - - - - - - {isCustom && - environments.map(({ name, slug }) => ( - - - - - - - - - ))} - -
- -
- Secret Path - - - -
-
ViewCreateModifyDelete
{name} - ( - /* eslint-disable-next-line no-template-curly-in-string */ - - - - )} - /> - - ( -
- -
- )} - /> -
- ( -
- -
- )} - /> -
- ( -
- -
- )} - /> -
- ( -
- -
- )} - /> -
-
-
-
- ); -}; diff --git a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/ProjectRoleModifySection.tsx b/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/ProjectRoleModifySection.tsx deleted file mode 100644 index c386ebc11..000000000 --- a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/ProjectRoleModifySection.tsx +++ /dev/null @@ -1,319 +0,0 @@ -import { useForm } from "react-hook-form"; -import { faElementor } from "@fortawesome/free-brands-svg-icons"; -import { - faAnchorLock, - faArrowLeft, - faBook, - faCertificate, - faCog, - faKey, - faLock, - faNetworkWired, - faPuzzlePiece, - faServer, - faShield, - faTags, - faUser, - faUsers -} from "@fortawesome/free-solid-svg-icons"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { zodResolver } from "@hookform/resolvers/zod"; - -import { createNotification } from "@app/components/notifications"; -import { Button, FormControl, Input, Spinner } from "@app/components/v2"; -import { ProjectPermissionSub, useWorkspace } from "@app/context"; -import { - useCreateProjectRole, - useGetProjectRoleBySlug, - useUpdateProjectRole -} from "@app/hooks/api"; -import { TProjectRole } from "@app/hooks/api/roles/types"; - -import { MultiEnvProjectPermission } from "./MultiEnvProjectPermission"; -import { - formRolePermission2API, - formSchema, - rolePermission2Form, - TFormSchema -} from "./ProjectRoleModifySection.utils"; -import { SecretRollbackPermission } from "./SecretRollbackPermission"; -import { SingleProjectPermission } from "./SingleProjectPermission"; -import { WsProjectPermission } from "./WsProjectPermission"; - -const SINGLE_PERMISSION_LIST = [ - { - title: "Integrations", - subtitle: "Integration management control", - icon: faPuzzlePiece, - formName: "integrations" - }, - { - title: "Secret Protect policy", - subtitle: "Manage policies for secret protection for unauthorized secret changes", - icon: faShield, - formName: ProjectPermissionSub.SecretApproval - }, - { - title: "Roles", - subtitle: "Role management control", - icon: faUsers, - formName: "role" - }, - { - title: "User management", - subtitle: "Add, view and remove users from the project", - icon: faUser, - formName: "member" - }, - { - title: "Group management", - subtitle: "Add, view and remove user groups from the project", - icon: faUsers, - formName: "groups" - }, - { - title: "Machine identity management", - subtitle: "Add, view, update and remove (machine) identities from the project", - icon: faServer, - formName: "identity" - }, - { - title: "Webhooks", - subtitle: "Webhook management control", - icon: faAnchorLock, - formName: "webhooks" - }, - { - title: "Service Tokens", - subtitle: "Token management control", - icon: faKey, - formName: "service-tokens" - }, - { - title: "Settings", - subtitle: "Settings control", - icon: faCog, - formName: "settings" - }, - { - title: "Environments", - subtitle: "Environment management control", - icon: faElementor, - formName: "environments" - }, - { - title: "Tags", - subtitle: "Tag management control", - icon: faTags, - formName: "tags" - }, - { - title: "Audit Logs", - subtitle: "Audit log management control", - icon: faBook, - formName: "audit-logs" - }, - { - title: "IP Allowlist", - subtitle: "IP allowlist management control", - icon: faNetworkWired, - formName: "ip-allowlist" - }, - { - title: "Certificate Authorities", - subtitle: "CA management control", - icon: faCertificate, - formName: "certificate-authorities" - }, - { - title: "Certificates", - subtitle: "Certificate management control", - icon: faCertificate, - formName: "certificates" - } -] as const; - -type Props = { - roleSlug?: string; - onGoBack: VoidFunction; -}; - -export const ProjectRoleModifySection = ({ roleSlug, onGoBack }: Props) => { - const isNonEditable = ["admin", "member", "viewer", "no-access"].includes(roleSlug || ""); - const isNewRole = !roleSlug; - - const { currentWorkspace } = useWorkspace(); - const projectSlug = currentWorkspace?.slug || ""; - const { data: roleDetails, isLoading: isRoleDetailsLoading } = useGetProjectRoleBySlug( - currentWorkspace?.slug || "", - roleSlug as string - ); - - const { - handleSubmit, - register, - formState: { isSubmitting, isDirty, errors }, - setValue, - getValues, - control - } = useForm({ - values: roleDetails - ? { ...roleDetails, permissions: rolePermission2Form(roleDetails.permissions) } - : ({} as TProjectRole), - resolver: zodResolver(formSchema) - }); - const { mutateAsync: createRole } = useCreateProjectRole(); - const { mutateAsync: updateRole } = useUpdateProjectRole(); - - const handleRoleUpdate = async (el: TFormSchema) => { - if (!roleDetails?.id) return; - - try { - await updateRole({ - id: roleDetails?.id as string, - projectSlug, - ...el, - permissions: formRolePermission2API(el.permissions) - }); - createNotification({ type: "success", text: "Successfully updated role" }); - onGoBack(); - } catch (err) { - console.log(err); - createNotification({ type: "error", text: "Failed to update role" }); - } - }; - - const handleFormSubmit = async (el: TFormSchema) => { - if (!isNewRole) { - await handleRoleUpdate(el); - return; - } - - try { - await createRole({ - projectSlug, - ...el, - permissions: formRolePermission2API(el.permissions) - }); - createNotification({ type: "success", text: "Created new role" }); - onGoBack(); - } catch (err) { - console.log(err); - createNotification({ type: "error", text: "Failed to create role" }); - } - }; - - if (!isNewRole && isRoleDetailsLoading) { - return ( -
- -
- ); - } - - return ( -
-
-
-

- {isNewRole ? "New" : "Edit"} Role -

- -
-

- Project-level roles allow you to define permissions for resources within projects at a - granular level -

-
- - - - - - - - - -
-
-

Add Permission

-
-
-
- -
-
- -
- {SINGLE_PERMISSION_LIST.map(({ title, subtitle, icon, formName }) => ( -
- -
- ))} -
- -
-
-
- - -
-
-
- ); -}; diff --git a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/SecretRollbackPermission.tsx b/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/SecretRollbackPermission.tsx deleted file mode 100644 index 8d1fb1db3..000000000 --- a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/SecretRollbackPermission.tsx +++ /dev/null @@ -1,147 +0,0 @@ -import { useEffect, useMemo } from "react"; -import { Control, Controller, UseFormSetValue, useWatch } from "react-hook-form"; -import { faPuzzlePiece } from "@fortawesome/free-solid-svg-icons"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { motion } from "framer-motion"; -import { twMerge } from "tailwind-merge"; - -import { Checkbox, Select, SelectItem } from "@app/components/v2"; -import { useToggle } from "@app/hooks"; - -import { TFormSchema } from "./ProjectRoleModifySection.utils"; - -type Props = { - isNonEditable?: boolean; - setValue: UseFormSetValue; - control: Control; -}; - -enum Permission { - NoAccess = "no-access", - ReadOnly = "read-only", - FullAccess = "full-acess", - Custom = "custom" -} - -const PERMISSIONS = [ - { action: "create", label: "Perform Rollback" }, - { action: "read", label: "View" } -] as const; - -export const SecretRollbackPermission = ({ isNonEditable, setValue, control }: Props) => { - const rule = useWatch({ - control, - name: "permissions.secret-rollback" - }); - const [isCustom, setIsCustom] = useToggle(); - - const selectedPermissionCategory = useMemo(() => { - const actions = Object.keys(rule || {}) as Array; - const totalActions = PERMISSIONS.length; - const score = actions.map((key) => (rule?.[key] ? 1 : 0)).reduce((a, b) => a + b, 0 as number); - - if (isCustom) return Permission.Custom; - if (score === 0) return Permission.NoAccess; - if (score === totalActions) return Permission.FullAccess; - - return Permission.Custom; - }, [rule, isCustom]); - - useEffect(() => { - if (selectedPermissionCategory === Permission.Custom) setIsCustom.on(); - else setIsCustom.off(); - }, [selectedPermissionCategory]); - - const handlePermissionChange = (val: Permission) => { - if(!val) return; - if (val === Permission.Custom) setIsCustom.on(); - else setIsCustom.off(); - - switch (val) { - case Permission.NoAccess: - setValue( - "permissions.secret-rollback", - { read: false, create: false }, - { shouldDirty: true } - ); - break; - case Permission.FullAccess: - setValue( - "permissions.secret-rollback", - { read: true, create: true }, - { shouldDirty: true } - ); - break; - case Permission.ReadOnly: - setValue( - "permissions.secret-rollback", - { read: true, create: false }, - { shouldDirty: true } - ); - break; - default: - setValue( - "permissions.secret-rollback", - { read: false, create: false }, - { shouldDirty: true } - ); - break; - } - }; - - return ( -
-
-
- -
-
-
Secret Rollback
-
Secret rollback control actions
-
-
- -
-
- - {isCustom && - PERMISSIONS.map(({ action, label }) => ( - ( - - {label} - - )} - /> - ))} - -
- ); -}; diff --git a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/SingleProjectPermission.tsx b/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/SingleProjectPermission.tsx deleted file mode 100644 index 763aa32f4..000000000 --- a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/SingleProjectPermission.tsx +++ /dev/null @@ -1,194 +0,0 @@ -import { useEffect, useMemo } from "react"; -import { Control, Controller, UseFormSetValue, useWatch } from "react-hook-form"; -import { IconProp } from "@fortawesome/fontawesome-svg-core"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { motion } from "framer-motion"; -import { twMerge } from "tailwind-merge"; - -import { Checkbox, Select, SelectItem } from "@app/components/v2"; -import { ProjectPermissionSub } from "@app/context"; -import { useToggle } from "@app/hooks"; - -import { TFormSchema } from "./ProjectRoleModifySection.utils"; - -type Props = { - formName: - | "role" - | "member" - | "groups" - | "integrations" - | "webhooks" - | "service-tokens" - | "settings" - | "environments" - | "tags" - | "audit-logs" - | "ip-allowlist" - | "identity" - | "certificate-authorities" - | "certificates" - | ProjectPermissionSub.SecretApproval; - isNonEditable?: boolean; - setValue: UseFormSetValue; - control: Control; - title: string; - subtitle: string; - icon: IconProp; -}; - -enum Permission { - NoAccess = "no-access", - ReadOnly = "read-only", - FullAccess = "full-acess", - Custom = "custom" -} - -const PERMISSIONS = [ - { action: "read", label: "View" }, - { action: "create", label: "Create" }, - { action: "edit", label: "Modify" }, - { action: "delete", label: "Remove" } -] as const; - -const MEMBERS_PERMISSIONS = [ - { action: "read", label: "View all members" }, - { action: "create", label: "Invite members" }, - { action: "edit", label: "Edit members" }, - { action: "delete", label: "Remove members" } -] as const; - -const getPermissionList = (option: Props["formName"]) => { - switch (option) { - case "member": - return MEMBERS_PERMISSIONS; - default: - return PERMISSIONS; - } -}; - -export const SingleProjectPermission = ({ - isNonEditable, - setValue, - control, - formName, - subtitle, - title, - icon -}: Props) => { - const rule = useWatch({ - control, - name: `permissions.${formName}` - }); - const [isCustom, setIsCustom] = useToggle(); - - const selectedPermissionCategory = useMemo(() => { - const actions = Object.keys(rule || {}) as Array; - const totalActions = PERMISSIONS.length; - const score = actions.map((key) => (rule?.[key] ? 1 : 0)).reduce((a, b) => a + b, 0 as number); - - if (isCustom) return Permission.Custom; - if (score === 0) return Permission.NoAccess; - if (score === totalActions) return Permission.FullAccess; - if (score === 1 && rule?.read) return Permission.ReadOnly; - - return Permission.Custom; - }, [rule, isCustom]); - - useEffect(() => { - if (selectedPermissionCategory === Permission.Custom) setIsCustom.on(); - else setIsCustom.off(); - }, [selectedPermissionCategory]); - - const handlePermissionChange = (val: Permission) => { - if(!val) return; - if (val === Permission.Custom) setIsCustom.on(); - else setIsCustom.off(); - - switch (val) { - case Permission.NoAccess: - setValue( - `permissions.${formName}`, - { read: false, edit: false, create: false, delete: false }, - { shouldDirty: true } - ); - break; - case Permission.FullAccess: - setValue( - `permissions.${formName}`, - { read: true, edit: true, create: true, delete: true }, - { shouldDirty: true } - ); - break; - case Permission.ReadOnly: - setValue( - `permissions.${formName}`, - { read: true, edit: false, create: false, delete: false }, - { shouldDirty: true } - ); - break; - default: - setValue( - `permissions.${formName}`, - { read: false, edit: false, create: false, delete: false }, - { shouldDirty: true } - ); - break; - } - }; - - return ( -
-
-
- -
-
-
{title}
-
{subtitle}
-
-
- -
-
- - {isCustom && - getPermissionList(formName).map(({ action, label }) => ( - ( - - {label} - - )} - /> - ))} - -
- ); -}; diff --git a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/WsProjectPermission.tsx b/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/WsProjectPermission.tsx deleted file mode 100644 index c13a6abde..000000000 --- a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/WsProjectPermission.tsx +++ /dev/null @@ -1,126 +0,0 @@ -import { useEffect, useMemo } from "react"; -import { Control, Controller, UseFormSetValue, useWatch } from "react-hook-form"; -import { faPuzzlePiece } from "@fortawesome/free-solid-svg-icons"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { motion } from "framer-motion"; -import { twMerge } from "tailwind-merge"; - -import { Checkbox, Select, SelectItem } from "@app/components/v2"; -import { useToggle } from "@app/hooks"; - -import { TFormSchema } from "./ProjectRoleModifySection.utils"; - -type Props = { - isNonEditable?: boolean; - setValue: UseFormSetValue; - control: Control; -}; - -enum Permission { - NoAccess = "no-access", - FullAccess = "full-acess", - Custom = "custom" -} - -const PERMISSIONS = [ - { action: "edit", label: "Update project details" }, - { action: "delete", label: "Delete projects" } -] as const; - -export const WsProjectPermission = ({ isNonEditable, setValue, control }: Props) => { - const rule = useWatch({ - control, - name: "permissions.workspace" - }); - const [isCustom, setIsCustom] = useToggle(); - - const selectedPermissionCategory = useMemo(() => { - const actions = Object.keys(rule || {}) as Array; - const totalActions = PERMISSIONS.length; - const score = actions.map((key) => (rule?.[key] ? 1 : 0)).reduce((a, b) => a + b, 0 as number); - - if (isCustom) return Permission.Custom; - if (score === 0) return Permission.NoAccess; - if (score === totalActions) return Permission.FullAccess; - - return Permission.Custom; - }, [rule, isCustom]); - - useEffect(() => { - if (selectedPermissionCategory === Permission.Custom) setIsCustom.on(); - else setIsCustom.off(); - }, [selectedPermissionCategory]); - - const handlePermissionChange = (val: Permission) => { - if(!val) return; - if (val === Permission.Custom) setIsCustom.on(); - else setIsCustom.off(); - - switch (val) { - case Permission.NoAccess: - setValue("permissions.workspace", { edit: false, delete: false }, { shouldDirty: true }); - break; - case Permission.FullAccess: - setValue("permissions.workspace", { edit: true, delete: true }, { shouldDirty: true }); - break; - default: - setValue("permissions.workspace", { edit: false, delete: false }, { shouldDirty: true }); - break; - } - }; - - return ( -
-
-
- -
-
-
Project
-
Project control actions
-
-
- -
-
- - {isCustom && - PERMISSIONS.map(({ action, label }) => ( - ( - - {label} - - )} - /> - ))} - -
- ); -}; diff --git a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/index.tsx b/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/index.tsx deleted file mode 100644 index b664a1d9b..000000000 --- a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/index.tsx +++ /dev/null @@ -1 +0,0 @@ -export { ProjectRoleModifySection } from "./ProjectRoleModifySection"; diff --git a/frontend/src/views/Project/RolePage/components/RoleDetailsSection.tsx b/frontend/src/views/Project/RolePage/components/RoleDetailsSection.tsx index 2b76a2fcd..95836cc37 100644 --- a/frontend/src/views/Project/RolePage/components/RoleDetailsSection.tsx +++ b/frontend/src/views/Project/RolePage/components/RoleDetailsSection.tsx @@ -26,7 +26,7 @@ export const RoleDetailsSection = ({ roleSlug, handlePopUpOpen }: Props) => { return data ? (
-

Details

+

Project Role Details

{isCustomRole && ( {(isAllowed) => { diff --git a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/ProjectRoleModifySection.utils.ts b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/ProjectRoleModifySection.utils.ts similarity index 100% rename from frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/ProjectRoleModifySection.utils.ts rename to frontend/src/views/Project/RolePage/components/RolePermissionsSection/ProjectRoleModifySection.utils.ts diff --git a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionRow.tsx b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionRow.tsx index a98bf0d93..725a2310e 100644 --- a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionRow.tsx +++ b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionRow.tsx @@ -6,7 +6,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { createNotification } from "@app/components/notifications"; import { Checkbox, Select, SelectItem, Td, Tr } from "@app/components/v2"; import { useToggle } from "@app/hooks"; -import { TFormSchema } from "@app/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/ProjectRoleModifySection.utils"; +import { TFormSchema } from "@app/views/Project/RolePage/components/RolePermissionsSection/ProjectRoleModifySection.utils"; const GENERAL_PERMISSIONS = [ { action: "read", label: "View" }, @@ -153,7 +153,7 @@ export const RolePermissionRow = ({ isEditable, title, formName, control, setVal return ( <> setIsRowExpanded.toggle()} > diff --git a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionSecretsRow.tsx b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionSecretsRow.tsx index 5833fee13..881dfa172 100644 --- a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionSecretsRow.tsx +++ b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionSecretsRow.tsx @@ -19,7 +19,7 @@ import { Tr } from "@app/components/v2"; import { useWorkspace } from "@app/context"; -import { TFormSchema } from "@app/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/ProjectRoleModifySection.utils"; +import { TFormSchema } from "@app/views/Project/RolePage/components/RolePermissionsSection/ProjectRoleModifySection.utils"; type Props = { title: string; diff --git a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx index 5010842ba..11c47a501 100644 --- a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx +++ b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx @@ -10,7 +10,7 @@ import { formSchema, rolePermission2Form, TFormSchema -} from "@app/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/ProjectRoleModifySection.utils"; +} from "@app/views/Project/RolePage/components/RolePermissionsSection/ProjectRoleModifySection.utils"; import { RolePermissionRow } from "./RolePermissionRow"; import { RowPermissionSecretsRow } from "./RolePermissionSecretsRow"; @@ -33,15 +33,15 @@ const SINGLE_PERMISSION_LIST = [ formName: "role" }, { - title: "User management", + title: "User Management", formName: "member" }, { - title: "Group management", + title: "Group Management", formName: "groups" }, { - title: "Machine identity management", + title: "Machine Identity Management", formName: "identity" }, { diff --git a/frontend/src/views/ShareSecretPublicPage/ShareSecretPublicPage.tsx b/frontend/src/views/ShareSecretPublicPage/ShareSecretPublicPage.tsx index 7bca1a3b2..92cdb9413 100644 --- a/frontend/src/views/ShareSecretPublicPage/ShareSecretPublicPage.tsx +++ b/frontend/src/views/ShareSecretPublicPage/ShareSecretPublicPage.tsx @@ -7,9 +7,9 @@ import { ShareSecretForm } from "./components"; export const ShareSecretPublicPage = () => { return ( -
+
-
+
@@ -43,36 +43,34 @@ export const ShareSecretPublicPage = () => {
-
-
-

- Open source{" "} - - secret management - {" "} - for developers +

+

+ Open source{" "} + + secret management + {" "} + for developers +

+
+

+ + Infisical + {" "} + is the all-in-one secret management platform to securely manage secrets, configs, and + certificates across your team and infrastructure.

-
-

- - Infisical - {" "} - is the all-in-one secret management platform to securely manage secrets, configs, - and certificates across your team and infrastructure. -

-
- -
-

Try Infisical

- -
- -
+
+ +
+

Try Infisical

+ +
+
diff --git a/frontend/src/views/ViewSecretPublicPage/ViewSecretPublicPage.tsx b/frontend/src/views/ViewSecretPublicPage/ViewSecretPublicPage.tsx index f6d09471e..ae4e733f1 100644 --- a/frontend/src/views/ViewSecretPublicPage/ViewSecretPublicPage.tsx +++ b/frontend/src/views/ViewSecretPublicPage/ViewSecretPublicPage.tsx @@ -22,9 +22,9 @@ export const ViewSecretPublicPage = () => { }); return ( -
+
-
+
@@ -57,47 +57,44 @@ export const ViewSecretPublicPage = () => {
-
-
-

- Open source{" "} - - secret management - {" "} - for developers +

+

+ Open source{" "} + + secret management + {" "} + for developers +

+
+

+ + Infisical + {" "} + is the all-in-one secret management platform to securely manage secrets, configs, and + certificates across your team and infrastructure.

-
-

- - Infisical - {" "} - is the all-in-one secret management platform to securely manage secrets, configs, - and certificates across your team and infrastructure. -

-
- -
-

Try Infisical

- -
- -
+
+ +
+

Try Infisical

+ +
+

- © 2024{" "} + Made with ❤️ by{" "} Infisical - . All rights reserved.
156 2nd st, 3rd Floor, San Francisco, California, 94105, United States. 🇺🇸