Commit fd5e4517 authored by Jeremy Elder's avatar Jeremy Elder Committed by Jacques Erasmus

Migrate Bootstrap button to GlButton in deprecated modal template

parent e8062f27
<script> <script>
import $ from 'jquery'; import $ from 'jquery';
import { GlButton } from '@gitlab/ui';
const buttonVariants = ['danger', 'primary', 'success', 'warning']; const buttonVariants = ['danger', 'primary', 'success', 'warning'];
const sizeVariants = ['sm', 'md', 'lg', 'xl']; const sizeVariants = ['sm', 'md', 'lg', 'xl'];
...@@ -7,6 +8,9 @@ const sizeVariants = ['sm', 'md', 'lg', 'xl']; ...@@ -7,6 +8,9 @@ const sizeVariants = ['sm', 'md', 'lg', 'xl'];
export default { export default {
name: 'DeprecatedModal2', // use GlModal instead name: 'DeprecatedModal2', // use GlModal instead
components: {
GlButton,
},
props: { props: {
id: { id: {
type: String, type: String,
...@@ -72,20 +76,21 @@ export default { ...@@ -72,20 +76,21 @@ export default {
<div :id="id" class="modal fade" tabindex="-1" role="dialog"> <div :id="id" class="modal fade" tabindex="-1" role="dialog">
<div :class="modalSizeClass" class="modal-dialog" role="document"> <div :class="modalSizeClass" class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header gl-pr-4">
<slot name="header"> <slot name="header">
<h4 class="modal-title"> <h4 class="modal-title">
<slot name="title"> {{ headerTitleText }} </slot> <slot name="title"> {{ headerTitleText }} </slot>
</h4> </h4>
<button <gl-button
:aria-label="s__('Modal|Close')" :aria-label="s__('Modal|Close')"
type="button" variant="default"
class="close js-modal-close-action" category="tertiary"
size="small"
icon="close"
class="js-modal-close-action"
data-dismiss="modal" data-dismiss="modal"
@click="emitCancel($event)" @click="emitCancel($event)"
> />
<span aria-hidden="true">&times;</span>
</button>
</slot> </slot>
</div> </div>
...@@ -93,23 +98,21 @@ export default { ...@@ -93,23 +98,21 @@ export default {
<div class="modal-footer"> <div class="modal-footer">
<slot name="footer"> <slot name="footer">
<button <gl-button
type="button" class="js-modal-cancel-action qa-modal-cancel-button"
class="btn js-modal-cancel-action qa-modal-cancel-button"
data-dismiss="modal" data-dismiss="modal"
@click="emitCancel($event)" @click="emitCancel($event)"
> >
{{ s__('Modal|Cancel') }} {{ s__('Modal|Cancel') }}
</button> </gl-button>
<button <gl-button
:class="`btn-${footerPrimaryButtonVariant}`" :class="`btn-${footerPrimaryButtonVariant}`"
type="button" class="js-modal-primary-action qa-modal-primary-button"
class="btn js-modal-primary-action qa-modal-primary-button"
data-dismiss="modal" data-dismiss="modal"
@click="emitSubmit($event)" @click="emitSubmit($event)"
> >
{{ footerPrimaryButtonText }} {{ footerPrimaryButtonText }}
</button> </gl-button>
</slot> </slot>
</div> </div>
</div> </div>
......
---
title: Migrating deprecated buttons to GlButtons for modals that have not yet been
migrated to the new GlModal component
merge_request: 44611
author:
type: other
...@@ -78,7 +78,7 @@ describe('DeprecatedModal2', () => { ...@@ -78,7 +78,7 @@ describe('DeprecatedModal2', () => {
}); });
it('sets the primary button text', () => { it('sets the primary button text', () => {
const primaryButton = vm.$el.querySelector('.modal-footer button:last-of-type'); const primaryButton = vm.$el.querySelector('.js-modal-primary-action .gl-button-text');
expect(primaryButton.innerHTML.trim()).toBe(props.footerPrimaryButtonText); expect(primaryButton.innerHTML.trim()).toBe(props.footerPrimaryButtonText);
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment