renamed from temp access to timed access

This commit is contained in:
Maidul Islam
2024-03-12 11:46:42 -04:00
committed by Akhil Mohan
parent 4152b3a524
commit fc57884035
4 changed files with 15 additions and 12 deletions

View File

@ -18,9 +18,12 @@ export const registerOrgRoleRouter = async (server: FastifyZodProvider) => {
.string()
.min(1)
.trim()
.refine((val) => Object.keys(OrgMembershipRole).includes(val), "Invalid keyword slugs")
.refine(
(val) => Object.keys(OrgMembershipRole).includes(val),
"Please choose a different slug, the slug you have entered is reserved"
)
.refine((v) => slugify(v) === v, {
message: "Slug must be a valid slug"
message: "Slug must be a valid"
}),
name: z.string().trim(),
description: z.string().trim().optional(),
@ -59,10 +62,10 @@ export const registerOrgRoleRouter = async (server: FastifyZodProvider) => {
.optional()
.refine(
(val) => typeof val === "undefined" || Object.keys(OrgMembershipRole).includes(val),
"Invalid keyword slugs"
"Please choose a different slug, the slug you have entered is reserved."
)
.refine((val) => typeof val === "undefined" || slugify(val) === val, {
message: "Slug must be a valid slug"
message: "Slug must be a valid"
}),
name: z.string().trim().optional(),
description: z.string().trim().optional(),

View File

@ -148,13 +148,13 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
role: z.string(),
isTemporary: z.literal(true),
temporaryMode: z.nativeEnum(ProjectUserMembershipTemporaryMode),
temporaryRange: z.string().refine((val) => ms(val) > 0, "Temporary range must be positive"),
temporaryRange: z.string().refine((val) => ms(val) > 0, "Temporary range must be a positive number"),
temporaryAccessStartTime: z.string().datetime()
})
])
)
.min(1)
.refine((data) => data.some(({ isTemporary }) => !isTemporary), "Atleast one permanent role required")
.refine((data) => data.some(({ isTemporary }) => !isTemporary), "At least long lived role is required")
}),
response: {
200: z.object({

View File

@ -70,7 +70,7 @@ export const registerIdentityProjectRouter = async (server: FastifyZodProvider)
role: z.string(),
isTemporary: z.literal(true),
temporaryMode: z.nativeEnum(ProjectUserMembershipTemporaryMode),
temporaryRange: z.string().refine((val) => ms(val) > 0, "Temporary range must be positive"),
temporaryRange: z.string().refine((val) => ms(val) > 0, "Temporary range must be a positive number"),
temporaryAccessStartTime: z.string().datetime()
})
])

View File

@ -73,7 +73,7 @@ const TemporaryRoleForm = ({
>
<PopoverTrigger>
<IconButton ariaLabel="role-temp" variant="plain" size="md">
<Tooltip content={isExpired ? "Access Expired" : "Grant Temporary Access"}>
<Tooltip content={isExpired ? "Timed access expired" : "Grant timed access"}>
<FontAwesomeIcon
icon={faClock}
className={twMerge(
@ -93,7 +93,7 @@ const TemporaryRoleForm = ({
>
<div className="flex flex-col space-y-4">
<div className="border-b border-b-gray-700 pb-2 text-sm text-mineshaft-300">
Set Role Temporarily
Configure timed access
</div>
{isExpired && <Tag colorSchema="red">Expired</Tag>}
<Controller
@ -292,12 +292,12 @@ export const MemberRoles = ({
.map(({ role, customRoleName, id, isTemporary, temporaryAccessEndTime }) => {
const isExpired = new Date() > new Date(temporaryAccessEndTime || ("" as string));
return (
<Tag key={id} className="capitalize">
<Tag key={id}>
<div className="flex items-center space-x-2">
<div>{formatRoleName(role, customRoleName)}</div>
{isTemporary && (
<div>
<Tooltip content={isExpired ? "Expired Temporary Access" : "Temporary Access"}>
<Tooltip content={isExpired ? "Timed role expired" : "Timed role access"}>
<FontAwesomeIcon
icon={faClock}
className={twMerge(isExpired && "text-red-600")}
@ -326,7 +326,7 @@ export const MemberRoles = ({
{isTemporary && (
<div>
<Tooltip
content={isExpired ? "Expired Temporary Access" : "Temporary Access"}
content={isExpired ? "Access expired" : "Temporary access"}
>
<FontAwesomeIcon
icon={faClock}