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 3 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
9 changes: 8 additions & 1 deletion public/apps/configuration/app-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
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,13 @@

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

Check failure on line 160 in public/apps/configuration/app-router.tsx

View workflow job for this annotation

GitHub Actions / Run unit tests (ubuntu-latest)

Insert `;`

Check failure on line 160 in public/apps/configuration/app-router.tsx

View workflow job for this annotation

GitHub Actions / Run unit tests (windows-latest)

Insert `;`

Check failure on line 160 in public/apps/configuration/app-router.tsx

View workflow job for this annotation

GitHub Actions / Run unit tests (macos-latest)

Insert `;`

Check failure on line 161 in public/apps/configuration/app-router.tsx

View workflow job for this annotation

GitHub Actions / Run unit tests (ubuntu-latest)

Delete `··`

Check failure on line 161 in public/apps/configuration/app-router.tsx

View workflow job for this annotation

GitHub Actions / Run unit tests (windows-latest)

Delete `··`

Check failure on line 161 in public/apps/configuration/app-router.tsx

View workflow job for this annotation

GitHub Actions / Run unit tests (macos-latest)

Delete `··`
const [dataSource, setDataSource] = useState<DataSourceOption>(
dataSourceId ? dataSourceId : null
);
console.log(dataSource)

Check failure on line 165 in public/apps/configuration/app-router.tsx

View workflow job for this annotation

GitHub Actions / Run unit tests (ubuntu-latest)

Insert `;`

Check failure on line 165 in public/apps/configuration/app-router.tsx

View workflow job for this annotation

GitHub Actions / Run unit tests (windows-latest)

Insert `;`

Check failure on line 165 in public/apps/configuration/app-router.tsx

View workflow job for this annotation

GitHub Actions / Run unit tests (macos-latest)

Insert `;`

return (
<DataSourceContext.Provider value={{ dataSource, setDataSource }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import { constructErrorMessageAndLog } from '../../../error-utils';
import { BackendRolePanel } from './backend-role-panel';
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 InternalUserEditDeps extends BreadcrumbsPageDependencies {
action: 'create' | 'edit' | 'duplicate';
Expand All @@ -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,10 @@ 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)} ${getClusterInfoIfEnabled(
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 @@ -63,7 +63,7 @@ import { generateResourceName } from '../../utils/resource-utils';
import { DocLinks } from '../../constants';
import { SecurityPluginTopNavMenu } from '../../top-nav-menu';
import { DataSourceContext } from '../../app-router';
import { createDataSourceQuery } from '../../../../utils/datasource-utils';
import { createDataSourceQuery, getClusterInfoIfEnabled } from '../../../../utils/datasource-utils';

export function renderBooleanToCheckMark(value: boolean): React.ReactNode {
return value ? <EuiIcon type="check" /> : '';
Expand Down 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,11 @@ export function PermissionList(props: AppDependencies) {
fetchData();
addToast({
id: 'saveSucceeded',
title: getSuccessToastMessage('Action group', action, groupName),
title: `${getSuccessToastMessage(
'Action group',
action,
groupName
)} ${getClusterInfoIfEnabled(dataSourceEnabled, dataSource)}`,
derek-ho marked this conversation as resolved.
Show resolved Hide resolved
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
8 changes: 6 additions & 2 deletions public/apps/configuration/panels/role-edit/role-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import { generateResourceName } from '../../utils/resource-utils';
import { NameRow } from '../../utils/name-row';
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 RoleEditDeps extends BreadcrumbsPageDependencies {
action: 'create' | 'edit' | 'duplicate';
Expand Down 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,10 @@ 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)} ${getClusterInfoIfEnabled(
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 @@ -21,7 +21,7 @@ import { setCrossPageToast } from '../../../utils/storage-utils';
import { fetchTenantNameList } from '../../../utils/tenant-utils';
import { ClusterPermissionPanel } from '../cluster-permission-panel';
import { IndexPermissionPanel } from '../index-permission-panel';
import { getSuccessToastMessage, RoleEdit } from '../role-edit';
import { RoleEdit } from '../role-edit';
import { TenantPanel } from '../tenant-panel';

jest.mock('../../../utils/role-detail-utils', () => ({
Expand Down 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 @@ -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 @@ -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