mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Simplify deleting spaces (#99960)
* Simplify deleting spaces * Fixed i18n * Fix functional tests * Update x-pack/plugins/spaces/public/management/spaces_management_app.tsx Co-authored-by: Larry Gregory <lgregorydev@gmail.com> * Fix snapshots Co-authored-by: Larry Gregory <lgregorydev@gmail.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
3c166a1472
commit
574b4559e7
13 changed files with 197 additions and 468 deletions
|
@ -1,93 +0,0 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`ConfirmDeleteModal renders as expected 1`] = `
|
||||
<EuiModal
|
||||
className="spcConfirmDeleteModal"
|
||||
initialFocus="input[name=\\"confirmDeleteSpaceInput\\"]"
|
||||
onClose={[MockFunction]}
|
||||
>
|
||||
<EuiModalHeader>
|
||||
<EuiModalHeaderTitle
|
||||
data-test-subj="confirmModalTitleText"
|
||||
>
|
||||
<FormattedMessage
|
||||
defaultMessage="Delete space {spaceName}"
|
||||
id="xpack.spaces.management.confirmDeleteModal.confirmDeleteSpaceButtonLabel"
|
||||
values={
|
||||
Object {
|
||||
"spaceName": "'My Space'",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</EuiModalHeaderTitle>
|
||||
</EuiModalHeader>
|
||||
<EuiModalBody>
|
||||
<EuiText
|
||||
data-test-subj="confirmModalBodyText"
|
||||
>
|
||||
<p>
|
||||
<FormattedMessage
|
||||
defaultMessage="Deleting a space permanently removes the space and {allContents}. You can't undo this action."
|
||||
id="xpack.spaces.management.confirmDeleteModal.deletingSpaceWarningMessage"
|
||||
values={
|
||||
Object {
|
||||
"allContents": <strong>
|
||||
<FormattedMessage
|
||||
defaultMessage="all of its contents"
|
||||
id="xpack.spaces.management.confirmDeleteModal.allContentsText"
|
||||
values={Object {}}
|
||||
/>
|
||||
</strong>,
|
||||
}
|
||||
}
|
||||
/>
|
||||
</p>
|
||||
<EuiFormRow
|
||||
describedByIds={Array []}
|
||||
display="row"
|
||||
error="Space names do not match."
|
||||
fullWidth={false}
|
||||
hasChildLabel={true}
|
||||
hasEmptyLabelSpace={false}
|
||||
isInvalid={false}
|
||||
label="Confirm space name to delete"
|
||||
labelType="label"
|
||||
>
|
||||
<EuiFieldText
|
||||
data-test-subj="deleteSpaceInput"
|
||||
disabled={false}
|
||||
name="confirmDeleteSpaceInput"
|
||||
onChange={[Function]}
|
||||
value=""
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiText>
|
||||
</EuiModalBody>
|
||||
<EuiModalFooter>
|
||||
<EuiButtonEmpty
|
||||
data-test-subj="confirmModalCancelButton"
|
||||
isDisabled={false}
|
||||
onClick={[MockFunction]}
|
||||
>
|
||||
<FormattedMessage
|
||||
defaultMessage="Cancel"
|
||||
id="xpack.spaces.management.confirmDeleteModal.cancelButtonLabel"
|
||||
values={Object {}}
|
||||
/>
|
||||
</EuiButtonEmpty>
|
||||
<EuiButton
|
||||
color="danger"
|
||||
data-test-subj="confirmModalConfirmButton"
|
||||
fill={true}
|
||||
isLoading={false}
|
||||
onClick={[Function]}
|
||||
>
|
||||
<FormattedMessage
|
||||
defaultMessage=" Delete space and all contents"
|
||||
id="xpack.spaces.management.confirmDeleteModal.deleteSpaceAndAllContentsButtonLabel"
|
||||
values={Object {}}
|
||||
/>
|
||||
</EuiButton>
|
||||
</EuiModalFooter>
|
||||
</EuiModal>
|
||||
`;
|
|
@ -1,3 +0,0 @@
|
|||
.spcConfirmDeleteModal {
|
||||
max-width: $euiFormMaxWidth + ($euiSizeL * 2);
|
||||
}
|
|
@ -6,10 +6,10 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
|
||||
import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest';
|
||||
|
||||
import type { SpacesManager } from '../../../spaces_manager';
|
||||
import { spacesManagerMock } from '../../../spaces_manager/mocks';
|
||||
import { ConfirmDeleteModal } from './confirm_delete_modal';
|
||||
|
||||
|
@ -22,25 +22,53 @@ describe('ConfirmDeleteModal', () => {
|
|||
};
|
||||
|
||||
const spacesManager = spacesManagerMock.create();
|
||||
spacesManager.getActiveSpace.mockResolvedValue(space);
|
||||
|
||||
const onCancel = jest.fn();
|
||||
const onConfirm = jest.fn();
|
||||
|
||||
expect(
|
||||
shallowWithIntl(
|
||||
<ConfirmDeleteModal.WrappedComponent
|
||||
space={space}
|
||||
spacesManager={(spacesManager as unknown) as SpacesManager}
|
||||
onCancel={onCancel}
|
||||
onConfirm={onConfirm}
|
||||
intl={null as any}
|
||||
/>
|
||||
<ConfirmDeleteModal space={space} spacesManager={spacesManager} onCancel={onCancel} />
|
||||
)
|
||||
).toMatchSnapshot();
|
||||
).toMatchInlineSnapshot(`
|
||||
<EuiConfirmModal
|
||||
buttonColor="danger"
|
||||
cancelButtonText="Cancel"
|
||||
confirmButtonText="Delete space and all contents"
|
||||
isLoading={false}
|
||||
onCancel={[MockFunction]}
|
||||
onConfirm={[Function]}
|
||||
title="Delete space 'My Space'?"
|
||||
>
|
||||
<EuiText>
|
||||
<p>
|
||||
<FormattedMessage
|
||||
defaultMessage="This space and {allContents} will be permanently deleted."
|
||||
id="xpack.spaces.management.confirmDeleteModal.description"
|
||||
values={
|
||||
Object {
|
||||
"allContents": <strong>
|
||||
<FormattedMessage
|
||||
defaultMessage="all contents"
|
||||
id="xpack.spaces.management.confirmDeleteModal.allContents"
|
||||
values={Object {}}
|
||||
/>
|
||||
</strong>,
|
||||
}
|
||||
}
|
||||
/>
|
||||
</p>
|
||||
<p>
|
||||
<FormattedMessage
|
||||
defaultMessage="You can't recover deleted spaces."
|
||||
id="xpack.spaces.management.confirmDeleteModal.cannotUndoWarning"
|
||||
values={Object {}}
|
||||
/>
|
||||
</p>
|
||||
</EuiText>
|
||||
</EuiConfirmModal>
|
||||
`);
|
||||
});
|
||||
|
||||
it(`requires the space name to be typed before confirming`, () => {
|
||||
it('deletes the space when confirmed', async () => {
|
||||
const space = {
|
||||
id: 'my-space',
|
||||
name: 'My Space',
|
||||
|
@ -48,34 +76,23 @@ describe('ConfirmDeleteModal', () => {
|
|||
};
|
||||
|
||||
const spacesManager = spacesManagerMock.create();
|
||||
spacesManager.getActiveSpace.mockResolvedValue(space);
|
||||
|
||||
const onCancel = jest.fn();
|
||||
const onConfirm = jest.fn();
|
||||
const onSuccess = jest.fn();
|
||||
|
||||
const wrapper = mountWithIntl(
|
||||
<ConfirmDeleteModal.WrappedComponent
|
||||
<ConfirmDeleteModal
|
||||
space={space}
|
||||
spacesManager={(spacesManager as unknown) as SpacesManager}
|
||||
spacesManager={spacesManager}
|
||||
onCancel={onCancel}
|
||||
onConfirm={onConfirm}
|
||||
intl={null as any}
|
||||
onSuccess={onSuccess}
|
||||
/>
|
||||
);
|
||||
|
||||
const input = wrapper.find('input');
|
||||
expect(input).toHaveLength(1);
|
||||
await act(async () => {
|
||||
wrapper.find('EuiButton[data-test-subj="confirmModalConfirmButton"]').simulate('click');
|
||||
await spacesManager.deleteSpace.mock.results[0];
|
||||
});
|
||||
|
||||
input.simulate('change', { target: { value: 'My Invalid Space Name ' } });
|
||||
|
||||
const confirmButton = wrapper.find('button[data-test-subj="confirmModalConfirmButton"]');
|
||||
confirmButton.simulate('click');
|
||||
|
||||
expect(onConfirm).not.toHaveBeenCalled();
|
||||
|
||||
input.simulate('change', { target: { value: 'My Space' } });
|
||||
confirmButton.simulate('click');
|
||||
|
||||
expect(onConfirm).toHaveBeenCalledTimes(1);
|
||||
expect(spacesManager.deleteSpace).toHaveBeenLastCalledWith(space);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,224 +5,127 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import './confirm_delete_modal.scss';
|
||||
import { EuiCallOut, EuiConfirmModal, EuiSpacer, EuiText } from '@elastic/eui';
|
||||
import type { FunctionComponent } from 'react';
|
||||
import React from 'react';
|
||||
import useAsync from 'react-use/lib/useAsync';
|
||||
import useAsyncFn from 'react-use/lib/useAsyncFn';
|
||||
|
||||
import type { CommonProps, EuiModalProps } from '@elastic/eui';
|
||||
import {
|
||||
EuiButton,
|
||||
EuiButtonEmpty,
|
||||
EuiCallOut,
|
||||
EuiFieldText,
|
||||
EuiFormRow,
|
||||
EuiModal,
|
||||
EuiModalBody,
|
||||
EuiModalFooter,
|
||||
EuiModalHeader,
|
||||
EuiModalHeaderTitle,
|
||||
EuiSpacer,
|
||||
EuiText,
|
||||
} from '@elastic/eui';
|
||||
import type { ChangeEvent } from 'react';
|
||||
import React, { Component } from 'react';
|
||||
|
||||
import type { InjectedIntl } from '@kbn/i18n/react';
|
||||
import { FormattedMessage, injectI18n } from '@kbn/i18n/react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import type { Space } from 'src/plugins/spaces_oss/common';
|
||||
|
||||
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
|
||||
import type { SpacesManager } from '../../../spaces_manager';
|
||||
|
||||
interface Props {
|
||||
space: Space;
|
||||
spacesManager: SpacesManager;
|
||||
onCancel: () => void;
|
||||
onConfirm: () => void;
|
||||
intl: InjectedIntl;
|
||||
onCancel(): void;
|
||||
onSuccess?(): void;
|
||||
}
|
||||
|
||||
interface State {
|
||||
confirmSpaceName: string;
|
||||
error: boolean | null;
|
||||
deleteInProgress: boolean;
|
||||
isDeletingCurrentSpace: boolean;
|
||||
}
|
||||
export const ConfirmDeleteModal: FunctionComponent<Props> = ({
|
||||
space,
|
||||
onSuccess,
|
||||
onCancel,
|
||||
spacesManager,
|
||||
}) => {
|
||||
const { services } = useKibana();
|
||||
|
||||
class ConfirmDeleteModalUI extends Component<Props, State> {
|
||||
public state = {
|
||||
confirmSpaceName: '',
|
||||
error: null,
|
||||
deleteInProgress: false,
|
||||
isDeletingCurrentSpace: false,
|
||||
};
|
||||
const { value: isCurrentSpace } = useAsync(
|
||||
async () => space.id === (await spacesManager.getActiveSpace()).id,
|
||||
[space.id]
|
||||
);
|
||||
|
||||
public componentDidMount() {
|
||||
isCurrentSpace(this.props.space, this.props.spacesManager).then((result) => {
|
||||
this.setState({
|
||||
isDeletingCurrentSpace: result,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public render() {
|
||||
const { space, onCancel, intl } = this.props;
|
||||
const { isDeletingCurrentSpace } = this.state;
|
||||
|
||||
let warning = null;
|
||||
if (isDeletingCurrentSpace) {
|
||||
const name = (
|
||||
<span>
|
||||
(<strong>{space.name}</strong>)
|
||||
</span>
|
||||
const [state, deleteSpace] = useAsyncFn(async () => {
|
||||
try {
|
||||
await spacesManager.deleteSpace(space);
|
||||
services.notifications!.toasts.addSuccess(
|
||||
i18n.translate('xpack.spaces.management.confirmDeleteModal.successMessage', {
|
||||
defaultMessage: "Deleted space '{name}'",
|
||||
values: { name: space.name },
|
||||
})
|
||||
);
|
||||
warning = (
|
||||
<>
|
||||
<EuiSpacer />
|
||||
<EuiCallOut color="warning">
|
||||
<EuiText>
|
||||
<FormattedMessage
|
||||
id="xpack.spaces.management.confirmDeleteModal.redirectAfterDeletingCurrentSpaceWarningMessage"
|
||||
defaultMessage="You are about to delete your current space {name}. You will be redirected to choose a different space if you continue."
|
||||
values={{ name }}
|
||||
/>
|
||||
</EuiText>
|
||||
</EuiCallOut>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// This is largely the same as the built-in EuiConfirmModal component, but we needed the ability
|
||||
// to disable the buttons since this could be a long-running operation
|
||||
|
||||
const modalProps: Omit<EuiModalProps, 'children'> & CommonProps = {
|
||||
onClose: onCancel,
|
||||
className: 'spcConfirmDeleteModal',
|
||||
initialFocus: 'input[name="confirmDeleteSpaceInput"]',
|
||||
};
|
||||
|
||||
return (
|
||||
<EuiModal {...modalProps}>
|
||||
<EuiModalHeader>
|
||||
<EuiModalHeaderTitle data-test-subj="confirmModalTitleText">
|
||||
<FormattedMessage
|
||||
id="xpack.spaces.management.confirmDeleteModal.confirmDeleteSpaceButtonLabel"
|
||||
defaultMessage="Delete space {spaceName}"
|
||||
values={{
|
||||
spaceName: "'" + space.name + "'",
|
||||
}}
|
||||
/>
|
||||
</EuiModalHeaderTitle>
|
||||
</EuiModalHeader>
|
||||
<EuiModalBody>
|
||||
<EuiText data-test-subj="confirmModalBodyText">
|
||||
<p>
|
||||
<FormattedMessage
|
||||
id="xpack.spaces.management.confirmDeleteModal.deletingSpaceWarningMessage"
|
||||
defaultMessage="Deleting a space permanently removes the space and {allContents}. You can't undo this action."
|
||||
values={{
|
||||
allContents: (
|
||||
<strong>
|
||||
<FormattedMessage
|
||||
id="xpack.spaces.management.confirmDeleteModal.allContentsText"
|
||||
defaultMessage="all of its contents"
|
||||
/>
|
||||
</strong>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
</p>
|
||||
|
||||
<EuiFormRow
|
||||
label={intl.formatMessage({
|
||||
id: 'xpack.spaces.management.confirmDeleteModal.confirmSpaceNameFormRowLabel',
|
||||
defaultMessage: 'Confirm space name to delete',
|
||||
})}
|
||||
isInvalid={!!this.state.error}
|
||||
error={intl.formatMessage({
|
||||
id: 'xpack.spaces.management.confirmDeleteModal.spaceNamesDoNoMatchErrorMessage',
|
||||
defaultMessage: 'Space names do not match.',
|
||||
})}
|
||||
>
|
||||
<EuiFieldText
|
||||
data-test-subj="deleteSpaceInput"
|
||||
name="confirmDeleteSpaceInput"
|
||||
value={this.state.confirmSpaceName}
|
||||
onChange={this.onSpaceNameChange}
|
||||
disabled={this.state.deleteInProgress}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
|
||||
{warning}
|
||||
</EuiText>
|
||||
</EuiModalBody>
|
||||
<EuiModalFooter>
|
||||
<EuiButtonEmpty
|
||||
data-test-subj="confirmModalCancelButton"
|
||||
onClick={onCancel}
|
||||
isDisabled={this.state.deleteInProgress}
|
||||
>
|
||||
<FormattedMessage
|
||||
id="xpack.spaces.management.confirmDeleteModal.cancelButtonLabel"
|
||||
defaultMessage="Cancel"
|
||||
/>
|
||||
</EuiButtonEmpty>
|
||||
|
||||
<EuiButton
|
||||
data-test-subj="confirmModalConfirmButton"
|
||||
onClick={this.onConfirm}
|
||||
fill
|
||||
color={'danger'}
|
||||
isLoading={this.state.deleteInProgress}
|
||||
>
|
||||
<FormattedMessage
|
||||
id="xpack.spaces.management.confirmDeleteModal.deleteSpaceAndAllContentsButtonLabel"
|
||||
defaultMessage=" Delete space and all contents"
|
||||
/>
|
||||
</EuiButton>
|
||||
</EuiModalFooter>
|
||||
</EuiModal>
|
||||
);
|
||||
}
|
||||
|
||||
private onSpaceNameChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
if (typeof this.state.error === 'boolean') {
|
||||
this.setState({
|
||||
confirmSpaceName: e.target.value,
|
||||
error: e.target.value !== this.props.space.name,
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
confirmSpaceName: e.target.value,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private onConfirm = async () => {
|
||||
if (this.state.confirmSpaceName === this.props.space.name) {
|
||||
const needsRedirect = this.state.isDeletingCurrentSpace;
|
||||
const spacesManager = this.props.spacesManager;
|
||||
|
||||
this.setState({
|
||||
deleteInProgress: true,
|
||||
});
|
||||
|
||||
await this.props.onConfirm();
|
||||
|
||||
this.setState({
|
||||
deleteInProgress: false,
|
||||
});
|
||||
|
||||
if (needsRedirect) {
|
||||
if (isCurrentSpace) {
|
||||
spacesManager.redirectToSpaceSelector();
|
||||
} else {
|
||||
onSuccess?.();
|
||||
}
|
||||
} else {
|
||||
this.setState({
|
||||
error: true,
|
||||
} catch (error) {
|
||||
services.notifications!.toasts.addDanger({
|
||||
title: i18n.translate('xpack.spaces.management.confirmDeleteModal.errorMessage', {
|
||||
defaultMessage: "Could not delete space '{name}'",
|
||||
values: { name: space.name },
|
||||
}),
|
||||
text: (error as any).body?.message || error.message,
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
}, [isCurrentSpace]);
|
||||
|
||||
async function isCurrentSpace(space: Space, spacesManager: SpacesManager) {
|
||||
return space.id === (await spacesManager.getActiveSpace()).id;
|
||||
}
|
||||
|
||||
export const ConfirmDeleteModal = injectI18n(ConfirmDeleteModalUI);
|
||||
return (
|
||||
<EuiConfirmModal
|
||||
title={i18n.translate('xpack.spaces.management.confirmDeleteModal.title', {
|
||||
defaultMessage: "Delete space '{name}'?",
|
||||
values: { name: space.name },
|
||||
})}
|
||||
onCancel={onCancel}
|
||||
onConfirm={deleteSpace}
|
||||
cancelButtonText={i18n.translate('xpack.spaces.management.confirmDeleteModal.cancelButton', {
|
||||
defaultMessage: 'Cancel',
|
||||
})}
|
||||
confirmButtonText={i18n.translate(
|
||||
'xpack.spaces.management.confirmDeleteModal.confirmButton',
|
||||
{
|
||||
defaultMessage:
|
||||
'{isLoading, select, true{Deleting space and all contents…} other{Delete space and all contents}}',
|
||||
values: { isLoading: state.loading },
|
||||
}
|
||||
)}
|
||||
buttonColor="danger"
|
||||
isLoading={state.loading}
|
||||
>
|
||||
{isCurrentSpace && (
|
||||
<>
|
||||
<EuiCallOut
|
||||
color="warning"
|
||||
iconType="alert"
|
||||
title={i18n.translate('xpack.spaces.management.confirmDeleteModal.currentSpaceTitle', {
|
||||
defaultMessage: 'You are currently in this space.',
|
||||
})}
|
||||
>
|
||||
<FormattedMessage
|
||||
id="xpack.spaces.management.confirmDeleteModal.currentSpaceDescription"
|
||||
defaultMessage="Once deleted, you must choose a different space."
|
||||
/>
|
||||
</EuiCallOut>
|
||||
<EuiSpacer />
|
||||
</>
|
||||
)}
|
||||
<EuiText>
|
||||
<p>
|
||||
<FormattedMessage
|
||||
id="xpack.spaces.management.confirmDeleteModal.description"
|
||||
defaultMessage="This space and {allContents} will be permanently deleted."
|
||||
values={{
|
||||
allContents: (
|
||||
<strong>
|
||||
<FormattedMessage
|
||||
id="xpack.spaces.management.confirmDeleteModal.allContents"
|
||||
defaultMessage="all contents"
|
||||
/>
|
||||
</strong>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
</p>
|
||||
<p>
|
||||
<FormattedMessage
|
||||
id="xpack.spaces.management.confirmDeleteModal.cannotUndoWarning"
|
||||
defaultMessage="You can't recover deleted spaces."
|
||||
/>
|
||||
</p>
|
||||
</EuiText>
|
||||
</EuiConfirmModal>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -95,44 +95,13 @@ export class DeleteSpacesButton extends Component<Props, State> {
|
|||
showConfirmDeleteModal: false,
|
||||
});
|
||||
}}
|
||||
onConfirm={this.deleteSpaces}
|
||||
onSuccess={() => {
|
||||
this.setState({
|
||||
showConfirmDeleteModal: false,
|
||||
});
|
||||
this.props.onDelete?.();
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
public deleteSpaces = async () => {
|
||||
const { spacesManager, space } = this.props;
|
||||
|
||||
this.setState({
|
||||
showConfirmDeleteModal: false,
|
||||
});
|
||||
|
||||
try {
|
||||
await spacesManager.deleteSpace(space);
|
||||
} catch (error) {
|
||||
const { message: errorMessage = '' } = error.data || error.body || {};
|
||||
|
||||
this.props.notifications.toasts.addDanger(
|
||||
i18n.translate('xpack.spaces.management.deleteSpacesButton.deleteSpaceErrorTitle', {
|
||||
defaultMessage: 'Error deleting space: {errorMessage}',
|
||||
values: { errorMessage },
|
||||
})
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const message = i18n.translate(
|
||||
'xpack.spaces.management.deleteSpacesButton.spaceSuccessfullyDeletedNotificationMessage',
|
||||
{
|
||||
defaultMessage: 'Deleted {spaceName} space.',
|
||||
values: { spaceName: space.name },
|
||||
}
|
||||
);
|
||||
|
||||
this.props.notifications.toasts.addSuccess(message);
|
||||
|
||||
if (this.props.onDelete) {
|
||||
this.props.onDelete();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -180,53 +180,16 @@ export class SpacesGridPage extends Component<Props, State> {
|
|||
showConfirmDeleteModal: false,
|
||||
});
|
||||
}}
|
||||
onConfirm={this.deleteSpace}
|
||||
onSuccess={() => {
|
||||
this.setState({
|
||||
showConfirmDeleteModal: false,
|
||||
});
|
||||
this.loadGrid();
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
public deleteSpace = async () => {
|
||||
const { spacesManager } = this.props;
|
||||
|
||||
const space = this.state.selectedSpace;
|
||||
|
||||
if (!space) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
showConfirmDeleteModal: false,
|
||||
});
|
||||
|
||||
try {
|
||||
await spacesManager.deleteSpace(space);
|
||||
} catch (error) {
|
||||
const { message: errorMessage = '' } = error.data || error.body || {};
|
||||
|
||||
this.props.notifications.toasts.addDanger(
|
||||
i18n.translate('xpack.spaces.management.spacesGridPage.errorDeletingSpaceErrorMessage', {
|
||||
defaultMessage: 'Error deleting space: {errorMessage}',
|
||||
values: {
|
||||
errorMessage,
|
||||
},
|
||||
})
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
this.loadGrid();
|
||||
|
||||
const message = i18n.translate(
|
||||
'xpack.spaces.management.spacesGridPage.spaceSuccessfullyDeletedNotificationMessage',
|
||||
{
|
||||
defaultMessage: 'Deleted "{spaceName}" space.',
|
||||
values: { spaceName: space.name },
|
||||
}
|
||||
);
|
||||
|
||||
this.props.notifications.toasts.addSuccess(message);
|
||||
};
|
||||
|
||||
public loadGrid = async () => {
|
||||
const { spacesManager, getFeatures, notifications } = this.props;
|
||||
|
||||
|
|
|
@ -14,7 +14,10 @@ import type { StartServicesAccessor } from 'src/core/public';
|
|||
import type { RegisterManagementAppArgs } from 'src/plugins/management/public';
|
||||
import type { Space } from 'src/plugins/spaces_oss/common';
|
||||
|
||||
import { RedirectAppLinks } from '../../../../../src/plugins/kibana_react/public';
|
||||
import {
|
||||
KibanaContextProvider,
|
||||
RedirectAppLinks,
|
||||
} from '../../../../../src/plugins/kibana_react/public';
|
||||
import type { PluginsStart } from '../plugin';
|
||||
import type { SpacesManager } from '../spaces_manager';
|
||||
|
||||
|
@ -36,22 +39,23 @@ export const spacesManagementApp = Object.freeze({
|
|||
title,
|
||||
|
||||
async mount({ element, setBreadcrumbs, history }) {
|
||||
const [startServices, { SpacesGridPage }, { ManageSpacePage }] = await Promise.all([
|
||||
const [
|
||||
[coreStart, { features }],
|
||||
{ SpacesGridPage },
|
||||
{ ManageSpacePage },
|
||||
] = await Promise.all([
|
||||
getStartServices(),
|
||||
import('./spaces_grid'),
|
||||
import('./edit_space'),
|
||||
]);
|
||||
|
||||
const [
|
||||
{ notifications, i18n: i18nStart, application, chrome },
|
||||
{ features },
|
||||
] = startServices;
|
||||
const spacesBreadcrumbs = [
|
||||
{
|
||||
text: title,
|
||||
href: `/`,
|
||||
},
|
||||
];
|
||||
const { notifications, i18n: i18nStart, application, chrome } = coreStart;
|
||||
|
||||
chrome.docTitle.change(title);
|
||||
|
||||
|
@ -119,23 +123,25 @@ export const spacesManagementApp = Object.freeze({
|
|||
};
|
||||
|
||||
render(
|
||||
<i18nStart.Context>
|
||||
<RedirectAppLinks application={application}>
|
||||
<Router history={history}>
|
||||
<Switch>
|
||||
<Route path={['', '/']} exact>
|
||||
<SpacesGridPageWithBreadcrumbs />
|
||||
</Route>
|
||||
<Route path="/create">
|
||||
<CreateSpacePageWithBreadcrumbs />
|
||||
</Route>
|
||||
<Route path="/edit/:spaceId">
|
||||
<EditSpacePageWithBreadcrumbs />
|
||||
</Route>
|
||||
</Switch>
|
||||
</Router>
|
||||
</RedirectAppLinks>
|
||||
</i18nStart.Context>,
|
||||
<KibanaContextProvider services={coreStart}>
|
||||
<i18nStart.Context>
|
||||
<RedirectAppLinks application={application}>
|
||||
<Router history={history}>
|
||||
<Switch>
|
||||
<Route path={['', '/']} exact>
|
||||
<SpacesGridPageWithBreadcrumbs />
|
||||
</Route>
|
||||
<Route path="/create">
|
||||
<CreateSpacePageWithBreadcrumbs />
|
||||
</Route>
|
||||
<Route path="/edit/:spaceId">
|
||||
<EditSpacePageWithBreadcrumbs />
|
||||
</Route>
|
||||
</Switch>
|
||||
</Router>
|
||||
</RedirectAppLinks>
|
||||
</i18nStart.Context>
|
||||
</KibanaContextProvider>,
|
||||
element
|
||||
);
|
||||
|
||||
|
|
|
@ -22650,13 +22650,6 @@
|
|||
"xpack.spaces.management.confirmAlterActiveSpaceModal.reloadWarningMessage": "このスペースで表示される機能を更新しました。保存後にページが更新されます。",
|
||||
"xpack.spaces.management.confirmAlterActiveSpaceModal.title": "スペースの更新の確認",
|
||||
"xpack.spaces.management.confirmAlterActiveSpaceModal.updateSpaceButton": "スペースを更新",
|
||||
"xpack.spaces.management.confirmDeleteModal.allContentsText": "すべてのコンテンツ",
|
||||
"xpack.spaces.management.confirmDeleteModal.cancelButtonLabel": "キャンセル",
|
||||
"xpack.spaces.management.confirmDeleteModal.confirmDeleteSpaceButtonLabel": "スペース {spaceName} を削除",
|
||||
"xpack.spaces.management.confirmDeleteModal.confirmSpaceNameFormRowLabel": "削除するスペース名の確定",
|
||||
"xpack.spaces.management.confirmDeleteModal.deleteSpaceAndAllContentsButtonLabel": " スペースとすべてのコンテンツを削除",
|
||||
"xpack.spaces.management.confirmDeleteModal.redirectAfterDeletingCurrentSpaceWarningMessage": "現在のスペース {name} を削除しようとしています。続行すると、別のスペースを選択する画面に移動します。",
|
||||
"xpack.spaces.management.confirmDeleteModal.spaceNamesDoNoMatchErrorMessage": "スペース名が一致していません。",
|
||||
"xpack.spaces.management.copyToSpace.actionDescription": "1つ以上のスペースでこの保存されたオブジェクトのコピーを作成します",
|
||||
"xpack.spaces.management.copyToSpace.actionTitle": "スペースにコピー",
|
||||
"xpack.spaces.management.copyToSpace.cancelButton": "キャンセル",
|
||||
|
@ -22721,8 +22714,6 @@
|
|||
"xpack.spaces.management.customizeSpaceAvatar.selectImageUrl": "画像ファイルを選択",
|
||||
"xpack.spaces.management.deleteSpacesButton.deleteSpaceAriaLabel": "スペースを削除",
|
||||
"xpack.spaces.management.deleteSpacesButton.deleteSpaceButtonLabel": "スペースを削除",
|
||||
"xpack.spaces.management.deleteSpacesButton.deleteSpaceErrorTitle": "スペースの削除中にエラーが発生:{errorMessage}",
|
||||
"xpack.spaces.management.deleteSpacesButton.spaceSuccessfullyDeletedNotificationMessage": "{spaceName} スペースが削除されました。",
|
||||
"xpack.spaces.management.deselectAllFeaturesLink": "すべて選択解除",
|
||||
"xpack.spaces.management.enabledFeatures.featureCategoryButtonLabel": "カテゴリ切り替え",
|
||||
"xpack.spaces.management.enabledSpaceFeatures.allFeaturesEnabledMessage": " (表示されているすべての機能) ",
|
||||
|
@ -22738,7 +22729,6 @@
|
|||
"xpack.spaces.management.manageSpacePage.avatarFormRowLabel": "アバター",
|
||||
"xpack.spaces.management.manageSpacePage.awesomeSpacePlaceholder": "素晴らしいスペース",
|
||||
"xpack.spaces.management.manageSpacePage.cancelSpaceButton": "キャンセル",
|
||||
"xpack.spaces.management.manageSpacePage.clickToCustomizeTooltip": "クリックしてこのスペースのアバターをカスタマイズします",
|
||||
"xpack.spaces.management.manageSpacePage.createSpaceButton": "スペースを作成",
|
||||
"xpack.spaces.management.manageSpacePage.createSpaceTitle": "スペースの作成",
|
||||
"xpack.spaces.management.manageSpacePage.customizeSpacePanelDescription": "スペースに名前を付けてアバターをカスタマイズします。",
|
||||
|
@ -22773,7 +22763,6 @@
|
|||
"xpack.spaces.management.spacesGridPage.deleteActionName": "{spaceName} を削除。",
|
||||
"xpack.spaces.management.spacesGridPage.descriptionColumnName": "説明",
|
||||
"xpack.spaces.management.spacesGridPage.editSpaceActionName": "{spaceName} を編集。",
|
||||
"xpack.spaces.management.spacesGridPage.errorDeletingSpaceErrorMessage": "スペースの削除中にエラーが発生:{errorMessage}",
|
||||
"xpack.spaces.management.spacesGridPage.errorTitle": "スペースの読み込みエラー",
|
||||
"xpack.spaces.management.spacesGridPage.featuresColumnName": "機能",
|
||||
"xpack.spaces.management.spacesGridPage.identifierColumnName": "識別子",
|
||||
|
@ -22783,7 +22772,6 @@
|
|||
"xpack.spaces.management.spacesGridPage.someFeaturesEnabled": "{totalFeatureCount} 件中 {enabledFeatureCount} 件の機能を表示中",
|
||||
"xpack.spaces.management.spacesGridPage.spaceColumnName": "スペース",
|
||||
"xpack.spaces.management.spacesGridPage.spacesTitle": "スペース",
|
||||
"xpack.spaces.management.spacesGridPage.spaceSuccessfullyDeletedNotificationMessage": "「{spaceName}」スペースが削除されました。",
|
||||
"xpack.spaces.management.spacesGridPage.tableCaption": "Kibana スペース",
|
||||
"xpack.spaces.management.toggleAllFeaturesLink": " (すべて変更) ",
|
||||
"xpack.spaces.management.unauthorizedPrompt.permissionDeniedDescription": "スペースを管理するアクセス権がありません。",
|
||||
|
|
|
@ -23009,14 +23009,6 @@
|
|||
"xpack.spaces.management.confirmAlterActiveSpaceModal.reloadWarningMessage": "您已更新此工作区中的可见功能。保存后,您的页面将重新加载。",
|
||||
"xpack.spaces.management.confirmAlterActiveSpaceModal.title": "确认更新工作区",
|
||||
"xpack.spaces.management.confirmAlterActiveSpaceModal.updateSpaceButton": "更新工作区",
|
||||
"xpack.spaces.management.confirmDeleteModal.allContentsText": "所有内容",
|
||||
"xpack.spaces.management.confirmDeleteModal.cancelButtonLabel": "取消",
|
||||
"xpack.spaces.management.confirmDeleteModal.confirmDeleteSpaceButtonLabel": "删除空间 {spaceName}",
|
||||
"xpack.spaces.management.confirmDeleteModal.confirmSpaceNameFormRowLabel": "确认要删除的工作区名称",
|
||||
"xpack.spaces.management.confirmDeleteModal.deleteSpaceAndAllContentsButtonLabel": " 删除空间及其所有内容",
|
||||
"xpack.spaces.management.confirmDeleteModal.deletingSpaceWarningMessage": "删除空间会永久删除空间及{allContents}。此操作无法撤消。",
|
||||
"xpack.spaces.management.confirmDeleteModal.redirectAfterDeletingCurrentSpaceWarningMessage": "您即将删除当前空间 {name}。如果继续,您将会被重定向以选择其他空间的位置。",
|
||||
"xpack.spaces.management.confirmDeleteModal.spaceNamesDoNoMatchErrorMessage": "空间名称不匹配。",
|
||||
"xpack.spaces.management.copyToSpace.actionDescription": "在一个或多个工作区中创建此已保存对象的副本",
|
||||
"xpack.spaces.management.copyToSpace.actionTitle": "复制到工作区",
|
||||
"xpack.spaces.management.copyToSpace.cancelButton": "取消",
|
||||
|
@ -23082,8 +23074,6 @@
|
|||
"xpack.spaces.management.customizeSpaceAvatar.selectImageUrl": "选择图像文件",
|
||||
"xpack.spaces.management.deleteSpacesButton.deleteSpaceAriaLabel": "删除此空间",
|
||||
"xpack.spaces.management.deleteSpacesButton.deleteSpaceButtonLabel": "删除空间",
|
||||
"xpack.spaces.management.deleteSpacesButton.deleteSpaceErrorTitle": "删除空间时出错:{errorMessage}",
|
||||
"xpack.spaces.management.deleteSpacesButton.spaceSuccessfullyDeletedNotificationMessage": "已删除 {spaceName} 空间。",
|
||||
"xpack.spaces.management.deselectAllFeaturesLink": "取消全选",
|
||||
"xpack.spaces.management.enabledFeatures.featureCategoryButtonLabel": "类别切换",
|
||||
"xpack.spaces.management.enabledSpaceFeatures.allFeaturesEnabledMessage": " (所有可见功能) ",
|
||||
|
@ -23099,7 +23089,6 @@
|
|||
"xpack.spaces.management.manageSpacePage.avatarFormRowLabel": "头像",
|
||||
"xpack.spaces.management.manageSpacePage.awesomeSpacePlaceholder": "超卓的空间",
|
||||
"xpack.spaces.management.manageSpacePage.cancelSpaceButton": "取消",
|
||||
"xpack.spaces.management.manageSpacePage.clickToCustomizeTooltip": "单击可定制此工作区头像",
|
||||
"xpack.spaces.management.manageSpacePage.createSpaceButton": "创建工作区",
|
||||
"xpack.spaces.management.manageSpacePage.createSpaceTitle": "创建一个空间",
|
||||
"xpack.spaces.management.manageSpacePage.customizeSpacePanelDescription": "命名您的工作区并定制其头像。",
|
||||
|
@ -23134,7 +23123,6 @@
|
|||
"xpack.spaces.management.spacesGridPage.deleteActionName": "删除 {spaceName}。",
|
||||
"xpack.spaces.management.spacesGridPage.descriptionColumnName": "描述",
|
||||
"xpack.spaces.management.spacesGridPage.editSpaceActionName": "编辑 {spaceName}。",
|
||||
"xpack.spaces.management.spacesGridPage.errorDeletingSpaceErrorMessage": "删除空间时出错:{errorMessage}",
|
||||
"xpack.spaces.management.spacesGridPage.errorTitle": "加载工作区时出错",
|
||||
"xpack.spaces.management.spacesGridPage.featuresColumnName": "功能",
|
||||
"xpack.spaces.management.spacesGridPage.identifierColumnName": "标识符",
|
||||
|
@ -23144,7 +23132,6 @@
|
|||
"xpack.spaces.management.spacesGridPage.someFeaturesEnabled": "{enabledFeatureCount} / {totalFeatureCount} 个功能可见",
|
||||
"xpack.spaces.management.spacesGridPage.spaceColumnName": "工作区",
|
||||
"xpack.spaces.management.spacesGridPage.spacesTitle": "工作区",
|
||||
"xpack.spaces.management.spacesGridPage.spaceSuccessfullyDeletedNotificationMessage": "已删除“{spaceName}”工作区。",
|
||||
"xpack.spaces.management.spacesGridPage.tableCaption": "Kibana 工作区",
|
||||
"xpack.spaces.management.toggleAllFeaturesLink": " (全部更改) ",
|
||||
"xpack.spaces.management.unauthorizedPrompt.permissionDeniedDescription": "您无权管理工作区。",
|
||||
|
|
|
@ -111,14 +111,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
await PageObjects.spaceSelector.clickManageSpaces();
|
||||
await PageObjects.spaceSelector.clickOnDeleteSpaceButton('space_b');
|
||||
await a11y.testAppSnapshot();
|
||||
// a11y test for no space name in confirm dialogue box
|
||||
await PageObjects.spaceSelector.confirmDeletingSpace();
|
||||
await a11y.testAppSnapshot();
|
||||
});
|
||||
|
||||
// test starts with deleting space b so we can get the space selection page instead of logging out in the test
|
||||
it('a11y test for space selection page', async () => {
|
||||
await PageObjects.spaceSelector.setSpaceNameTobeDeleted('space_b');
|
||||
await PageObjects.spaceSelector.confirmDeletingSpace();
|
||||
await a11y.testAppSnapshot();
|
||||
await PageObjects.spaceSelector.clickSpaceCard('default');
|
||||
|
|
|
@ -167,10 +167,6 @@ export function SpaceSelectorPageProvider({ getService, getPageObjects }: FtrPro
|
|||
await testSubjects.click(`${spaceName}-deleteSpace`);
|
||||
}
|
||||
|
||||
async setSpaceNameTobeDeleted(spaceName: string) {
|
||||
await testSubjects.setValue('deleteSpaceInput', spaceName);
|
||||
}
|
||||
|
||||
async cancelDeletingSpace() {
|
||||
await testSubjects.click('confirmModalCancelButton');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue