Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where custom permission groups are missing #1636

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

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 !== 'index' && actionGroup[1].type !== 'cluster'))

Check failure on line 178 in public/apps/configuration/panels/role-edit/role-edit.tsx

View workflow job for this annotation

GitHub Actions / Run unit tests (ubuntu-latest)

Replace `(actionGroup)·=>·(actionGroup[1].type·!==·'index'·&&··actionGroup[1].type·!==·'cluster')` with `⏎··········(actionGroup)·=>·actionGroup[1].type·!==·'index'·&&·actionGroup[1].type·!==·'cluster'⏎········`

Check failure on line 178 in public/apps/configuration/panels/role-edit/role-edit.tsx

View workflow job for this annotation

GitHub Actions / Run unit tests (windows-latest)

Replace `(actionGroup)·=>·(actionGroup[1].type·!==·'index'·&&··actionGroup[1].type·!==·'cluster')` with `␍⏎··········(actionGroup)·=>·actionGroup[1].type·!==·'index'·&&·actionGroup[1].type·!==·'cluster'␍⏎········`

Check failure on line 178 in public/apps/configuration/panels/role-edit/role-edit.tsx

View workflow job for this annotation

GitHub Actions / Run unit tests (macos-latest)

Replace `(actionGroup)·=>·(actionGroup[1].type·!==·'index'·&&··actionGroup[1].type·!==·'cluster')` with `⏎··········(actionGroup)·=>·actionGroup[1].type·!==·'index'·&&·actionGroup[1].type·!==·'cluster'⏎········`
.map((actionGroup) => actionGroup[0])
.map(stringToComboBoxOption),
},
{
label: 'Cluster permissions',
options: CLUSTER_PERMISSIONS.map(stringToComboBoxOption),
Expand All @@ -180,12 +187,19 @@

const indexWisePermissionOptions = [
{
label: 'Permission groups',
label: 'Index permission groups',
options: actionGroups
.filter((actionGroup) => actionGroup[1].type === 'index')
.map((actionGroup) => actionGroup[0])
.map(stringToComboBoxOption),
},
{
derek-ho marked this conversation as resolved.
Show resolved Hide resolved
label: 'Other permission groups',
options: actionGroups
derek-ho marked this conversation as resolved.
Show resolved Hide resolved
.filter((actionGroup) => (actionGroup[1].type !== 'index' && actionGroup[1].type !== 'cluster'))

Check failure on line 199 in public/apps/configuration/panels/role-edit/role-edit.tsx

View workflow job for this annotation

GitHub Actions / Run unit tests (ubuntu-latest)

Replace `(actionGroup)·=>·(actionGroup[1].type·!==·'index'·&&··actionGroup[1].type·!==·'cluster')` with `⏎··········(actionGroup)·=>·actionGroup[1].type·!==·'index'·&&·actionGroup[1].type·!==·'cluster'⏎········`

Check failure on line 199 in public/apps/configuration/panels/role-edit/role-edit.tsx

View workflow job for this annotation

GitHub Actions / Run unit tests (windows-latest)

Replace `(actionGroup)·=>·(actionGroup[1].type·!==·'index'·&&··actionGroup[1].type·!==·'cluster')` with `␍⏎··········(actionGroup)·=>·actionGroup[1].type·!==·'index'·&&·actionGroup[1].type·!==·'cluster'␍⏎········`

Check failure on line 199 in public/apps/configuration/panels/role-edit/role-edit.tsx

View workflow job for this annotation

GitHub Actions / Run unit tests (macos-latest)

Replace `(actionGroup)·=>·(actionGroup[1].type·!==·'index'·&&··actionGroup[1].type·!==·'cluster')` with `⏎··········(actionGroup)·=>·actionGroup[1].type·!==·'index'·&&·actionGroup[1].type·!==·'cluster'⏎········`
.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
Loading