Skip to content

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

feat: resolved review comments: metadata overflow, save not working on first policy etc

=7667a7e6650a
diff --git a/backend/src/ee/services/license/license-fns.ts b/backend/src/ee/services/license/license-fns.ts
index 2a60fb03e8..fa67b72d16 100644
--- a/backend/src/ee/services/license/license-fns.ts
+++ b/backend/src/ee/services/license/license-fns.ts
@@ -21,14 +21,14 @@ export const getDefaultOnPremFeatures = (): TFeatureSet => ({
secretVersioning: true,
pitRecovery: false,
ipAllowlisting: false,
- rbac: true,
+ rbac: false,
customRateLimits: false,
customAlerts: false,
auditLogs: false,
auditLogsRetentionDays: 0,
auditLogStreams: false,
auditLogStreamLimit: 3,
- samlSSO: true,
+ samlSSO: false,
oidcSSO: false,
scim: false,
ldap: false,
diff --git a/backend/src/ee/services/permission/project-permission.ts b/backend/src/ee/services/permission/project-permission.ts
index 71cd78821a..7c9e75dedf 100644
--- a/backend/src/ee/services/permission/project-permission.ts
+++ b/backend/src/ee/services/permission/project-permission.ts
@@ -137,9 +137,7 @@ const SecretConditionSchema = z
export const ProjectPermissionSchema = z.discriminatedUnion("subject", [
z.object({
- subject: z
- .literal(ProjectPermissionSub.Secrets)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.Secrets).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
),
@@ -148,185 +146,139 @@ export const ProjectPermissionSchema = z.discriminatedUnion("subject", [
).optional()
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.SecretApproval)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.SecretApproval).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.SecretRotation)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.SecretRotation).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.SecretRollback)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.SecretRollback).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_ENUM([ProjectPermissionActions.Read, ProjectPermissionActions.Create]).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.Member)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.Member).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.Groups)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.Groups).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.Role)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.Role).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.Integrations)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.Integrations).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.Webhooks)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.Webhooks).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.Identity)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.Identity).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.ServiceTokens)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.ServiceTokens).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.Settings)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.Settings).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.Environments)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.Environments).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.Tags)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.Tags).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.AuditLogs)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.AuditLogs).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.IpAllowList)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.IpAllowList).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.CertificateAuthorities)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.CertificateAuthorities).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.Certificates)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.Certificates).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.CertificateTemplates)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.CertificateTemplates).describe("The entity this permission pertains to. "),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.PkiAlerts)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.PkiAlerts).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.PkiCollections)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.PkiCollections).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.Project)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.Project).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_ENUM([ProjectPermissionActions.Edit, ProjectPermissionActions.Delete]).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.Kms)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.Kms).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_ENUM([ProjectPermissionActions.Edit]).describe(
"Describe what action an entity can take."
)
}),
z.object({
- subject: z
- .literal(ProjectPermissionSub.SecretFolders)
- .describe("The entity this permission pertains to. Possible options: secrets, environments"),
+ subject: z.literal(ProjectPermissionSub.SecretFolders).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_ENUM([ProjectPermissionActions.Read]).describe(
"Describe what action an entity can take."
)
diff --git a/backend/src/lib/knex/dynamic.ts b/backend/src/lib/knex/dynamic.ts
index 90a9d2abe3..c336d7a9e9 100644
--- a/backend/src/lib/knex/dynamic.ts
+++ b/backend/src/lib/knex/dynamic.ts
@@ -21,6 +21,7 @@ type TKnexGroupOperator = {
value: (TKnexNonGroupOperator | TKnexGroupOperator)[];
};
+// akhilmhdh: This is still in pending state and not yet ready. If you want to use it ping me.
// used when you need to write a complex query with the orm
// use it when you need complex or and and condition - most of the time not needed
// majorly used with casl permission to filter data based on permission
@@ -33,19 +34,19 @@ export const buildDynamicKnexQuery = (dynamicQuery: TKnexDynamicOperator, rootQu
const { filterAst, queryBuilder } = stack.pop()!;
switch (filterAst.operator) {
case "eq": {
- void queryBuilder.where(filterAst.field, filterAst.value);
+ void queryBuilder.where(filterAst.field, "=", filterAst.value);
break;
}
case "ne": {
- void queryBuilder.where(filterAst.field, filterAst.value);
+ void queryBuilder.whereNot(filterAst.field, filterAst.value);
break;
}
case "startsWith": {
- void queryBuilder.where(filterAst.field, filterAst.value);
+ void queryBuilder.whereILike(filterAst.field, `${filterAst.value}%`);
break;
}
case "endsWith": {
- void queryBuilder.where(filterAst.field, filterAst.value);
+ void queryBuilder.whereILike(filterAst.field, `%${filterAst.value}`);
break;
}
case "and": {
diff --git a/frontend/src/views/Org/IdentityPage/components/IdentityDetailsSection.tsx b/frontend/src/views/Org/IdentityPage/components/IdentityDetailsSection.tsx
index c9cba17c65..fe56d32603 100644
--- a/frontend/src/views/Org/IdentityPage/components/IdentityDetailsSection.tsx
+++ b/frontend/src/views/Org/IdentityPage/components/IdentityDetailsSection.tsx
@@ -85,7 +85,7 @@ export const IdentityDetailsSection = ({ identityId, handlePopUpOpen }: Props) =
<div>
<p className="text-sm font-semibold text-mineshaft-300">Metadata</p>
{data?.metadata?.length ? (
- <div className="mt-1 flex gap-2 text-sm text-mineshaft-300">
+ <div className="mt-1 flex flex-wrap gap-2 text-sm text-mineshaft-300">
{data.metadata?.map((el) => (
<div key={el.id} className="flex items-center">
<Tag
@@ -99,7 +99,9 @@ export const IdentityDetailsSection = ({ identityId, handlePopUpOpen }: Props) =
size="xs"
className="flex items-center rounded-l-none border border-mineshaft-500 bg-mineshaft-900 pl-1"
>
- <div>{el.value}</div>
+ <div className="max-w-[150px] overflow-hidden text-ellipsis whitespace-nowrap">
+ {el.value}
+ </div>
</Tag>
</div>
))}
diff --git a/frontend/src/views/Org/UserPage/components/UserDetailsSection.tsx b/frontend/src/views/Org/UserPage/components/UserDetailsSection.tsx
index c00e556882..d439c7ecdf 100644
--- a/frontend/src/views/Org/UserPage/components/UserDetailsSection.tsx
+++ b/frontend/src/views/Org/UserPage/components/UserDetailsSection.tsx
@@ -171,7 +171,7 @@ export const UserDetailsSection = ({ membershipId, handlePopUpOpen }: Props) =>
<div>
<p className="text-sm font-semibold text-mineshaft-300">Metadata</p>
{membership?.metadata?.length ? (
- <div className="mt-1 flex gap-2 text-sm text-mineshaft-300">
+ <div className="mt-1 flex flex-wrap gap-2 text-sm text-mineshaft-300">
{membership.metadata?.map((el) => (
<div key={el.id} className="flex items-center">
<Tag
@@ -185,7 +185,9 @@ export const UserDetailsSection = ({ membershipId, handlePopUpOpen }: Props) =>
size="xs"
className="flex items-center rounded-l-none border border-mineshaft-500 bg-mineshaft-900 pl-1"
>
- <div>{el.value}</div>
+ <div className="max-w-[150px] overflow-hidden text-ellipsis whitespace-nowrap">
+ {el.value}
+ </div>
</Tag>
</div>
))}
diff --git a/frontend/src/views/Project/RolePage/RolePage.tsx b/frontend/src/views/Project/RolePage/RolePage.tsx
index 373de25385..929265dcf7 100644
--- a/frontend/src/views/Project/RolePage/RolePage.tsx
+++ b/frontend/src/views/Project/RolePage/RolePage.tsx
@@ -17,7 +17,7 @@ import {
} from "@app/components/v2";
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
import { withProjectPermission } from "@app/hoc";
-import { useDeleteProjectRole,useGetProjectRoleBySlug } from "@app/hooks/api";
+import { useDeleteProjectRole, useGetProjectRoleBySlug } from "@app/hooks/api";
import { usePopUp } from "@app/hooks/usePopUp";
import { TabSections } from "../Types";
@@ -76,7 +76,9 @@ export const RolePage = withProjectPermission(
variant="link"
type="submit"
leftIcon={<FontAwesomeIcon icon={faChevronLeft} />}
- onClick={() => router.push(`/project/${projectId}/members?selectedTab=${TabSections.Roles}`)}
+ onClick={() =>
+ router.push(`/project/${projectId}/members?selectedTab=${TabSections.Roles}`)
+ }
className="mb-4"
>
Roles
@@ -139,7 +141,7 @@ export const RolePage = withProjectPermission(
<div className="mr-4 w-96">
<RoleDetailsSection roleSlug={roleSlug} handlePopUpOpen={handlePopUpOpen} />
</div>
- <RolePermissionsSection roleSlug={roleSlug} />
+ <RolePermissionsSection roleSlug={roleSlug} isDisabled={!isCustomRole} />
</div>
</div>
)}
diff --git a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/ProjectRoleModifySection.utils.ts b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/ProjectRoleModifySection.utils.ts
index 84ffc85d1a..94a118058d 100644
--- a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/ProjectRoleModifySection.utils.ts
+++ b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/ProjectRoleModifySection.utils.ts
@@ -178,7 +178,7 @@ export const rolePermission2Form = (permissions: TProjectPermission[] = []) => {
if (canCreate) formVal[subject as ProjectPermissionSub.Member]![0].create = true;
} else if (subject === ProjectPermissionSub.SecretFolders) {
const canRead = action.includes(ProjectPermissionActions.Read);
- if (!formVal[subject]) formVal[subject] = [];
+ if (!formVal[subject]) formVal[subject] = [{}];
// from above statement we are sure it won't be undefined
if (canRead) formVal[subject as ProjectPermissionSub.Member]![0].read = true;
diff --git a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx
index 8f2cce4a13..3828d9c21f 100644
--- a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx
+++ b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx
@@ -2,7 +2,6 @@ import { FormProvider, useForm } from "react-hook-form";
import { faPlus } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { zodResolver } from "@hookform/resolvers/zod";
-import { AnimatePresence } from "framer-motion";
import { createNotification } from "@app/components/notifications";
import { Button, Modal, ModalContent, ModalTrigger } from "@app/components/v2";
@@ -95,22 +94,21 @@ export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => {
)}
</div>
</div>
- <AnimatePresence>
- <div className="py-4">
- {(Object.keys(PROJECT_PERMISSION_OBJECT) as ProjectPermissionSub[]).map((subject) => (
- <GeneralPermissionOptions
- subject={subject}
- actions={PROJECT_PERMISSION_OBJECT[subject].actions}
- title={PROJECT_PERMISSION_OBJECT[subject].title}
- key={`project-permission-${subject}`}
- >
- {subject === ProjectPermissionSub.Secrets ? (
- <SecretPermissionConditions />
- ) : undefined}
- </GeneralPermissionOptions>
- ))}
- </div>
- </AnimatePresence>
+ <div className="py-4">
+ {(Object.keys(PROJECT_PERMISSION_OBJECT) as ProjectPermissionSub[]).map((subject) => (
+ <GeneralPermissionOptions
+ subject={subject}
+ actions={PROJECT_PERMISSION_OBJECT[subject].actions}
+ title={PROJECT_PERMISSION_OBJECT[subject].title}
+ key={`project-permission-${subject}`}
+ isDisabled={isDisabled}
+ >
+ {subject === ProjectPermissionSub.Secrets ? (
+ <SecretPermissionConditions isDisabled={isDisabled} />
+ ) : undefined}
+ </GeneralPermissionOptions>
+ ))}
+ </div>
<Modal
isOpen={popUp.createPolicy.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("createPolicy", isOpen)}
diff --git a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/GeneralPermissionOptions.tsx b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/GeneralPermissionOptions.tsx
index e551809481..be3404dfe9 100644
--- a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/GeneralPermissionOptions.tsx
+++ b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/GeneralPermissionOptions.tsx
@@ -2,7 +2,7 @@ import { cloneElement } from "react";
import { Controller, useFieldArray, useFormContext } from "react-hook-form";
import { faChevronDown, faChevronRight, faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { motion } from "framer-motion";
+import { AnimatePresence, motion } from "framer-motion";
import { Button, Checkbox, Tag } from "@app/components/v2";
import { ProjectPermissionSub } from "@app/context";
@@ -15,13 +15,15 @@ type Props<T extends ProjectPermissionSub> = {
subject: T;
actions: TProjectPermissionObject[T]["actions"];
children?: JSX.Element;
+ isDisabled?: boolean;
};
export const GeneralPermissionOptions = <T extends keyof NonNullable<TFormSchema["permissions"]>>({
subject,
actions,
children,
- title
+ title,
+ isDisabled
}: Props<T>) => {
const { control } = useFormContext<TFormSchema>();
const items = useFieldArray({
@@ -57,74 +59,93 @@ export const GeneralPermissionOptions = <T extends keyof NonNullable<TFormSchema
</div>
)}
</div>
- {isOpen && (
- <motion.div
- key={`select-${subject}-type`}
- transition={{ duration: 0.3 }}
- initial={{ opacity: 0, translateY: -10 }}
- animate={{ opacity: 1, translateY: 0 }}
- exit={{ opacity: 0, translateX: 10 }}
- className="flex flex-col space-y-4 bg-bunker-800 p-6"
- >
- {items.fields.map((el, rootIndex) => (
- <div key={el.id} className="bg-mineshaft-800 p-5 first:rounded-t-md last:rounded-b-md">
- <div className="flex text-gray-300">
- <div className="w-1/4">Actions</div>
- <div className="flex flex-grow flex-wrap justify-start gap-8">
- {actions.map(({ label, value }) => {
- if (typeof value !== "string") return undefined;
- return (
- <Controller
- key={`${el.id}-${label}`}
- name={`permissions.${subject}.${rootIndex}.${value}` as any}
- control={control}
- defaultValue={false}
- render={({ field }) => (
- <div className="flex items-center justify-center">
- <Checkbox
- isChecked={Boolean(field.value)}
- onCheckedChange={field.onChange}
- id={`permissions.${subject}.${rootIndex}.${String(value)}`}
- >
- {label}
- </Checkbox>
- </div>
- )}
- />
- );
- })}
- </div>
- </div>
- {children &&
- cloneElement(children, {
- position: rootIndex
- })}
- <div className="mt-2 flex justify-end space-x-4">
- {subject === ProjectPermissionSub.Secrets && (
- <Button
- leftIcon={<FontAwesomeIcon icon={faPlus} />}
- variant="star"
- size="xs"
- className="mt-2"
- onClick={() => items.insert(rootIndex, [{} as any])}
- >
- Add rule
- </Button>
- )}
- <Button
- leftIcon={<FontAwesomeIcon icon={faTrash} />}
- variant="outline_bg"
- size="xs"
- className="mt-2 hover:border-red"
- onClick={() => items.remove(rootIndex)}
+ <AnimatePresence>
+ {isOpen && (
+ <motion.div
+ key={`select-${subject}-type`}
+ transition={{ duration: 0.3 }}
+ initial={{ opacity: 0, translateY: -10 }}
+ animate={{ opacity: 1, translateY: 0 }}
+ exit={{ opacity: 0, translateY: 10 }}
+ className="flex flex-col space-y-4 bg-bunker-800 p-6"
+ >
+ <AnimatePresence>
+ {items.fields.map((el, rootIndex) => (
+ <motion.div
+ key={el.id}
+ transition={{ duration: 0.3 }}
+ initial={{ opacity: 0, translateY: -20 }}
+ animate={{ opacity: 1, translateY: 0 }}
+ exit={{ opacity: 0, translateY: -20 }}
+ className="bg-mineshaft-800 p-5 first:rounded-t-md last:rounded-b-md"
>
- Remove Rule
- </Button>
- </div>
- </div>
- ))}
- </motion.div>
- )}
+ <div className="flex text-gray-300">
+ <div className="w-1/4">Actions</div>
+ <div className="flex flex-grow flex-wrap justify-start gap-8">
+ {actions.map(({ label, value }) => {
+ if (typeof value !== "string") return undefined;
+ return (
+ <Controller
+ key={`${el.id}-${label}`}
+ name={`permissions.${subject}.${rootIndex}.${value}` as any}
+ control={control}
+ defaultValue={false}
+ render={({ field }) => (
+ <div className="flex items-center justify-center">
+ <Checkbox
+ isChecked={Boolean(field.value)}
+ onCheckedChange={field.onChange}
+ id={`permissions.${subject}.${rootIndex}.${String(value)}`}
+ >
+ {label}
+ </Checkbox>
+ </div>
+ )}
+ />
+ );
+ })}
+ </div>
+ </div>
+ {children &&
+ cloneElement(children, {
+ position: rootIndex
+ })}
+ <div className="mt-2 flex justify-end space-x-4">
+ {!isDisabled && subject === ProjectPermissionSub.Secrets && (
+ <Button
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ variant="star"
+ size="xs"
+ className="mt-2"
+ onClick={() => {
+ items.insert(rootIndex, [
+ { read: false, edit: false, create: false, delete: false } as any
+ ]);
+ }}
+ isDisabled={isDisabled}
+ >
+ Add rule
+ </Button>
+ )}
+ {!isDisabled && (
+ <Button
+ leftIcon={<FontAwesomeIcon icon={faTrash} />}
+ variant="outline_bg"
+ size="xs"
+ className="mt-2 hover:border-red"
+ onClick={() => items.remove(rootIndex)}
+ isDisabled={isDisabled}
+ >
+ Remove Rule
+ </Button>
+ )}{" "}
+ </div>
+ </motion.div>
+ ))}
+ </AnimatePresence>
+ </motion.div>
+ )}
+ </AnimatePresence>
</div>
);
};
diff --git a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/NewPermissionRule.tsx b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/NewPermissionRule.tsx
index 390e4d2729..5950bee369 100644
--- a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/NewPermissionRule.tsx
+++ b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/NewPermissionRule.tsx
@@ -90,16 +90,20 @@ export const NewPermissionRule = ({ onClose }: Props) => {
onClick={form.handleSubmit((el) => {
const rootPolicyValue = rootForm.getValues("permissions")?.[el.type];
if (rootPolicyValue && selectedSubject === ProjectPermissionSub.Secrets) {
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore-error akhilmhdh: this is because of ts collision with both
- rootForm.setValue(`permissions.${el.type}`, [
- ...rootPolicyValue,
- ...(el?.permissions[el.type] || [])
- ]);
+ rootForm.setValue(
+ `permissions.${el.type}`,
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore-error akhilmhdh: this is because of ts collision with both
+ [...rootPolicyValue, ...(el?.permissions[el.type] || [])],
+ { shouldDirty: true, shouldTouch: true }
+ );
} else {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore-error akhilmhdh: this is because of ts collision with both
- rootForm.setValue(`permissions.${el.type}`, el?.permissions?.[el.type]);
+ rootForm.setValue(`permissions.${el.type}`, el?.permissions?.[el.type], {
+ shouldDirty: true,
+ shouldTouch: true
+ });
}
onClose();
})}
diff --git a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/SecretPermissionConditions.tsx b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/SecretPermissionConditions.tsx
index a4713cfbf4..f724f81212 100644
--- a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/SecretPermissionConditions.tsx
+++ b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/SecretPermissionConditions.tsx
@@ -9,9 +9,10 @@ import { TFormSchema } from "../ProjectRoleModifySection.utils";
type Props = {
position?: number;
+ isDisabled?: boolean;
};
-export const SecretPermissionConditions = ({ position = 0 }: Props) => {
+export const SecretPermissionConditions = ({ position = 0, isDisabled }: Props) => {
const { control } = useFormContext<TFormSchema>();
const items = useFieldArray({
control,
@@ -108,6 +109,7 @@ export const SecretPermissionConditions = ({ position = 0 }: Props) => {
variant="star"
size="xs"
className="mt-3"
+ isDisabled={isDisabled}
onClick={() =>
items.append({
lhs: "environment",