Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
feat: allow to hide cancel button of confirmation modal (#1796)
Browse files Browse the repository at this point in the history
  • Loading branch information
dated authored Mar 9, 2020
1 parent 99bc099 commit d04ac63
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
18 changes: 18 additions & 0 deletions __tests__/unit/components/Modal/ModalConfirmation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ describe('ModalConfirmation', () => {
expect(wrapper.isVueInstance()).toBeTrue()
})

it('should render buttons', () => {
expect(wrapper.findAll('button')).toHaveLength(2)
expect(wrapper.find('.ModalConfirmation__cancel-button').isVisible())
expect(wrapper.find('.ModalConfirmation__continue-button').isVisible())
})

it('should be possible to hide the cancel button', () => {
wrapper = shallowMount(ModalConfirmation, {
i18n,
propsData: {
showCancelButton: false
}
})
expect(wrapper.findAll('button')).toHaveLength(1)
expect(wrapper.find('.ModalConfirmation__cancel-button').exists()).toBe(false)
expect(wrapper.find('.ModalConfirmation__continue-button').isVisible())
})

it('should default portal target to "modal"', () => {
expect(wrapper.props('portalTarget')).toBe('modal')
})
Expand Down
10 changes: 8 additions & 2 deletions src/renderer/components/Modal/ModalConfirmation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@

<div class="mt-4 flex flex-row">
<button
class="blue-button"
v-if="showCancelButton"
class="ModalConfirmation__cancel-button blue-button"
@click="emitCancel"
>
{{ cancelButton }}
</button>

<button
class="action-button px-8"
class="ModalConfirmation__continue-button action-button py-4 px-8"
@click="emitContinue"
>
{{ continueButton }}
Expand Down Expand Up @@ -63,6 +64,11 @@ export default {
return this.$t('MODAL_CONFIRMATION.CANCEL')
}
},
showCancelButton: {
type: Boolean,
required: false,
default: true
},
containerClasses: {
type: String,
required: false,
Expand Down

0 comments on commit d04ac63

Please sign in to comment.