Commit 5f12034b authored by Rajat Jain's avatar Rajat Jain

Migrate Epic Tabs to use Button Group

Changelog: changed
EE: true
parent 53e4024e
<script> <script>
import { GlTabs, GlTab } from '@gitlab/ui'; import { GlButtonGroup, GlButton } from '@gitlab/ui';
import initRelatedItemsTree from 'ee/related_items_tree/related_items_tree_bundle'; import initRelatedItemsTree from 'ee/related_items_tree/related_items_tree_bundle';
const displayNoneClass = 'gl-display-none'; const displayNoneClass = 'gl-display-none';
...@@ -7,8 +7,8 @@ const containerClass = 'container-limited'; ...@@ -7,8 +7,8 @@ const containerClass = 'container-limited';
export default { export default {
components: { components: {
GlTabs, GlButton,
GlTab, GlButtonGroup,
}, },
inject: { inject: {
allowSubEpics: { allowSubEpics: {
...@@ -27,6 +27,7 @@ export default { ...@@ -27,6 +27,7 @@ export default {
data() { data() {
return { return {
roadmapLoaded: false, roadmapLoaded: false,
activeButton: this.$options.TABS.TREE,
}; };
}, },
computed: { computed: {
...@@ -51,11 +52,13 @@ export default { ...@@ -51,11 +52,13 @@ export default {
.catch(() => {}); .catch(() => {});
}, },
onTreeTabClick() { onTreeTabClick() {
this.activeButton = this.$options.TABS.TREE;
this.roadmapElement.classList.add(displayNoneClass); this.roadmapElement.classList.add(displayNoneClass);
this.treeElement.classList.remove(displayNoneClass); this.treeElement.classList.remove(displayNoneClass);
this.containerElement.classList.add(containerClass); this.containerElement.classList.add(containerClass);
}, },
showRoadmapTabContent() { showRoadmapTabContent() {
this.activeButton = this.$options.TABS.ROADMAP;
this.roadmapElement.classList.remove(displayNoneClass); this.roadmapElement.classList.remove(displayNoneClass);
this.treeElement.classList.add(displayNoneClass); this.treeElement.classList.add(displayNoneClass);
this.containerElement.classList.remove(containerClass); this.containerElement.classList.remove(containerClass);
...@@ -73,26 +76,34 @@ export default { ...@@ -73,26 +76,34 @@ export default {
} }
}, },
}, },
TABS: {
TREE: 'related_items_tree',
ROADMAP: 'roadmap',
},
}; };
</script> </script>
<template> <template>
<gl-tabs <div class="epic-tabs-holder gl-pl-0 gl-pr-0 gl-ml-0 gl-mr-0">
content-class="gl-display-none" <div class="epic-tabs-container gl-pt-3 gl-pb-3">
nav-wrapper-class="epic-tabs-container" <gl-button-group data-testid="tabs">
nav-class="gl-border-bottom-0" <gl-button
class="epic-tabs-holder" class="js-epic-tree-tab"
data-testid="tabs" data-testid="epic-tree-tab"
> :selected="activeButton === $options.TABS.TREE"
<gl-tab title-link-class="js-epic-tree-tab" data-testid="epic-tree-tab" @click="onTreeTabClick"> @click="onTreeTabClick"
<template #title>{{ allowSubEpics ? __('Epics and Issues') : __('Issues') }}</template> >
</gl-tab> {{ allowSubEpics ? __('Epics and Issues') : __('Issues') }}
<gl-tab </gl-button>
v-if="allowSubEpics" <gl-button
title-link-class="js-epic-roadmap-tab" v-if="allowSubEpics"
data-testid="epic-roadmap-tab" class="js-epic-roadmap-tab"
@click="onRoadmapTabClick" data-testid="epic-roadmap-tab"
> :selected="activeButton === $options.TABS.ROADMAP"
<template #title>{{ __('Roadmap') }}</template> @click="onRoadmapTabClick"
</gl-tab> >
</gl-tabs> {{ __('Roadmap') }}
</gl-button>
</gl-button-group>
</div>
</div>
</template> </template>
...@@ -60,6 +60,7 @@ describe('EpicTabs', () => { ...@@ -60,6 +60,7 @@ describe('EpicTabs', () => {
const treeTab = findEpicTreeTab(); const treeTab = findEpicTreeTab();
expect(treeTab.exists()).toBe(true); expect(treeTab.exists()).toBe(true);
expect(treeTab.text()).toBe('Epics and Issues'); expect(treeTab.text()).toBe('Epics and Issues');
expect(treeTab.props().selected).toBe(true);
}); });
it('displays the roadmap tab', () => { it('displays the roadmap tab', () => {
...@@ -68,6 +69,7 @@ describe('EpicTabs', () => { ...@@ -68,6 +69,7 @@ describe('EpicTabs', () => {
const treeTab = findEpicRoadmapTab(); const treeTab = findEpicRoadmapTab();
expect(treeTab.exists()).toBe(true); expect(treeTab.exists()).toBe(true);
expect(treeTab.text()).toBe('Roadmap'); expect(treeTab.text()).toBe('Roadmap');
expect(treeTab.props().selected).toBe(false);
}); });
const treeTabFixture = ` const treeTabFixture = `
......
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