Commit a76c0301 authored by David O'Regan's avatar David O'Regan

Merge branch 'switch-order-of-buttons-configure-feature-flag-modal' into 'master'

Change Order of Buttons in Configure Feature Flags

See merge request gitlab-org/gitlab!54731
parents 3be46f6e e10865c8
...@@ -84,6 +84,11 @@ export default { ...@@ -84,6 +84,11 @@ export default {
cancelActionProps() { cancelActionProps() {
return { return {
text: this.$options.translations.cancelActionLabel, text: this.$options.translations.cancelActionLabel,
attributes: [
{
category: 'secondary',
},
],
}; };
}, },
canRegenerateInstanceId() { canRegenerateInstanceId() {
...@@ -120,11 +125,11 @@ export default { ...@@ -120,11 +125,11 @@ export default {
<template> <template>
<gl-modal <gl-modal
:modal-id="modalId" :modal-id="modalId"
:action-cancel="cancelActionProps" :action-primary="cancelActionProps"
:action-primary="regenerateInstanceIdActionProps" :action-secondary="regenerateInstanceIdActionProps"
@canceled="clearState" @secondary.prevent="rotateToken"
@hide="clearState" @hide="clearState"
@primary.prevent="rotateToken" @primary="clearState"
> >
<template #modal-title> <template #modal-title>
{{ $options.translations.modalTitle }} {{ $options.translations.modalTitle }}
......
---
title: Change the order of action buttons in the configure feature flags modal
merge_request: 54731
author:
type: changed
...@@ -32,8 +32,9 @@ describe('Configure Feature Flags Modal', () => { ...@@ -32,8 +32,9 @@ describe('Configure Feature Flags Modal', () => {
}); });
}; };
const findGlModal = () => wrapper.find(GlModal); const findGlModal = () => wrapper.findComponent(GlModal);
const findPrimaryAction = () => findGlModal().props('actionPrimary'); const findPrimaryAction = () => findGlModal().props('actionPrimary');
const findSecondaryAction = () => findGlModal().props('actionSecondary');
const findProjectNameInput = () => wrapper.find('#project_name_verification'); const findProjectNameInput = () => wrapper.find('#project_name_verification');
const findDangerGlAlert = () => const findDangerGlAlert = () =>
wrapper.findAll(GlAlert).filter((c) => c.props('variant') === 'danger'); wrapper.findAll(GlAlert).filter((c) => c.props('variant') === 'danger');
...@@ -42,18 +43,18 @@ describe('Configure Feature Flags Modal', () => { ...@@ -42,18 +43,18 @@ describe('Configure Feature Flags Modal', () => {
afterEach(() => wrapper.destroy()); afterEach(() => wrapper.destroy());
beforeEach(factory); beforeEach(factory);
it('should have Primary and Cancel actions', () => { it('should have Primary and Secondary actions', () => {
expect(findGlModal().props('actionCancel').text).toBe('Close'); expect(findPrimaryAction().text).toBe('Close');
expect(findPrimaryAction().text).toBe('Regenerate instance ID'); expect(findSecondaryAction().text).toBe('Regenerate instance ID');
}); });
it('should default disable the primary action', async () => { it('should default disable the primary action', () => {
const [{ disabled }] = findPrimaryAction().attributes; const [{ disabled }] = findSecondaryAction().attributes;
expect(disabled).toBe(true); expect(disabled).toBe(true);
}); });
it('should emit a `token` event when clicking on the Primary action', async () => { it('should emit a `token` event when clicking on the Primary action', async () => {
findGlModal().vm.$emit('primary', mockEvent); findGlModal().vm.$emit('secondary', mockEvent);
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
expect(wrapper.emitted('token')).toEqual([[]]); expect(wrapper.emitted('token')).toEqual([[]]);
expect(mockEvent.preventDefault).toHaveBeenCalled(); expect(mockEvent.preventDefault).toHaveBeenCalled();
...@@ -112,10 +113,10 @@ describe('Configure Feature Flags Modal', () => { ...@@ -112,10 +113,10 @@ describe('Configure Feature Flags Modal', () => {
afterEach(() => wrapper.destroy()); afterEach(() => wrapper.destroy());
beforeEach(factory); beforeEach(factory);
it('should enable the primary action', async () => { it('should enable the secondary action', async () => {
findProjectNameInput().vm.$emit('input', provide.projectName); findProjectNameInput().vm.$emit('input', provide.projectName);
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
const [{ disabled }] = findPrimaryAction().attributes; const [{ disabled }] = findSecondaryAction().attributes;
expect(disabled).toBe(false); expect(disabled).toBe(false);
}); });
}); });
...@@ -124,8 +125,8 @@ describe('Configure Feature Flags Modal', () => { ...@@ -124,8 +125,8 @@ describe('Configure Feature Flags Modal', () => {
afterEach(() => wrapper.destroy()); afterEach(() => wrapper.destroy());
beforeEach(factory.bind(null, { canUserRotateToken: false })); beforeEach(factory.bind(null, { canUserRotateToken: false }));
it('should not display the primary action', async () => { it('should not display the primary action', () => {
expect(findPrimaryAction()).toBe(null); expect(findSecondaryAction()).toBe(null);
}); });
it('should not display regenerating instance ID', async () => { it('should not display regenerating instance ID', async () => {
......
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