Skip to content

Commit 70ff602

Browse files
authored
Preventing storing quick navigator if the feature flag is off (#398)
* [r97377452] fix: preventing storing quick navigator if the feature flag is off * [r97377452] fix: modify showQuickNavigation in DocumentationTopic component
1 parent c126039 commit 70ff602

File tree

6 files changed

+22
-11
lines changed

6 files changed

+22
-11
lines changed

src/components/Navigator.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
:error-fetching="errorFetching"
2626
:breakpoint="breakpoint"
2727
:api-changes="apiChanges"
28+
:enableQuickNavigation="enableQuickNavigation"
2829
@close="$emit('close')"
2930
/>
3031
<NavigatorCardInner v-else class="loading-placeholder">
@@ -46,6 +47,7 @@ import NavigatorCardInner from 'docc-render/components/Navigator/NavigatorCardIn
4647
import { INDEX_ROOT_KEY } from 'docc-render/constants/sidebar';
4748
import { TopicTypes } from 'docc-render/constants/TopicTypes';
4849
import { BreakpointName } from 'docc-render/utils/breakpoints';
50+
import { getSetting } from 'docc-render/utils/theme-settings';
4951
5052
/**
5153
* @typedef NavigatorFlatItem
@@ -140,13 +142,20 @@ export default {
140142
}
141143
return parentTopicReferences.slice(itemsToSlice).map(r => r.url).concat(path);
142144
},
145+
enableQuickNavigation: () => (
146+
getSetting(['features', 'docs', 'quickNavigation', 'enable'], false)
147+
),
143148
/**
144149
* Recomputes the list of flat children.
145150
* @return NavigatorFlatItem[]
146151
*/
147-
flatChildren: ({ flattenNestedData, technology = {}, store }) => {
152+
flatChildren: ({
153+
enableQuickNavigation, flattenNestedData, technology = {}, store,
154+
}) => {
148155
const flatIndex = flattenNestedData(technology.children || [], null, 0, technology.beta);
149-
store.setFlattenIndex(flatIndex);
156+
if (enableQuickNavigation) {
157+
store.setFlattenIndex(flatIndex);
158+
}
150159
return flatIndex;
151160
},
152161
/**

src/components/Navigator/NavigatorCard.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ import { isEqual, last } from 'docc-render/utils/arrays';
124124
import { ChangeNames, ChangeNameToType } from 'docc-render/constants/Changes';
125125
import Badge from 'docc-render/components/Badge.vue';
126126
import MagnifierIcon from 'docc-render/components/Icons/MagnifierIcon.vue';
127-
import { getSetting } from 'docc-render/utils/theme-settings';
128127
import QuickNavigationStore from 'docc-render/stores/QuickNavigationStore';
129128
130129
const STORAGE_KEY = 'navigator.state';
@@ -235,6 +234,10 @@ export default {
235234
type: Boolean,
236235
default: false,
237236
},
237+
enableQuickNavigation: {
238+
type: Boolean,
239+
default: false,
240+
},
238241
},
239242
mixins: [
240243
keyboardNavigation,
@@ -464,9 +467,6 @@ export default {
464467
hasNodes: ({ nodesToRender }) => !!nodesToRender.length,
465468
totalItemsToNavigate: ({ nodesToRender }) => nodesToRender.length,
466469
lastActivePathItem: ({ activePath }) => last(activePath),
467-
enableQuickNavigation: () => (
468-
getSetting(['features', 'docs', 'quickNavigation', 'enable'], false)
469-
),
470470
},
471471
created() {
472472
this.restorePersistedState();

src/stores/QuickNavigationStore.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
export default {
1212
state: {
13-
enableQuickNavigation: false,
13+
showQuickNavigation: false,
1414
flattenIndex: [],
1515
},
1616
reset() {
@@ -20,7 +20,7 @@ export default {
2020
this.state.flattenIndex = flattenIndex;
2121
},
2222
toggleShowQuickNavigationModal() {
23-
this.state.enableQuickNavigation = !this.state.enableQuickNavigation;
23+
this.state.showQuickNavigation = !this.state.showQuickNavigation;
2424
},
2525

2626
};

src/views/DocumentationTopic.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
-->
1010

1111
<template>
12-
<div :class="{ 'modal-open': quickNavigationStore.state.enableQuickNavigation }">
13-
<div v-show="quickNavigationStore.state.enableQuickNavigation">
12+
<div :class="{ 'modal-open': quickNavigationStore.state.showQuickNavigation }">
13+
<div v-show="quickNavigationStore.state.showQuickNavigation">
1414
<QuickNavigationModal/>
1515
</div>
1616
<CodeTheme class="doc-topic-view">

tests/unit/components/Navigator.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ describe('Navigator', () => {
134134
activePath: [references.first.url, references.second.url, mocks.$route.path],
135135
// will assert in another test
136136
children: expect.any(Array),
137+
enableQuickNavigation: false,
137138
type: TopicTypes.module,
138139
technology: technology.title,
139140
technologyPath: technology.path,
@@ -186,6 +187,7 @@ describe('Navigator', () => {
186187
activePath: [references.first.url, references.second.url, mocks.$route.path],
187188
// will assert in another test
188189
children: [],
190+
enableQuickNavigation: false,
189191
type: TopicTypes.module,
190192
technology: fallbackTechnology.title,
191193
technologyPath: fallbackTechnology.url,

tests/unit/components/Navigator/QuickNavigationModal.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('QuickNavigationModal', () => {
4141
provide: {
4242
quickNavigationStore: {
4343
state: {
44-
enableQuickNavigation: false,
44+
showQuickNavigation: false,
4545
flattenIndex: symbols,
4646
},
4747
},

0 commit comments

Comments
 (0)