From 7e218e03b2d1671d906b3494a0f9bf2d8d36d4d1 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 23 Oct 2022 14:01:20 +0200 Subject: [PATCH] fix(task): only show create list or import cta when there are no tasks --- cypress/e2e/task/overview.spec.ts | 20 ++++++++++++++++++++ src/stores/tasks.ts | 2 ++ 2 files changed, 22 insertions(+) diff --git a/cypress/e2e/task/overview.spec.ts b/cypress/e2e/task/overview.spec.ts index 147c70b61..a84eb36ef 100644 --- a/cypress/e2e/task/overview.spec.ts +++ b/cypress/e2e/task/overview.spec.ts @@ -128,4 +128,24 @@ describe('Home Page Task Overview', () => { .last() .should('contain.text', newTaskTitle) }) + + it('Should show the cta buttons for new list when there are no tasks', () => { + TaskFactory.truncate() + + cy.visit('/') + + cy.get('.home.app-content .content') + .should('contain.text', 'You can create a new list for your new tasks:') + .should('contain.text', 'Or import your lists and tasks from other services into Vikunja:') + }) + + it('Should not show the cta buttons for new list when there are tasks', () => { + seedTasks() + + cy.visit('/') + + cy.get('.home.app-content .content') + .should('not.contain.text', 'You can create a new list for your new tasks:') + .should('not.contain.text', 'Or import your lists and tasks from other services into Vikunja:') + }) }) diff --git a/src/stores/tasks.ts b/src/stores/tasks.ts index e28252f24..d7ab57842 100644 --- a/src/stores/tasks.ts +++ b/src/stores/tasks.ts @@ -28,6 +28,7 @@ import {useLabelStore} from '@/stores/labels' import {useListStore} from '@/stores/lists' import {useAttachmentStore} from '@/stores/attachments' import {useKanbanStore} from '@/stores/kanban' +import {useBaseStore} from '@/stores/base' // IDEA: maybe use a small fuzzy search here to prevent errors function findPropertyByValue(object, key, value) { @@ -105,6 +106,7 @@ export const useTaskStore = defineStore('task', { const cancel = setModuleLoading(this) try { this.tasks = await taskService.getAll({}, params) + useBaseStore().setHasTasks(this.tasks.length > 0) return this.tasks } finally { cancel()