Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add empty content when history is empty #63

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/AssistantTextProcessingForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</div>
<TaskList
class="history--list"
:task-type="mySelectedTaskTypeId"
:task-type="selectedTaskType"
:loading.sync="historyLoading"
@try-again="onHistoryTryAgain"
@load-task="onHistoryLoadTask" />
Expand Down
44 changes: 31 additions & 13 deletions src/components/TaskList.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
<template>
<ul
class="task-list">
<TaskListItem v-for="task in tasks"
:key="task.id"
class="task-list--item"
:task="task"
@try-again="$emit('try-again', task)"
@load="$emit('load-task', task)"
@delete="onTaskDelete(task)"
@cancel="onTaskCancel(task)" />
</ul>
<div>
<ul
class="task-list">
<TaskListItem v-for="task in tasks"
:key="task.id"
class="task-list--item"
:task="task"
@try-again="$emit('try-again', task)"
@load="$emit('load-task', task)"
@delete="onTaskDelete(task)"
@cancel="onTaskCancel(task)" />
</ul>
<NcEmptyContent v-if="!loading && tasks.length === 0"
:name="t('assistant', 'Nothing yet')"
:description="emptyContentDescription">
<template #icon>
<HistoryIcon />
</template>
</NcEmptyContent>
</div>
</template>

<script>
import HistoryIcon from 'vue-material-design-icons/History.vue'

import TaskListItem from './TaskListItem.vue'

import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'

import axios from '@nextcloud/axios'
import { generateOcsUrl } from '@nextcloud/router'

Expand All @@ -24,12 +37,14 @@ export default {
name: 'TaskList',

components: {
HistoryIcon,
TaskListItem,
NcEmptyContent,
},

props: {
taskType: {
type: [String, null],
type: [Object, null],
default: null,
},
loading: {
Expand All @@ -50,6 +65,9 @@ export default {
},

computed: {
emptyContentDescription() {
return t('assistant', 'You have not submitted any "{taskTypeName}" task yet', { taskTypeName: this.taskType?.name })
},
},

watch: {
Expand All @@ -67,7 +85,7 @@ export default {
this.$emit('update:loading', true)
const req = {
params: {
taskType: this.taskType,
taskType: this.taskType.id,
},
}
const url = generateOcsUrl('/apps/assistant/api/v1/tasks')
Expand Down
Loading