Commit e6b5f452 authored by Phil Hughes's avatar Phil Hughes

Merge branch '8621-add-environment-info-index' into 'master'

Adds environment column to the feature flags page

See merge request gitlab-org/gitlab-ee!9196
parents a055cb9c 7fabd9a8
<script> <script>
import { GlButton, GlLink, GlTooltipDirective } from '@gitlab/ui'; import { GlButton, GlLink, GlTooltipDirective } from '@gitlab/ui';
import { sprintf, s__ } from '~/locale';
import DeleteFeatureFlag from './delete_feature_flag.vue'; import DeleteFeatureFlag from './delete_feature_flag.vue';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
...@@ -23,6 +24,13 @@ export default { ...@@ -23,6 +24,13 @@ export default {
required: true, required: true,
}, },
}, },
methods: {
scopeTooltipText(scope) {
return !scope.active
? sprintf(s__('Inactive flag for %{scope}'), { scope: scope.environment_scope })
: '';
},
},
}; };
</script> </script>
<template> <template>
...@@ -31,8 +39,11 @@ export default { ...@@ -31,8 +39,11 @@ export default {
<div class="table-section section-10" role="columnheader"> <div class="table-section section-10" role="columnheader">
{{ s__('FeatureFlags|Status') }} {{ s__('FeatureFlags|Status') }}
</div> </div>
<div class="table-section section-20" role="columnheader">
{{ s__('FeatureFlags|Feature Flag') }}
</div>
<div class="table-section section-50" role="columnheader"> <div class="table-section section-50" role="columnheader">
{{ s__('FeatureFlags|Feature flag') }} {{ s__('FeatureFlags|Environment Specs') }}
</div> </div>
</div> </div>
...@@ -41,16 +52,14 @@ export default { ...@@ -41,16 +52,14 @@ export default {
<div class="table-section section-10" role="gridcell"> <div class="table-section section-10" role="gridcell">
<div class="table-mobile-header" role="rowheader">{{ s__('FeatureFlags|Status') }}</div> <div class="table-mobile-header" role="rowheader">{{ s__('FeatureFlags|Status') }}</div>
<div class="table-mobile-content js-feature-flag-status"> <div class="table-mobile-content js-feature-flag-status">
<template v-if="featureFlag.active"> <span v-if="featureFlag.active" class="badge badge-success">{{
<span class="badge badge-success">{{ s__('FeatureFlags|Active') }}</span> s__('FeatureFlags|Active')
</template> }}</span>
<template v-else> <span v-else class="badge badge-danger">{{ s__('FeatureFlags|Inactive') }}</span>
<span class="badge badge-danger">{{ s__('FeatureFlags|Inactive') }}</span>
</template>
</div> </div>
</div> </div>
<div class="table-section section-50" role="gridcell"> <div class="table-section section-20" role="gridcell">
<div class="table-mobile-header" role="rowheader"> <div class="table-mobile-header" role="rowheader">
{{ s__('FeatureFlags|Feature Flag') }} {{ s__('FeatureFlags|Feature Flag') }}
</div> </div>
...@@ -62,7 +71,25 @@ export default { ...@@ -62,7 +71,25 @@ export default {
</div> </div>
</div> </div>
<div class="table-section section-40 table-button-footer" role="gridcell"> <div class="table-section section-50" role="gridcell">
<div class="table-mobile-header" role="rowheader">
{{ s__('FeatureFlags|Environment Specs') }}
</div>
<div
class="table-mobile-content d-flex flex-wrap justify-content-end js-feature-flag-environments"
>
<span
v-for="scope in featureFlag.scopes"
:key="scope.id"
v-gl-tooltip.hover="scopeTooltipText(scope)"
class="badge append-right-8 prepend-top-2"
:class="{ 'badge-active': scope.active, 'badge-inactive': !scope.active }"
>{{ scope.environment_scope }}</span
>
</div>
</div>
<div class="table-section section-20 table-button-footer" role="gridcell">
<div class="table-action-buttons btn-group"> <div class="table-action-buttons btn-group">
<template v-if="featureFlag.edit_path"> <template v-if="featureFlag.edit_path">
<gl-button <gl-button
......
$label-blue: #428bca;
.badge-active {
color: $white-light;
background-color: $label-blue;
}
.badge-inactive {
color: $white-light;
background-color: $gray-500;
}
---
title: Adds environment column to the feature flags page
merge_request:
author:
type: changed
...@@ -43,6 +43,30 @@ describe('Feature Flag table', () => { ...@@ -43,6 +43,30 @@ describe('Feature Flag table', () => {
); );
}); });
it('should render a environments specs column', () => {
const envColumn = vm.$el.querySelector('.js-feature-flag-environments');
expect(envColumn).not.toBeNull();
expect(envColumn.textContent.trim()).toContain(featureFlag.scopes[0].environment_scope);
expect(envColumn.textContent.trim()).toContain(featureFlag.scopes[1].environment_scope);
});
it('should render a environments specs badge with inactive class', () => {
const envColumn = vm.$el.querySelector('.js-feature-flag-environments');
expect(envColumn.querySelector('.badge-inactive').textContent.trim()).toContain(
featureFlag.scopes[1].environment_scope,
);
});
it('should render a environments specs badge with active class', () => {
const envColumn = vm.$el.querySelector('.js-feature-flag-environments');
expect(envColumn.querySelector('.badge-active').textContent.trim()).toContain(
featureFlag.scopes[0].environment_scope,
);
});
it('Should render an actions column', () => { it('Should render an actions column', () => {
expect(vm.$el.querySelector('.table-action-buttons')).not.toBeNull(); expect(vm.$el.querySelector('.table-action-buttons')).not.toBeNull();
expect(vm.$el.querySelector('.js-feature-flag-delete-button')).not.toBeNull(); expect(vm.$el.querySelector('.js-feature-flag-delete-button')).not.toBeNull();
......
...@@ -20,4 +20,20 @@ export const featureFlag = { ...@@ -20,4 +20,20 @@ export const featureFlag = {
description: 'flag for tests', description: 'flag for tests',
destroy_path: 'feature_flags/1', destroy_path: 'feature_flags/1',
edit_path: 'feature_flags/1/edit', edit_path: 'feature_flags/1/edit',
scopes: [
{
id: 1,
active: true,
environment_scope: '*',
created_at: '2019-01-14T06:41:40.987Z',
updated_at: '2019-01-14T06:41:40.987Z',
},
{
id: 2,
active: false,
environment_scope: 'production',
created_at: '2019-01-14T06:41:40.987Z',
updated_at: '2019-01-14T06:41:40.987Z',
},
],
}; };
...@@ -3764,13 +3764,13 @@ msgstr "" ...@@ -3764,13 +3764,13 @@ msgstr ""
msgid "FeatureFlags|Edit Feature Flag" msgid "FeatureFlags|Edit Feature Flag"
msgstr "" msgstr ""
msgid "FeatureFlags|Feature Flag" msgid "FeatureFlags|Environment Specs"
msgstr "" msgstr ""
msgid "FeatureFlags|Feature Flags" msgid "FeatureFlags|Feature Flag"
msgstr "" msgstr ""
msgid "FeatureFlags|Feature flag" msgid "FeatureFlags|Feature Flags"
msgstr "" msgstr ""
msgid "FeatureFlags|Feature flag %{name} will be removed. Are you sure?" msgid "FeatureFlags|Feature flag %{name} will be removed. Are you sure?"
...@@ -4903,6 +4903,9 @@ msgstr "" ...@@ -4903,6 +4903,9 @@ msgstr ""
msgid "In the next step, you'll be able to select the projects you want to import." msgid "In the next step, you'll be able to select the projects you want to import."
msgstr "" msgstr ""
msgid "Inactive flag for %{scope}"
msgstr ""
msgid "Include a Terms of Service agreement and Privacy Policy that all users must accept." msgid "Include a Terms of Service agreement and Privacy Policy that all users must accept."
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