-
Notifications
You must be signed in to change notification settings - Fork 112
Feat/pci object lock #20560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Feat/pci object lock #20560
Conversation
…g object lock settings (wip)
… duration settings
...bject-storage/src/pages/object-storage/create/_components/steps/ObjectLockStep.component.tsx
Outdated
Show resolved
Hide resolved
...pps/pci-object-storage/src/pages/object-storage/create/_components/OrderFunnel.component.tsx
Outdated
Show resolved
Hide resolved
...t-storage/storage/s3Id/dashboard/_components/object-lock-options/ObjectLockOptions.sheet.tsx
Outdated
Show resolved
Hide resolved
| <> | ||
| <div className="space-y-2"> | ||
| <div className="flex flex-row justify-between"> | ||
| <Badge | ||
| variant={ | ||
| s3.objectLock.status === storages.ObjectLockStatusEnum.enabled | ||
| ? 'success' | ||
| : 'warning' | ||
| } | ||
| > | ||
| {t(`${prefix}Label`)} | ||
| </Badge> | ||
| {isObjectLockEnabled && ( | ||
| <Button | ||
| data-testid="label-object-lock-options-button" | ||
| mode="outline" | ||
| size="sm" | ||
| className="h-6" | ||
| onClick={() => navigate('./object-lock-options')} | ||
| > | ||
| <Settings className="size-4" /> | ||
| <span className="font-semibold"> | ||
| {t('objectLockOptionsButton')} | ||
| </span> | ||
| </Button> | ||
| )} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need a fragment here as you already have a single element (your div)
| <> | |
| <div className="space-y-2"> | |
| <div className="flex flex-row justify-between"> | |
| <Badge | |
| variant={ | |
| s3.objectLock.status === storages.ObjectLockStatusEnum.enabled | |
| ? 'success' | |
| : 'warning' | |
| } | |
| > | |
| {t(`${prefix}Label`)} | |
| </Badge> | |
| {isObjectLockEnabled && ( | |
| <Button | |
| data-testid="label-object-lock-options-button" | |
| mode="outline" | |
| size="sm" | |
| className="h-6" | |
| onClick={() => navigate('./object-lock-options')} | |
| > | |
| <Settings className="size-4" /> | |
| <span className="font-semibold"> | |
| {t('objectLockOptionsButton')} | |
| </span> | |
| </Button> | |
| )} | |
| </div> | |
| </div> | |
| </div> | |
| </> | |
| <div className="space-y-2"> | |
| <div className="flex flex-row justify-between"> | |
| <Badge | |
| variant={ | |
| s3.objectLock.status === storages.ObjectLockStatusEnum.enabled | |
| ? 'success' | |
| : 'warning' | |
| } | |
| > | |
| {t(`${prefix}Label`)} | |
| </Badge> | |
| {isObjectLockEnabled && ( | |
| <Button | |
| data-testid="label-object-lock-options-button" | |
| mode="outline" | |
| size="sm" | |
| className="h-6" | |
| onClick={() => navigate('./object-lock-options')} | |
| > | |
| <Settings className="size-4" /> | |
| <span className="font-semibold"> | |
| {t('objectLockOptionsButton')} | |
| </span> | |
| </Button> | |
| )} | |
| </div> | |
| </div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use zod and react-hook-forms to handle every form in the app. Could you use it here also ? It would ease validation and complex rules, as they can be handled by the schema:
const objectLockSchema = z.object({
status: z.nativeEnum(ObjectLockStatusEnum),
retentionEnabled: z.boolean(),
rule: z
.object({
mode: z.nativeEnum(ObjectLockModeEnum),
durationValue: z
.number()
.min(1, t("errorDurationMin")),
durationUnit: z.enum(["D", "Y"]),
})
.optional(),
})
.superRefine((data, ctx) => {
if (data.retentionEnabled && !data.rule) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: t("errorRuleRequired"),
path: ["rule"],
});
return;
}
if (!data.retentionEnabled && data.rule) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: t("errorRuleMustBeEmpty"),
path: ["rule"],
});
return;
}
if (data.rule) {
const { durationValue, durationUnit } = data.rule;
const max = durationUnit === "D" ? durationLimits.D : durationLimits.Y;
if (durationValue > max) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: t("errorDurationMax"),
path: ["rule", "durationValue"],
});
}
}
})
const form = useForm({
resolver: zodResolver(objectLockSchema),
defaultValues: {
status: s3Query.data?.objectLock?.status,
rule: s3Query.data?.objectLock?.rule ?? undefined,
},
});
const onSubmit = form.handleSubmit((values) => {
...
}
… and adjust SelectTrigger styling
…sioning when Object Lock is enabled
…mode and warning messages
…ck and validation logic
…dling for Object Lock
📝 Description
This PR adds a new Object Lock feature options to storage buckets, allowing users to configure retention policies with granular control over mode and duration.
✨ Features
Object Lock
P1Y,P30D)