|
72 | 72 | </span> |
73 | 73 | </template> |
74 | 74 | </Breadcrumbs> |
75 | | - <BaseMenu |
| 75 | + <KIconButton |
76 | 76 | v-if="!loadingAncestors" |
77 | | - class="pa-1" |
| 77 | + icon="list" |
| 78 | + :tooltip="$tr('viewModeTooltip')" |
78 | 79 | > |
79 | | - <template #activator="{ on }"> |
80 | | - <IconButton |
81 | | - icon="list" |
82 | | - :text="$tr('viewModeTooltip')" |
83 | | - v-on="on" |
| 80 | + <template #menu> |
| 81 | + <KDropdownMenu |
| 82 | + :options="viewModeOptions" |
| 83 | + :hasIcons="true" |
| 84 | + @select="handleViewModeSelect" |
84 | 85 | /> |
85 | 86 | </template> |
86 | | - <VList> |
87 | | - <VListTile |
88 | | - v-for="mode in viewModes" |
89 | | - :key="mode" |
90 | | - @click="(setViewMode(mode), trackViewMode(mode))" |
91 | | - > |
92 | | - <VListTileAction style="min-width: 32px"> |
93 | | - <Icon |
94 | | - v-if="mode === viewMode" |
95 | | - icon="check" |
96 | | - /> |
97 | | - </VListTileAction> |
98 | | - <VListTileTitle>{{ $tr(mode) }}</VListTileTitle> |
99 | | - </VListTile> |
100 | | - </VList> |
101 | | - </BaseMenu> |
| 87 | + </KIconButton> |
102 | 88 | </VToolbar> |
103 | 89 |
|
104 | 90 | <!-- Topic actions --> |
|
164 | 150 | /> |
165 | 151 | <VSpacer v-if="!selected.length" /> |
166 | 152 | <VToolbarItems v-if="!loadingAncestors"> |
167 | | - <BaseMenu v-if="canEdit"> |
168 | | - <template #activator="{ on }"> |
169 | | - <VBtn |
170 | | - color="primary" |
171 | | - class="ml-2" |
172 | | - style="height: 32px" |
173 | | - v-on="on" |
174 | | - > |
175 | | - {{ $tr('addButton') }} |
176 | | - <Icon |
177 | | - icon="dropdown" |
178 | | - :color="$themeTokens.textInverted" |
179 | | - /> |
180 | | - </VBtn> |
| 153 | + <KButton |
| 154 | + v-if="canEdit" |
| 155 | + :primary="true" |
| 156 | + :text="$tr('addButton')" |
| 157 | + hasDropdown |
| 158 | + class="ml-2" |
| 159 | + style="height: 32px" |
| 160 | + > |
| 161 | + <template #menu> |
| 162 | + <KDropdownMenu |
| 163 | + :options="addMenuOptions" |
| 164 | + @select="handleAddMenuSelect" |
| 165 | + /> |
181 | 166 | </template> |
182 | | - <VList> |
183 | | - <VListTile @click="newTopicNode"> |
184 | | - <VListTileTitle>{{ $tr('addTopic') }}</VListTileTitle> |
185 | | - </VListTile> |
186 | | - <VListTile |
187 | | - :to="uploadFilesLink" |
188 | | - @click="trackClickEvent('Upload files')" |
189 | | - > |
190 | | - <VListTileTitle>{{ $tr('uploadFiles') }}</VListTileTitle> |
191 | | - </VListTile> |
192 | | - <VListTile @click="newExerciseNode"> |
193 | | - <VListTileTitle>{{ $tr('addExercise') }}</VListTileTitle> |
194 | | - </VListTile> |
195 | | - <VListTile |
196 | | - :to="importFromChannelsRoute" |
197 | | - @click="trackClickEvent('Import from other channels')" |
198 | | - > |
199 | | - <VListTileTitle>{{ $tr('importFromChannels') }}</VListTileTitle> |
200 | | - </VListTile> |
201 | | - </VList> |
202 | | - </BaseMenu> |
| 167 | + </KButton> |
203 | 168 | </VToolbarItems> |
204 | 169 | </ToolBar> |
205 | 170 |
|
|
325 | 290 | import { searchRecommendationsStrings } from 'shared/strings/searchRecommendationsStrings'; |
326 | 291 | import AiRecommendationsBanner from 'shared/views/AiRecommendationsBanner'; |
327 | 292 |
|
| 293 | + const AddMenuOptions = { |
| 294 | + ADD_TOPIC: 'add-topic', |
| 295 | + UPLOAD_FILES: 'upload-files', |
| 296 | + ADD_EXERCISE: 'add-exercise', |
| 297 | + IMPORT_FROM_CHANNELS: 'import-from-channels', |
| 298 | + }; |
| 299 | +
|
328 | 300 | export default { |
329 | 301 | name: 'CurrentTopicView', |
330 | 302 | components: { |
|
566 | 538 | viewModes() { |
567 | 539 | return Object.values(viewModes); |
568 | 540 | }, |
| 541 | + viewModeOptions() { |
| 542 | + return this.viewModes.map(mode => ({ |
| 543 | + label: this.$tr(mode), |
| 544 | + value: mode, |
| 545 | + icon: mode === this.viewMode ? 'check' : undefined, |
| 546 | + })); |
| 547 | + }, |
569 | 548 | importFromChannelsRoute() { |
570 | 549 | return { |
571 | 550 | name: RouteNames.IMPORT_FROM_CHANNELS_BROWSE, |
|
574 | 553 | }, |
575 | 554 | }; |
576 | 555 | }, |
| 556 | + addMenuOptions() { |
| 557 | + return [ |
| 558 | + { label: this.$tr('addTopic'), value: AddMenuOptions.ADD_TOPIC }, |
| 559 | + { label: this.$tr('uploadFiles'), value: AddMenuOptions.UPLOAD_FILES }, |
| 560 | + { label: this.$tr('addExercise'), value: AddMenuOptions.ADD_EXERCISE }, |
| 561 | + { label: this.$tr('importFromChannels'), value: AddMenuOptions.IMPORT_FROM_CHANNELS }, |
| 562 | + ]; |
| 563 | + }, |
577 | 564 | selectionText() { |
578 | 565 | return this.getSelectedTopicAndResourceCountText(this.selected); |
579 | 566 | }, |
|
1015 | 1002 | trackViewMode(mode) { |
1016 | 1003 | this.$analytics.trackAction('general', mode); |
1017 | 1004 | }, |
| 1005 | + handleViewModeSelect(option) { |
| 1006 | + this.setViewMode(option.value); |
| 1007 | + this.trackViewMode(option.value); |
| 1008 | + }, |
| 1009 | + handleAddMenuSelect(option) { |
| 1010 | + switch (option.value) { |
| 1011 | + case AddMenuOptions.ADD_TOPIC: |
| 1012 | + this.newTopicNode(); |
| 1013 | + break; |
| 1014 | + case AddMenuOptions.UPLOAD_FILES: |
| 1015 | + this.trackClickEvent('Upload files'); |
| 1016 | + this.$router.push(this.uploadFilesLink); |
| 1017 | + break; |
| 1018 | + case AddMenuOptions.ADD_EXERCISE: |
| 1019 | + this.newExerciseNode(); |
| 1020 | + break; |
| 1021 | + case AddMenuOptions.IMPORT_FROM_CHANNELS: |
| 1022 | + this.trackClickEvent('Import from other channels'); |
| 1023 | + this.$router.push(this.importFromChannelsRoute); |
| 1024 | + break; |
| 1025 | + } |
| 1026 | + }, |
1018 | 1027 | showTitleDescriptionModal(nodeId) { |
1019 | 1028 | this.editTitleDescriptionModal = { |
1020 | 1029 | nodeId, |
|
0 commit comments