Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Lint

Daniel Hougaard3c2a66f7228e
diff --git a/frontend/src/views/SecretMainPage/components/SecretListView/SecretItem.tsx b/frontend/src/views/SecretMainPage/components/SecretListView/SecretItem.tsx
index 7900fad826..36f95055e8 100644
--- a/frontend/src/views/SecretMainPage/components/SecretListView/SecretItem.tsx
+++ b/frontend/src/views/SecretMainPage/components/SecretListView/SecretItem.tsx
@@ -52,7 +52,6 @@ import { WsTag } from "@app/hooks/api/types";
import { formSchema, SecretActionType, TFormSchema } from "./SecretListView.utils";
import { CreateReminderForm } from "./CreateReminderForm";
-
type Props = {
secret: DecryptedSecret;
onSaveSecret: (
@@ -71,8 +70,6 @@ type Props = {
secretPath: string;
};
-
-
export const SecretItem = memo(
({
secret,
@@ -189,346 +186,344 @@ export const SecretItem = memo(
return (
<>
+ <CreateReminderForm
+ isOpen={createReminderFormOpen}
+ onClose={(data) => {
+ if (data) {
+ setValue("reminderCron", data.cron, { shouldDirty: true });
+ setValue("reminderNote", data.note, { shouldDirty: true });
+ }
+ setCreateReminderFormOpen.off();
+ }}
+ />
- <CreateReminderForm
- isOpen={createReminderFormOpen}
- onClose={data => {
- if(data) {
- setValue("reminderCron", data.cron, {shouldDirty: true});
- setValue("reminderNote", data.note, {shouldDirty: true});
- }
- setCreateReminderFormOpen.off();
- }}
- />
-
- <form onSubmit={handleSubmit(handleFormSubmit)}>
- <div
- className={twMerge(
- "border-b border-mineshaft-600 bg-mineshaft-800 shadow-none hover:bg-mineshaft-700",
- isDirty && "border-primary-400/50"
- )}
- >
- <div className="group flex">
- <div
- className={twMerge(
- "flex h-11 w-11 items-center justify-center px-4 py-3",
- isDirty && "text-primary"
- )}
- >
- <Checkbox
- id={`checkbox-${secret._id}`}
- isChecked={isSelected}
- onCheckedChange={() => onToggleSecretSelect(secret._id)}
- className={twMerge("ml-3 hidden group-hover:flex", isSelected && "flex")}
- />
- <FontAwesomeIcon
- icon={faKey}
- className={twMerge("ml-3 block group-hover:hidden", isSelected && "hidden")}
- />
- </div>
- <div className="flex h-11 w-80 flex-shrink-0 items-center px-4 py-2">
- <Controller
- name="key"
- control={control}
- render={({ field }) => (
- <Input
- autoComplete="off"
- isReadOnly={isReadOnly}
- autoCapitalization={currentWorkspace?.autoCapitalization}
- variant="plain"
- isDisabled={isOverriden}
- {...field}
- className="w-full px-0 focus:text-bunker-100 focus:ring-transparent"
- />
+ <form onSubmit={handleSubmit(handleFormSubmit)}>
+ <div
+ className={twMerge(
+ "border-b border-mineshaft-600 bg-mineshaft-800 shadow-none hover:bg-mineshaft-700",
+ isDirty && "border-primary-400/50"
+ )}
+ >
+ <div className="group flex">
+ <div
+ className={twMerge(
+ "flex h-11 w-11 items-center justify-center px-4 py-3",
+ isDirty && "text-primary"
)}
- />
- </div>
- <div
- className="flex flex-grow items-center border-x border-mineshaft-600 py-1 pl-4 pr-2"
- tabIndex={0}
- role="button"
- >
- {isOverriden ? (
- <Controller
- name="valueOverride"
- key="value-overriden"
- control={control}
- render={({ field }) => (
- <SecretInput
- key="value-overriden"
- isVisible={isVisible}
- isReadOnly={isReadOnly}
- {...field}
- containerClassName="py-1.5 rounded-md transition-all group-hover:mr-2"
- />
- )}
+ >
+ <Checkbox
+ id={`checkbox-${secret._id}`}
+ isChecked={isSelected}
+ onCheckedChange={() => onToggleSecretSelect(secret._id)}
+ className={twMerge("ml-3 hidden group-hover:flex", isSelected && "flex")}
/>
- ) : (
+ <FontAwesomeIcon
+ icon={faKey}
+ className={twMerge("ml-3 block group-hover:hidden", isSelected && "hidden")}
+ />
+ </div>
+ <div className="flex h-11 w-80 flex-shrink-0 items-center px-4 py-2">
<Controller
- name="value"
- key="secret-value"
+ name="key"
control={control}
render={({ field }) => (
- <SecretInput
+ <Input
+ autoComplete="off"
isReadOnly={isReadOnly}
- key="secret-value"
- isVisible={isVisible}
+ autoCapitalization={currentWorkspace?.autoCapitalization}
+ variant="plain"
+ isDisabled={isOverriden}
{...field}
- containerClassName="py-1.5 rounded-md transition-all group-hover:mr-2"
+ className="w-full px-0 focus:text-bunker-100 focus:ring-transparent"
/>
)}
/>
- )}
- <div key="actions" className="flex h-8 flex-shrink-0 self-start transition-all">
- <Tooltip content="Copy secret">
- <IconButton
- ariaLabel="copy-value"
- variant="plain"
- size="sm"
- className="w-0 overflow-hidden p-0 group-hover:mr-2 group-hover:w-5"
- onClick={copyTokenToClipboard}
- >
- <FontAwesomeIcon icon={isSecValueCopied ? faCheck : faCopy} />
- </IconButton>
- </Tooltip>
- <DropdownMenu>
- <ProjectPermissionCan
- I={ProjectPermissionActions.Edit}
- a={subject(ProjectPermissionSub.Secrets, { environment, secretPath })}
- >
- {(isAllowed) => (
- <DropdownMenuTrigger asChild disabled={!isAllowed}>
- <IconButton
- ariaLabel="tags"
- variant="plain"
- size="sm"
- className={twMerge(
- "w-0 overflow-hidden p-0 group-hover:mr-2 group-hover:w-5 data-[state=open]:w-5",
- hasTagsApplied && "w-5 text-primary"
- )}
- isDisabled={!isAllowed}
- >
- <Tooltip content="Tags">
- <FontAwesomeIcon icon={faTags} />
- </Tooltip>
- </IconButton>
- </DropdownMenuTrigger>
+ </div>
+ <div
+ className="flex flex-grow items-center border-x border-mineshaft-600 py-1 pl-4 pr-2"
+ tabIndex={0}
+ role="button"
+ >
+ {isOverriden ? (
+ <Controller
+ name="valueOverride"
+ key="value-overriden"
+ control={control}
+ render={({ field }) => (
+ <SecretInput
+ key="value-overriden"
+ isVisible={isVisible}
+ isReadOnly={isReadOnly}
+ {...field}
+ containerClassName="py-1.5 rounded-md transition-all group-hover:mr-2"
+ />
)}
- </ProjectPermissionCan>
- <DropdownMenuContent align="end">
- <DropdownMenuLabel>Apply tags to this secrets</DropdownMenuLabel>
- {tags.map((tag) => {
- const { _id: tagId, name, tagColor } = tag;
-
- const isTagSelected = selectedTagsGroupById?.[tagId];
- return (
- <DropdownMenuItem
- onClick={() => handleTagSelect(tag)}
- key={tagId}
- icon={isTagSelected && <FontAwesomeIcon icon={faCheckCircle} />}
- iconPos="right"
- >
- <div className="flex items-center">
- <div
- className="mr-2 h-2 w-2 rounded-full"
- style={{ background: tagColor || "#bec2c8" }}
- />
- {name}
- </div>
- </DropdownMenuItem>
- );
- })}
- <DropdownMenuItem className="px-1.5">
- <Button
- size="xs"
- className="w-full"
- colorSchema="primary"
- variant="outline_bg"
- leftIcon={<FontAwesomeIcon icon={faTag} />}
- onClick={onCreateTag}
- >
- Create a tag
- </Button>
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- <ProjectPermissionCan
- I={ProjectPermissionActions.Edit}
- a={subject(ProjectPermissionSub.Secrets, { environment, secretPath })}
- renderTooltip
- allowedLabel="Override"
- >
- {(isAllowed) => (
+ />
+ ) : (
+ <Controller
+ name="value"
+ key="secret-value"
+ control={control}
+ render={({ field }) => (
+ <SecretInput
+ isReadOnly={isReadOnly}
+ key="secret-value"
+ isVisible={isVisible}
+ {...field}
+ containerClassName="py-1.5 rounded-md transition-all group-hover:mr-2"
+ />
+ )}
+ />
+ )}
+ <div key="actions" className="flex h-8 flex-shrink-0 self-start transition-all">
+ <Tooltip content="Copy secret">
<IconButton
- ariaLabel="override-value"
- isDisabled={!isAllowed}
+ ariaLabel="copy-value"
variant="plain"
size="sm"
- onClick={handleOverrideClick}
- className={twMerge(
- "w-0 overflow-hidden p-0 group-hover:mr-2 group-hover:w-5",
- isOverriden && "w-5 text-primary"
- )}
+ className="w-0 overflow-hidden p-0 group-hover:mr-2 group-hover:w-5"
+ onClick={copyTokenToClipboard}
>
- <FontAwesomeIcon icon={faCodeBranch} />
+ <FontAwesomeIcon icon={isSecValueCopied ? faCheck : faCopy} />
</IconButton>
- )}
- </ProjectPermissionCan>
-
-
- <IconButton
- className={twMerge(
- "w-0 overflow-hidden p-0 group-hover:mr-2 group-hover:w-5 data-[state=open]:w-6",
- hasReminder && "w-5 text-primary"
- )}
- variant="plain"
- size="md"
- ariaLabel="add-reminder"
- >
- <Tooltip content="Reminder">
- <FontAwesomeIcon
- onClick={() => {
- if(!hasReminder) {
- setCreateReminderFormOpen.on();
- }
- else {
- setValue("reminderCron", null, {shouldDirty: true});
- setValue("reminderNote", null, {shouldDirty: true});
- }
- }}
- icon={faClock} />
- </Tooltip>
- </IconButton>
+ </Tooltip>
+ <DropdownMenu>
+ <ProjectPermissionCan
+ I={ProjectPermissionActions.Edit}
+ a={subject(ProjectPermissionSub.Secrets, { environment, secretPath })}
+ >
+ {(isAllowed) => (
+ <DropdownMenuTrigger asChild disabled={!isAllowed}>
+ <IconButton
+ ariaLabel="tags"
+ variant="plain"
+ size="sm"
+ className={twMerge(
+ "w-0 overflow-hidden p-0 group-hover:mr-2 group-hover:w-5 data-[state=open]:w-5",
+ hasTagsApplied && "w-5 text-primary"
+ )}
+ isDisabled={!isAllowed}
+ >
+ <Tooltip content="Tags">
+ <FontAwesomeIcon icon={faTags} />
+ </Tooltip>
+ </IconButton>
+ </DropdownMenuTrigger>
+ )}
+ </ProjectPermissionCan>
+ <DropdownMenuContent align="end">
+ <DropdownMenuLabel>Apply tags to this secrets</DropdownMenuLabel>
+ {tags.map((tag) => {
+ const { _id: tagId, name, tagColor } = tag;
- <Popover>
+ const isTagSelected = selectedTagsGroupById?.[tagId];
+ return (
+ <DropdownMenuItem
+ onClick={() => handleTagSelect(tag)}
+ key={tagId}
+ icon={isTagSelected && <FontAwesomeIcon icon={faCheckCircle} />}
+ iconPos="right"
+ >
+ <div className="flex items-center">
+ <div
+ className="mr-2 h-2 w-2 rounded-full"
+ style={{ background: tagColor || "#bec2c8" }}
+ />
+ {name}
+ </div>
+ </DropdownMenuItem>
+ );
+ })}
+ <DropdownMenuItem className="px-1.5">
+ <Button
+ size="xs"
+ className="w-full"
+ colorSchema="primary"
+ variant="outline_bg"
+ leftIcon={<FontAwesomeIcon icon={faTag} />}
+ onClick={onCreateTag}
+ >
+ Create a tag
+ </Button>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
<ProjectPermissionCan
I={ProjectPermissionActions.Edit}
a={subject(ProjectPermissionSub.Secrets, { environment, secretPath })}
+ renderTooltip
+ allowedLabel="Override"
>
{(isAllowed) => (
- <PopoverTrigger asChild disabled={!isAllowed}>
- <IconButton
- className={twMerge(
- "w-0 overflow-hidden p-0 group-hover:mr-2 group-hover:w-5 data-[state=open]:w-6",
- hasComment && "w-5 text-primary"
- )}
- variant="plain"
- size="md"
- ariaLabel="add-comment"
- isDisabled={!isAllowed}
- >
- <Tooltip content="Comment">
- <FontAwesomeIcon icon={faComment} />
- </Tooltip>
- </IconButton>
- </PopoverTrigger>
+ <IconButton
+ ariaLabel="override-value"
+ isDisabled={!isAllowed}
+ variant="plain"
+ size="sm"
+ onClick={handleOverrideClick}
+ className={twMerge(
+ "w-0 overflow-hidden p-0 group-hover:mr-2 group-hover:w-5",
+ isOverriden && "w-5 text-primary"
+ )}
+ >
+ <FontAwesomeIcon icon={faCodeBranch} />
+ </IconButton>
)}
</ProjectPermissionCan>
- <PopoverContent
- className="w-auto border border-mineshaft-600 bg-mineshaft-800 p-2 drop-shadow-2xl"
- sticky="always"
+
+ <IconButton
+ className={twMerge(
+ "w-0 overflow-hidden p-0 group-hover:mr-2 group-hover:w-5 data-[state=open]:w-6",
+ hasReminder && "w-5 text-primary"
+ )}
+ variant="plain"
+ size="md"
+ ariaLabel="add-reminder"
>
- <FormControl label="Comment" className="mb-0">
- <TextArea
- className="border border-mineshaft-600 text-sm"
- rows={8}
- cols={30}
- {...register("comment")}
+ <Tooltip content="Reminder">
+ <FontAwesomeIcon
+ onClick={() => {
+ if (!hasReminder) {
+ setCreateReminderFormOpen.on();
+ } else {
+ setValue("reminderCron", null, { shouldDirty: true });
+ setValue("reminderNote", null, { shouldDirty: true });
+ }
+ }}
+ icon={faClock}
/>
- </FormControl>
- </PopoverContent>
- </Popover>
- </div>
- </div>
- <AnimatePresence exitBeforeEnter>
- {!isDirty ? (
- <motion.div
- key="options"
- className="flex h-10 flex-shrink-0 items-center space-x-4 px-3"
- initial={{ x: 0, opacity: 0 }}
- animate={{ x: 0, opacity: 1 }}
- exit={{ x: 10, opacity: 0 }}
- >
- <Tooltip content="More">
- <IconButton
- ariaLabel="more"
- variant="plain"
- size="md"
- className="p-0 opacity-0 group-hover:opacity-100"
- onClick={() => onDetailViewSecret(secret)}
+ </Tooltip>
+ </IconButton>
+
+ <Popover>
+ <ProjectPermissionCan
+ I={ProjectPermissionActions.Edit}
+ a={subject(ProjectPermissionSub.Secrets, { environment, secretPath })}
>
- <FontAwesomeIcon icon={faEllipsis} size="lg" />
- </IconButton>
- </Tooltip>
- <ProjectPermissionCan
- I={ProjectPermissionActions.Delete}
- a={subject(ProjectPermissionSub.Secrets, { environment, secretPath })}
- renderTooltip
- allowedLabel="Delete"
+ {(isAllowed) => (
+ <PopoverTrigger asChild disabled={!isAllowed}>
+ <IconButton
+ className={twMerge(
+ "w-0 overflow-hidden p-0 group-hover:mr-2 group-hover:w-5 data-[state=open]:w-6",
+ hasComment && "w-5 text-primary"
+ )}
+ variant="plain"
+ size="md"
+ ariaLabel="add-comment"
+ isDisabled={!isAllowed}
+ >
+ <Tooltip content="Comment">
+ <FontAwesomeIcon icon={faComment} />
+ </Tooltip>
+ </IconButton>
+ </PopoverTrigger>
+ )}
+ </ProjectPermissionCan>
+ <PopoverContent
+ className="w-auto border border-mineshaft-600 bg-mineshaft-800 p-2 drop-shadow-2xl"
+ sticky="always"
+ >
+ <FormControl label="Comment" className="mb-0">
+ <TextArea
+ className="border border-mineshaft-600 text-sm"
+ rows={8}
+ cols={30}
+ {...register("comment")}
+ />
+ </FormControl>
+ </PopoverContent>
+ </Popover>
+ </div>
+ </div>
+ <AnimatePresence exitBeforeEnter>
+ {!isDirty ? (
+ <motion.div
+ key="options"
+ className="flex h-10 flex-shrink-0 items-center space-x-4 px-3"
+ initial={{ x: 0, opacity: 0 }}
+ animate={{ x: 0, opacity: 1 }}
+ exit={{ x: 10, opacity: 0 }}
>
- {(isAllowed) => (
+ <Tooltip content="More">
<IconButton
- ariaLabel="delete-value"
+ ariaLabel="more"
variant="plain"
- colorSchema="danger"
size="md"
className="p-0 opacity-0 group-hover:opacity-100"
- onClick={() => onDeleteSecret(secret)}
- isDisabled={!isAllowed}
+ onClick={() => onDetailViewSecret(secret)}
>
- <FontAwesomeIcon icon={faClose} size="lg" />
+ <FontAwesomeIcon icon={faEllipsis} size="lg" />
</IconButton>
- )}
- </ProjectPermissionCan>
- </motion.div>
- ) : (
- <motion.div
- key="options-save"
- className="flex h-10 flex-shrink-0 items-center space-x-4 px-3"
- initial={{ x: -10, opacity: 0 }}
- animate={{ x: 0, opacity: 1 }}
- exit={{ x: -10, opacity: 0 }}
- >
- <Tooltip content="Save">
- <IconButton
- ariaLabel="more"
- variant="plain"
- type="submit"
- size="md"
- className={twMerge(
- "p-0 text-primary opacity-0 group-hover:opacity-100",
- isDirty && "opacity-100"
- )}
- isDisabled={isSubmitting}
+ </Tooltip>
+ <ProjectPermissionCan
+ I={ProjectPermissionActions.Delete}
+ a={subject(ProjectPermissionSub.Secrets, { environment, secretPath })}
+ renderTooltip
+ allowedLabel="Delete"
>
- {isSubmitting ? (
- <Spinner className="m-0 h-4 w-4 p-0" />
- ) : (
- <FontAwesomeIcon icon={faCheck} size="lg" className="text-primary" />
- )}
- </IconButton>
- </Tooltip>
- <Tooltip content="Cancel">
- <IconButton
- ariaLabel="more"
- variant="plain"
- size="md"
- className={twMerge(
- "p-0 opacity-0 group-hover:opacity-100",
- isDirty && "opacity-100"
+ {(isAllowed) => (
+ <IconButton
+ ariaLabel="delete-value"
+ variant="plain"
+ colorSchema="danger"
+ size="md"
+ className="p-0 opacity-0 group-hover:opacity-100"
+ onClick={() => onDeleteSecret(secret)}
+ isDisabled={!isAllowed}
+ >
+ <FontAwesomeIcon icon={faClose} size="lg" />
+ </IconButton>
)}
- onClick={() => reset()}
- isDisabled={isSubmitting}
- >
- <FontAwesomeIcon icon={faClose} size="lg" />
- </IconButton>
- </Tooltip>
- </motion.div>
- )}
- </AnimatePresence>
+ </ProjectPermissionCan>
+ </motion.div>
+ ) : (
+ <motion.div
+ key="options-save"
+ className="flex h-10 flex-shrink-0 items-center space-x-4 px-3"
+ initial={{ x: -10, opacity: 0 }}
+ animate={{ x: 0, opacity: 1 }}
+ exit={{ x: -10, opacity: 0 }}
+ >
+ <Tooltip content="Save">
+ <IconButton
+ ariaLabel="more"
+ variant="plain"
+ type="submit"
+ size="md"
+ className={twMerge(
+ "p-0 text-primary opacity-0 group-hover:opacity-100",
+ isDirty && "opacity-100"
+ )}
+ isDisabled={isSubmitting}
+ >
+ {isSubmitting ? (
+ <Spinner className="m-0 h-4 w-4 p-0" />
+ ) : (
+ <FontAwesomeIcon icon={faCheck} size="lg" className="text-primary" />
+ )}
+ </IconButton>
+ </Tooltip>
+ <Tooltip content="Cancel">
+ <IconButton
+ ariaLabel="more"
+ variant="plain"
+ size="md"
+ className={twMerge(
+ "p-0 opacity-0 group-hover:opacity-100",
+ isDirty && "opacity-100"
+ )}
+ onClick={() => reset()}
+ isDisabled={isSubmitting}
+ >
+ <FontAwesomeIcon icon={faClose} size="lg" />
+ </IconButton>
+ </Tooltip>
+ </motion.div>
+ )}
+ </AnimatePresence>
+ </div>
</div>
- </div>
- </form>
+ </form>
</>
);
}