Commit d3948f06 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch '352423-change-button-variant-in-web-ide-modals' into 'master'

Change button variant to confirm in Web IDE modals

See merge request gitlab-org/gitlab!80780
parents 8da7d508 b4603317
...@@ -6,6 +6,10 @@ import { __, sprintf } from '~/locale'; ...@@ -6,6 +6,10 @@ import { __, sprintf } from '~/locale';
import { modalTypes } from '../../constants'; import { modalTypes } from '../../constants';
import { trimPathComponents, getPathParent } from '../../utils'; import { trimPathComponents, getPathParent } from '../../utils';
const i18n = {
cancelButtonText: __('Cancel'),
};
export default { export default {
components: { components: {
GlModal, GlModal,
...@@ -43,6 +47,18 @@ export default { ...@@ -43,6 +47,18 @@ export default {
return __('Create file'); return __('Create file');
}, },
actionPrimary() {
return {
text: this.buttonLabel,
attributes: [{ variant: 'confirm' }],
};
},
actionCancel() {
return {
text: i18n.cancelButtonText,
attributes: [{ variant: 'default' }],
};
},
isCreatingNewFile() { isCreatingNewFile() {
return this.modalType === modalTypes.blob; return this.modalType === modalTypes.blob;
}, },
...@@ -136,11 +152,11 @@ export default { ...@@ -136,11 +152,11 @@ export default {
data-qa-selector="new_file_modal" data-qa-selector="new_file_modal"
data-testid="ide-new-entry" data-testid="ide-new-entry"
:title="modalTitle" :title="modalTitle"
:ok-title="buttonLabel"
ok-variant="success"
size="lg" size="lg"
@ok="submitForm" :action-primary="actionPrimary"
@hide="resetData" :action-cancel="actionCancel"
@primary="submitForm"
@cancel="resetData"
> >
<div class="form-group row"> <div class="form-group row">
<label class="label-bold col-form-label col-sm-2"> {{ __('Name') }} </label> <label class="label-bold col-form-label col-sm-2"> {{ __('Name') }} </label>
......
...@@ -38,7 +38,7 @@ describe('new file modal component', () => { ...@@ -38,7 +38,7 @@ describe('new file modal component', () => {
}); });
it(`sets button label as ${entryType}`, () => { it(`sets button label as ${entryType}`, () => {
expect(document.querySelector('.btn-success').textContent.trim()).toBe(btnTitle); expect(document.querySelector('.btn-confirm').textContent.trim()).toBe(btnTitle);
}); });
it(`sets form label as ${entryType}`, () => { it(`sets form label as ${entryType}`, () => {
...@@ -77,7 +77,7 @@ describe('new file modal component', () => { ...@@ -77,7 +77,7 @@ describe('new file modal component', () => {
await nextTick(); await nextTick();
expect(document.querySelector('.modal-title').textContent.trim()).toBe(modalTitle); expect(document.querySelector('.modal-title').textContent.trim()).toBe(modalTitle);
expect(document.querySelector('.btn-success').textContent.trim()).toBe(btnTitle); expect(document.querySelector('.btn-confirm').textContent.trim()).toBe(btnTitle);
}, },
); );
......
...@@ -106,7 +106,7 @@ const fillFileNameModal = async (value, submitText = 'Create file') => { ...@@ -106,7 +106,7 @@ const fillFileNameModal = async (value, submitText = 'Create file') => {
const nameField = await findByTestId(modal, 'file-name-field'); const nameField = await findByTestId(modal, 'file-name-field');
fireEvent.input(nameField, { target: { value } }); fireEvent.input(nameField, { target: { value } });
const createButton = getByText(modal, submitText, { selector: 'button' }); const createButton = getByText(modal, submitText, { selector: 'button > span' });
createButton.click(); createButton.click();
}; };
......
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