mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 06:28:11 +00:00
feat(user-auth): add pr suggestions
This commit is contained in:
+73
-60
@@ -3,8 +3,9 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
|
import { OrgPermissionCan } from "@app/components/permissions";
|
||||||
import { Button, FormControl, Input, Select, SelectItem } from "@app/components/v2";
|
import { Button, FormControl, Input, Select, SelectItem } from "@app/components/v2";
|
||||||
import { useOrganization } from "@app/context";
|
import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
|
||||||
import { useUpdateOrg } from "@app/hooks/api";
|
import { useUpdateOrg } from "@app/hooks/api";
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
@@ -93,66 +94,78 @@ export const OrgUserAccessTokenLimitSection = () => {
|
|||||||
This defines the maximum time a user token will be valid. After this time, the user will
|
This defines the maximum time a user token will be valid. After this time, the user will
|
||||||
need to re-authenticate.
|
need to re-authenticate.
|
||||||
</p>
|
</p>
|
||||||
<form onSubmit={handleSubmit(handleUserTokenExpirationSubmit)} autoComplete="off">
|
<OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Settings}>
|
||||||
<div className="flex max-w-md gap-4">
|
{(isAllowed) => (
|
||||||
<div className="flex-1">
|
<form onSubmit={handleSubmit(handleUserTokenExpirationSubmit)} autoComplete="off">
|
||||||
<Controller
|
<div className="flex max-w-md gap-4">
|
||||||
control={control}
|
<div className="flex-1">
|
||||||
name="expirationValue"
|
<Controller
|
||||||
render={({ field, fieldState: { error } }) => (
|
control={control}
|
||||||
<FormControl
|
name="expirationValue"
|
||||||
isError={Boolean(error)}
|
render={({ field, fieldState: { error } }) => (
|
||||||
errorText={error?.message}
|
<FormControl
|
||||||
label="Expiration value"
|
isError={Boolean(error)}
|
||||||
>
|
errorText={error?.message}
|
||||||
<Input
|
label="Expiration value"
|
||||||
{...field}
|
>
|
||||||
type="number"
|
<Input
|
||||||
min={1}
|
{...field}
|
||||||
step={1}
|
type="number"
|
||||||
value={field.value}
|
min={1}
|
||||||
onChange={(e) => field.onChange(parseInt(e.target.value, 10) || 1)}
|
step={1}
|
||||||
/>
|
value={field.value}
|
||||||
</FormControl>
|
onChange={(e) => field.onChange(parseInt(e.target.value, 10))}
|
||||||
)}
|
disabled={!isAllowed}
|
||||||
/>
|
/>
|
||||||
</div>
|
</FormControl>
|
||||||
<div className="flex-1">
|
)}
|
||||||
<Controller
|
/>
|
||||||
control={control}
|
</div>
|
||||||
name="expirationUnit"
|
<div className="flex-1">
|
||||||
render={({ field, fieldState: { error } }) => (
|
<Controller
|
||||||
<FormControl isError={Boolean(error)} errorText={error?.message} label="Time unit">
|
control={control}
|
||||||
<Select
|
name="expirationUnit"
|
||||||
value={field.value}
|
render={({ field, fieldState: { error } }) => (
|
||||||
onValueChange={field.onChange}
|
<FormControl
|
||||||
placeholder="Select time unit"
|
isError={Boolean(error)}
|
||||||
>
|
errorText={error?.message}
|
||||||
{timeUnits.map(({ value, label }) => (
|
label="Time unit"
|
||||||
<SelectItem
|
>
|
||||||
key={value}
|
<Select
|
||||||
value={value}
|
value={field.value}
|
||||||
className="relative py-2 pl-6 pr-8 text-sm hover:bg-mineshaft-700"
|
className="pr-2"
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
placeholder="Select time unit"
|
||||||
|
isDisabled={!isAllowed}
|
||||||
>
|
>
|
||||||
<div className="ml-3 font-medium">{label}</div>
|
{timeUnits.map(({ value, label }) => (
|
||||||
</SelectItem>
|
<SelectItem
|
||||||
))}
|
key={value}
|
||||||
</Select>
|
value={value}
|
||||||
</FormControl>
|
className="relative py-2 pl-6 pr-8 text-sm hover:bg-mineshaft-700"
|
||||||
)}
|
>
|
||||||
/>
|
<div className="ml-3 font-medium">{label}</div>
|
||||||
</div>
|
</SelectItem>
|
||||||
</div>
|
))}
|
||||||
<Button
|
</Select>
|
||||||
colorSchema="secondary"
|
</FormControl>
|
||||||
type="submit"
|
)}
|
||||||
isLoading={isSubmitting}
|
/>
|
||||||
disabled={!isDirty}
|
</div>
|
||||||
className="mt-4"
|
</div>
|
||||||
>
|
<Button
|
||||||
Save
|
colorSchema="secondary"
|
||||||
</Button>
|
type="submit"
|
||||||
</form>
|
isLoading={isSubmitting}
|
||||||
|
disabled={!isDirty}
|
||||||
|
className="mt-4"
|
||||||
|
isDisabled={!isAllowed}
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</Button>
|
||||||
|
</form>
|
||||||
|
)}
|
||||||
|
</OrgPermissionCan>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user