Compare commits

...

3 Commits

Author SHA1 Message Date
dependabot[bot]
aa8ab44c79 Bump the minor-updates group across 1 directory with 18 updates
Bumps the minor-updates group with 18 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [brick/money](https://github.com/brick/money) | `0.15.1` | `0.15.2` |
| [dedoc/scramble](https://github.com/dedoc/scramble) | `0.13.45` | `0.13.48` |
| [filament/filament](https://github.com/filamentphp/panels) | `5.8.4` | `5.10.2` |
| [gotenberg/gotenberg-php](https://github.com/gotenberg/gotenberg-php) | `2.25.0` | `2.26.0` |
| [guzzlehttp/guzzle](https://github.com/guzzle/guzzle) | `8.2.0` | `8.3.0` |
| [inertiajs/inertia-laravel](https://github.com/inertiajs/inertia-laravel) | `3.3.4` | `3.5.1` |
| [laravel/fortify](https://github.com/laravel/fortify) | `1.40.0` | `1.41.0` |
| [laravel/framework](https://github.com/laravel/framework) | `13.33.0` | `13.37.0` |
| [laravel/octane](https://github.com/laravel/octane) | `2.20.0` | `2.22.0` |
| [laravel/passport](https://github.com/laravel/passport) | `13.8.0` | `13.10.0` |
| [maatwebsite/excel](https://github.com/SpartnerNL/Laravel-Excel) | `4.0.3` | `4.0.4` |
| [stechstudio/filament-impersonate](https://github.com/stechstudio/filament-impersonate) | `5.6.0` | `5.6.1` |
| [tightenco/ziggy](https://github.com/tighten/ziggy) | `2.6.4` | `2.6.5` |
| [tpetry/laravel-postgresql-enhanced](https://github.com/tpetry/laravel-postgresql-enhanced) | `3.7.0` | `3.10.0` |
| [fumeapp/modeltyper](https://github.com/fumeapp/modeltyper) | `3.13.0` | `3.14.0` |
| [larastan/larastan](https://github.com/larastan/larastan) | `3.12.2` | `3.13.0` |
| [laravel/sail](https://github.com/laravel/sail) | `1.68.0` | `1.69.0` |
| [laravel/telescope](https://github.com/laravel/telescope) | `5.25.0` | `5.26.0` |



Updates `brick/money` from 0.15.1 to 0.15.2
- [Release notes](https://github.com/brick/money/releases)
- [Changelog](https://github.com/brick/money/blob/main/CHANGELOG.md)
- [Commits](https://github.com/brick/money/compare/0.15.1...0.15.2)

Updates `dedoc/scramble` from 0.13.45 to 0.13.48
- [Release notes](https://github.com/dedoc/scramble/releases)
- [Commits](https://github.com/dedoc/scramble/compare/v0.13.45...v0.13.48)

Updates `filament/filament` from 5.8.4 to 5.10.2
- [Commits](https://github.com/filamentphp/panels/compare/v5.8.4...v5.10.2)

Updates `gotenberg/gotenberg-php` from 2.25.0 to 2.26.0
- [Release notes](https://github.com/gotenberg/gotenberg-php/releases)
- [Commits](https://github.com/gotenberg/gotenberg-php/compare/v2.25.0...v2.26.0)

Updates `guzzlehttp/guzzle` from 8.2.0 to 8.3.0
- [Release notes](https://github.com/guzzle/guzzle/releases)
- [Changelog](https://github.com/guzzle/guzzle/blob/8.3/CHANGELOG.md)
- [Commits](https://github.com/guzzle/guzzle/compare/8.2.0...8.3.0)

Updates `inertiajs/inertia-laravel` from 3.3.4 to 3.5.1
- [Release notes](https://github.com/inertiajs/inertia-laravel/releases)
- [Changelog](https://github.com/inertiajs/inertia-laravel/blob/3.x/CHANGELOG.md)
- [Commits](https://github.com/inertiajs/inertia-laravel/compare/v3.3.4...v3.5.1)

Updates `laravel/fortify` from 1.40.0 to 1.41.0
- [Release notes](https://github.com/laravel/fortify/releases)
- [Changelog](https://github.com/laravel/fortify/blob/1.x/CHANGELOG.md)
- [Commits](https://github.com/laravel/fortify/compare/v1.40.0...v1.41.0)

Updates `laravel/framework` from 13.33.0 to 13.37.0
- [Release notes](https://github.com/laravel/framework/releases)
- [Changelog](https://github.com/laravel/framework/blob/13.x/CHANGELOG.md)
- [Commits](https://github.com/laravel/framework/compare/v13.33.0...v13.37.0)

Updates `laravel/octane` from 2.20.0 to 2.22.0
- [Release notes](https://github.com/laravel/octane/releases)
- [Changelog](https://github.com/laravel/octane/blob/2.x/CHANGELOG.md)
- [Commits](https://github.com/laravel/octane/compare/v2.20.0...v2.22.0)

Updates `laravel/passport` from 13.8.0 to 13.10.0
- [Release notes](https://github.com/laravel/passport/releases)
- [Changelog](https://github.com/laravel/passport/blob/13.x/CHANGELOG.md)
- [Commits](https://github.com/laravel/passport/compare/v13.8.0...v13.10.0)

Updates `maatwebsite/excel` from 4.0.3 to 4.0.4
- [Release notes](https://github.com/SpartnerNL/Laravel-Excel/releases)
- [Changelog](https://github.com/SpartnerNL/Laravel-Excel/blob/4.x/CHANGELOG.md)
- [Commits](https://github.com/SpartnerNL/Laravel-Excel/compare/4.0.3...4.0.4)

Updates `stechstudio/filament-impersonate` from 5.6.0 to 5.6.1
- [Release notes](https://github.com/stechstudio/filament-impersonate/releases)
- [Commits](https://github.com/stechstudio/filament-impersonate/compare/v5.6.0...v5.6.1)

Updates `tightenco/ziggy` from 2.6.4 to 2.6.5
- [Release notes](https://github.com/tighten/ziggy/releases)
- [Changelog](https://github.com/tighten/ziggy/blob/2.x/CHANGELOG.md)
- [Commits](https://github.com/tighten/ziggy/compare/v2.6.4...v2.6.5)

Updates `tpetry/laravel-postgresql-enhanced` from 3.7.0 to 3.10.0
- [Changelog](https://github.com/tpetry/laravel-postgresql-enhanced/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tpetry/laravel-postgresql-enhanced/compare/3.7.0...3.10.0)

Updates `fumeapp/modeltyper` from 3.13.0 to 3.14.0
- [Release notes](https://github.com/fumeapp/modeltyper/releases)
- [Commits](https://github.com/fumeapp/modeltyper/compare/v3.13.0...v3.14.0)

Updates `larastan/larastan` from 3.12.2 to 3.13.0
- [Release notes](https://github.com/larastan/larastan/releases)
- [Changelog](https://github.com/larastan/larastan/blob/3.x/RELEASE.md)
- [Commits](https://github.com/larastan/larastan/compare/v3.12.2...v3.13.0)

Updates `laravel/sail` from 1.68.0 to 1.69.0
- [Release notes](https://github.com/laravel/sail/releases)
- [Changelog](https://github.com/laravel/sail/blob/1.x/CHANGELOG.md)
- [Commits](https://github.com/laravel/sail/compare/v1.68.0...v1.69.0)

Updates `laravel/telescope` from 5.25.0 to 5.26.0
- [Release notes](https://github.com/laravel/telescope/releases)
- [Changelog](https://github.com/laravel/telescope/blob/5.x/CHANGELOG.md)
- [Commits](https://github.com/laravel/telescope/compare/v5.25.0...v5.26.0)

---
updated-dependencies:
- dependency-name: brick/money
  dependency-version: 0.15.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-updates
- dependency-name: dedoc/scramble
  dependency-version: 0.13.48
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-updates
- dependency-name: filament/filament
  dependency-version: 5.10.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-updates
- dependency-name: gotenberg/gotenberg-php
  dependency-version: 2.26.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-updates
- dependency-name: guzzlehttp/guzzle
  dependency-version: 8.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-updates
- dependency-name: inertiajs/inertia-laravel
  dependency-version: 3.5.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-updates
- dependency-name: laravel/fortify
  dependency-version: 1.41.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-updates
- dependency-name: laravel/framework
  dependency-version: 13.37.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-updates
- dependency-name: laravel/octane
  dependency-version: 2.22.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-updates
- dependency-name: laravel/passport
  dependency-version: 13.10.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-updates
- dependency-name: maatwebsite/excel
  dependency-version: 4.0.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-updates
- dependency-name: stechstudio/filament-impersonate
  dependency-version: 5.6.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-updates
- dependency-name: tightenco/ziggy
  dependency-version: 2.6.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-updates
- dependency-name: tpetry/laravel-postgresql-enhanced
  dependency-version: 3.10.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-updates
- dependency-name: fumeapp/modeltyper
  dependency-version: 3.14.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-updates
- dependency-name: larastan/larastan
  dependency-version: 3.13.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-updates
- dependency-name: laravel/sail
  dependency-version: 1.69.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-updates
- dependency-name: laravel/telescope
  dependency-version: 5.26.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-updates
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-10-19 08:06:04 +00:00
Gregor Vostrak
b46f015754 Always show the create goal button and open the upgrade modal when the goal limit is reached 2026-10-14 16:59:51 +02:00
Gregor Vostrak
fc8985f513 Invalidate goals after time entry and member changes 2026-10-14 16:59:51 +02:00
16 changed files with 805 additions and 525 deletions

1075
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -342,6 +342,89 @@ test('test that a running time entry counts towards the goal progress', async ({
); );
}); });
// Close to midnight UTC an entry that started a few minutes ago could fall on the previous day, so
// the day of the goal is moved to a timezone (without daylight saving time) where it is late morning
function timezoneAwayFromMidnight() {
const utcHour = new Date().getUTCHours();
return utcHour >= 2 && utcHour < 22 ? 'UTC' : 'Asia/Tokyo';
}
// Navigates via the sidebar, a full page load would start with an empty query cache and hide
// a missing goals invalidation
async function navigateViaSidebar(page: Page, name: 'Time' | 'Goals') {
await page.getByRole('link', { name, exact: true }).first().click();
await expect(page).toHaveURL(new RegExp('/' + name.toLowerCase() + '$'));
}
test('test that goal progress updates after creating a time entry without a page reload', async ({
page,
ctx,
}) => {
const goal = await createGoalViaApi(ctx, {
name: 'Cache goal',
target_seconds: 3600,
period: 'day',
timezone: timezoneAwayFromMidnight(),
});
await goToGoalsOverview(page);
await expect(goalRow(page, goal.id).getByTestId('goal_tracked_time')).toHaveText('0h 00min');
await navigateViaSidebar(page, 'Time');
await page.getByRole('button', { name: 'Time entry actions' }).click();
await page.getByRole('menuitem', { name: 'Manual time entry' }).click();
const durationInput = page.locator('[role="dialog"] input[name="Duration"]');
await durationInput.fill('15min');
await durationInput.press('Tab');
await Promise.all([
page.waitForResponse(
(response) => response.url().includes('/time-entries') && response.status() === 201
),
page.getByRole('button', { name: 'Create Time Entry' }).click(),
]);
await navigateViaSidebar(page, 'Goals');
await expect(goalRow(page, goal.id).getByTestId('goal_tracked_time')).toHaveText('0h 15min');
});
test('test that goal progress updates after changing the project of the running time entry without a page reload', async ({
page,
ctx,
}) => {
const project = await createProjectViaApi(ctx, { name: 'Running Project', is_public: true });
const start = new Date(Date.now() - 30 * 60 * 1000).toISOString().replace(/\.\d{3}Z$/, 'Z');
await createRunningTimeEntryWithStartViaApi(ctx, 'Running work', start);
const goal = await createGoalViaApi(ctx, {
name: 'Running project goal',
target_seconds: 3600,
period: 'day',
timezone: timezoneAwayFromMidnight(),
filters: { project_ids: [project.id], time_entry_type: 'work' },
});
await goToGoalsOverview(page);
await expect(goalRow(page, goal.id).getByTestId('goal_tracked_time')).toHaveText('0h 00min');
await navigateViaSidebar(page, 'Time');
await page.getByRole('button', { name: 'No Project' }).click();
await Promise.all([
page.waitForResponse(
async (response) =>
response.url().includes('/time-entries') &&
response.request().method() === 'PUT' &&
response.status() === 200 &&
(await response.json()).data.project_id === project.id
),
page.getByRole('option').filter({ hasText: project.name }).click(),
]);
await navigateViaSidebar(page, 'Goals');
// The entry keeps running while the test runs
await expect(goalRow(page, goal.id).getByTestId('goal_tracked_time')).toHaveText(
/^0h 3[0-2]min$/
);
});
test('test that editing a goal via the modal works', async ({ page, ctx }) => { test('test that editing a goal via the modal works', async ({ page, ctx }) => {
const goal = await createGoalViaApi(ctx, { const goal = await createGoalViaApi(ctx, {
name: 'Old goal name', name: 'Old goal name',

View File

@@ -29,6 +29,7 @@ import ClientCreateModal from '@/Components/Common/Client/ClientCreateModal.vue'
import TaskCreateModal from '@/Components/Common/Task/TaskCreateModal.vue'; import TaskCreateModal from '@/Components/Common/Task/TaskCreateModal.vue';
import TagCreateModal from '@/packages/ui/src/Tag/TagCreateModal.vue'; import TagCreateModal from '@/packages/ui/src/Tag/TagCreateModal.vue';
import GoalCreateModal from '@/Components/Common/Goal/GoalCreateModal.vue'; import GoalCreateModal from '@/Components/Common/Goal/GoalCreateModal.vue';
import UpgradeModal from '@/packages/ui/src/UpgradeModal.vue';
import MemberInviteModal from '@/Components/Common/Member/MemberInviteModal.vue'; import MemberInviteModal from '@/Components/Common/Member/MemberInviteModal.vue';
import TimeEntryCreateModal from '@/packages/ui/src/TimeEntry/TimeEntryCreateModal.vue'; import TimeEntryCreateModal from '@/packages/ui/src/TimeEntry/TimeEntryCreateModal.vue';
@@ -53,6 +54,7 @@ const {
showCreateTaskModal, showCreateTaskModal,
showCreateTagModal, showCreateTagModal,
showCreateGoalModal, showCreateGoalModal,
showGoalUpgradeModal,
showInviteMemberModal, showInviteMemberModal,
showCreateTimeEntryModal, showCreateTimeEntryModal,
showProjectSelector, showProjectSelector,
@@ -185,6 +187,7 @@ const firstProjectId = computed(() => projects.value[0]?.id ?? '');
<!-- Goal Create Modal --> <!-- Goal Create Modal -->
<GoalCreateModal v-model:show="showCreateGoalModal" /> <GoalCreateModal v-model:show="showCreateGoalModal" />
<UpgradeModal v-model:show="showGoalUpgradeModal" feature="goals" />
<!-- Member Invite Modal --> <!-- Member Invite Modal -->
<MemberInviteModal v-model:show="showInviteMemberModal" :available-roles="availableRoles" /> <MemberInviteModal v-model:show="showInviteMemberModal" :available-roles="availableRoles" />

View File

@@ -0,0 +1,43 @@
import { describe, it, expect } from 'vitest';
import { mount } from '@vue/test-utils';
import GoalCreateButton from './GoalCreateButton.vue';
function mountGoalCreateButton(canCreateMoreGoals: boolean) {
return mount(GoalCreateButton, {
props: { canCreateMoreGoals },
slots: { default: 'Create your first goal' },
global: {
stubs: {
GoalCreateModal: { name: 'GoalCreateModal', props: ['show'], template: '<div />' },
UpgradeModal: {
name: 'UpgradeModal',
props: ['show', 'feature'],
template: '<div />',
},
},
},
});
}
describe('GoalCreateButton', () => {
it('opens the create modal while more goals can be created', async () => {
const wrapper = mountGoalCreateButton(true);
await wrapper.get('button').trigger('click');
expect(wrapper.getComponent({ name: 'GoalCreateModal' }).props('show')).toBe(true);
expect(wrapper.getComponent({ name: 'UpgradeModal' }).props('show')).toBe(false);
});
it('opens the upgrade modal once the goal limit is reached', async () => {
const wrapper = mountGoalCreateButton(false);
expect(wrapper.get('button').text()).toBe('Create your first goal');
await wrapper.get('button').trigger('click');
const upgradeModal = wrapper.getComponent({ name: 'UpgradeModal' });
expect(upgradeModal.props('show')).toBe(true);
expect(upgradeModal.props('feature')).toBe('goals');
expect(wrapper.getComponent({ name: 'GoalCreateModal' }).props('show')).toBe(false);
});
});

View File

@@ -0,0 +1,31 @@
<script setup lang="ts">
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
import UpgradeModal from '@/packages/ui/src/UpgradeModal.vue';
import GoalCreateModal from '@/Components/Common/Goal/GoalCreateModal.vue';
import { PlusIcon } from '@heroicons/vue/16/solid';
import { ref } from 'vue';
const props = defineProps<{
canCreateMoreGoals: boolean;
}>();
const showCreateGoalModal = ref(false);
const showUpgradeModal = ref(false);
// The button stays visible when the goal limit is reached and explains the limit instead
function onClick() {
if (props.canCreateMoreGoals) {
showCreateGoalModal.value = true;
} else {
showUpgradeModal.value = true;
}
}
</script>
<template>
<GoalCreateModal v-model:show="showCreateGoalModal"></GoalCreateModal>
<UpgradeModal v-model:show="showUpgradeModal" feature="goals" />
<SecondaryButton :icon="PlusIcon" @click="onClick">
<slot>Create Goal</slot>
</SecondaryButton>
</template>

View File

@@ -1,12 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
import { Target } from '@lucide/vue'; import { Target } from '@lucide/vue';
import { PlusIcon } from '@heroicons/vue/16/solid';
import { ref } from 'vue';
import type { Goal } from '@/packages/api/src'; import type { Goal } from '@/packages/api/src';
import GoalTableRow from '@/Components/Common/Goal/GoalTableRow.vue'; import GoalTableRow from '@/Components/Common/Goal/GoalTableRow.vue';
import GoalTableHeading from '@/Components/Common/Goal/GoalTableHeading.vue'; import GoalTableHeading from '@/Components/Common/Goal/GoalTableHeading.vue';
import GoalCreateModal from '@/Components/Common/Goal/GoalCreateModal.vue'; import GoalCreateButton from '@/Components/Common/Goal/GoalCreateButton.vue';
import { canCreateGoals } from '@/utils/permissions'; import { canCreateGoals } from '@/utils/permissions';
import { LoadingSpinner } from '@/packages/ui/src'; import { LoadingSpinner } from '@/packages/ui/src';
import { isGoalsExtensionActivated } from '@/utils/billing'; import { isGoalsExtensionActivated } from '@/utils/billing';
@@ -18,7 +15,6 @@ const props = defineProps<{
showingArchived: boolean; showingArchived: boolean;
}>(); }>();
const showCreateGoalModal = ref(false);
const showTargetColumn = isGoalsExtensionActivated(); const showTargetColumn = isGoalsExtensionActivated();
// Every column gets a share of the free space so the columns are spread evenly over the table // Every column gets a share of the free space so the columns are spread evenly over the table
const gridTemplateColumns = [ const gridTemplateColumns = [
@@ -33,7 +29,6 @@ const gridTemplateColumns = [
</script> </script>
<template> <template>
<GoalCreateModal v-model:show="showCreateGoalModal"></GoalCreateModal>
<div class="flow-root max-w-[100vw] overflow-x-auto"> <div class="flow-root max-w-[100vw] overflow-x-auto">
<div class="inline-block min-w-full align-middle"> <div class="inline-block min-w-full align-middle">
<div data-testid="goal_table" class="grid min-w-full" :style="{ gridTemplateColumns }"> <div data-testid="goal_table" class="grid min-w-full" :style="{ gridTemplateColumns }">
@@ -51,14 +46,11 @@ const gridTemplateColumns = [
<p v-if="canCreateGoals() && !props.showingArchived" class="pb-5"> <p v-if="canCreateGoals() && !props.showingArchived" class="pb-5">
Set yourself a target and track your progress every day, week or month. Set yourself a target and track your progress every day, week or month.
</p> </p>
<SecondaryButton <GoalCreateButton
v-if=" v-if="canCreateGoals() && !props.showingArchived"
canCreateGoals() && !props.showingArchived && props.canCreateMoreGoals :can-create-more-goals="props.canCreateMoreGoals"
"
:icon="PlusIcon"
@click="showCreateGoalModal = true"
>Create your first goal >Create your first goal
</SecondaryButton> </GoalCreateButton>
</div> </div>
<template v-for="goal in props.goals" :key="goal.id"> <template v-for="goal in props.goals" :key="goal.id">
<GoalTableRow <GoalTableRow

View File

@@ -43,6 +43,7 @@ const deleteMutation = useMutation({
onSuccess: () => { onSuccess: () => {
close(); close();
queryClient.invalidateQueries({ queryKey: ['members'] }); queryClient.invalidateQueries({ queryKey: ['members'] });
queryClient.invalidateQueries({ queryKey: ['goals'] });
}, },
}); });

View File

@@ -52,6 +52,7 @@ async function submit() {
'There was an error merging the members.', 'There was an error merging the members.',
() => { () => {
queryClient.invalidateQueries({ queryKey: ['members'] }); queryClient.invalidateQueries({ queryKey: ['members'] });
queryClient.invalidateQueries({ queryKey: ['goals'] });
show.value = false; show.value = false;
} }
); );

View File

@@ -2,19 +2,15 @@
import MainContainer from '@/packages/ui/src/MainContainer.vue'; import MainContainer from '@/packages/ui/src/MainContainer.vue';
import AppLayout from '@/Layouts/AppLayout.vue'; import AppLayout from '@/Layouts/AppLayout.vue';
import { Target } from '@lucide/vue'; import { Target } from '@lucide/vue';
import { PlusIcon } from '@heroicons/vue/16/solid';
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import GoalTable from '@/Components/Common/Goal/GoalTable.vue'; import GoalTable from '@/Components/Common/Goal/GoalTable.vue';
import GoalCreateModal from '@/Components/Common/Goal/GoalCreateModal.vue'; import GoalCreateButton from '@/Components/Common/Goal/GoalCreateButton.vue';
import PageTitle from '@/Components/Common/PageTitle.vue'; import PageTitle from '@/Components/Common/PageTitle.vue';
import UpgradeBadge from '@/packages/ui/src/UpgradeBadge.vue';
import { canCreateGoals } from '@/utils/permissions'; import { canCreateGoals } from '@/utils/permissions';
import { canCreateMoreGoals } from '@/utils/billing'; import { canCreateMoreGoals } from '@/utils/billing';
import { useGoalsQuery } from '@/utils/useGoalsQuery'; import { useGoalsQuery } from '@/utils/useGoalsQuery';
import { TabBar, TabBarItem } from '@/packages/ui/src'; import { TabBar, TabBarItem } from '@/packages/ui/src';
const showCreateGoalModal = ref(false);
const activeTab = ref('active'); const activeTab = ref('active');
const showArchived = computed(() => activeTab.value === 'archived'); const showArchived = computed(() => activeTab.value === 'archived');
@@ -41,16 +37,9 @@ const canCreateMore = computed(() => canCreateMoreGoals(goals.value.length));
</TabBarItem> </TabBarItem>
</TabBar> </TabBar>
</div> </div>
<div class="flex items-center space-x-3"> <GoalCreateButton
<UpgradeBadge v-if="canCreateGoals() && !canCreateMore" feature="goals" /> v-if="canCreateGoals()"
<SecondaryButton :can-create-more-goals="canCreateMore"></GoalCreateButton>
v-if="canCreateGoals() && canCreateMore"
:icon="PlusIcon"
@click="showCreateGoalModal = true"
>Create Goal
</SecondaryButton>
</div>
<GoalCreateModal v-model:show="showCreateGoalModal"></GoalCreateModal>
</MainContainer> </MainContainer>
<GoalTable <GoalTable
:goals="visibleGoals" :goals="visibleGoals"

View File

@@ -422,6 +422,7 @@ export function useBreakPlacement(deps: BreakPlacementDeps) {
}, },
onSettled: () => { onSettled: () => {
queryClient.invalidateQueries({ queryKey: ['timeEntries'] }); queryClient.invalidateQueries({ queryKey: ['timeEntries'] });
queryClient.invalidateQueries({ queryKey: ['goals'] });
}, },
}); });

View File

@@ -217,6 +217,7 @@ export function useCopyLastWeek(
} }
queryClient.invalidateQueries({ queryKey: ['timeEntries'] }); queryClient.invalidateQueries({ queryKey: ['timeEntries'] });
queryClient.invalidateQueries({ queryKey: ['goals'] });
if (attempted === 0) return; if (attempted === 0) return;

View File

@@ -174,6 +174,7 @@ export function useTimesheetCellMutations(
); );
} finally { } finally {
queryClient.invalidateQueries({ queryKey: ['timeEntries'] }); queryClient.invalidateQueries({ queryKey: ['timeEntries'] });
queryClient.invalidateQueries({ queryKey: ['goals'] });
} }
} }

View File

@@ -22,6 +22,8 @@ import {
canCreateInvitations, canCreateInvitations,
} from '@/utils/permissions'; } from '@/utils/permissions';
import { isBillingActivated, isInvoicingActivated } from '@/utils/billing'; import { isBillingActivated, isInvoicingActivated } from '@/utils/billing';
import { useQueryClient } from '@tanstack/vue-query';
import { fetchCanCreateMoreGoals } from '@/utils/useGoalsQuery';
import { useTimeEntriesInfiniteQuery } from '@/utils/useTimeEntriesInfiniteQuery'; import { useTimeEntriesInfiniteQuery } from '@/utils/useTimeEntriesInfiniteQuery';
import { useProjectsQuery } from '@/utils/useProjectsQuery'; import { useProjectsQuery } from '@/utils/useProjectsQuery';
import { useClientsQuery } from '@/utils/useClientsQuery'; import { useClientsQuery } from '@/utils/useClientsQuery';
@@ -66,6 +68,7 @@ const showCreateClientModal = ref(false);
const showCreateTaskModal = ref(false); const showCreateTaskModal = ref(false);
const showCreateTagModal = ref(false); const showCreateTagModal = ref(false);
const showCreateGoalModal = ref(false); const showCreateGoalModal = ref(false);
const showGoalUpgradeModal = ref(false);
const showInviteMemberModal = ref(false); const showInviteMemberModal = ref(false);
const showCreateTimeEntryModal = ref(false); const showCreateTimeEntryModal = ref(false);
@@ -103,6 +106,7 @@ const ENTITY_ICONS: Record<string, typeof FolderIcon> = {
}; };
export function useCommandPalette() { export function useCommandPalette() {
const queryClient = useQueryClient();
const currentTimeEntryStore = useCurrentTimeEntryStore(); const currentTimeEntryStore = useCurrentTimeEntryStore();
const { currentTimeEntry, isActive } = storeToRefs(currentTimeEntryStore); const { currentTimeEntry, isActive } = storeToRefs(currentTimeEntryStore);
const { setActiveState, updateTimer } = currentTimeEntryStore; const { setActiveState, updateTimer } = currentTimeEntryStore;
@@ -240,9 +244,13 @@ export function useCommandPalette() {
showCreateTagModal.value = true; showCreateTagModal.value = true;
} }
function openCreateGoalModal() { async function openCreateGoalModal() {
closePaletteAfterAction(); closePaletteAfterAction();
showCreateGoalModal.value = true; if (await fetchCanCreateMoreGoals(queryClient)) {
showCreateGoalModal.value = true;
} else {
showGoalUpgradeModal.value = true;
}
} }
function openInviteMemberModal() { function openInviteMemberModal() {
@@ -525,6 +533,7 @@ export function useCommandPalette() {
showCreateTaskModal, showCreateTaskModal,
showCreateTagModal, showCreateTagModal,
showCreateGoalModal, showCreateGoalModal,
showGoalUpgradeModal,
showInviteMemberModal, showInviteMemberModal,
showCreateTimeEntryModal, showCreateTimeEntryModal,
showProjectSelector, showProjectSelector,

View File

@@ -261,6 +261,7 @@ export const useCurrentTimeEntryStore = defineStore('currentTimeEntry', () => {
stopLiveTimer(); stopLiveTimer();
} }
} }
queryClient.invalidateQueries({ queryKey: ['goals'] });
} else { } else {
throw new Error( throw new Error(
'Failed to fetch current time entry because organization ID is missing.' 'Failed to fetch current time entry because organization ID is missing.'

View File

@@ -1,9 +1,10 @@
import { useQuery, useQueryClient } from '@tanstack/vue-query'; import { useQuery, useQueryClient, type QueryClient } from '@tanstack/vue-query';
import { api } from '@/packages/api/src'; import { api } from '@/packages/api/src';
import { getCurrentOrganizationId } from '@/utils/useUser'; import { getCurrentOrganizationId } from '@/utils/useUser';
import type { Goal } from '@/packages/api/src'; import type { Goal } from '@/packages/api/src';
import { computed } from 'vue'; import { computed } from 'vue';
import { fetchAllPages } from '@/utils/fetchAllPages'; import { fetchAllPages } from '@/utils/fetchAllPages';
import { canCreateMoreGoals, goalLimit } from '@/utils/billing';
export type GoalArchivedFilter = 'true' | 'false' | 'all'; export type GoalArchivedFilter = 'true' | 'false' | 'all';
@@ -19,19 +20,38 @@ export async function fetchAllGoals(
); );
} }
export function useGoalsQuery(archived: GoalArchivedFilter = 'false') { export function goalsQueryOptions(archived: GoalArchivedFilter = 'false') {
const queryClient = useQueryClient(); return {
queryKey: ['goals', getCurrentOrganizationId(), archived],
const query = useQuery({
queryKey: computed(() => ['goals', getCurrentOrganizationId(), archived]),
queryFn: async () => { queryFn: async () => {
const organizationId = getCurrentOrganizationId(); const organizationId = getCurrentOrganizationId();
if (!organizationId) throw new Error('No organization'); if (!organizationId) throw new Error('No organization');
const data = await fetchAllGoals(organizationId, archived); const data = await fetchAllGoals(organizationId, archived);
return { data }; return { data };
}, },
enabled: () => !!getCurrentOrganizationId(),
staleTime: 1000 * 30, // 30 seconds staleTime: 1000 * 30, // 30 seconds
};
}
/**
* Checks the goal limit outside of the goals page, where the goals are not loaded yet.
* Archived goals count towards the limit, so all goals are counted.
*/
export async function fetchCanCreateMoreGoals(queryClient: QueryClient): Promise<boolean> {
if (goalLimit() === null) {
return true;
}
const { data } = await queryClient.fetchQuery(goalsQueryOptions('all'));
return canCreateMoreGoals(data.length);
}
export function useGoalsQuery(archived: GoalArchivedFilter = 'false') {
const queryClient = useQueryClient();
const query = useQuery({
...goalsQueryOptions(archived),
queryKey: computed(() => goalsQueryOptions(archived).queryKey),
enabled: () => !!getCurrentOrganizationId(),
// Progress is computed server side, keep it fresh while the page is open // Progress is computed server side, keep it fresh while the page is open
refetchInterval: 1000 * 60, refetchInterval: 1000 * 60,
}); });

View File

@@ -36,6 +36,7 @@ export function useTimeEntriesMutations() {
}, },
onSuccess: () => { onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['timeEntries'] }); queryClient.invalidateQueries({ queryKey: ['timeEntries'] });
queryClient.invalidateQueries({ queryKey: ['goals'] });
}, },
}); });
@@ -58,6 +59,7 @@ export function useTimeEntriesMutations() {
}, },
onSuccess: () => { onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['timeEntries'] }); queryClient.invalidateQueries({ queryKey: ['timeEntries'] });
queryClient.invalidateQueries({ queryKey: ['goals'] });
}, },
}); });
@@ -105,6 +107,7 @@ export function useTimeEntriesMutations() {
}, },
onSuccess: () => { onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['timeEntries'] }); queryClient.invalidateQueries({ queryKey: ['timeEntries'] });
queryClient.invalidateQueries({ queryKey: ['goals'] });
}, },
}); });
@@ -127,6 +130,7 @@ export function useTimeEntriesMutations() {
}, },
onSuccess: () => { onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['timeEntries'] }); queryClient.invalidateQueries({ queryKey: ['timeEntries'] });
queryClient.invalidateQueries({ queryKey: ['goals'] });
}, },
}); });
@@ -152,6 +156,7 @@ export function useTimeEntriesMutations() {
}, },
onSuccess: () => { onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['timeEntries'] }); queryClient.invalidateQueries({ queryKey: ['timeEntries'] });
queryClient.invalidateQueries({ queryKey: ['goals'] });
}, },
}); });