diff options
-rw-r--r-- | app/assets/javascripts/vue_shared/components/sidebar/labels_select/base.vue | 24 | ||||
-rw-r--r-- | spec/javascripts/vue_shared/components/sidebar/labels_select/base_spec.js | 26 |
2 files changed, 50 insertions, 0 deletions
diff --git a/app/assets/javascripts/vue_shared/components/sidebar/labels_select/base.vue b/app/assets/javascripts/vue_shared/components/sidebar/labels_select/base.vue index c1dd4d42d9d..5ede53d8d01 100644 --- a/app/assets/javascripts/vue_shared/components/sidebar/labels_select/base.vue +++ b/app/assets/javascripts/vue_shared/components/sidebar/labels_select/base.vue @@ -1,4 +1,5 @@ <script> +import { __ } from '~/locale'; import LabelsSelect from '~/labels_select'; import LoadingIcon from '../../loading_icon.vue'; @@ -31,6 +32,11 @@ export default { required: false, default: false, }, + isProject: { + type: Boolean, + required: false, + default: false, + }, abilityName: { type: String, required: true, @@ -73,6 +79,20 @@ export default { hiddenInputName() { return this.showCreate ? `${this.abilityName}[label_names][]` : 'label_id[]'; }, + createLabelTitle() { + if (this.isProject) { + return __('Create project label'); + } + + return __('Create group label'); + }, + manageLabelsTitle() { + if (this.isProject) { + return __('Manage project labels'); + } + + return __('Manage group labels'); + }, }, mounted() { this.labelsDropdown = new LabelsSelect(this.$refs.dropdownButton, { @@ -137,10 +157,14 @@ dropdown-menu-labels dropdown-menu-selectable" <dropdown-footer v-if="showCreate" :labels-web-url="labelsWebUrl" + :create-label-title="createLabelTitle" + :manage-labels-title="manageLabelsTitle" /> </div> <dropdown-create-label v-if="showCreate" + :is-project="isProject" + :header-title="createLabelTitle" /> </div> </div> diff --git a/spec/javascripts/vue_shared/components/sidebar/labels_select/base_spec.js b/spec/javascripts/vue_shared/components/sidebar/labels_select/base_spec.js index 67056793a20..8daaf018396 100644 --- a/spec/javascripts/vue_shared/components/sidebar/labels_select/base_spec.js +++ b/spec/javascripts/vue_shared/components/sidebar/labels_select/base_spec.js @@ -37,6 +37,32 @@ describe('BaseComponent', () => { vmNonEditable.$destroy(); }); }); + + describe('createLabelTitle', () => { + it('returns `Create project label` when `isProject` prop is true', () => { + expect(vm.createLabelTitle).toBe('Create project label'); + }); + + it('return `Create group label` when `isProject` prop is false', () => { + const mockConfigGroup = Object.assign({}, mockConfig, { isProject: false }); + const vmGroup = createComponent(mockConfigGroup); + expect(vmGroup.createLabelTitle).toBe('Create group label'); + vmGroup.$destroy(); + }); + }); + + describe('manageLabelsTitle', () => { + it('returns `Manage project labels` when `isProject` prop is true', () => { + expect(vm.manageLabelsTitle).toBe('Manage project labels'); + }); + + it('return `Manage group labels` when `isProject` prop is false', () => { + const mockConfigGroup = Object.assign({}, mockConfig, { isProject: false }); + const vmGroup = createComponent(mockConfigGroup); + expect(vmGroup.manageLabelsTitle).toBe('Manage group labels'); + vmGroup.$destroy(); + }); + }); }); describe('methods', () => { |