mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 10:27:26 +00:00
Removed cron functionality completely
This commit is contained in:
@@ -3,8 +3,6 @@ import { useForm } from "react-hook-form";
|
|||||||
import { faClock } from "@fortawesome/free-solid-svg-icons";
|
import { faClock } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { isValidCron } from "cron-validator";
|
|
||||||
import cronstrue from "cronstrue";
|
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { Button, FormControl, Input, Modal, ModalContent, TextArea } from "@app/components/v2";
|
import { Button, FormControl, Input, Modal, ModalContent, TextArea } from "@app/components/v2";
|
||||||
@@ -14,8 +12,7 @@ const ReminderFormSchema = z.object({
|
|||||||
days: z
|
days: z
|
||||||
.number()
|
.number()
|
||||||
.min(1, { message: "Must be at least 1 day" })
|
.min(1, { message: "Must be at least 1 day" })
|
||||||
.max(365, { message: "Must be less than 365 days" }),
|
.max(365, { message: "Must be less than 365 days" })
|
||||||
cron: z.string().refine(isValidCron, { message: "Invalid cron expression" })
|
|
||||||
});
|
});
|
||||||
export type TReminderFormSchema = z.infer<typeof ReminderFormSchema>;
|
export type TReminderFormSchema = z.infer<typeof ReminderFormSchema>;
|
||||||
|
|
||||||
@@ -37,20 +34,11 @@ export const CreateReminderForm = ({ isOpen, onOpenChange }: ReminderFormProps)
|
|||||||
});
|
});
|
||||||
|
|
||||||
const daysWatch = watch("days");
|
const daysWatch = watch("days");
|
||||||
const cronWatch = watch("cron");
|
|
||||||
|
|
||||||
const handleFormSubmit = async (data: TReminderFormSchema) => {
|
const handleFormSubmit = async (data: TReminderFormSchema) => {
|
||||||
onOpenChange(false, data);
|
onOpenChange(false, data);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!daysWatch) {
|
|
||||||
setValue("cron", "");
|
|
||||||
} else {
|
|
||||||
setValue("cron", `0 0 */${daysWatch} * *`);
|
|
||||||
}
|
|
||||||
}, [daysWatch]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
reset();
|
reset();
|
||||||
@@ -65,8 +53,8 @@ export const CreateReminderForm = ({ isOpen, onOpenChange }: ReminderFormProps)
|
|||||||
// ? Or should we be call it something more generic?
|
// ? Or should we be call it something more generic?
|
||||||
subTitle={
|
subTitle={
|
||||||
<div>
|
<div>
|
||||||
Set up a reminder for when this secret should be rotated. Everyone in the workspace will
|
Set up a reminder for when this secret should be rotated. Everyone with access to this
|
||||||
be notified when the reminder is triggered.
|
project will be notified when the reminder is triggered.
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -85,8 +73,10 @@ export const CreateReminderForm = ({ isOpen, onOpenChange }: ReminderFormProps)
|
|||||||
placeholder="every 5 days"
|
placeholder="every 5 days"
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
{!!daysWatch && cronWatch && isValidCron(cronWatch) && (
|
{!!daysWatch && (
|
||||||
<div className="mt-2 ml-1 text-xs opacity-60">{cronstrue.toString(cronWatch)}</div>
|
<div className="mt-2 ml-1 text-xs opacity-60">
|
||||||
|
Every {daysWatch > 1 ? `${daysWatch} days` : "day"}
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ export const SecretItem = memo(
|
|||||||
|
|
||||||
const overrideAction = watch("overrideAction");
|
const overrideAction = watch("overrideAction");
|
||||||
const hasComment = Boolean(watch("comment"));
|
const hasComment = Boolean(watch("comment"));
|
||||||
const hasReminder = Boolean(watch("reminderCron"));
|
const hasReminder = Boolean(watch("reminderRepeatDays"));
|
||||||
|
|
||||||
const selectedTags = watch("tags", []);
|
const selectedTags = watch("tags", []);
|
||||||
const selectedTagsGroupById = selectedTags.reduce<Record<string, boolean>>(
|
const selectedTagsGroupById = selectedTags.reduce<Record<string, boolean>>(
|
||||||
@@ -152,7 +152,9 @@ export const SecretItem = memo(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
setValue("valueOverride", secret?.valueOverride, { shouldDirty: !isUnsavedOverride });
|
setValue("valueOverride", secret?.valueOverride, { shouldDirty: !isUnsavedOverride });
|
||||||
setValue("reminderCron", secret?.reminderCron, { shouldDirty: !isUnsavedOverride });
|
setValue("reminderRepeatDays", secret?.reminderRepeatDays, {
|
||||||
|
shouldDirty: !isUnsavedOverride
|
||||||
|
});
|
||||||
setValue("reminderNote", secret?.reminderNote, { shouldDirty: !isUnsavedOverride });
|
setValue("reminderNote", secret?.reminderNote, { shouldDirty: !isUnsavedOverride });
|
||||||
} else {
|
} else {
|
||||||
reset();
|
reset();
|
||||||
@@ -194,7 +196,7 @@ export const SecretItem = memo(
|
|||||||
setCreateReminderFormOpen.toggle();
|
setCreateReminderFormOpen.toggle();
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
setValue("reminderCron", data.cron, { shouldDirty: true });
|
setValue("reminderRepeatDays", data.days, { shouldDirty: true });
|
||||||
setValue("reminderNote", data.note, { shouldDirty: true });
|
setValue("reminderNote", data.note, { shouldDirty: true });
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
@@ -390,7 +392,7 @@ export const SecretItem = memo(
|
|||||||
if (!hasReminder) {
|
if (!hasReminder) {
|
||||||
setCreateReminderFormOpen.on();
|
setCreateReminderFormOpen.on();
|
||||||
} else {
|
} else {
|
||||||
setValue("reminderCron", null, { shouldDirty: true });
|
setValue("reminderRepeatDays", null, { shouldDirty: true });
|
||||||
setValue("reminderNote", null, { shouldDirty: true });
|
setValue("reminderNote", null, { shouldDirty: true });
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ export const SecretListView = ({
|
|||||||
{
|
{
|
||||||
value,
|
value,
|
||||||
comment,
|
comment,
|
||||||
reminderCron,
|
reminderRepeatDays,
|
||||||
reminderNote,
|
reminderNote,
|
||||||
tags,
|
tags,
|
||||||
skipMultilineEncoding,
|
skipMultilineEncoding,
|
||||||
@@ -131,7 +131,7 @@ export const SecretListView = ({
|
|||||||
}: Partial<{
|
}: Partial<{
|
||||||
value: string;
|
value: string;
|
||||||
comment: string;
|
comment: string;
|
||||||
reminderCron: string | null;
|
reminderRepeatDays: number | null;
|
||||||
reminderNote: string | null;
|
reminderNote: string | null;
|
||||||
tags: string[];
|
tags: string[];
|
||||||
skipMultilineEncoding: boolean;
|
skipMultilineEncoding: boolean;
|
||||||
@@ -163,7 +163,7 @@ export const SecretListView = ({
|
|||||||
latestFileKey: decryptFileKey,
|
latestFileKey: decryptFileKey,
|
||||||
tags,
|
tags,
|
||||||
secretComment: comment,
|
secretComment: comment,
|
||||||
secretReminderCron: reminderCron,
|
secretReminderRepeatDays: reminderRepeatDays,
|
||||||
secretReminderNote: reminderNote,
|
secretReminderNote: reminderNote,
|
||||||
skipMultilineEncoding,
|
skipMultilineEncoding,
|
||||||
newSecretName: newKey
|
newSecretName: newKey
|
||||||
@@ -194,16 +194,33 @@ export const SecretListView = ({
|
|||||||
cb?: () => void
|
cb?: () => void
|
||||||
) => {
|
) => {
|
||||||
const { key: oldKey } = orgSecret;
|
const { key: oldKey } = orgSecret;
|
||||||
const { key, value, overrideAction, idOverride, valueOverride, tags, comment, reminderCron, reminderNote } = modSecret;
|
const {
|
||||||
|
key,
|
||||||
|
value,
|
||||||
|
overrideAction,
|
||||||
|
idOverride,
|
||||||
|
valueOverride,
|
||||||
|
tags,
|
||||||
|
comment,
|
||||||
|
reminderRepeatDays,
|
||||||
|
reminderNote
|
||||||
|
} = modSecret;
|
||||||
const hasKeyChanged = oldKey !== key;
|
const hasKeyChanged = oldKey !== key;
|
||||||
|
|
||||||
const tagIds = tags.map(({ _id }) => _id);
|
const tagIds = tags.map(({ _id }) => _id);
|
||||||
const oldTagIds = orgSecret.tags.map(({ _id }) => _id);
|
const oldTagIds = orgSecret.tags.map(({ _id }) => _id);
|
||||||
const isSameTags = JSON.stringify(tagIds) === JSON.stringify(oldTagIds);
|
const isSameTags = JSON.stringify(tagIds) === JSON.stringify(oldTagIds);
|
||||||
const isSharedSecUnchanged =
|
const isSharedSecUnchanged =
|
||||||
(["key", "value", "comment", "skipMultilineEncoding", "reminderCron", "reminderNote"] as const).every(
|
(
|
||||||
(el) => orgSecret[el] === modSecret[el]
|
[
|
||||||
) && isSameTags;
|
"key",
|
||||||
|
"value",
|
||||||
|
"comment",
|
||||||
|
"skipMultilineEncoding",
|
||||||
|
"reminderRepeatDays",
|
||||||
|
"reminderNote"
|
||||||
|
] as const
|
||||||
|
).every((el) => orgSecret[el] === modSecret[el]) && isSameTags;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// personal secret change
|
// personal secret change
|
||||||
@@ -228,7 +245,7 @@ export const SecretListView = ({
|
|||||||
value,
|
value,
|
||||||
tags: tagIds,
|
tags: tagIds,
|
||||||
comment,
|
comment,
|
||||||
reminderCron,
|
reminderRepeatDays,
|
||||||
reminderNote,
|
reminderNote,
|
||||||
secretId: orgSecret._id,
|
secretId: orgSecret._id,
|
||||||
newKey: hasKeyChanged ? key : undefined,
|
newKey: hasKeyChanged ? key : undefined,
|
||||||
@@ -313,7 +330,7 @@ export const SecretListView = ({
|
|||||||
<div className="flex flex-col" key={`${namespace}-${groupedSecrets.length}`}>
|
<div className="flex flex-col" key={`${namespace}-${groupedSecrets.length}`}>
|
||||||
<div
|
<div
|
||||||
className={twMerge(
|
className={twMerge(
|
||||||
"bg-bunker-600 capitalize text-md h-0 transition-all",
|
"text-md h-0 bg-bunker-600 capitalize transition-all",
|
||||||
Boolean(namespace) && Boolean(filteredSecrets.length) && "h-11 py-3 pl-4 "
|
Boolean(namespace) && Boolean(filteredSecrets.length) && "h-11 py-3 pl-4 "
|
||||||
)}
|
)}
|
||||||
key={namespace}
|
key={namespace}
|
||||||
|
|||||||
@@ -21,7 +21,12 @@ export const formSchema = z.object({
|
|||||||
comment: z.string().trim().optional(),
|
comment: z.string().trim().optional(),
|
||||||
skipMultilineEncoding: z.boolean().optional(),
|
skipMultilineEncoding: z.boolean().optional(),
|
||||||
|
|
||||||
reminderCron: z.string().trim().nullable().optional(),
|
reminderRepeatDays: z
|
||||||
|
.number()
|
||||||
|
.min(1, { message: "Days must be between 1 and 365" })
|
||||||
|
.max(365, { message: "Days must be between 1 and 365" })
|
||||||
|
.nullable()
|
||||||
|
.optional(),
|
||||||
reminderNote: z.string().trim().nullable().optional(),
|
reminderNote: z.string().trim().nullable().optional(),
|
||||||
|
|
||||||
tags: z
|
tags: z
|
||||||
|
|||||||
Reference in New Issue
Block a user