feat(home): correctly check if tasks exist before showing import hint
Resolves https://community.vikunja.io/t/import-your-data-button-is-shown-unnecessarily/3681/5
This commit is contained in:
parent
c3fffefcf4
commit
0bb287023e
|
|
@ -0,0 +1,47 @@
|
|||
<script lang="ts" setup>
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useConfigStore } from '@/stores/config'
|
||||
import { useBaseStore } from '@/stores/base'
|
||||
import { useTaskStore } from '@/stores/tasks'
|
||||
import TaskService from '@/services/task'
|
||||
|
||||
const configStore = useConfigStore()
|
||||
const baseStore = useBaseStore()
|
||||
const taskStore = useTaskStore()
|
||||
|
||||
const migratorsEnabled = computed(() => configStore.availableMigrators?.length > 0)
|
||||
const hasTasks = computed(() => baseStore.hasTasks)
|
||||
const loading = computed(() => taskStore.isLoading)
|
||||
const show = ref(false)
|
||||
|
||||
onMounted(async () => {
|
||||
show.value = false
|
||||
|
||||
if (!migratorsEnabled.value) {
|
||||
return
|
||||
}
|
||||
|
||||
if (hasTasks.value) {
|
||||
show.value = false
|
||||
return
|
||||
}
|
||||
|
||||
const taskService = new TaskService()
|
||||
const tasks = await taskService.getAll({}, {per_page: 1})
|
||||
show.value = tasks.length === 0
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<template v-if="show && !loading">
|
||||
<p class="mt-4">
|
||||
{{ $t('home.project.importText') }}
|
||||
</p>
|
||||
<x-button
|
||||
:to="{ name: 'migrate.start' }"
|
||||
:shadow="false"
|
||||
>
|
||||
{{ $t('home.project.import') }}
|
||||
</x-button>
|
||||
</template>
|
||||
</template>
|
||||
|
|
@ -23,17 +23,7 @@
|
|||
class="is-max-width-desktop"
|
||||
@taskAdded="updateTaskKey"
|
||||
/>
|
||||
<template v-if="tasksLoaded && !hasTasks && !loading && migratorsEnabled">
|
||||
<p class="mt-4">
|
||||
{{ $t('home.project.importText') }}
|
||||
</p>
|
||||
<x-button
|
||||
:to="{ name: 'migrate.start' }"
|
||||
:shadow="false"
|
||||
>
|
||||
{{ $t('home.project.import') }}
|
||||
</x-button>
|
||||
</template>
|
||||
<ImportHint v-if="tasksLoaded" />
|
||||
<div
|
||||
v-if="projectHistory.length > 0"
|
||||
class="is-max-width-desktop has-text-left mt-4"
|
||||
|
|
@ -61,25 +51,20 @@ import Message from '@/components/misc/Message.vue'
|
|||
import ShowTasks from '@/views/tasks/ShowTasks.vue'
|
||||
import ProjectCardGrid from '@/components/project/partials/ProjectCardGrid.vue'
|
||||
import AddTask from '@/components/tasks/AddTask.vue'
|
||||
import ImportHint from '@/components/home/ImportHint.vue'
|
||||
|
||||
import {getHistory} from '@/modules/projectHistory'
|
||||
import {parseDateOrNull} from '@/helpers/parseDateOrNull'
|
||||
import {formatDateShort, formatDateSince} from '@/helpers/time/formatDate'
|
||||
import {useDaytimeSalutation} from '@/composables/useDaytimeSalutation'
|
||||
|
||||
import {useBaseStore} from '@/stores/base'
|
||||
import {useProjectStore} from '@/stores/projects'
|
||||
import {useConfigStore} from '@/stores/config'
|
||||
import {useAuthStore} from '@/stores/auth'
|
||||
import {useTaskStore} from '@/stores/tasks'
|
||||
|
||||
const salutation = useDaytimeSalutation()
|
||||
|
||||
const baseStore = useBaseStore()
|
||||
const authStore = useAuthStore()
|
||||
const configStore = useConfigStore()
|
||||
const projectStore = useProjectStore()
|
||||
const taskStore = useTaskStore()
|
||||
|
||||
const projectHistory = computed(() => {
|
||||
// If we don't check this, it tries to load the project background right after logging out
|
||||
|
|
@ -94,9 +79,6 @@ const projectHistory = computed(() => {
|
|||
|
||||
const tasksLoaded = ref(false)
|
||||
|
||||
const migratorsEnabled = computed(() => configStore.availableMigrators?.length > 0)
|
||||
const hasTasks = computed(() => baseStore.hasTasks)
|
||||
const loading = computed(() => taskStore.isLoading)
|
||||
const deletionScheduledAt = computed(() => parseDateOrNull(authStore.info?.deletionScheduledAt))
|
||||
|
||||
// This is to reload the tasks list after adding a new task through the global task add.
|
||||
|
|
|
|||
Loading…
Reference in New Issue