Skip to content

Commit

Permalink
Fix bug where custom permission groups are missing (#1636)
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Ho <dxho@amazon.com>
(cherry picked from commit d14bb68)
  • Loading branch information
derek-ho authored and github-actions[bot] committed Nov 2, 2023
1 parent c4cd81e commit f6673da
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
18 changes: 16 additions & 2 deletions public/apps/configuration/panels/role-edit/role-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit f6673da

Please sign in to comment.