mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-09 22:28:25 +00:00
Added secret reminders to sidebar (and formatting)
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
|||||||
faCheckCircle,
|
faCheckCircle,
|
||||||
faCircle,
|
faCircle,
|
||||||
faCircleDot,
|
faCircleDot,
|
||||||
|
faClock,
|
||||||
faPlus,
|
faPlus,
|
||||||
faTag
|
faTag
|
||||||
} from "@fortawesome/free-solid-svg-icons";
|
} from "@fortawesome/free-solid-svg-icons";
|
||||||
@@ -33,9 +34,11 @@ import {
|
|||||||
Tooltip
|
Tooltip
|
||||||
} from "@app/components/v2";
|
} from "@app/components/v2";
|
||||||
import { ProjectPermissionActions, ProjectPermissionSub, useProjectPermission } from "@app/context";
|
import { ProjectPermissionActions, ProjectPermissionSub, useProjectPermission } from "@app/context";
|
||||||
|
import { useToggle } from "@app/hooks";
|
||||||
import { useGetSecretVersion } from "@app/hooks/api";
|
import { useGetSecretVersion } from "@app/hooks/api";
|
||||||
import { DecryptedSecret, UserWsKeyPair, WsTag } from "@app/hooks/api/types";
|
import { DecryptedSecret, UserWsKeyPair, WsTag } from "@app/hooks/api/types";
|
||||||
|
|
||||||
|
import { CreateReminderForm } from "./CreateReminderForm";
|
||||||
import { formSchema, SecretActionType, TFormSchema } from "./SecretListView.utils";
|
import { formSchema, SecretActionType, TFormSchema } from "./SecretListView.utils";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -147,13 +150,34 @@ export const SecretDetailSidebar = ({
|
|||||||
await onSaveSecret(secret, { ...secret, ...data }, () => reset());
|
await onSaveSecret(secret, { ...secret, ...data }, () => reset());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const [createReminderFormOpen, setCreateReminderFormOpen] = useToggle(false);
|
||||||
|
|
||||||
|
const secretReminderRepeatDays = watch("reminderRepeatDays");
|
||||||
|
const secretReminderNote = watch("reminderNote");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
|
<CreateReminderForm
|
||||||
|
repeatDays={secretReminderRepeatDays}
|
||||||
|
note={secretReminderNote}
|
||||||
|
isOpen={createReminderFormOpen}
|
||||||
|
onOpenChange={(_, data) => {
|
||||||
|
setCreateReminderFormOpen.toggle();
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
setValue("reminderRepeatDays", data.days, { shouldDirty: true });
|
||||||
|
setValue("reminderNote", data.note, { shouldDirty: true });
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<Drawer
|
<Drawer
|
||||||
onOpenChange={(state) => {
|
onOpenChange={(state) => {
|
||||||
if (isOpen && isDirty) {
|
if (isOpen && isDirty) {
|
||||||
if (
|
if (
|
||||||
// eslint-disable-next-line no-alert
|
// eslint-disable-next-line no-alert
|
||||||
window.confirm("You have edited the secret. Are you sure you want to reset the change?")
|
window.confirm(
|
||||||
|
"You have edited the secret. Are you sure you want to reset the change?"
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
onToggle(false);
|
onToggle(false);
|
||||||
reset();
|
reset();
|
||||||
@@ -313,6 +337,39 @@ export const SecretDetailSidebar = ({
|
|||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</div>
|
</div>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
<FormControl label="Reminder">
|
||||||
|
{secretReminderRepeatDays && secretReminderRepeatDays > 0 ? (
|
||||||
|
<div className="mt-2 ml-1 flex items-center justify-between">
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<FontAwesomeIcon className="text-primary-500" icon={faClock} />
|
||||||
|
<span className="text-sm text-bunker-300">
|
||||||
|
Reminder every {secretReminderRepeatDays}{" "}
|
||||||
|
{secretReminderRepeatDays > 1 ? "days" : "day"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Button
|
||||||
|
className="px-2 py-1"
|
||||||
|
variant="outline_bg"
|
||||||
|
onClick={() => setCreateReminderFormOpen.on()}
|
||||||
|
>
|
||||||
|
Update
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="mt-2 ml-1 flex items-center space-x-2">
|
||||||
|
<Button
|
||||||
|
className="px-2 py-1"
|
||||||
|
variant="outline_bg"
|
||||||
|
leftIcon={<FontAwesomeIcon icon={faClock} />}
|
||||||
|
onClick={() => setCreateReminderFormOpen.on()}
|
||||||
|
>
|
||||||
|
Create Reminder
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</FormControl>
|
||||||
<FormControl label="Comments & Notes">
|
<FormControl label="Comments & Notes">
|
||||||
<TextArea
|
<TextArea
|
||||||
className="border border-mineshaft-600 text-sm"
|
className="border border-mineshaft-600 text-sm"
|
||||||
@@ -404,5 +461,6 @@ export const SecretDetailSidebar = ({
|
|||||||
</form>
|
</form>
|
||||||
</DrawerContent>
|
</DrawerContent>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user