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

Add cluster info to toasts, adds cluster info to URL #1877

Merged
Show file tree
Hide file tree
Changes from 20 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 @@ -123,4 +123,4 @@ jobs:
uses: ./.github/actions/run-cypress-tests
with:
dashboards_config_file: opensearch_dashboards_multidatasources.yml
yarn_command: 'yarn cypress:run --browser chrome --headed --env LOGIN_AS_ADMIN=true --spec "test/cypress/e2e/multi-datasources/multi_datasources_enabled.spec.js"'
yarn_command: 'yarn cypress:run --browser chrome --env LOGIN_AS_ADMIN=true --spec "test/cypress/e2e/multi-datasources/multi_datasources_enabled.spec.js"'
2 changes: 1 addition & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:
TEST_BROWSER_HEADLESS: 1
CI: 1
PLUGIN_NAME: opensearch-security
OPENSEARCH_INITIAL_ADMIN_PASSWORD: myStrongPassword123!
OPENSEARCH_INITIAL_ADMIN_PASSWORD: admin

jobs:
tests:
Expand Down
7 changes: 5 additions & 2 deletions public/apps/configuration/app-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { EuiBreadcrumb, EuiPage, EuiPageBody, EuiPageSideBar } from '@elastic/eu
import { flow, partial } from 'lodash';
import React, { createContext, useState } from 'react';
import { HashRouter as Router, Route, Switch, Redirect } from 'react-router-dom';
import { DataSourceOption } from '../../../../../src/plugins/data_source_management/public/components/data_source_selector/data_source_selector';
import { DataSourceOption } from 'src/plugins/data_source_management/public/components/data_source_menu/types';
import { AppDependencies } from '../types';
import { AuditLogging } from './panels/audit-logging/audit-logging';
import { AuditLoggingEditSettings } from './panels/audit-logging/audit-logging-edit-settings';
Expand All @@ -41,6 +41,7 @@ import { Action, RouteItem, SubAction } from './types';
import { ResourceType } from '../../../common';
import { buildHashUrl, buildUrl } from './utils/url-builder';
import { CrossPageToast } from './cross-page-toast';
import { getDataSourceFromUrl } from '../../utils/datasource-utils';

const LANDING_PAGE_URL = '/getstarted';

