Skip to content

Commit 33f6902

Browse files
authored
Merge pull request #1970 from jonboiser/profile-link-active
Fix logic for making sidebar profile link active
2 parents b9263f7 + 3e7f64a commit 33f6902

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

.eslintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
parserOptions:
22
ecmaVersion: 7
33
sourceType: module
4+
globals:
5+
__version: true
46
extends:
57
- eslint:recommended
68
- prettier

kolibri/core/assets/src/views/side-nav/index.vue

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@
112112
toggleNav() {
113113
this.$emit('toggleSideNav');
114114
},
115+
pageIsActive(pageName) {
116+
return this.topLevelPageName === pageName;
117+
},
115118
},
116119
computed: {
117120
closeStyle() {
@@ -147,42 +150,27 @@
147150
ariaLabel() {
148151
return this.$tr('navigationLabel');
149152
},
150-
learnActive() {
151-
return this.topLevelPageName === TopLevelPageNames.LEARN;
152-
},
153-
coachActive() {
154-
return this.topLevelPageName === TopLevelPageNames.COACH;
155-
},
156-
manageActive() {
157-
return this.topLevelPageName === TopLevelPageNames.MANAGE;
158-
},
159-
profileActive() {
160-
return this.topLevelPageName === TopLevelPageNames.PROFILE;
161-
},
162-
aboutActive() {
163-
return this.topLevelPageName === TopLevelPageNames.ABOUT;
164-
},
165153
menuOptions() {
166154
const options = [
167155
{
168156
label: this.$tr('learn'),
169-
active: this.learnActive,
157+
active: this.pageIsActive(TopLevelPageNames.LEARN),
170158
icon: 'school',
171159
href: '/learn',
172160
},
173161
];
174162
if (this.isAdmin || this.isSuperuser || this.isCoach) {
175163
options.push({
176164
label: this.$tr('coach'),
177-
active: this.coachActive,
165+
active: this.pageIsActive(TopLevelPageNames.COACH),
178166
icon: 'assessment',
179167
href: '/coach',
180168
});
181169
}
182170
if (this.isAdmin || this.isSuperuser) {
183171
options.push({
184172
label: this.$tr('manage'),
185-
active: this.manageActive,
173+
active: this.pageIsActive(TopLevelPageNames.MANAGE),
186174
icon: 'people',
187175
href: '/management',
188176
});
@@ -191,7 +179,7 @@
191179
if (this.isUserLoggedIn) {
192180
options.push({
193181
label: this.$tr('profile'),
194-
active: this.profileActive,
182+
active: this.pageIsActive(TopLevelPageNames.USER),
195183
icon: 'account_circle',
196184
href: '/user',
197185
});

0 commit comments

Comments
 (0)