-
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.
Browse files
Browse the repository at this point in the history
* Reactify the confirmation modal Up next: jest tests * Add tests - Relies on #10821 getting checked in first for commonHtmlProps * Don't include the overlay as part of the confirm modal component * Use the react version of a confirmation modal - Can’t use the modalOverlay or it would be two nested react roots, due to the way it’s embedded in angular. * Add snapshots * Fix tests * fix confirm_modal_promise tests I have no idea why the introduction of react would cause this to fail as it was, but for some reason, grabbing the button reference has to be after the digest loop. * Address code review comments * switch over the remaining React.PropType references (in the modals dir anyway)
- Loading branch information
1 parent
02ad0ac
commit 7e74b2d
Showing
40 changed files
with
598 additions
and
158 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,9 @@ | ||
<div class="kuiModal" style="width: 450px" data-test-subj="confirmModal"> | ||
<div class="kuiModalHeader" ng-if="title"> | ||
<div class="kuiModalHeader__title" data-test-subj="confirmModalTitleText"> | ||
{{title}} | ||
</div> | ||
</div> | ||
<div class="kuiModalBody"> | ||
<div | ||
class="kuiModalBodyText" | ||
data-test-subj="confirmModalBodyText" | ||
> | ||
{{message}} | ||
</div> | ||
</div> | ||
|
||
<div class="kuiModalFooter"> | ||
<button | ||
class="kuiButton kuiButton--hollow" | ||
data-test-subj="confirmModalCancelButton" | ||
ng-click="onCancel()" | ||
> | ||
{{cancelButtonText}} | ||
</button> | ||
<button | ||
class="kuiButton kuiButton--primary" | ||
data-test-subj="confirmModalConfirmButton" | ||
ng-click="onConfirm()" | ||
> | ||
{{confirmButtonText}} | ||
</button> | ||
</div> | ||
</div> | ||
<confirm-modal | ||
data-test-subj="confirmModal" | ||
on-cancel="onCancel" | ||
on-confirm="onConfirm" | ||
confirm-button-text="confirmButtonText" | ||
cancel-button-text="cancelButtonText" | ||
message="message" | ||
title="title" | ||
></confirm-modal> |
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
59 changes: 59 additions & 0 deletions
59
ui_framework/components/modal/__snapshots__/confirm_modal.test.js.snap
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,59 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders KuiConfirmModal 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="kuiModal testClass1 testClass2" | ||
data-tests-subj="test subject string" | ||
style="width:450px;" | ||
> | ||
<div | ||
class="kuiModalHeader" | ||
> | ||
<div | ||
class="kuiModalHeader__title" | ||
data-test-subj="confirmModalTitleText" | ||
> | ||
A confirmation modal | ||
</div> | ||
</div> | ||
<div | ||
class="kuiModalBody" | ||
> | ||
<div | ||
class="kuiModalBodyText" | ||
data-test-subj="confirmModalBodyText" | ||
> | ||
This is a confirmation modal example | ||
</div> | ||
</div> | ||
<div | ||
class="kuiModalFooter" | ||
> | ||
<button | ||
class="kuiButton kuiButton--hollow" | ||
data-test-subj="confirmModalCancelButton" | ||
> | ||
<span | ||
class="kuiButton__inner" | ||
> | ||
<span> | ||
Cancel Button Text | ||
</span> | ||
</span> | ||
</button> | ||
<button | ||
class="kuiButton kuiButton--primary" | ||
data-test-subj="confirmModalConfirmButton" | ||
> | ||
<span | ||
class="kuiButton__inner" | ||
> | ||
<span> | ||
Confirm Button Text | ||
</span> | ||
</span> | ||
</button> | ||
</div> | ||
</div> | ||
`; |
11 changes: 11 additions & 0 deletions
11
ui_framework/components/modal/__snapshots__/modal.test.js.snap
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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders KuiModal 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="kuiModal testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
> | ||
children | ||
</div> | ||
`; |
11 changes: 11 additions & 0 deletions
11
ui_framework/components/modal/__snapshots__/modal_body.test.js.snap
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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders KuiModalBody 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="kuiModalBody testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
> | ||
children | ||
</div> | ||
`; |
11 changes: 11 additions & 0 deletions
11
ui_framework/components/modal/__snapshots__/modal_body_text.test.js.snap
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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders KuiModalBodyText 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="kuiModalBodyText testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
> | ||
children | ||
</div> | ||
`; |
11 changes: 11 additions & 0 deletions
11
ui_framework/components/modal/__snapshots__/modal_footer.test.js.snap
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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders KuiModalFooter 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="kuiModalFooter testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
> | ||
children | ||
</div> | ||
`; |
11 changes: 11 additions & 0 deletions
11
ui_framework/components/modal/__snapshots__/modal_header.test.js.snap
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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders KuiModalHeader 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="kuiModalHeader testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
> | ||
children | ||
</div> | ||
`; |
11 changes: 11 additions & 0 deletions
11
ui_framework/components/modal/__snapshots__/modal_header_title.test.js.snap
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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders KuiModalHeaderTitle 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="kuiModalHeader__title testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
> | ||
children | ||
</div> | ||
`; |
11 changes: 11 additions & 0 deletions
11
ui_framework/components/modal/__snapshots__/modal_overlay.test.js.snap
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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders KuiModalOverlay 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="kuiModalOverlay testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
> | ||
children | ||
</div> | ||
`; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
.kuiModalOverlay { | ||
position: fixed; | ||
z-index: 1000; | ||
z-index: $globalModalDepth; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
|
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,75 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { KuiModal } from './modal'; | ||
import { KuiModalFooter } from './modal_footer'; | ||
import { KuiModalHeader } from './modal_header'; | ||
import { KuiModalHeaderTitle } from './modal_header_title'; | ||
import { KuiModalBody } from './modal_body'; | ||
import { KuiModalBodyText } from './modal_body_text'; | ||
import { KuiButton } from '../index'; | ||
|
||
export function KuiConfirmModal({ | ||
message, | ||
title, | ||
onCancel, | ||
onConfirm, | ||
cancelButtonText, | ||
confirmButtonText, | ||
className, | ||
...rest }) { | ||
const ariaLabel = rest['aria-label']; | ||
const dataTestSubj = rest['data-test-subj']; | ||
return ( | ||
<KuiModal | ||
style={{ 'width': '450px' }} | ||
data-tests-subj={ dataTestSubj } | ||
aria-label={ ariaLabel } | ||
className={ className } | ||
> | ||
{ | ||
title ? | ||
<KuiModalHeader> | ||
<KuiModalHeaderTitle data-test-subj="confirmModalTitleText"> | ||
{ title } | ||
</KuiModalHeaderTitle> | ||
</KuiModalHeader> | ||
: null | ||
} | ||
<KuiModalBody> | ||
<KuiModalBodyText data-test-subj="confirmModalBodyText"> | ||
{ message } | ||
</KuiModalBodyText> | ||
</KuiModalBody> | ||
|
||
<KuiModalFooter> | ||
<KuiButton | ||
type="hollow" | ||
data-test-subj="confirmModalCancelButton" | ||
onClick={ onCancel } | ||
> | ||
{cancelButtonText} | ||
</KuiButton> | ||
<KuiButton | ||
type="primary" | ||
data-test-subj="confirmModalConfirmButton" | ||
onClick={ onConfirm } | ||
> | ||
{confirmButtonText} | ||
</KuiButton> | ||
</KuiModalFooter> | ||
</KuiModal> | ||
); | ||
} | ||
|
||
KuiConfirmModal.propTypes = { | ||
message: PropTypes.string, | ||
title: PropTypes.string, | ||
cancelButtonText: PropTypes.string, | ||
confirmButtonText: PropTypes.string, | ||
onCancel: PropTypes.func, | ||
onConfirm: PropTypes.func, | ||
dataTestSubj: PropTypes.string, | ||
ariaLabel: PropTypes.string, | ||
className: PropTypes.string, | ||
}; |
Oops, something went wrong.