Skip to content

Commit fb4f226

Browse files
authored
Merge pull request #7982 from nextcloud/backport/7980/stable32
[stable32] Assistant button performance and visibility fixes
2 parents f7237e5 + 2ec5261 commit fb4f226

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

src/components/Menu/AssistantAction.vue

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
close-after-click
6060
@click="showTaskList = true">
6161
<template #icon>
62-
<NcAssistantIcon :size="20" class="assistant-icon" />
62+
<NcLoadingIcon v-if="loading" :size="20" />
63+
<NcAssistantIcon v-else :size="20" class="assistant-icon" />
6364
</template>
6465
{{ t('text', 'Show assistant results') }}
6566
</NcActionButton>
@@ -161,6 +162,7 @@ import NcActions from '@nextcloud/vue/components/NcActions'
161162
import NcActionSeparator from '@nextcloud/vue/components/NcActionSeparator'
162163
import NcAssistantIcon from '@nextcloud/vue/components/NcAssistantIcon'
163164
import NcListItem from '@nextcloud/vue/components/NcListItem'
165+
import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon'
164166
import NcModal from '@nextcloud/vue/components/NcModal'
165167
import ErrorOutlineIcon from 'vue-material-design-icons/AlertCircleOutline.vue'
166168
import CheckCircleOutlineIcon from 'vue-material-design-icons/CheckCircleOutline.vue'
@@ -206,6 +208,7 @@ export default {
206208
NcActionButton,
207209
NcActionSeparator,
208210
NcListItem,
211+
NcLoadingIcon,
209212
NcModal,
210213
},
211214
extends: BaseActionEntry,
@@ -217,9 +220,10 @@ export default {
217220
data() {
218221
return {
219222
menuOpen: false,
220-
taskTypes: OCP.InitialState.loadState('text', 'taskprocessing'),
223+
taskTypes: loadState('text', 'taskprocessing', []),
221224
selection: '',
222225
tasks: [],
226+
loading: false,
223227
224228
STATUS_FAILED,
225229
STATUS_RUNNING,
@@ -262,9 +266,17 @@ export default {
262266
return this.taskTypes.map((type) => type.id)
263267
},
264268
},
269+
watch: {
270+
async menuOpen(isOpen) {
271+
if (isOpen && this.tasks.length === 0) {
272+
this.loading = true
273+
await this.fetchTasks()
274+
this.loading = false
275+
}
276+
},
277+
},
265278
beforeMount() {
266279
this.editor.on('selectionUpdate', this.onSelection)
267-
this.fetchTasks()
268280
subscribe('notifications:notification:received', this.checkNotification)
269281
},
270282
beforeDestroy() {

src/components/Menu/MenuBar.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,12 @@ export default {
129129
130130
data() {
131131
return {
132-
entries: this.openReadOnly
132+
entries: (this.openReadOnly
133133
? [...ReadOnlyDoneEntries, ...MenuEntries]
134134
: this.isPublic || this.isRichWorkSpace
135135
? [...MenuEntries]
136-
: [...MenuEntries, ...AssistantMenuEntries],
136+
: [...MenuEntries, ...AssistantMenuEntries]
137+
).filter((entry) => !!entry),
137138
randomID: `menu-bar-${Math.ceil(Math.random() * 10000 + 500).toString(16)}`,
138139
displayHelp: false,
139140
isReady: false,

src/components/Menu/entries.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import ActionInsertLink from './ActionInsertLink.vue'
4242
import AssistantAction from './AssistantAction.vue'
4343
import EmojiPickerAction from './EmojiPickerAction.vue'
4444

45+
import { loadState } from '@nextcloud/initial-state'
4546
import { t } from '@nextcloud/l10n'
4647
import { isMobileDevice } from '../../helpers/isMobileDevice.js'
4748
import { MODIFIERS } from './keys.js'
@@ -438,11 +439,15 @@ if (!isMobileDevice) {
438439
})
439440
}
440441

442+
const hasAssistantTaskTypes = loadState('text', 'taskprocessing', []).length > 0
443+
441444
export const AssistantMenuEntries = [
442-
{
443-
key: 'assistant',
444-
label: t('text', 'Nextcloud Assistant'),
445-
component: AssistantAction,
446-
priority: 7,
447-
},
445+
hasAssistantTaskTypes
446+
? {
447+
key: 'assistant',
448+
label: t('text', 'Nextcloud Assistant'),
449+
component: AssistantAction,
450+
priority: 7,
451+
}
452+
: undefined,
448453
]

0 commit comments

Comments
 (0)