Commit bdecf93c authored by Rajat Jain's avatar Rajat Jain

Display Epic Icon in epics list

Add a new constant that maps issuableType to the icon.
Previously, we only had a default issue icon rendered everytime.
For epics list we'd need to render the epic icon, hence the change.
parent 6395c5e4
...@@ -6,6 +6,7 @@ import sortableConfig from 'ee/sortable/sortable_config'; ...@@ -6,6 +6,7 @@ import sortableConfig from 'ee/sortable/sortable_config';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import issueItem from './issue_item.vue'; import issueItem from './issue_item.vue';
import addIssuableForm from './add_issuable_form.vue'; import addIssuableForm from './add_issuable_form.vue';
import { issuableIconMap } from '../constants';
export default { export default {
name: 'RelatedIssuesBlock', name: 'RelatedIssuesBlock',
...@@ -99,6 +100,9 @@ export default { ...@@ -99,6 +100,9 @@ export default {
hasHelpPath() { hasHelpPath() {
return this.helpPath.length > 0; return this.helpPath.length > 0;
}, },
issuableTypeIcon() {
return issuableIconMap[this.issuableType];
},
}, },
mounted() { mounted() {
if (this.canReorder) { if (this.canReorder) {
...@@ -161,7 +165,7 @@ export default { ...@@ -161,7 +165,7 @@ export default {
class="js-related-issues-header-issue-count related-issues-header-issue-count issue-count-badge mx-1" class="js-related-issues-header-issue-count related-issues-header-issue-count issue-count-badge mx-1"
> >
<span class="issue-count-badge-count"> <span class="issue-count-badge-count">
<icon name="issues" class="mr-1 text-secondary" /> {{ badgeLabel }} <icon :name="issuableTypeIcon" class="mr-1 text-secondary" /> {{ badgeLabel }}
</span> </span>
</div> </div>
<button <button
......
...@@ -30,3 +30,13 @@ export const addRelatedIssueErrorMap = { ...@@ -30,3 +30,13 @@ export const addRelatedIssueErrorMap = {
issue: __("We can't find an issue that matches what you are looking for."), issue: __("We can't find an issue that matches what you are looking for."),
epic: __("We can't find an epic that matches what you are looking for."), epic: __("We can't find an epic that matches what you are looking for."),
}; };
/**
* These are used to map issuableType to the correct icon.
* Since these are never used for any display purposes, don't wrap
* them inside i18n functions.
*/
export const issuableIconMap = {
issue: 'issues',
epic: 'epic',
};
---
title: Display epic icon in related epics list
merge_request: 9166
author:
type: fixed
...@@ -147,4 +147,30 @@ describe('RelatedIssuesBlock', () => { ...@@ -147,4 +147,30 @@ describe('RelatedIssuesBlock', () => {
expect(beforeAfterIds.afterId).toBe(5); expect(beforeAfterIds.afterId).toBe(5);
}); });
}); });
describe('renders correct icon when', () => {
[
{
icon: 'issues',
issuableType: 'issue',
},
{
icon: 'epic',
issuableType: 'epic',
},
].forEach(({ issuableType, icon }) => {
it(`issuableType=${issuableType} is passed`, () => {
vm = new RelatedIssuesBlock({
propsData: {
pathIdSeparator: '#',
issuableType,
},
}).$mount();
const el = vm.$el.querySelector(`.issue-count-badge-count .ic-${icon}`);
expect(el).not.toBeNull();
});
});
});
}); });
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