-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ResponseOps][Cases] Allow users to edit or delete template (#185877)
## Summary Merging into feature branch. Implements edit and delete functionality #181864 Edit or delete template from case settings page. https://github.com/elastic/kibana/assets/117571355/f6fd45fa-c1eb-45ab-8936-02c764dbadc4 **How to test** - Go to Cases > Settings - Add a template - Click on edit template icon - Update the fields - Click save - Click on delete template icon - Click on confirm modal - Click save **Scenarios:** - Edit template with different custom fields - Edit template with connector - Delete template **Flaky Test** [here](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/6331) ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) --------- Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
f975c33
commit c3b0759
Showing
48 changed files
with
2,026 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
x-pack/plugins/cases/public/components/configure_cases/delete_confirmation_modal.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* 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 userEvent from '@testing-library/user-event'; | ||
import React from 'react'; | ||
import type { AppMockRenderer } from '../../common/mock'; | ||
import { createAppMockRenderer } from '../../common/mock'; | ||
import { DeleteConfirmationModal } from './delete_confirmation_modal'; | ||
|
||
describe('DeleteConfirmationModal', () => { | ||
let appMock: AppMockRenderer; | ||
const props = { | ||
title: 'My custom field', | ||
message: 'This is a sample message', | ||
onCancel: jest.fn(), | ||
onConfirm: jest.fn(), | ||
}; | ||
|
||
beforeEach(() => { | ||
appMock = createAppMockRenderer(); | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('renders correctly', async () => { | ||
const result = appMock.render(<DeleteConfirmationModal {...props} />); | ||
|
||
expect(result.getByTestId('confirm-delete-modal')).toBeInTheDocument(); | ||
expect(result.getByText('Delete')).toBeInTheDocument(); | ||
expect(result.getByText('Cancel')).toBeInTheDocument(); | ||
}); | ||
|
||
it('calls onConfirm', async () => { | ||
const result = appMock.render(<DeleteConfirmationModal {...props} />); | ||
|
||
expect(result.getByText('Delete')).toBeInTheDocument(); | ||
userEvent.click(result.getByText('Delete')); | ||
|
||
expect(props.onConfirm).toHaveBeenCalled(); | ||
}); | ||
|
||
it('calls onCancel', async () => { | ||
const result = appMock.render(<DeleteConfirmationModal {...props} />); | ||
|
||
expect(result.getByText('Cancel')).toBeInTheDocument(); | ||
userEvent.click(result.getByText('Cancel')); | ||
|
||
expect(props.onCancel).toHaveBeenCalled(); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
x-pack/plugins/cases/public/components/configure_cases/delete_confirmation_modal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { EuiConfirmModal } from '@elastic/eui'; | ||
import * as i18n from '../custom_fields/translations'; | ||
|
||
interface ConfirmDeleteCaseModalProps { | ||
title: string; | ||
message: string; | ||
onCancel: () => void; | ||
onConfirm: () => void; | ||
} | ||
|
||
const DeleteConfirmationModalComponent: React.FC<ConfirmDeleteCaseModalProps> = ({ | ||
title, | ||
message, | ||
onCancel, | ||
onConfirm, | ||
}) => { | ||
return ( | ||
<EuiConfirmModal | ||
buttonColor="danger" | ||
cancelButtonText={i18n.CANCEL} | ||
data-test-subj="confirm-delete-modal" | ||
defaultFocusedButton="confirm" | ||
onCancel={onCancel} | ||
onConfirm={onConfirm} | ||
title={title} | ||
confirmButtonText={i18n.DELETE} | ||
> | ||
{message} | ||
</EuiConfirmModal> | ||
); | ||
}; | ||
DeleteConfirmationModalComponent.displayName = 'DeleteConfirmationModal'; | ||
|
||
export const DeleteConfirmationModal = React.memo(DeleteConfirmationModalComponent); |
Oops, something went wrong.