-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Signed-off-by: Vijayan Balasubramanian <[email protected]> (cherry picked from commit c688c23) Co-authored-by: Vijayan Balasubramanian <[email protected]>
- Loading branch information
1 parent
d6aafcf
commit 391bdb6
Showing
4 changed files
with
62 additions
and
20 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
23 changes: 23 additions & 0 deletions
23
public/components/layer_control_panel/delete_layer_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,23 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { DeleteLayerModal } from './delete_layer_modal'; | ||
import React from 'react'; | ||
import { EuiConfirmModal } from '@elastic/eui'; | ||
import TestRenderer from 'react-test-renderer'; | ||
|
||
describe('test delete layer modal', function () { | ||
it('should show modal', function () { | ||
const deleteLayerModal = TestRenderer.create( | ||
<DeleteLayerModal layerName={'test-layer'} onCancel={() => {}} onConfirm={() => {}} /> | ||
); | ||
const testInstance = deleteLayerModal.root; | ||
expect(testInstance.findByType(EuiConfirmModal).props.title).toBe('Delete layer'); | ||
expect(testInstance.findByType(EuiConfirmModal).props.confirmButtonText).toBe('Delete'); | ||
expect(testInstance.findByType(EuiConfirmModal).props.cancelButtonText).toBe('Cancel'); | ||
expect(testInstance.findByType(EuiConfirmModal).props.buttonColor).toBe('danger'); | ||
expect(testInstance.findByType(EuiConfirmModal).props.defaultFocusedButton).toBe('confirm'); | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
public/components/layer_control_panel/delete_layer_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,30 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { EuiConfirmModal } from '@elastic/eui'; | ||
import React from 'react'; | ||
|
||
interface DeleteLayerModalProps { | ||
onCancel: () => void; | ||
onConfirm: () => void; | ||
layerName: string; | ||
} | ||
export const DeleteLayerModal = ({ onCancel, onConfirm, layerName }: DeleteLayerModalProps) => { | ||
return ( | ||
<EuiConfirmModal | ||
title="Delete layer" | ||
onCancel={onCancel} | ||
onConfirm={onConfirm} | ||
cancelButtonText="Cancel" | ||
confirmButtonText="Delete" | ||
buttonColor="danger" | ||
defaultFocusedButton="confirm" | ||
> | ||
<p> | ||
Do you want to delete layer <strong>{layerName}</strong>? | ||
</p> | ||
</EuiConfirmModal> | ||
); | ||
}; |
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