Commit 2796016f authored by Mark Florian's avatar Mark Florian

Merge branch 'update-feature-flag-error-banner' into 'master'

Adding GlAlert component

See merge request gitlab-org/gitlab!52217
parents 5503174e 6108015b
...@@ -91,9 +91,9 @@ export default { ...@@ -91,9 +91,9 @@ export default {
<h3 class="page-title gl-m-0">{{ title }}</h3> <h3 class="page-title gl-m-0">{{ title }}</h3>
</div> </div>
<div v-if="error.length" class="alert alert-danger"> <gl-alert v-if="error.length" variant="warning" class="gl-mb-5" :dismissible="false">
<p v-for="(message, index) in error" :key="index" class="gl-mb-0">{{ message }}</p> <p v-for="(message, index) in error" :key="index" class="gl-mb-0">{{ message }}</p>
</div> </gl-alert>
<feature-flag-form <feature-flag-form
:name="name" :name="name"
......
<script> <script>
import { GlAlert } from '@gitlab/ui';
import { mapState, mapActions } from 'vuex'; import { mapState, mapActions } from 'vuex';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import FeatureFlagForm from './form.vue'; import FeatureFlagForm from './form.vue';
...@@ -10,6 +11,7 @@ import featureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; ...@@ -10,6 +11,7 @@ import featureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
export default { export default {
components: { components: {
FeatureFlagForm, FeatureFlagForm,
GlAlert,
}, },
mixins: [featureFlagsMixin()], mixins: [featureFlagsMixin()],
inject: { inject: {
...@@ -61,9 +63,9 @@ export default { ...@@ -61,9 +63,9 @@ export default {
<div> <div>
<h3 class="page-title">{{ s__('FeatureFlags|New feature flag') }}</h3> <h3 class="page-title">{{ s__('FeatureFlags|New feature flag') }}</h3>
<div v-if="error.length" class="alert alert-danger"> <gl-alert v-if="error.length" variant="warning" class="gl-mb-5" :dismissible="false">
<p v-for="(message, index) in error" :key="index" class="mb-0">{{ message }}</p> <p v-for="(message, index) in error" :key="index" class="gl-mb-0">{{ message }}</p>
</div> </gl-alert>
<feature-flag-form <feature-flag-form
:cancel-path="path" :cancel-path="path"
......
---
title: Update styling of validation messages in New Feature Flag form
merge_request: 52217
author:
type: changed
...@@ -75,6 +75,8 @@ describe('Edit feature flag form', () => { ...@@ -75,6 +75,8 @@ describe('Edit feature flag form', () => {
}); });
const findAlert = () => wrapper.find(GlAlert); const findAlert = () => wrapper.find(GlAlert);
const findWarningGlAlert = () =>
wrapper.findAll(GlAlert).filter((c) => c.props('variant') === 'warning');
it('should display the iid', () => { it('should display the iid', () => {
expect(wrapper.find('h3').text()).toContain('^5'); expect(wrapper.find('h3').text()).toContain('^5');
...@@ -88,7 +90,7 @@ describe('Edit feature flag form', () => { ...@@ -88,7 +90,7 @@ describe('Edit feature flag form', () => {
expect(wrapper.find(GlToggle).props('value')).toBe(true); expect(wrapper.find(GlToggle).props('value')).toBe(true);
}); });
it('should not alert users that feature flags are changing soon', () => { it('should alert users the flag is read only', () => {
expect(findAlert().text()).toContain('GitLab is moving to a new way of managing feature flags'); expect(findAlert().text()).toContain('GitLab is moving to a new way of managing feature flags');
}); });
...@@ -96,8 +98,9 @@ describe('Edit feature flag form', () => { ...@@ -96,8 +98,9 @@ describe('Edit feature flag form', () => {
it('should render the error', () => { it('should render the error', () => {
store.dispatch('receiveUpdateFeatureFlagError', { message: ['The name is required'] }); store.dispatch('receiveUpdateFeatureFlagError', { message: ['The name is required'] });
return wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(wrapper.find('.alert-danger').exists()).toEqual(true); const warningGlAlert = findWarningGlAlert();
expect(wrapper.find('.alert-danger').text()).toContain('The name is required'); expect(warningGlAlert.at(1).exists()).toEqual(true);
expect(warningGlAlert.at(1).text()).toContain('The name is required');
}); });
}); });
}); });
......
...@@ -41,6 +41,9 @@ describe('New feature flag form', () => { ...@@ -41,6 +41,9 @@ describe('New feature flag form', () => {
}); });
}; };
const findWarningGlAlert = () =>
wrapper.findAll(GlAlert).filter((c) => c.props('variant') === 'warning');
beforeEach(() => { beforeEach(() => {
factory(); factory();
}); });
...@@ -53,8 +56,9 @@ describe('New feature flag form', () => { ...@@ -53,8 +56,9 @@ describe('New feature flag form', () => {
it('should render the error', () => { it('should render the error', () => {
store.dispatch('receiveCreateFeatureFlagError', { message: ['The name is required'] }); store.dispatch('receiveCreateFeatureFlagError', { message: ['The name is required'] });
return wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(wrapper.find('.alert').exists()).toEqual(true); const warningGlAlert = findWarningGlAlert();
expect(wrapper.find('.alert').text()).toContain('The name is required'); expect(warningGlAlert.at(0).exists()).toBe(true);
expect(warningGlAlert.at(0).text()).toContain('The name is required');
}); });
}); });
}); });
...@@ -81,10 +85,6 @@ describe('New feature flag form', () => { ...@@ -81,10 +85,6 @@ describe('New feature flag form', () => {
expect(wrapper.find(Form).props('scopes')).toContainEqual(defaultScope); expect(wrapper.find(Form).props('scopes')).toContainEqual(defaultScope);
}); });
it('should not alert users that feature flags are changing soon', () => {
expect(wrapper.find(GlAlert).exists()).toBe(false);
});
it('has an all users strategy by default', () => { it('has an all users strategy by default', () => {
const strategies = wrapper.find(Form).props('strategies'); const strategies = wrapper.find(Form).props('strategies');
......
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