Skip to content

Commit fdee11c

Browse files
authored
Merge pull request #131 from nextcloud/enh/noid/back-buttons-after-launching-task
Add back buttons after launching a task
2 parents e3e3da2 + 63ddaf7 commit fdee11c

File tree

6 files changed

+84
-18
lines changed

6 files changed

+84
-18
lines changed

src/assistant.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ export async function openAssistantForm({
156156
}
157157
view.$destroy()
158158
})
159+
view.$on('back-to-assistant', () => {
160+
view.showScheduleConfirmation = false
161+
view.showSyncTaskRunning = false
162+
view.loading = false
163+
view.outputs = null
164+
lastTask = null
165+
})
159166
})
160167
}
161168

@@ -419,6 +426,13 @@ export async function openAssistantTask(task, { isInsideViewer = undefined, acti
419426
}
420427
view.$destroy()
421428
})
429+
view.$on('back-to-assistant', () => {
430+
view.showScheduleConfirmation = false
431+
view.showSyncTaskRunning = false
432+
view.loading = false
433+
view.outputs = null
434+
lastTask = null
435+
})
422436
}
423437

424438
export async function addAssistantMenuEntry() {

src/components/AssistantTextProcessingModal.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@
2222
:description="shortInput"
2323
:progress="progress"
2424
@background-notify="$emit('background-notify')"
25-
@cancel="$emit('cancel-task')" />
25+
@cancel="$emit('cancel-task')"
26+
@back="onBackToAssistant" />
2627
<ScheduledEmptyContent
2728
v-else-if="showScheduleConfirmation"
2829
:description="shortInput"
2930
:show-close-button="true"
30-
@close="onCancel" />
31+
@close="onCancel"
32+
@back="onBackToAssistant" />
3133
<AssistantTextProcessingForm
3234
v-else
3335
class="form"
@@ -122,6 +124,7 @@ export default {
122124
'action-button-clicked',
123125
'try-again',
124126
'load-task',
127+
'back-to-assistant',
125128
],
126129
data() {
127130
return {
@@ -151,6 +154,9 @@ export default {
151154
}
152155
},
153156
methods: {
157+
onBackToAssistant() {
158+
this.$emit('back-to-assistant')
159+
},
154160
onCancel() {
155161
this.show = false
156162
this.$emit('cancel')

src/components/RunningEmptyContent.vue

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
:name="t('assistant', 'Getting results…')"
44
:description="description">
55
<template #action>
6-
<div class="actions">
6+
<div class="running-actions">
77
<div v-if="progress !== null"
88
class="progress">
99
<span>{{ formattedProgress }} %</span>
@@ -12,11 +12,24 @@
1212
</div>
1313
<NcButton
1414
@click="$emit('background-notify')">
15-
{{ t('assistant', 'Run in the background and get notified') }}
15+
<template #icon>
16+
<ProgressClockIcon />
17+
</template>
18+
{{ t('assistant', 'Run task in the background and get notified') }}
19+
</NcButton>
20+
<NcButton
21+
@click="$emit('back')">
22+
<template #icon>
23+
<ArrowLeftIcon />
24+
</template>
25+
{{ t('assistant', 'Back to the Assistant') }}
1626
</NcButton>
1727
<NcButton
1828
@click="$emit('cancel')">
19-
{{ t('assistant', 'Cancel') }}
29+
<template #icon>
30+
<CloseIcon />
31+
</template>
32+
{{ t('assistant', 'Cancel task') }}
2033
</NcButton>
2134
</div>
2235
</template>
@@ -27,6 +40,10 @@
2740
</template>
2841

2942
<script>
43+
import ArrowLeftIcon from 'vue-material-design-icons/ArrowLeft.vue'
44+
import CloseIcon from 'vue-material-design-icons/Close.vue'
45+
import ProgressClockIcon from 'vue-material-design-icons/ProgressClock.vue'
46+
3047
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
3148
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
3249
import NcProgressBar from '@nextcloud/vue/dist/Components/NcProgressBar.js'
@@ -40,6 +57,9 @@ export default {
4057
NcEmptyContent,
4158
NcLoadingIcon,
4259
NcProgressBar,
60+
ArrowLeftIcon,
61+
CloseIcon,
62+
ProgressClockIcon,
4363
},
4464
4565
props: {
@@ -56,6 +76,7 @@ export default {
5676
emits: [
5777
'cancel',
5878
'background-notify',
79+
'back',
5980
],
6081
6182
data() {
@@ -81,9 +102,10 @@ export default {
81102
</script>
82103

83104
<style lang="scss">
84-
.actions {
105+
.running-actions {
85106
display: flex;
86107
flex-direction: column;
108+
align-items: center;
87109
gap: 12px;
88110
89111
.progress {

src/components/ScheduledEmptyContent.vue

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@
22
<NcEmptyContent
33
:name="title"
44
:description="t('assistant', 'You will receive a notification when it has finished')">
5-
<template v-if="showCloseButton" #action>
6-
<NcButton
7-
type="tertiary"
8-
@click="$emit('close')">
9-
<template #icon>
10-
<CloseIcon />
11-
</template>
12-
{{ t('assistant', 'Close') }}
13-
</NcButton>
5+
<template #action>
6+
<div class="schedule-confirmation-actions">
7+
<NcButton
8+
@click="$emit('back')">
9+
<template #icon>
10+
<ArrowLeftIcon />
11+
</template>
12+
{{ t('assistant', 'Back to the Assistant') }}
13+
</NcButton>
14+
<NcButton v-if="showCloseButton"
15+
@click="$emit('close')">
16+
<template #icon>
17+
<CloseIcon />
18+
</template>
19+
{{ t('assistant', 'Close') }}
20+
</NcButton>
21+
</div>
1422
</template>
1523
<template #icon>
1624
<AssistantIcon />
@@ -20,6 +28,7 @@
2028

2129
<script>
2230
import CloseIcon from 'vue-material-design-icons/Close.vue'
31+
import ArrowLeftIcon from 'vue-material-design-icons/ArrowLeft.vue'
2332
2433
import AssistantIcon from './icons/AssistantIcon.vue'
2534
@@ -34,6 +43,7 @@ export default {
3443
NcButton,
3544
NcEmptyContent,
3645
CloseIcon,
46+
ArrowLeftIcon,
3747
},
3848
3949
props: {
@@ -49,6 +59,7 @@ export default {
4959
5060
emits: [
5161
'cancel',
62+
'back',
5263
],
5364
5465
data() {
@@ -69,5 +80,10 @@ export default {
6980
</script>
7081

7182
<style lang="scss">
72-
// nothing yet
83+
.schedule-confirmation-actions {
84+
display: flex;
85+
flex-direction: column;
86+
align-items: center;
87+
gap: 12px;
88+
}
7389
</style>

src/components/TaskListItem.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
{{ t('assistant', 'Try again') }}
3939
</NcActionButton>
4040
<NcActionButton v-if="isScheduled || isRunning"
41+
:close-after-click="true"
4142
@click="$emit('cancel')">
4243
<template #icon>
4344
<CloseIcon />

src/views/AssistantPage.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
:description="shortInput"
88
:progress="progress"
99
@background-notify="onBackgroundNotify"
10-
@cancel="onCancel" />
10+
@cancel="onCancel"
11+
@back="onBackToAssistant" />
1112
<ScheduledEmptyContent
1213
v-else-if="showScheduleConfirmation"
1314
:description="shortInput"
14-
:show-close-button="false" />
15+
:show-close-button="false"
16+
@back="onBackToAssistant" />
1517
<AssistantTextProcessingForm
1618
v-else
1719
class="form"
@@ -95,6 +97,11 @@ export default {
9597
this.showSyncTaskRunning = false
9698
setNotifyReady(this.task.id)
9799
},
100+
onBackToAssistant() {
101+
this.showSyncTaskRunning = false
102+
this.showScheduleConfirmation = false
103+
this.task.output = null
104+
},
98105
onCancel() {
99106
cancelTaskPolling()
100107
cancelTask(this.task.id)

0 commit comments

Comments
 (0)