mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 15:28:25 +00:00
feat: resolved review comments: metadata overflow, save not working on first policy etc
This commit is contained in:
@@ -21,14 +21,14 @@ export const getDefaultOnPremFeatures = (): TFeatureSet => ({
|
|||||||
secretVersioning: true,
|
secretVersioning: true,
|
||||||
pitRecovery: false,
|
pitRecovery: false,
|
||||||
ipAllowlisting: false,
|
ipAllowlisting: false,
|
||||||
rbac: true,
|
rbac: false,
|
||||||
customRateLimits: false,
|
customRateLimits: false,
|
||||||
customAlerts: false,
|
customAlerts: false,
|
||||||
auditLogs: false,
|
auditLogs: false,
|
||||||
auditLogsRetentionDays: 0,
|
auditLogsRetentionDays: 0,
|
||||||
auditLogStreams: false,
|
auditLogStreams: false,
|
||||||
auditLogStreamLimit: 3,
|
auditLogStreamLimit: 3,
|
||||||
samlSSO: true,
|
samlSSO: false,
|
||||||
oidcSSO: false,
|
oidcSSO: false,
|
||||||
scim: false,
|
scim: false,
|
||||||
ldap: false,
|
ldap: false,
|
||||||
|
|||||||
@@ -137,9 +137,7 @@ const SecretConditionSchema = z
|
|||||||
|
|
||||||
export const ProjectPermissionSchema = z.discriminatedUnion("subject", [
|
export const ProjectPermissionSchema = z.discriminatedUnion("subject", [
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.Secrets).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.Secrets)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
),
|
),
|
||||||
@@ -148,185 +146,139 @@ export const ProjectPermissionSchema = z.discriminatedUnion("subject", [
|
|||||||
).optional()
|
).optional()
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.SecretApproval).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.SecretApproval)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.SecretRotation).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.SecretRotation)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.SecretRollback).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.SecretRollback)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_ENUM([ProjectPermissionActions.Read, ProjectPermissionActions.Create]).describe(
|
action: CASL_ACTION_SCHEMA_ENUM([ProjectPermissionActions.Read, ProjectPermissionActions.Create]).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.Member).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.Member)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.Groups).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.Groups)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.Role).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.Role)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.Integrations).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.Integrations)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.Webhooks).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.Webhooks)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.Identity).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.Identity)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.ServiceTokens).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.ServiceTokens)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.Settings).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.Settings)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.Environments).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.Environments)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.Tags).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.Tags)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.AuditLogs).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.AuditLogs)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.IpAllowList).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.IpAllowList)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.CertificateAuthorities).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.CertificateAuthorities)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.Certificates).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.Certificates)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.CertificateTemplates).describe("The entity this permission pertains to. "),
|
||||||
.literal(ProjectPermissionSub.CertificateTemplates)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.PkiAlerts).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.PkiAlerts)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.PkiCollections).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.PkiCollections)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.Project).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.Project)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_ENUM([ProjectPermissionActions.Edit, ProjectPermissionActions.Delete]).describe(
|
action: CASL_ACTION_SCHEMA_ENUM([ProjectPermissionActions.Edit, ProjectPermissionActions.Delete]).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.Kms).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.Kms)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_ENUM([ProjectPermissionActions.Edit]).describe(
|
action: CASL_ACTION_SCHEMA_ENUM([ProjectPermissionActions.Edit]).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
subject: z
|
subject: z.literal(ProjectPermissionSub.SecretFolders).describe("The entity this permission pertains to."),
|
||||||
.literal(ProjectPermissionSub.SecretFolders)
|
|
||||||
.describe("The entity this permission pertains to. Possible options: secrets, environments"),
|
|
||||||
action: CASL_ACTION_SCHEMA_ENUM([ProjectPermissionActions.Read]).describe(
|
action: CASL_ACTION_SCHEMA_ENUM([ProjectPermissionActions.Read]).describe(
|
||||||
"Describe what action an entity can take."
|
"Describe what action an entity can take."
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ type TKnexGroupOperator = {
|
|||||||
value: (TKnexNonGroupOperator | 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
|
// 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
|
// 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
|
// 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()!;
|
const { filterAst, queryBuilder } = stack.pop()!;
|
||||||
switch (filterAst.operator) {
|
switch (filterAst.operator) {
|
||||||
case "eq": {
|
case "eq": {
|
||||||
void queryBuilder.where(filterAst.field, filterAst.value);
|
void queryBuilder.where(filterAst.field, "=", filterAst.value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "ne": {
|
case "ne": {
|
||||||
void queryBuilder.where(filterAst.field, filterAst.value);
|
void queryBuilder.whereNot(filterAst.field, filterAst.value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "startsWith": {
|
case "startsWith": {
|
||||||
void queryBuilder.where(filterAst.field, filterAst.value);
|
void queryBuilder.whereILike(filterAst.field, `${filterAst.value}%`);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "endsWith": {
|
case "endsWith": {
|
||||||
void queryBuilder.where(filterAst.field, filterAst.value);
|
void queryBuilder.whereILike(filterAst.field, `%${filterAst.value}`);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "and": {
|
case "and": {
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ export const IdentityDetailsSection = ({ identityId, handlePopUpOpen }: Props) =
|
|||||||
<div>
|
<div>
|
||||||
<p className="text-sm font-semibold text-mineshaft-300">Metadata</p>
|
<p className="text-sm font-semibold text-mineshaft-300">Metadata</p>
|
||||||
{data?.metadata?.length ? (
|
{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) => (
|
{data.metadata?.map((el) => (
|
||||||
<div key={el.id} className="flex items-center">
|
<div key={el.id} className="flex items-center">
|
||||||
<Tag
|
<Tag
|
||||||
@@ -99,7 +99,9 @@ export const IdentityDetailsSection = ({ identityId, handlePopUpOpen }: Props) =
|
|||||||
size="xs"
|
size="xs"
|
||||||
className="flex items-center rounded-l-none border border-mineshaft-500 bg-mineshaft-900 pl-1"
|
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>
|
</Tag>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ export const UserDetailsSection = ({ membershipId, handlePopUpOpen }: Props) =>
|
|||||||
<div>
|
<div>
|
||||||
<p className="text-sm font-semibold text-mineshaft-300">Metadata</p>
|
<p className="text-sm font-semibold text-mineshaft-300">Metadata</p>
|
||||||
{membership?.metadata?.length ? (
|
{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) => (
|
{membership.metadata?.map((el) => (
|
||||||
<div key={el.id} className="flex items-center">
|
<div key={el.id} className="flex items-center">
|
||||||
<Tag
|
<Tag
|
||||||
@@ -185,7 +185,9 @@ export const UserDetailsSection = ({ membershipId, handlePopUpOpen }: Props) =>
|
|||||||
size="xs"
|
size="xs"
|
||||||
className="flex items-center rounded-l-none border border-mineshaft-500 bg-mineshaft-900 pl-1"
|
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>
|
</Tag>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
} from "@app/components/v2";
|
} from "@app/components/v2";
|
||||||
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
||||||
import { withProjectPermission } from "@app/hoc";
|
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 { usePopUp } from "@app/hooks/usePopUp";
|
||||||
|
|
||||||
import { TabSections } from "../Types";
|
import { TabSections } from "../Types";
|
||||||
@@ -76,7 +76,9 @@ export const RolePage = withProjectPermission(
|
|||||||
variant="link"
|
variant="link"
|
||||||
type="submit"
|
type="submit"
|
||||||
leftIcon={<FontAwesomeIcon icon={faChevronLeft} />}
|
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"
|
className="mb-4"
|
||||||
>
|
>
|
||||||
Roles
|
Roles
|
||||||
@@ -139,7 +141,7 @@ export const RolePage = withProjectPermission(
|
|||||||
<div className="mr-4 w-96">
|
<div className="mr-4 w-96">
|
||||||
<RoleDetailsSection roleSlug={roleSlug} handlePopUpOpen={handlePopUpOpen} />
|
<RoleDetailsSection roleSlug={roleSlug} handlePopUpOpen={handlePopUpOpen} />
|
||||||
</div>
|
</div>
|
||||||
<RolePermissionsSection roleSlug={roleSlug} />
|
<RolePermissionsSection roleSlug={roleSlug} isDisabled={!isCustomRole} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
+1
-1
@@ -178,7 +178,7 @@ export const rolePermission2Form = (permissions: TProjectPermission[] = []) => {
|
|||||||
if (canCreate) formVal[subject as ProjectPermissionSub.Member]![0].create = true;
|
if (canCreate) formVal[subject as ProjectPermissionSub.Member]![0].create = true;
|
||||||
} else if (subject === ProjectPermissionSub.SecretFolders) {
|
} else if (subject === ProjectPermissionSub.SecretFolders) {
|
||||||
const canRead = action.includes(ProjectPermissionActions.Read);
|
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
|
// from above statement we are sure it won't be undefined
|
||||||
if (canRead) formVal[subject as ProjectPermissionSub.Member]![0].read = true;
|
if (canRead) formVal[subject as ProjectPermissionSub.Member]![0].read = true;
|
||||||
|
|||||||
+15
-17
@@ -2,7 +2,6 @@ import { FormProvider, useForm } from "react-hook-form";
|
|||||||
import { faPlus } from "@fortawesome/free-solid-svg-icons";
|
import { faPlus } 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 { AnimatePresence } from "framer-motion";
|
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
import { Button, Modal, ModalContent, ModalTrigger } from "@app/components/v2";
|
import { Button, Modal, ModalContent, ModalTrigger } from "@app/components/v2";
|
||||||
@@ -95,22 +94,21 @@ export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<AnimatePresence>
|
<div className="py-4">
|
||||||
<div className="py-4">
|
{(Object.keys(PROJECT_PERMISSION_OBJECT) as ProjectPermissionSub[]).map((subject) => (
|
||||||
{(Object.keys(PROJECT_PERMISSION_OBJECT) as ProjectPermissionSub[]).map((subject) => (
|
<GeneralPermissionOptions
|
||||||
<GeneralPermissionOptions
|
subject={subject}
|
||||||
subject={subject}
|
actions={PROJECT_PERMISSION_OBJECT[subject].actions}
|
||||||
actions={PROJECT_PERMISSION_OBJECT[subject].actions}
|
title={PROJECT_PERMISSION_OBJECT[subject].title}
|
||||||
title={PROJECT_PERMISSION_OBJECT[subject].title}
|
key={`project-permission-${subject}`}
|
||||||
key={`project-permission-${subject}`}
|
isDisabled={isDisabled}
|
||||||
>
|
>
|
||||||
{subject === ProjectPermissionSub.Secrets ? (
|
{subject === ProjectPermissionSub.Secrets ? (
|
||||||
<SecretPermissionConditions />
|
<SecretPermissionConditions isDisabled={isDisabled} />
|
||||||
) : undefined}
|
) : undefined}
|
||||||
</GeneralPermissionOptions>
|
</GeneralPermissionOptions>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</AnimatePresence>
|
|
||||||
<Modal
|
<Modal
|
||||||
isOpen={popUp.createPolicy.isOpen}
|
isOpen={popUp.createPolicy.isOpen}
|
||||||
onOpenChange={(isOpen) => handlePopUpToggle("createPolicy", isOpen)}
|
onOpenChange={(isOpen) => handlePopUpToggle("createPolicy", isOpen)}
|
||||||
|
|||||||
+90
-69
@@ -2,7 +2,7 @@ import { cloneElement } from "react";
|
|||||||
import { Controller, useFieldArray, useFormContext } from "react-hook-form";
|
import { Controller, useFieldArray, useFormContext } from "react-hook-form";
|
||||||
import { faChevronDown, faChevronRight, faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";
|
import { faChevronDown, faChevronRight, faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
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 { Button, Checkbox, Tag } from "@app/components/v2";
|
||||||
import { ProjectPermissionSub } from "@app/context";
|
import { ProjectPermissionSub } from "@app/context";
|
||||||
@@ -15,13 +15,15 @@ type Props<T extends ProjectPermissionSub> = {
|
|||||||
subject: T;
|
subject: T;
|
||||||
actions: TProjectPermissionObject[T]["actions"];
|
actions: TProjectPermissionObject[T]["actions"];
|
||||||
children?: JSX.Element;
|
children?: JSX.Element;
|
||||||
|
isDisabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const GeneralPermissionOptions = <T extends keyof NonNullable<TFormSchema["permissions"]>>({
|
export const GeneralPermissionOptions = <T extends keyof NonNullable<TFormSchema["permissions"]>>({
|
||||||
subject,
|
subject,
|
||||||
actions,
|
actions,
|
||||||
children,
|
children,
|
||||||
title
|
title,
|
||||||
|
isDisabled
|
||||||
}: Props<T>) => {
|
}: Props<T>) => {
|
||||||
const { control } = useFormContext<TFormSchema>();
|
const { control } = useFormContext<TFormSchema>();
|
||||||
const items = useFieldArray({
|
const items = useFieldArray({
|
||||||
@@ -57,74 +59,93 @@ export const GeneralPermissionOptions = <T extends keyof NonNullable<TFormSchema
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{isOpen && (
|
<AnimatePresence>
|
||||||
<motion.div
|
{isOpen && (
|
||||||
key={`select-${subject}-type`}
|
<motion.div
|
||||||
transition={{ duration: 0.3 }}
|
key={`select-${subject}-type`}
|
||||||
initial={{ opacity: 0, translateY: -10 }}
|
transition={{ duration: 0.3 }}
|
||||||
animate={{ opacity: 1, translateY: 0 }}
|
initial={{ opacity: 0, translateY: -10 }}
|
||||||
exit={{ opacity: 0, translateX: 10 }}
|
animate={{ opacity: 1, translateY: 0 }}
|
||||||
className="flex flex-col space-y-4 bg-bunker-800 p-6"
|
exit={{ opacity: 0, translateY: 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">
|
<AnimatePresence>
|
||||||
<div className="flex text-gray-300">
|
{items.fields.map((el, rootIndex) => (
|
||||||
<div className="w-1/4">Actions</div>
|
<motion.div
|
||||||
<div className="flex flex-grow flex-wrap justify-start gap-8">
|
key={el.id}
|
||||||
{actions.map(({ label, value }) => {
|
transition={{ duration: 0.3 }}
|
||||||
if (typeof value !== "string") return undefined;
|
initial={{ opacity: 0, translateY: -20 }}
|
||||||
return (
|
animate={{ opacity: 1, translateY: 0 }}
|
||||||
<Controller
|
exit={{ opacity: 0, translateY: -20 }}
|
||||||
key={`${el.id}-${label}`}
|
className="bg-mineshaft-800 p-5 first:rounded-t-md last:rounded-b-md"
|
||||||
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)}
|
|
||||||
>
|
>
|
||||||
Remove Rule
|
<div className="flex text-gray-300">
|
||||||
</Button>
|
<div className="w-1/4">Actions</div>
|
||||||
</div>
|
<div className="flex flex-grow flex-wrap justify-start gap-8">
|
||||||
</div>
|
{actions.map(({ label, value }) => {
|
||||||
))}
|
if (typeof value !== "string") return undefined;
|
||||||
</motion.div>
|
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>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+11
-7
@@ -90,16 +90,20 @@ export const NewPermissionRule = ({ onClose }: Props) => {
|
|||||||
onClick={form.handleSubmit((el) => {
|
onClick={form.handleSubmit((el) => {
|
||||||
const rootPolicyValue = rootForm.getValues("permissions")?.[el.type];
|
const rootPolicyValue = rootForm.getValues("permissions")?.[el.type];
|
||||||
if (rootPolicyValue && selectedSubject === ProjectPermissionSub.Secrets) {
|
if (rootPolicyValue && selectedSubject === ProjectPermissionSub.Secrets) {
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
rootForm.setValue(
|
||||||
// @ts-ignore-error akhilmhdh: this is because of ts collision with both
|
`permissions.${el.type}`,
|
||||||
rootForm.setValue(`permissions.${el.type}`, [
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
...rootPolicyValue,
|
// @ts-ignore-error akhilmhdh: this is because of ts collision with both
|
||||||
...(el?.permissions[el.type] || [])
|
[...rootPolicyValue, ...(el?.permissions[el.type] || [])],
|
||||||
]);
|
{ shouldDirty: true, shouldTouch: true }
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore-error akhilmhdh: this is because of ts collision with both
|
// @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();
|
onClose();
|
||||||
})}
|
})}
|
||||||
|
|||||||
+3
-1
@@ -9,9 +9,10 @@ import { TFormSchema } from "../ProjectRoleModifySection.utils";
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
position?: number;
|
position?: number;
|
||||||
|
isDisabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SecretPermissionConditions = ({ position = 0 }: Props) => {
|
export const SecretPermissionConditions = ({ position = 0, isDisabled }: Props) => {
|
||||||
const { control } = useFormContext<TFormSchema>();
|
const { control } = useFormContext<TFormSchema>();
|
||||||
const items = useFieldArray({
|
const items = useFieldArray({
|
||||||
control,
|
control,
|
||||||
@@ -108,6 +109,7 @@ export const SecretPermissionConditions = ({ position = 0 }: Props) => {
|
|||||||
variant="star"
|
variant="star"
|
||||||
size="xs"
|
size="xs"
|
||||||
className="mt-3"
|
className="mt-3"
|
||||||
|
isDisabled={isDisabled}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
items.append({
|
items.append({
|
||||||
lhs: "environment",
|
lhs: "environment",
|
||||||
|
|||||||
Reference in New Issue
Block a user