Commit fc313b97 authored by Illya Klymov's avatar Illya Klymov

Merge branch...

Merge branch '218355-make-alert-users-that-feature-flags-will-be-changing-dismissable' into 'master'

Make New Feature Flags alert dismissible

See merge request gitlab-org/gitlab!37306
parents 3a920cdd 4cef268a
...@@ -40,6 +40,11 @@ export default { ...@@ -40,6 +40,11 @@ export default {
required: true, required: true,
}, },
}, },
data() {
return {
userDidDismissNewFlagAlert: false,
};
},
translations: { translations: {
legacyFlagAlert: s__( legacyFlagAlert: s__(
'FeatureFlags|GitLab is moving to a new way of managing feature flags, and in 13.4, this feature flag will become read-only. Please create a new feature flag.', 'FeatureFlags|GitLab is moving to a new way of managing feature flags, and in 13.4, this feature flag will become read-only. Please create a new feature flag.',
...@@ -70,6 +75,9 @@ export default { ...@@ -70,6 +75,9 @@ export default {
hasNewVersionFlags() { hasNewVersionFlags() {
return this.glFeatures.featureFlagsNewVersion; return this.glFeatures.featureFlagsNewVersion;
}, },
shouldShowNewFlagAlert() {
return !(this.hasNewVersionFlags || this.userDidDismissNewFlagAlert);
},
}, },
created() { created() {
this.setPath(this.path); this.setPath(this.path);
...@@ -88,7 +96,12 @@ export default { ...@@ -88,7 +96,12 @@ export default {
</script> </script>
<template> <template>
<div> <div>
<gl-alert v-if="!hasNewVersionFlags" variant="warning" :dismissible="false" class="gl-my-5"> <gl-alert
v-if="shouldShowNewFlagAlert"
variant="warning"
class="gl-my-5"
@dismiss="userDidDismissNewFlagAlert = true"
>
{{ $options.translations.newFlagAlert }} {{ $options.translations.newFlagAlert }}
</gl-alert> </gl-alert>
<gl-loading-icon v-if="isLoading" /> <gl-loading-icon v-if="isLoading" />
......
...@@ -40,6 +40,11 @@ export default { ...@@ -40,6 +40,11 @@ export default {
required: true, required: true,
}, },
}, },
data() {
return {
userDidDismissNewFlagAlert: false,
};
},
translations: { translations: {
newFlagAlert: NEW_FLAG_ALERT, newFlagAlert: NEW_FLAG_ALERT,
}, },
...@@ -62,6 +67,9 @@ export default { ...@@ -62,6 +67,9 @@ export default {
hasNewVersionFlags() { hasNewVersionFlags() {
return this.glFeatures.featureFlagsNewVersion; return this.glFeatures.featureFlagsNewVersion;
}, },
shouldShowNewFlagAlert() {
return !(this.hasNewVersionFlags || this.userDidDismissNewFlagAlert);
},
strategies() { strategies() {
return [{ name: ROLLOUT_STRATEGY_ALL_USERS, parameters: {}, scopes: [] }]; return [{ name: ROLLOUT_STRATEGY_ALL_USERS, parameters: {}, scopes: [] }];
}, },
...@@ -77,7 +85,12 @@ export default { ...@@ -77,7 +85,12 @@ export default {
</script> </script>
<template> <template>
<div> <div>
<gl-alert v-if="!hasNewVersionFlags" variant="warning" :dismissible="false" class="gl-my-5"> <gl-alert
v-if="shouldShowNewFlagAlert"
variant="warning"
class="gl-my-5"
@dismiss="userDidDismissNewFlagAlert = true"
>
{{ $options.translations.newFlagAlert }} {{ $options.translations.newFlagAlert }}
</gl-alert> </gl-alert>
<h3 class="page-title">{{ s__('FeatureFlags|New feature flag') }}</h3> <h3 class="page-title">{{ s__('FeatureFlags|New feature flag') }}</h3>
......
---
title: Make New Feature Flags alert dismissible
merge_request: 37306
author:
type: changed
...@@ -152,8 +152,13 @@ describe('Edit feature flag form', () => { ...@@ -152,8 +152,13 @@ describe('Edit feature flag form', () => {
describe('without new version flags', () => { describe('without new version flags', () => {
beforeEach(() => factory({ provide: { glFeatures: { featureFlagsNewVersion: false } } })); beforeEach(() => factory({ provide: { glFeatures: { featureFlagsNewVersion: false } } }));
it('should alert users that feature flags are changing soon', () => { it('should alert users that feature flags are changing soon', () => {
expect(wrapper.find(GlAlert).text()).toBe(NEW_FLAG_ALERT); expect(wrapper.find(GlAlert).text()).toBe(NEW_FLAG_ALERT);
}); });
it('the new feature flags alert should be dismissable', () => {
expect(wrapper.find(GlAlert).props('dismissible')).toBe(true);
});
}); });
}); });
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
DEFAULT_PERCENT_ROLLOUT, DEFAULT_PERCENT_ROLLOUT,
NEW_FLAG_ALERT, NEW_FLAG_ALERT,
} from 'ee/feature_flags/constants'; } from 'ee/feature_flags/constants';
import { TEST_HOST } from 'spec/test_constants';
import { allUsersStrategy } from '../mock_data'; import { allUsersStrategy } from '../mock_data';
describe('New feature flag form', () => { describe('New feature flag form', () => {
...@@ -20,15 +21,25 @@ describe('New feature flag form', () => { ...@@ -20,15 +21,25 @@ describe('New feature flag form', () => {
}, },
}); });
const factory = () => { const factory = (opts = {}) => {
if (wrapper) {
wrapper.destroy();
wrapper = null;
}
wrapper = shallowMount(NewFeatureFlag, { wrapper = shallowMount(NewFeatureFlag, {
propsData: { propsData: {
endpoint: 'feature_flags.json', endpoint: `${TEST_HOST}/feature_flags.json`,
path: '/feature_flags', path: '/feature_flags',
environmentsEndpoint: 'environments.json', environmentsEndpoint: 'environments.json',
projectId: '8', projectId: '8',
}, },
store, store,
provide: {
glFeatures: {
featureFlagsNewVersion: true,
},
},
...opts,
}); });
}; };
...@@ -76,8 +87,8 @@ describe('New feature flag form', () => { ...@@ -76,8 +87,8 @@ describe('New feature flag form', () => {
expect(wrapper.find(Form).props('scopes')).toContainEqual(defaultScope); expect(wrapper.find(Form).props('scopes')).toContainEqual(defaultScope);
}); });
it('should alert users that feature flags are changing soon', () => { it('should not alert users that feature flags are changing soon', () => {
expect(wrapper.find(GlAlert).text()).toBe(NEW_FLAG_ALERT); expect(wrapper.contains(GlAlert)).toBe(false);
}); });
it('should pass in the project ID', () => { it('should pass in the project ID', () => {
...@@ -89,4 +100,16 @@ describe('New feature flag form', () => { ...@@ -89,4 +100,16 @@ describe('New feature flag form', () => {
expect(strategies).toEqual([allUsersStrategy]); expect(strategies).toEqual([allUsersStrategy]);
}); });
describe('without new version flags', () => {
beforeEach(() => factory({ provide: { glFeatures: { featureFlagsNewVersion: false } } }));
it('should alert users that feature flags are changing soon', () => {
expect(wrapper.find(GlAlert).text()).toBe(NEW_FLAG_ALERT);
});
it('the new feature flags alert should be dismissable', () => {
expect(wrapper.find(GlAlert).props('dismissible')).toBe(true);
});
});
}); });
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