Commit eeb957ec authored by Kushal Pandya's avatar Kushal Pandya

Add `isProject` and computed props to for contextual info for dropdown

parent a831267c
<script> <script>
import { __ } from '~/locale';
import LabelsSelect from '~/labels_select'; import LabelsSelect from '~/labels_select';
import LoadingIcon from '../../loading_icon.vue'; import LoadingIcon from '../../loading_icon.vue';
...@@ -31,6 +32,11 @@ export default { ...@@ -31,6 +32,11 @@ export default {
required: false, required: false,
default: false, default: false,
}, },
isProject: {
type: Boolean,
required: false,
default: false,
},
abilityName: { abilityName: {
type: String, type: String,
required: true, required: true,
...@@ -73,6 +79,20 @@ export default { ...@@ -73,6 +79,20 @@ export default {
hiddenInputName() { hiddenInputName() {
return this.showCreate ? `${this.abilityName}[label_names][]` : 'label_id[]'; 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() { mounted() {
this.labelsDropdown = new LabelsSelect(this.$refs.dropdownButton, { this.labelsDropdown = new LabelsSelect(this.$refs.dropdownButton, {
...@@ -137,10 +157,14 @@ dropdown-menu-labels dropdown-menu-selectable" ...@@ -137,10 +157,14 @@ dropdown-menu-labels dropdown-menu-selectable"
<dropdown-footer <dropdown-footer
v-if="showCreate" v-if="showCreate"
:labels-web-url="labelsWebUrl" :labels-web-url="labelsWebUrl"
:create-label-title="createLabelTitle"
:manage-labels-title="manageLabelsTitle"
/> />
</div> </div>
<dropdown-create-label <dropdown-create-label
v-if="showCreate" v-if="showCreate"
:is-project="isProject"
:header-title="createLabelTitle"
/> />
</div> </div>
</div> </div>
......
...@@ -37,6 +37,32 @@ describe('BaseComponent', () => { ...@@ -37,6 +37,32 @@ describe('BaseComponent', () => {
vmNonEditable.$destroy(); 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', () => { describe('methods', () => {
......
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