Commit ea307cd5 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'alert-users-of-legacy-flags' into 'master'

Alert users of legacy flags

See merge request gitlab-org/gitlab!30543
parents 9d8f800f 46c99e74
<script> <script>
import { GlLoadingIcon, GlToggle } from '@gitlab/ui'; import { GlAlert, GlLoadingIcon, GlToggle } from '@gitlab/ui';
import { createNamespacedHelpers } from 'vuex'; import { createNamespacedHelpers } from 'vuex';
import { sprintf, s__ } from '~/locale'; import { sprintf, s__ } from '~/locale';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { LEGACY_FLAG } from '../constants';
import store from '../store/index'; import store from '../store/index';
import FeatureFlagForm from './form.vue'; import FeatureFlagForm from './form.vue';
...@@ -11,6 +12,7 @@ const { mapState, mapActions } = createNamespacedHelpers('edit'); ...@@ -11,6 +12,7 @@ const { mapState, mapActions } = createNamespacedHelpers('edit');
export default { export default {
store, store,
components: { components: {
GlAlert,
GlLoadingIcon, GlLoadingIcon,
GlToggle, GlToggle,
FeatureFlagForm, FeatureFlagForm,
...@@ -30,6 +32,11 @@ export default { ...@@ -30,6 +32,11 @@ export default {
required: true, required: true,
}, },
}, },
translations: {
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.',
),
},
computed: { computed: {
...mapState([ ...mapState([
'error', 'error',
...@@ -48,6 +55,9 @@ export default { ...@@ -48,6 +55,9 @@ export default {
? `^${this.iid} ${this.name}` ? `^${this.iid} ${this.name}`
: sprintf(s__('Edit %{name}'), { name: this.name }); : sprintf(s__('Edit %{name}'), { name: this.name });
}, },
deprecated() {
return this.glFeatures.featureFlagsNewVersion && this.version === LEGACY_FLAG;
},
}, },
created() { created() {
this.setPath(this.path); this.setPath(this.path);
...@@ -69,6 +79,9 @@ export default { ...@@ -69,6 +79,9 @@ export default {
<gl-loading-icon v-if="isLoading" /> <gl-loading-icon v-if="isLoading" />
<template v-else-if="!isLoading && !hasError"> <template v-else-if="!isLoading && !hasError">
<gl-alert v-if="deprecated" variant="warning" :dismissible="false" class="gl-my-5">
{{ $options.translations.legacyFlagAlert }}
</gl-alert>
<div class="d-flex align-items-center mb-3 mt-3"> <div class="d-flex align-items-center mb-3 mt-3">
<gl-toggle :value="active" class="m-0 mr-3" @change="toggleActive" /> <gl-toggle :value="active" class="m-0 mr-3" @change="toggleActive" />
<h3 class="page-title m-0">{{ title }}</h3> <h3 class="page-title m-0">{{ title }}</h3>
......
<script> <script>
import { escape } from 'lodash'; import { escape } from 'lodash';
import { GlDeprecatedButton, GlTooltipDirective, GlModal, GlToggle } from '@gitlab/ui'; import { GlDeprecatedButton, GlTooltipDirective, GlModal, GlToggle, GlIcon } from '@gitlab/ui';
import { sprintf, s__ } from '~/locale'; import { sprintf, s__ } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { ROLLOUT_STRATEGY_PERCENT_ROLLOUT } from '../constants'; import { ROLLOUT_STRATEGY_PERCENT_ROLLOUT, NEW_VERSION_FLAG } from '../constants';
export default { export default {
components: { components: {
GlDeprecatedButton, GlDeprecatedButton,
Icon, GlIcon,
GlModal, GlModal,
GlToggle, GlToggle,
}, },
...@@ -33,10 +32,16 @@ export default { ...@@ -33,10 +32,16 @@ export default {
deleteFeatureFlagName: null, deleteFeatureFlagName: null,
}; };
}, },
translations: {
legacyFlagAlert: s__('FeatureFlags|Flag becomes read only soon'),
},
computed: { computed: {
permissions() { permissions() {
return this.glFeatures.featureFlagPermissions; return this.glFeatures.featureFlagPermissions;
}, },
isNewVersionFlagsEnabled() {
return this.glFeatures.featureFlagsNewVersion;
},
modalTitle() { modalTitle() {
return sprintf( return sprintf(
s__('FeatureFlags|Delete %{name}?'), s__('FeatureFlags|Delete %{name}?'),
...@@ -60,6 +65,9 @@ export default { ...@@ -60,6 +65,9 @@ export default {
}, },
}, },
methods: { methods: {
isLegacyFlag(flag) {
return this.isNewVersionFlagsEnabled && flag.version !== NEW_VERSION_FLAG;
},
scopeTooltipText(scope) { scopeTooltipText(scope) {
return !scope.active return !scope.active
? sprintf(s__('FeatureFlags|Inactive flag for %{scope}'), { ? sprintf(s__('FeatureFlags|Inactive flag for %{scope}'), {
...@@ -149,7 +157,17 @@ export default { ...@@ -149,7 +157,17 @@ export default {
{{ s__('FeatureFlags|Feature Flag') }} {{ s__('FeatureFlags|Feature Flag') }}
</div> </div>
<div class="table-mobile-content d-flex flex-column js-feature-flag-title"> <div class="table-mobile-content d-flex flex-column js-feature-flag-title">
<div class="feature-flag-name text-monospace text-truncate">{{ featureFlag.name }}</div> <div class="gl-display-flex gl-align-items-center">
<div class="feature-flag-name text-monospace text-truncate">
{{ featureFlag.name }}
</div>
<gl-icon
v-if="isLegacyFlag(featureFlag)"
v-gl-tooltip.hover="$options.translations.legacyFlagAlert"
class="gl-ml-3"
name="information-o"
/>
</div>
<div class="feature-flag-description text-secondary text-truncate"> <div class="feature-flag-description text-secondary text-truncate">
{{ featureFlag.description }} {{ featureFlag.description }}
</div> </div>
...@@ -186,7 +204,7 @@ export default { ...@@ -186,7 +204,7 @@ export default {
variant="outline-primary" variant="outline-primary"
:href="featureFlag.edit_path" :href="featureFlag.edit_path"
> >
<icon name="pencil" :size="16" /> <gl-icon name="pencil" :size="16" />
</gl-deprecated-button> </gl-deprecated-button>
</template> </template>
<template v-if="featureFlag.destroy_path"> <template v-if="featureFlag.destroy_path">
...@@ -197,7 +215,7 @@ export default { ...@@ -197,7 +215,7 @@ export default {
:disabled="!canDeleteFlag(featureFlag)" :disabled="!canDeleteFlag(featureFlag)"
@click="setDeleteModalData(featureFlag)" @click="setDeleteModalData(featureFlag)"
> >
<icon name="remove" :size="16" /> <gl-icon name="remove" :size="16" />
</gl-deprecated-button> </gl-deprecated-button>
</template> </template>
</div> </div>
......
...@@ -9146,9 +9146,15 @@ msgstr "" ...@@ -9146,9 +9146,15 @@ msgstr ""
msgid "FeatureFlags|Feature flags allow you to configure your code into different flavors by dynamically toggling certain functionality." msgid "FeatureFlags|Feature flags allow you to configure your code into different flavors by dynamically toggling certain functionality."
msgstr "" msgstr ""
msgid "FeatureFlags|Flag becomes read only soon"
msgstr ""
msgid "FeatureFlags|Get started with feature flags" msgid "FeatureFlags|Get started with feature flags"
msgstr "" msgstr ""
msgid "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."
msgstr ""
msgid "FeatureFlags|ID" msgid "FeatureFlags|ID"
msgstr "" msgstr ""
......
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