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

[App Search] Role mappings migration part 1 #94346

Merged
Show file tree
Hide file tree
Changes from 5 commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const EnginesTable: React.FC<EnginesTableProps> = ({
const { navigateToUrl } = useValues(KibanaLogic);
const { hasPlatinumLicense } = useValues(LicensingLogic);

const generteEncodedEnginePath = (engineName: string) =>
const generateEncodedEnginePath = (engineName: string) =>
generateEncodedPath(ENGINE_PATH, { engineName });
const sendEngineTableLinkClickTelemetry = () =>
sendAppSearchTelemetry({
Expand All @@ -71,7 +71,7 @@ export const EnginesTable: React.FC<EnginesTableProps> = ({
render: (name: string) => (
<EuiLinkTo
data-test-subj="EngineNameLink"
to={generteEncodedEnginePath(name)}
to={generateEncodedEnginePath(name)}
onClick={sendEngineTableLinkClickTelemetry}
>
{name}
Expand Down Expand Up @@ -159,7 +159,7 @@ export const EnginesTable: React.FC<EnginesTableProps> = ({
icon: 'eye',
onClick: (engineDetails) => {
sendEngineTableLinkClickTelemetry();
navigateToUrl(generteEncodedEnginePath(engineDetails.name));
scottybollinger marked this conversation as resolved.
Show resolved Hide resolved
navigateToUrl(generateEncodedEnginePath(engineDetails.name));
},
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { generateRoleMappingPath } from './utils';

describe('generateRoleMappingPath', () => {
it('generates paths with roleId filled', () => {
const roleId = 'role123';

expect(generateRoleMappingPath(roleId)).toEqual(`/role-mappings/${roleId}/edit`);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { ROLE_MAPPING_PATH } from '../../routes';
import { generateEncodedPath } from '../../utils/encode_path_params';

export const generateRoleMappingPath = (roleId: string) =>
generateEncodedPath(ROLE_MAPPING_PATH, { roleId });
scottybollinger marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ import { docLinks } from '../shared/doc_links';
export const DOCS_PREFIX = docLinks.appSearchBase;

export const ROOT_PATH = '/';
export const NOT_FOUND_PATH = '/404';
scottybollinger marked this conversation as resolved.
Show resolved Hide resolved
export const SETUP_GUIDE_PATH = '/setup_guide';
export const LIBRARY_PATH = '/library';
export const SETTINGS_PATH = '/settings/account';
export const CREDENTIALS_PATH = '/credentials';
export const ROLE_MAPPINGS_PATH = '#/role-mappings'; // This page seems to 404 if the # isn't included

export const ROLE_MAPPINGS_PATH = '/role-mappings';
scottybollinger marked this conversation as resolved.
Show resolved Hide resolved
export const ROLE_MAPPING_PATH = `${ROLE_MAPPINGS_PATH}/:roleId/edit`;
scottybollinger marked this conversation as resolved.
Show resolved Hide resolved
export const ROLE_MAPPING_NEW_PATH = `${ROLE_MAPPINGS_PATH}/new`;

export const ENGINES_PATH = '/engines';
export const ENGINE_CREATION_PATH = '/engine_creation';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { roleHasScopedEngines } from './';

describe('roleHasScopedEngines()', () => {
describe('roleHasScopedEngines', () => {
cee-chen marked this conversation as resolved.
Show resolved Hide resolved
it('returns false for owner and admin roles', () => {
expect(roleHasScopedEngines('owner')).toEqual(false);
expect(roleHasScopedEngines('admin')).toEqual(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import { shallow, ShallowWrapper } from 'enzyme';

import { EuiComboBox, EuiFieldText } from '@elastic/eui';

import { AttributeSelector, AttributeName } from './attribute_selector';
import { AttributeName } from '../types';

import { AttributeSelector } from './attribute_selector';
import { ANY_AUTH_PROVIDER, ANY_AUTH_PROVIDER_OPTION_LABEL } from './constants';

const handleAttributeSelectorChange = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
EuiTitle,
} from '@elastic/eui';

import { AttributeName, AttributeExamples } from '../types';

import {
ANY_AUTH_PROVIDER,
ANY_AUTH_PROVIDER_OPTION_LABEL,
Expand All @@ -31,8 +33,6 @@ import {
ATTRIBUTE_VALUE_LABEL,
} from './constants';

export type AttributeName = keyof AttributeExamples | 'role';

interface Props {
attributeName: AttributeName;
attributeValue?: string;
Expand All @@ -47,12 +47,6 @@ interface Props {
handleAuthProviderChange?(value: string[]): void;
}

interface AttributeExamples {
username: string;
email: string;
metadata: string;
}

interface ParentOption extends EuiComboBoxOptionOption<string> {
label: string;
options: ChildOption[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,25 @@ export const MANAGE_ROLE_MAPPING_BUTTON = i18n.translate(
defaultMessage: 'Manage',
}
);

export const ROLE_MAPPINGS_TITLE = i18n.translate(
'xpack.enterpriseSearch.roleMapping.roleMappingsTitle',
{
defaultMessage: 'Users & roles',
}
);

export const EMPTY_ROLE_MAPPINGS_TITLE = i18n.translate(
'xpack.enterpriseSearch.roleMapping.emptyRoleMappingsTitle',
{
defaultMessage: 'No role mappings yet',
}
);

export const ROLE_MAPPINGS_DESCRIPTION = i18n.translate(
'xpack.enterpriseSearch.roleMapping.roleMappingsDescription',
scottybollinger marked this conversation as resolved.
Show resolved Hide resolved
{
defaultMessage:
'Define role mappings for elasticsearch-native and elasticsearch-saml authentication.',
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,17 @@ export interface RoleRules {
metadata?: string;
}

export interface AttributeExamples {
username: string;
email: string;
metadata: string;
}

export type AttributeName = keyof AttributeExamples | 'role';

export interface RoleMapping {
id: string;
attributeName: string;
attributeName: AttributeName;
attributeValue: string;
authProvider: string[];
roleType: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ export const GROUP_ASSIGNMENT_ALL_GROUPS_LABEL = i18n.translate(
}
);

export const EMPTY_ROLE_MAPPINGS_TITLE = i18n.translate(
'xpack.enterpriseSearch.workplaceSearch.roleMapping.emptyRoleMappingsTitle',
{
defaultMessage: 'No role mappings yet',
}
);

export const EMPTY_ROLE_MAPPINGS_BODY = i18n.translate(
'xpack.enterpriseSearch.workplaceSearch.roleMapping.emptyRoleMappingsBody',
{
Expand All @@ -80,18 +73,3 @@ export const ROLE_MAPPINGS_TABLE_HEADER = i18n.translate(
defaultMessage: 'Group Access',
}
);

export const ROLE_MAPPINGS_TITLE = i18n.translate(
'xpack.enterpriseSearch.workplaceSearch.roleMapping.roleMappingsTitle',
{
defaultMessage: 'Users & roles',
}
);

export const ROLE_MAPPINGS_DESCRIPTION = i18n.translate(
'xpack.enterpriseSearch.workplaceSearch.roleMapping.roleMappingsDescription',
{
defaultMessage:
'Define role mappings for elasticsearch-native and elasticsearch-saml authentication.',
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ import { EuiEmptyPrompt } from '@elastic/eui';
import { FlashMessages } from '../../../shared/flash_messages';
import { Loading } from '../../../shared/loading';
import { AddRoleMappingButton, RoleMappingsTable } from '../../../shared/role_mapping';
import { ViewContentHeader } from '../../components/shared/view_content_header';
import { getRoleMappingPath, ROLE_MAPPING_NEW_PATH } from '../../routes';

import {
EMPTY_ROLE_MAPPINGS_TITLE,
EMPTY_ROLE_MAPPINGS_BODY,
ROLE_MAPPINGS_TABLE_HEADER,
ROLE_MAPPINGS_TITLE,
ROLE_MAPPINGS_DESCRIPTION,
} from './constants';
} from '../../../shared/role_mapping/constants';
import { ViewContentHeader } from '../../components/shared/view_content_header';
import { getRoleMappingPath, ROLE_MAPPING_NEW_PATH } from '../../routes';

import { EMPTY_ROLE_MAPPINGS_BODY, ROLE_MAPPINGS_TABLE_HEADER } from './constants';
scottybollinger marked this conversation as resolved.
Show resolved Hide resolved

import { RoleMappingsLogic } from './role_mappings_logic';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { kea, MakeLogicType } from 'kea';
import { clearFlashMessages, flashAPIErrors } from '../../../shared/flash_messages';
import { HttpLogic } from '../../../shared/http';
import { KibanaLogic } from '../../../shared/kibana';
import { AttributeName } from '../../../shared/role_mapping/attribute_selector';
import { ANY_AUTH_PROVIDER } from '../../../shared/role_mapping/constants';
import { AttributeName } from '../../../shared/types';
import { ROLE_MAPPINGS_PATH } from '../../routes';
import { RoleGroup, WSRoleMapping, Role } from '../../types';

Expand Down