Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions shell/components/nav/Group.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ export default {
fixedOpen: {
type: Boolean,
default: false,
},

highlightRoute: {
type: Boolean,
default: true,
}
},

Expand Down Expand Up @@ -233,7 +238,7 @@ export default {
<template>
<div
class="accordion"
:class="{[`depth-${depth}`]: true, 'expanded': isExpanded, 'has-children': hasChildren, 'group-highlight': isGroupActive }"
:class="{[`depth-${depth}`]: true, 'expanded': isExpanded, 'has-children': hasChildren, 'group-highlight': highlightRoute && isGroupActive }"
>
<div
v-if="showHeader || (!onlyHasOverview && canCollapse)"
Expand All @@ -242,7 +247,7 @@ export default {
<div
v-if="showHeader"
class="header"
:class="{'active': isOverview, 'noHover': !canCollapse || fixedOpen}"
:class="{'active': highlightRoute && isOverview, 'noHover': !canCollapse || fixedOpen}"
role="button"
:tabindex="fixedOpen ? -1 : 0"
:aria-label="group.labelDisplay || group.label || ''"
Expand Down Expand Up @@ -311,6 +316,7 @@ export default {
:can-collapse="canCollapse"
:group="child"
:fixed-open="fixedOpen"
:highlight-route="highlightRoute"
@selected="groupSelected($event)"
@expand="expandGroup($event)"
@close="close($event)"
Expand All @@ -322,6 +328,7 @@ export default {
:is-root="depth == 0 && !showHeader"
:type="child"
:depth="depth"
:highlight-route="highlightRoute"
@selected="selectType($event)"
/>
</template>
Expand Down
11 changes: 8 additions & 3 deletions shell/components/nav/Type.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export default {
type: Number,
default: 0,
},

highlightRoute: {
type: Boolean,
default: true,
},
},

data() {
Expand Down Expand Up @@ -121,12 +126,12 @@ export default {
>
<li
class="child nav-type"
:class="{'root': isRoot, [`depth-${depth}`]: true, 'router-link-active': isActive, 'router-link-exact-active': isExactActive}"
:class="{'root': isRoot, [`depth-${depth}`]: true, 'router-link-active': highlightRoute && isActive, 'router-link-exact-active': highlightRoute && isExactActive}"
@click="navigate"
@keypress.enter="navigate"
>
<TabTitle
v-if="isExactActive"
v-if="highlightRoute && isExactActive"
:show-child="false"
>
{{ type.labelKey ? t(type.labelKey) : (type.labelDisplay || type.label) }}
Expand All @@ -136,7 +141,7 @@ export default {
:aria-label="type.labelKey ? t(type.labelKey) : (type.labelDisplay || type.label)"
:href="href"
class="type-link"
:aria-current="isActive ? 'page' : undefined"
:aria-current="highlightRoute && isActive ? 'page' : undefined"
@click="selectType(); navigate($event);"
@mouseenter="setNear(true)"
@mouseleave="setNear(false)"
Expand Down
59 changes: 59 additions & 0 deletions shell/components/nav/__tests__/Type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,65 @@ describe('component: Type', () => {
});
});

describe('should respect highlightRoute prop', () => {
it('should not use active class when highlightRoute is false even if route is active', () => {
const wrapper = shallowMount(Type as any, {
props: { type: defaultRouteTypeProp, highlightRoute: false },

global: {
directives: { cleanHtml: (identity) => identity },

mocks: {
$store: storeMock, $router: routerMock, $route: routeMock
},
stubs: { routerLink: createChildRenderingRouterLinkStub() },
},
});

const elementWithSelector = wrapper.find(`.${ activeClass }`);

expect(elementWithSelector.exists()).toBe(false);
});

it('should not use exact active class when highlightRoute is false even if route is exact active', () => {
const wrapper = shallowMount(Type as any, {
props: { type: defaultRouteTypeProp, highlightRoute: false },

global: {
directives: { cleanHtml: (identity) => identity },

mocks: {
$store: storeMock, $router: routerMock, $route: routeMock
},
stubs: { routerLink: createChildRenderingRouterLinkStub({ isExactActive: true }) },
},
});

const elementWithSelector = wrapper.find(`.${ exactActiveClass }`);

expect(elementWithSelector.exists()).toBe(false);
});

it('should use active class when highlightRoute is true (default) and route is active', () => {
const wrapper = shallowMount(Type as any, {
props: { type: defaultRouteTypeProp, highlightRoute: true },

global: {
directives: { cleanHtml: (identity) => identity },

mocks: {
$store: storeMock, $router: routerMock, $route: routeMock
},
stubs: { routerLink: createChildRenderingRouterLinkStub() },
},
});

const elementWithSelector = wrapper.find(`.${ activeClass }`);

expect(elementWithSelector.exists()).toBe(true);
});
});

describe('should handle the favorite icon appropriately', () => {
it('should show favorite icon if mouse is over and type is favorite', async() => {
const wrapper = shallowMount(Type as any, {
Expand Down
1 change: 1 addition & 0 deletions shell/dialog/SearchDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export default {
:group="g"
:can-collapse="false"
:fixed-open="true"
:highlight-route="false"
@close="$emit('close')"
>
<template #accordion>
Expand Down
Loading