diff --git a/frontend/src/views/Project/MembersPage/components/IdentityTab/IdentityTab.tsx b/frontend/src/views/Project/MembersPage/components/IdentityTab/IdentityTab.tsx index 213b08246..2ab1ebeec 100644 --- a/frontend/src/views/Project/MembersPage/components/IdentityTab/IdentityTab.tsx +++ b/frontend/src/views/Project/MembersPage/components/IdentityTab/IdentityTab.tsx @@ -49,6 +49,7 @@ const MAX_ROLES_TO_BE_SHOWN_IN_TABLE = 2; const formatRoleName = (role: string, customRoleName?: string) => { if (role === ProjectMembershipRole.Custom) return customRoleName; if (role === ProjectMembershipRole.Member) return "Developer"; + if (role === ProjectMembershipRole.NoAccess) return "No access"; return role; }; export const IdentityTab = withProjectPermission( @@ -173,7 +174,9 @@ export const IdentityTab = withProjectPermission( return (
-
{formatRoleName(role, customRoleName)}
+
+ {formatRoleName(role, customRoleName)} +
{isTemporary && (
- +
+ + + +
{ @@ -324,7 +343,7 @@ export const IdentityRbacSection = ({ identityProjectMember, onOpenUpgradeModal )} isLoading={roleForm.formState.isSubmitting} > - Save Roles + Save Roles
diff --git a/frontend/src/views/Project/MembersPage/components/IdentityTab/components/IdentityRoleForm/SpecificPrivilegeSection.tsx b/frontend/src/views/Project/MembersPage/components/IdentityTab/components/IdentityRoleForm/SpecificPrivilegeSection.tsx index 9d543f466..b8c9e8caa 100644 --- a/frontend/src/views/Project/MembersPage/components/IdentityTab/components/IdentityRoleForm/SpecificPrivilegeSection.tsx +++ b/frontend/src/views/Project/MembersPage/components/IdentityTab/components/IdentityRoleForm/SpecificPrivilegeSection.tsx @@ -1,8 +1,15 @@ import { Controller, useForm } from "react-hook-form"; -import { faArrowRotateLeft, faCaretDown, faCheck, faClock, faPlus, faTrash } from "@fortawesome/free-solid-svg-icons"; +import { + faArrowRotateLeft, + faCaretDown, + faCheck, + faClock, + faPlus, + faTrash +} from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { zodResolver } from "@hookform/resolvers/zod"; -import { format } from "date-fns"; +import { format, formatDistance } from "date-fns"; import ms from "ms"; import { twMerge } from "tailwind-merge"; import { z } from "zod"; @@ -173,10 +180,15 @@ const SpecificPrivilegeSecretForm = ({ } }; - const getAccessLabel = () => { + const getAccessLabel = (exactTime = false) => { if (isExpired) return "Access expired"; if (!temporaryAccessField?.isTemporary) return "Permanent"; - return `Until ${format(new Date(temporaryAccessField.temporaryAccessEndTime || ""), "yyyy-MM-dd HH:mm:ss")}`; + if (exactTime) + return `Until ${format( + new Date(temporaryAccessField.temporaryAccessEndTime || ""), + "yyyy-MM-dd HH:mm:ss" + )}`; + return formatDistance(new Date(temporaryAccessField.temporaryAccessEndTime || ""), new Date()); }; return ( @@ -281,24 +293,23 @@ const SpecificPrivilegeSecretForm = ({
- - - +
+ + + +
privilegeForm.reset()} @@ -389,7 +400,10 @@ const SpecificPrivilegeSecretForm = ({ - + {privilegeForm.formState.isSubmitting ? ( - + ) : ( - + )} ) : ( - + handlePopUpOpen("deletePrivilege")} > @@ -480,7 +497,7 @@ export const SpecificPrivilegeSection = ({ identityId }: Props) => { Additional Privileges {isLoading && }
-

+

Select individual privileges to associate with the identity.

diff --git a/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberListTab.tsx b/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberListTab.tsx index 20a2079ac..b59286577 100644 --- a/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberListTab.tsx +++ b/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberListTab.tsx @@ -76,6 +76,7 @@ const MAX_ROLES_TO_BE_SHOWN_IN_TABLE = 2; const formatRoleName = (role: string, customRoleName?: string) => { if (role === ProjectMembershipRole.Custom) return customRoleName; if (role === ProjectMembershipRole.Member) return "Developer"; + if (role === ProjectMembershipRole.NoAccess) return "No access"; return role; }; @@ -279,7 +280,9 @@ export const MemberListTab = () => { return (
-
{formatRoleName(role, customRoleName)}
+
+ {formatRoleName(role, customRoleName)} +
{isTemporary && (
onChange(e)} - className="w-full bg-mineshaft-600 hover:bg-mineshaft-500 duration-200" + className="w-full bg-mineshaft-600 duration-200 hover:bg-mineshaft-500" > {projectRoles?.map(({ name, slug, id: projectRoleId }) => ( @@ -181,25 +183,42 @@ export const MemberRbacSection = ({ projectMember, onOpenUpgradeModal }: Props) )} /> - - + +
+ + + +
{ @@ -321,7 +340,7 @@ export const MemberRbacSection = ({ projectMember, onOpenUpgradeModal }: Props) )} isLoading={roleForm.formState.isSubmitting} > - Save Roles + Save Roles
diff --git a/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberRoleForm/SpecificPrivilegeSection.tsx b/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberRoleForm/SpecificPrivilegeSection.tsx index f50480f0f..2df959a94 100644 --- a/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberRoleForm/SpecificPrivilegeSection.tsx +++ b/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberRoleForm/SpecificPrivilegeSection.tsx @@ -1,8 +1,15 @@ import { Controller, useForm } from "react-hook-form"; -import { faArrowRotateLeft, faCaretDown, faCheck, faClock, faPlus, faTrash } from "@fortawesome/free-solid-svg-icons"; +import { + faArrowRotateLeft, + faCaretDown, + faCheck, + faClock, + faPlus, + faTrash +} from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { zodResolver } from "@hookform/resolvers/zod"; -import { format } from "date-fns"; +import { format, formatDistance } from "date-fns"; import ms from "ms"; import { twMerge } from "tailwind-merge"; import { z } from "zod"; @@ -161,10 +168,15 @@ const SpecificPrivilegeSecretForm = ({ privilege }: { privilege: TProjectUserPri } }; - const getAccessLabel = () => { + const getAccessLabel = (exactTime = false) => { if (isExpired) return "Access expired"; if (!temporaryAccessField?.isTemporary) return "Permanent"; - return `Until ${format(new Date(temporaryAccessField.temporaryAccessEndTime || ""), "yyyy-MM-dd HH:mm:ss")}`; + if (exactTime) + return `Until ${format( + new Date(temporaryAccessField.temporaryAccessEndTime || ""), + "yyyy-MM-dd HH:mm:ss" + )}`; + return formatDistance(new Date(temporaryAccessField.temporaryAccessEndTime || ""), new Date()); }; return ( @@ -269,24 +281,23 @@ const SpecificPrivilegeSecretForm = ({ privilege }: { privilege: TProjectUserPri
- - - +
+ + + +
privilegeForm.reset()} @@ -377,7 +388,10 @@ const SpecificPrivilegeSecretForm = ({ privilege }: { privilege: TProjectUserPri - + {privilegeForm.formState.isSubmitting ? ( - + ) : ( - + )} ) : ( - + handlePopUpOpen("deletePrivilege")} > @@ -463,7 +480,7 @@ export const SpecificPrivilegeSection = ({ membershipId }: Props) => { Additional Privileges {isLoading && }
-

+

Select individual privileges to associate with the user.