From d14bb6875cfec22e1bd790ad7b3103755832a366 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 2 Nov 2023 14:53:50 -0400 Subject: [PATCH] Fix bug where custom permission groups are missing (#1636) Signed-off-by: Derek Ho --- .../panels/role-edit/role-edit.tsx | 18 ++++++++++-- .../test/role-edit-filtering.test.tsx | 29 +++++++++++++++++-- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/public/apps/configuration/panels/role-edit/role-edit.tsx b/public/apps/configuration/panels/role-edit/role-edit.tsx index 142cba1b3..e5b3c832a 100644 --- a/public/apps/configuration/panels/role-edit/role-edit.tsx +++ b/public/apps/configuration/panels/role-edit/role-edit.tsx @@ -166,12 +166,19 @@ export function RoleEdit(props: RoleEditDeps) { const clusterWisePermissionOptions = [ { - label: 'Permission groups', + label: 'Cluster permission groups', options: actionGroups .filter((actionGroup) => actionGroup[1].type === 'cluster') .map((actionGroup) => actionGroup[0]) .map(stringToComboBoxOption), }, + { + label: 'Other permission groups', + options: actionGroups + .filter((actionGroup) => actionGroup[1].type === undefined) + .map((actionGroup) => actionGroup[0]) + .map(stringToComboBoxOption), + }, { label: 'Cluster permissions', options: CLUSTER_PERMISSIONS.map(stringToComboBoxOption), @@ -180,12 +187,19 @@ export function RoleEdit(props: RoleEditDeps) { const indexWisePermissionOptions = [ { - label: 'Permission groups', + label: 'Index permission groups', options: actionGroups .filter((actionGroup) => actionGroup[1].type === 'index') .map((actionGroup) => actionGroup[0]) .map(stringToComboBoxOption), }, + { + label: 'Other permission groups', + options: actionGroups + .filter((actionGroup) => actionGroup[1].type === undefined) + .map((actionGroup) => actionGroup[0]) + .map(stringToComboBoxOption), + }, { label: 'Index permissions', options: INDEX_PERMISSIONS.map(stringToComboBoxOption), diff --git a/public/apps/configuration/panels/role-edit/test/role-edit-filtering.test.tsx b/public/apps/configuration/panels/role-edit/test/role-edit-filtering.test.tsx index 7142db663..4f3a4f909 100644 --- a/public/apps/configuration/panels/role-edit/test/role-edit-filtering.test.tsx +++ b/public/apps/configuration/panels/role-edit/test/role-edit-filtering.test.tsx @@ -16,7 +16,6 @@ import React from 'react'; import { ClusterPermissionPanel } from '../cluster-permission-panel'; import { RoleEdit } from '../role-edit'; -import { ActionGroupItem } from '../../../types'; import { fetchActionGroups } from '../../../utils/action-groups-utils'; import { render, waitFor } from '@testing-library/react'; @@ -67,6 +66,14 @@ describe('Role edit filtering', () => { description: 'Manage pipelines', static: true, }, + custom: { + reserved: false, + hidden: false, + allowed_actions: ['cluster:admin/ingest/pipeline/*'], + type: undefined, + description: 'Custom group', + static: true, + }, }); it('basic cluster permission panel rendering', async () => { @@ -98,13 +105,21 @@ describe('Role edit filtering', () => { // Cluster Permission Panel props is filtered to action groups with type cluster, and only the cluster permission constants expect(props.optionUniverse).toEqual([ { - label: 'Permission groups', + label: 'Cluster permission groups', options: [ { label: 'cluster_manage_pipelines', }, ], }, + { + label: 'Other permission groups', + options: [ + { + label: 'custom', + }, + ], + }, { label: 'Cluster permissions', options: CLUSTER_PERMISSIONS.map((x) => { @@ -143,13 +158,21 @@ describe('Role edit filtering', () => { // Index Permission Panel props is filtered to action groups with type index, and only the index permission constants expect(props.optionUniverse).toEqual([ { - label: 'Permission groups', + label: 'Index permission groups', options: [ { label: 'data_access', }, ], }, + { + label: 'Other permission groups', + options: [ + { + label: 'custom', + }, + ], + }, { label: 'Index permissions', options: INDEX_PERMISSIONS.map((x) => {