diff --git a/ui/actions/roles/roles.ts b/ui/actions/roles/roles.ts index d0dd07bd9a..e69300ab26 100644 --- a/ui/actions/roles/roles.ts +++ b/ui/actions/roles/roles.ts @@ -120,8 +120,7 @@ export const addRole = async (formData: FormData) => { manage_providers: formData.get("manage_providers") === "true", manage_scans: formData.get("manage_scans") === "true", manage_account: formData.get("manage_account") === "true", - // TODO: Add back when we have integrations ready - // manage_integrations: formData.get("manage_integrations") === "true", + manage_integrations: formData.get("manage_integrations") === "true", unlimited_visibility: formData.get("unlimited_visibility") === "true", }, relationships: {}, diff --git a/ui/components/roles/workflow/forms/add-role-form.tsx b/ui/components/roles/workflow/forms/add-role-form.tsx index 6b16dbd09a..a833cbe2c2 100644 --- a/ui/components/roles/workflow/forms/add-role-form.tsx +++ b/ui/components/roles/workflow/forms/add-role-form.tsx @@ -36,6 +36,7 @@ export const AddRoleForm = ({ name: "", manage_users: false, manage_providers: false, + manage_integrations: false, manage_scans: false, unlimited_visibility: false, groups: [], @@ -68,7 +69,7 @@ export const AddRoleForm = ({ "manage_account", "manage_billing", "manage_providers", - // "manage_integrations", + "manage_integrations", "manage_scans", "unlimited_visibility", ]; @@ -87,6 +88,7 @@ export const AddRoleForm = ({ formData.append("name", values.name); formData.append("manage_users", String(values.manage_users)); formData.append("manage_providers", String(values.manage_providers)); + formData.append("manage_integrations", String(values.manage_integrations)); formData.append("manage_scans", String(values.manage_scans)); formData.append("manage_account", String(values.manage_account)); formData.append( diff --git a/ui/components/roles/workflow/forms/edit-role-form.tsx b/ui/components/roles/workflow/forms/edit-role-form.tsx index 70f2161355..7573d40502 100644 --- a/ui/components/roles/workflow/forms/edit-role-form.tsx +++ b/ui/components/roles/workflow/forms/edit-role-form.tsx @@ -99,7 +99,7 @@ export const EditRoleForm = ({ updatedFields.manage_users = values.manage_users; updatedFields.manage_providers = values.manage_providers; updatedFields.manage_account = values.manage_account; - // updatedFields.manage_integrations = values.manage_integrations; + updatedFields.manage_integrations = values.manage_integrations; updatedFields.manage_scans = values.manage_scans; updatedFields.unlimited_visibility = values.unlimited_visibility; diff --git a/ui/components/ui/sidebar/menu.tsx b/ui/components/ui/sidebar/menu.tsx index 7a1e20f261..9ce1b2feb3 100644 --- a/ui/components/ui/sidebar/menu.tsx +++ b/ui/components/ui/sidebar/menu.tsx @@ -33,6 +33,10 @@ const MENU_HIDE_RULES: MenuHideRule[] = [ label: "Billing", condition: (permissions) => permissions?.manage_billing === false, }, + { + label: "Integrations", + condition: (permissions) => permissions?.manage_integrations === false, + }, // Add more rules as needed: // { // label: "Users", diff --git a/ui/lib/helper.ts b/ui/lib/helper.ts index 6e0b89fbbb..61b431c7c9 100644 --- a/ui/lib/helper.ts +++ b/ui/lib/helper.ts @@ -322,12 +322,12 @@ export const permissionFormFields: PermissionInfo[] = [ description: "Allows configuration and management of cloud provider connections", }, - // { - // field: "manage_integrations", - // label: "Manage Integrations", - // description: - // "Controls the setup and management of third-party integrations", - // }, + { + field: "manage_integrations", + label: "Manage Integrations", + description: + "Allows configuration and management of third-party integrations", + }, { field: "manage_scans", label: "Manage Scans", diff --git a/ui/middleware.ts b/ui/middleware.ts index 54116aaa57..d332bc03e8 100644 --- a/ui/middleware.ts +++ b/ui/middleware.ts @@ -29,6 +29,13 @@ export default auth((req: NextRequest & { auth: any }) => { if (pathname.startsWith("/billing") && !permissions.manage_billing) { return NextResponse.redirect(new URL("/profile", req.url)); } + + if ( + pathname.startsWith("/integrations") && + !permissions.manage_integrations + ) { + return NextResponse.redirect(new URL("/profile", req.url)); + } } return NextResponse.next(); diff --git a/ui/types/formSchemas.ts b/ui/types/formSchemas.ts index b1deadf489..5b1891379f 100644 --- a/ui/types/formSchemas.ts +++ b/ui/types/formSchemas.ts @@ -11,7 +11,7 @@ export const addRoleFormSchema = z.object({ manage_account: z.boolean().default(false), manage_billing: z.boolean().default(false), manage_providers: z.boolean().default(false), - // manage_integrations: z.boolean().default(false), + manage_integrations: z.boolean().default(false), manage_scans: z.boolean().default(false), unlimited_visibility: z.boolean().default(false), groups: z.array(z.string()).optional(), @@ -23,7 +23,7 @@ export const editRoleFormSchema = z.object({ manage_account: z.boolean().default(false), manage_billing: z.boolean().default(false), manage_providers: z.boolean().default(false), - // manage_integrations: z.boolean().default(false), + manage_integrations: z.boolean().default(false), manage_scans: z.boolean().default(false), unlimited_visibility: z.boolean().default(false), groups: z.array(z.string()).optional(),