Fix error handling on role management screen (#23583) (#23701)

Fixes #23542 - old error handling was not working when API calls to create/update roles returned an error
This commit is contained in:
Larry Gregory 2018-10-02 16:14:31 -04:00 committed by GitHub
parent aeda9cfec9
commit ad8dc820c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View file

@ -44,7 +44,6 @@ interface Props {
allowDocumentLevelSecurity: boolean;
allowFieldLevelSecurity: boolean;
kibanaAppPrivileges: KibanaPrivilege[];
notifier: any;
spaces?: Space[];
spacesEnabled: boolean;
userProfile: UserProfile;
@ -275,7 +274,7 @@ export class EditRolePage extends Component<Props, State> {
formError: null,
});
const { httpClient, notifier } = this.props;
const { httpClient } = this.props;
const role = {
...this.state.role,
@ -292,13 +291,13 @@ export class EditRolePage extends Component<Props, State> {
this.backToRoleList();
})
.catch((error: any) => {
notifier.error(get(error, 'data.message'));
toastNotifications.addDanger(get(error, 'data.message'));
});
}
};
public handleDeleteRole = () => {
const { httpClient, role, notifier } = this.props;
const { httpClient, role } = this.props;
deleteRole(httpClient, role.name)
.then(() => {
@ -306,7 +305,7 @@ export class EditRolePage extends Component<Props, State> {
this.backToRoleList();
})
.catch((error: any) => {
notifier.error(get(error, 'data.message'));
toastNotifications.addDanger(get(error, 'data.message'));
});
};

View file

@ -91,8 +91,6 @@ routes.when(`${EDIT_ROLES_PATH}/:name?`, {
const $route = $injector.get('$route');
const Private = $injector.get('Private');
const Notifier = $injector.get('Notifier');
const role = $route.current.locals.role;
const xpackInfo = Private(XPackInfoProvider);
@ -139,7 +137,6 @@ routes.when(`${EDIT_ROLES_PATH}/:name?`, {
httpClient={$http}
allowDocumentLevelSecurity={allowDocumentLevelSecurity}
allowFieldLevelSecurity={allowFieldLevelSecurity}
notifier={Notifier}
spaces={spaces}
spacesEnabled={enableSpaceAwarePrivileges}
userProfile={userProfile}