Expand Down Expand Up @@ -155,7 +156,9 @@ export const DataSourceContext = createContext<DataSourceContextType | null>(nul

export function AppRouter(props: AppDependencies) {
const setGlobalBreadcrumbs = flow(getBreadcrumbs, props.coreStart.chrome.setBreadcrumbs);
const [dataSource, setDataSource] = useState<DataSourceOption>(LocalCluster);
const dataSourceFromUrl = getDataSourceFromUrl();

const [dataSource, setDataSource] = useState<DataSourceOption>(dataSourceFromUrl);

return (
<DataSourceContext.Provider value={{ dataSource, setDataSource }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ exports[`Audit logs render when AuditLoggingSettings.enabled is true 1`] = `
<div
className="panel-restrict-width"
>
<SecurityPluginTopNavMenu
<Memo()
derek-ho marked this conversation as resolved.
Show resolved Hide resolved
coreStart={
Object {
"http": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export function InternalUserEdit(props: InternalUserEditDeps) {
const [toasts, addToast, removeToast] = useToastState();

const [isFormValid, setIsFormValid] = useState<boolean>(true);
const dataSourceEnabled = !!props.depsStart.dataSource?.dataSourceEnabled;
const { dataSource, setDataSource } = useContext(DataSourceContext)!;

React.useEffect(() => {
Expand Down Expand Up @@ -135,7 +136,13 @@ export function InternalUserEdit(props: InternalUserEditDeps) {
setCrossPageToast(buildUrl(ResourceType.users), {
id: 'updateUserSucceeded',
color: 'success',
title: getSuccessToastMessage('User', props.action, userName),
title: `${getSuccessToastMessage(
'User',
props.action,
userName,
dataSourceEnabled,
dataSource
derek-ho marked this conversation as resolved.
Show resolved Hide resolved
)}`,
});
// Redirect to user listing
window.location.href = buildHashUrl(ResourceType.users);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('Internal user edit', () => {
sourceUserName={sampleUsername}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -77,7 +77,7 @@ describe('Internal user edit', () => {
sourceUserName={sampleUsername}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -98,7 +98,7 @@ describe('Internal user edit', () => {
sourceUserName={sampleUsername}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -118,7 +118,7 @@ describe('Internal user edit', () => {
sourceUserName={sampleUsername}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -140,7 +140,7 @@ describe('Internal user edit', () => {
sourceUserName={sampleUsername}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export function PermissionList(props: AppDependencies) {
const [selection, setSelection] = React.useState<PermissionListingItem[]>([]);
const [itemIdToExpandedRowMap, setItemIdToExpandedRowMap] = useState<ExpandedRowMapInterface>({});

const dataSourceEnabled = !!props.depsStart.dataSource?.dataSourceEnabled;
const { dataSource, setDataSource } = useContext(DataSourceContext)!;

// Modal state
Expand Down Expand Up @@ -305,7 +306,13 @@ export function PermissionList(props: AppDependencies) {
fetchData();
addToast({
id: 'saveSucceeded',
title: getSuccessToastMessage('Action group', action, groupName),
title: `${getSuccessToastMessage(
'Action group',
action,
groupName,
dataSourceEnabled,
dataSource
)}`,
color: 'success',
});
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('Permission list page ', () => {
const component = shallow(
<PermissionList
coreStart={{} as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -123,7 +123,7 @@ describe('Permission list page ', () => {
shallow(
<PermissionList
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -145,7 +145,7 @@ describe('Permission list page ', () => {
shallow(
<PermissionList
coreStart={{} as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -159,7 +159,7 @@ describe('Permission list page ', () => {
const component = shallow(
<PermissionList
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -186,7 +186,7 @@ describe('Permission list page ', () => {
const component = shallow(
<PermissionList
coreStart={{} as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -203,7 +203,7 @@ describe('Permission list page ', () => {
shallow(
<PermissionList
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -223,7 +223,7 @@ describe('Permission list page ', () => {
const component = shallow(
<PermissionList
coreStart={{} as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand Down
9 changes: 8 additions & 1 deletion public/apps/configuration/panels/role-edit/role-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export function RoleEdit(props: RoleEditDeps) {

const [isFormValid, setIsFormValid] = useState<boolean>(true);

const dataSourceEnabled = !!props.depsStart.dataSource?.dataSourceEnabled;
const { dataSource, setDataSource } = useContext(DataSourceContext)!;

React.useEffect(() => {
Expand Down Expand Up @@ -174,7 +175,13 @@ export function RoleEdit(props: RoleEditDeps) {
setCrossPageToast(buildUrl(ResourceType.roles, Action.view, roleName), {
id: 'updateRoleSucceeded',
color: 'success',
title: getSuccessToastMessage('Role', props.action, roleName),
title: `${getSuccessToastMessage(
'Role',
props.action,
roleName,
dataSourceEnabled,
dataSource
)}`,
});
// Redirect to role view
window.location.href = buildHashUrl(ResourceType.roles, Action.view, roleName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('Role edit', () => {
sourceRoleName={sampleSourceRole}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -89,7 +89,7 @@ describe('Role edit', () => {
sourceRoleName={sampleSourceRole}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -112,7 +112,7 @@ describe('Role edit', () => {
sourceRoleName={sampleSourceRole}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { setCrossPageToast } from '../../utils/storage-utils';
import { ExternalLink } from '../../utils/display-utils';
import { SecurityPluginTopNavMenu } from '../../top-nav-menu';
import { DataSourceContext } from '../../app-router';
import { createDataSourceQuery } from '../../../../utils/datasource-utils';
import { createDataSourceQuery, getClusterInfoIfEnabled } from '../../../../utils/datasource-utils';

interface RoleEditMappedUserProps extends BreadcrumbsPageDependencies {
roleName: string;
Expand All @@ -63,6 +63,7 @@ export function RoleEditMappedUser(props: RoleEditMappedUserProps) {
const [userNames, setUserNames] = useState<string[]>([]);
const [hosts, setHosts] = React.useState<string[]>([]);
const [toasts, addToast, removeToast] = useToastState();
const dataSourceEnabled = !!props.depsStart.dataSource?.dataSourceEnabled;
const { dataSource, setDataSource } = useContext(DataSourceContext)!;

React.useEffect(() => {
Expand Down Expand Up @@ -130,7 +131,10 @@ export function RoleEditMappedUser(props: RoleEditMappedUserProps) {
{
id: 'updateRoleMappingSucceeded',
color: 'success',
title: 'Role "' + props.roleName + '" successfully updated.',
title: `Role "${props.roleName}" successfully updated ${getClusterInfoIfEnabled(
dataSourceEnabled,
dataSource
)}`,
}
);
window.location.href = buildHashUrl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('Role mapping edit', () => {
roleName={sampleRole}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -81,7 +81,7 @@ describe('Role mapping edit', () => {
roleName={sampleRole}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -102,7 +102,7 @@ describe('Role mapping edit', () => {
roleName={sampleRole}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand Down Expand Up @@ -135,7 +135,7 @@ describe('Role mapping edit', () => {
roleName={sampleRole}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand Down
8 changes: 6 additions & 2 deletions public/apps/configuration/panels/role-view/role-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import { requestDeleteRoles } from '../../utils/role-list-utils';
import { setCrossPageToast } from '../../utils/storage-utils';
import { DataSourceContext } from '../../app-router';
import { SecurityPluginTopNavMenu } from '../../top-nav-menu';
import { createDataSourceQuery } from '../../../../utils/datasource-utils';
import { createDataSourceQuery, getClusterInfoIfEnabled } from '../../../../utils/datasource-utils';

interface RoleViewProps extends BreadcrumbsPageDependencies {
roleName: string;
Expand Down Expand Up @@ -111,6 +111,7 @@ export function RoleView(props: RoleViewProps) {
const [toasts, addToast, removeToast] = useToastState();
const [isReserved, setIsReserved] = React.useState(false);
const [loading, setLoading] = React.useState(false);
const dataSourceEnabled = !!props.depsStart.dataSource?.dataSourceEnabled;
const { dataSource, setDataSource } = useContext(DataSourceContext)!;

const PERMISSIONS_TAB_INDEX = 0;
Expand Down Expand Up @@ -378,7 +379,10 @@ export function RoleView(props: RoleViewProps) {
setCrossPageToast(buildUrl(ResourceType.roles), {
id: 'deleteRole',
color: 'success',
title: props.roleName + ' deleted.',
title: `${props.roleName} deleted ${getClusterInfoIfEnabled(
dataSourceEnabled,
dataSource
)}`,
});
window.location.href = buildHashUrl(ResourceType.roles);
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`Role view basic rendering when permission tab is selected 1`] = `
<Fragment>
<SecurityPluginTopNavMenu
<Memo()
buildBreadcrumbs={
[MockFunction] {
"calls": Array [
Expand All @@ -25,7 +25,7 @@ exports[`Role view basic rendering when permission tab is selected 1`] = `
}
}
dataSourcePickerReadOnly={true}
navigation={Object {}}
depsStart={Object {}}
params={Object {}}
prevAction=""
roleName="role"
Expand Down Expand Up @@ -327,7 +327,7 @@ exports[`Role view basic rendering when permission tab is selected 1`] = `

exports[`Role view renders when mapped user tab is selected 1`] = `
<Fragment>
<SecurityPluginTopNavMenu
<Memo()
buildBreadcrumbs={
[MockFunction] {
"calls": Array [
Expand All @@ -350,7 +350,7 @@ exports[`Role view renders when mapped user tab is selected 1`] = `
}
}
dataSourcePickerReadOnly={true}
navigation={Object {}}
depsStart={Object {}}
params={Object {}}
prevAction="mapuser"
roleName="role"
Expand Down
Loading
Loading