TaskView is a self-hosted project and task management platform focused on clarity, ownership, and control. TaskView is built for teams that want a transparent, self-hosted alternative to SaaS task managers.
TypeScript graphviewkanban-boardnodejsproductivityproject-managementself-hostedtasktask-managementtask-managertodoapp
wip: fixed permissions and UI
Nikolai Gimanee673423137e
diff --git a/api/src/migrations/taskview/migrate.json b/api/src/migrations/taskview/migrate.jsonindex bca640b..0ac18b9 100644--- a/api/src/migrations/taskview/migrate.json+++ b/api/src/migrations/taskview/migrate.json@@ -542,12 +542,13 @@"43": {"version": "1.50.0","name": "Release 1.50.0",- "releaseDate": "20260514",+ "releaseDate": "20260515","scripts": ["/1.50.0/0.update-timetracking-permissions-descriptions.sql"],"description": [- "Updated descriptions of timetracking_can_view and timetracking_can_manage_all to document that these permissions also expose contributor emails through the time-entry log"+ "Updated descriptions of timetracking_can_view and timetracking_can_manage_all to document that these permissions also expose contributor emails through the time-entry log",+ "Tightened timetracking_can_log description: it grants only start/stop/createManual, NOT edit/delete (including own entries). Edit/delete now requires timetracking_can_manage_all — see can-access-time-entry middleware change."]}}\ No newline at end of filediff --git a/api/src/migrations/taskview/sql/1.50.0/0.update-timetracking-permissions-descriptions.sql b/api/src/migrations/taskview/sql/1.50.0/0.update-timetracking-permissions-descriptions.sqlindex 0be775a..4b828a3 100644--- a/api/src/migrations/taskview/sql/1.50.0/0.update-timetracking-permissions-descriptions.sql+++ b/api/src/migrations/taskview/sql/1.50.0/0.update-timetracking-permissions-descriptions.sql@@ -1,11 +1,17 @@UPDATE tv_auth.permissionsSET- description = 'View all time entries on this project — both own and other members''. Also exposes the emails of all contributors via the time-entry log',+ description = 'View all time entries; exposes emails of contributors via the entry log',description_locales = '{"en": "View time entries. User can see all time entries on this project — both own and other members''. Also exposes the emails of all contributors who have logged time on this project. Does not grant logging or editing.", "ru": "Просмотр записей времени. Пользователь видит все записи проекта — свои и других участников. Также видны email-адреса всех участников, логировавших время. Логировать и редактировать нельзя."}'::jsonbWHERE name = 'timetracking_can_view';UPDATE tv_auth.permissionsSET- description = 'Full time-tracking access: log own time + view and edit/delete entries of any project member. Also exposes emails of all contributors',- description_locales = '{"en": "Manage all time entries. Full time-tracking access on this project: user can log own time, view all entries (own and other members''), and edit/delete entries of any project member. Also exposes the emails of all contributors who have logged time on this project. Implies both view and log permissions.", "ru": "Управление всеми записями времени. Полный доступ к учёту времени на этом проекте: пользователь может вести свой таймер, видеть все записи (свои и других участников) и редактировать/удалять записи любого участника. Также видны email-адреса всех участников, логировавших время. Включает права на просмотр и ведение времени."}'::jsonb+ description = 'Start/stop timer and create manual entries; editing/deleting requires manage_all',+ description_locales = '{"en": "Log time. User can start/stop the timer and add manual entries on this project. Cannot edit or delete entries (including own) — editing requires manage_all permission. Does not grant viewing other members'' entries.", "ru": "Учёт времени. Пользователь может запускать/останавливать таймер и добавлять записи вручную в этом проекте. Редактировать и удалять записи (даже свои) нельзя — для этого нужно право управления. Не даёт права просматривать записи других участников."}'::jsonb+WHERE name = 'timetracking_can_log';++UPDATE tv_auth.permissions+SET+ description = 'Full time-tracking access: log, view, edit, delete entries; exposes contributor emails',+ description_locales = '{"en": "Manage all time entries. Full time-tracking access on this project: user can log own time, view all entries (own and other members''), and edit/delete entries of any project member (including own). Also exposes the emails of all contributors who have logged time on this project. Implies both view and log permissions.", "ru": "Управление всеми записями времени. Полный доступ к учёту времени на этом проекте: пользователь может вести свой таймер, видеть все записи (свои и других участников) и редактировать/удалять записи любого участника (включая свои). Также видны email-адреса всех участников, логировавших время. Включает права на просмотр и ведение времени."}'::jsonbWHERE name = 'timetracking_can_manage_all';diff --git a/api/src/tv-modules/time-tracking/middlewares/can-access-time-entry.ts b/api/src/tv-modules/time-tracking/middlewares/can-access-time-entry.tsindex 7b7df82..16fe572 100644--- a/api/src/tv-modules/time-tracking/middlewares/can-access-time-entry.ts+++ b/api/src/tv-modules/time-tracking/middlewares/can-access-time-entry.ts@@ -9,8 +9,6 @@ export const canAccessTimeEntry = (action: Action) => async (req: Request, res:const entryId = Number(req.params.id)if (!entryId) return res.status(400).end()- const userId = req.appUser.getUserData()!.id-const entry = await req.appUser.timeTrackingManager.repository.findById(entryId).catch(logError)if (!entry) return res.status(404).end()@@ -33,8 +31,6 @@ export const canAccessTimeEntry = (action: Action) => async (req: Request, res:return res.status(403).end()}- const isOwn = entry.userId === userId- if (isOwn && checker.hasPermissions(GoalPermissions.TIMETRACKING_CAN_LOG)) return next()if (checker.hasPermissions(GoalPermissions.TIMETRACKING_CAN_MANAGE_ALL)) return next()return res.status(403).end()diff --git a/taskview-packages/taskview-api/src/api/__tests__/time-tracking.test.ts b/taskview-packages/taskview-api/src/api/__tests__/time-tracking.test.tsindex ccf5d2d..dd5106f 100644--- a/taskview-packages/taskview-api/src/api/__tests__/time-tracking.test.ts+++ b/taskview-packages/taskview-api/src/api/__tests__/time-tracking.test.ts@@ -475,7 +475,7 @@ describe('TvApi time-tracking tests', () => {invitedRoleId = roleId;});- it('can start, stop, createManual, update and delete OWN entries', async () => {+ it('can start, stop and createManual but cannot update or delete OWN entries', async () => {const started = await $invitedUser.timeTracking.start({ taskId }).catch(console.error);expect(started?.entry).toBeDefined();@@ -489,14 +489,14 @@ describe('TvApi time-tracking tests', () => {}).catch(console.error);expect(manual?.taskId).toBe(taskId);- const updated = await $invitedUser.timeTracking.update({+ const updateStatus = await $invitedUser.timeTracking.update({id: manual!.id,- description: 'updated own',- }).catch(console.error);- expect(updated?.description).toBe('updated own');+ description: 'should not pass',+ }).catch((err) => err.status);+ expect(updateStatus).toBe(403);- const del = await $invitedUser.timeTracking.delete(manual!.id).catch(console.error);- expect(del?.deleted).toBe(true);+ const deleteStatus = await $invitedUser.timeTracking.delete(manual!.id).catch((err) => err.status);+ expect(deleteStatus).toBe(403);});it('cannot view or edit other users entries (no VIEW/MANAGE_ALL)', async () => {@@ -537,26 +537,9 @@ describe('TvApi time-tracking tests', () => {expect(status).toBe(403);});- it('cannot update or delete OWN entry after TIMETRACKING_CAN_LOG is revoked', async () => {- const ownEntry = await $invitedUser.timeTracking.createManual({- taskId,- startedAt: isoMinutesAgo(60),- endedAt: isoMinutesAgo(30),- description: 'original',- }).catch(console.error);- expect(ownEntry).toBeDefined();-+ it('cannot start or createManual after TIMETRACKING_CAN_LOG is revoked', async () => {await togglePermissionForRole(invitedRoleId, TvPermissions.TIMETRACKING_CAN_LOG);- const updateStatus = await $invitedUser.timeTracking.update({- id: ownEntry!.id,- description: 'should not pass',- }).catch((err) => err.status);- expect(updateStatus).toBe(403);-- const deleteStatus = await $invitedUser.timeTracking.delete(ownEntry!.id).catch((err) => err.status);- expect(deleteStatus).toBe(403);-const startStatus = await $invitedUser.timeTracking.start({ taskId }).catch((err) => err.status);expect(startStatus).toBe(403);diff --git a/web/src/components/features/tasks/parts/TaskTimeTracking.vue b/web/src/components/features/tasks/parts/TaskTimeTracking.vueindex 72f01c9..8bb510d 100644--- a/web/src/components/features/tasks/parts/TaskTimeTracking.vue+++ b/web/src/components/features/tasks/parts/TaskTimeTracking.vue@@ -56,28 +56,30 @@<span>{{ t('timeTracking.willStopOther') }}</span></div>- <div- v-if="entries.length > 0"- class="flex flex-col gap-2 max-h-80 overflow-y-auto pr-1"- >- <TaskTimeTrackingEntry- v-for="entry in entries"- :key="entry.id"- :entry="entry"- @delete="onDelete"- @update="onUpdate"- />- </div>- <div- v-else- class="flex flex-col items-center gap-1 py-3 text-xs text-muted"- >- <UIcon- name="i-lucide-inbox"- class="size-5"- />- <span>{{ t('timeTracking.empty') }}</span>- </div>+ <template v-if="canViewTimeTracking">+ <div+ v-if="entries.length > 0"+ class="flex flex-col gap-2 max-h-80 overflow-y-auto pr-1"+ >+ <TaskTimeTrackingEntry+ v-for="entry in entries"+ :key="entry.id"+ :entry="entry"+ @delete="onDelete"+ @update="onUpdate"+ />+ </div>+ <div+ v-else+ class="flex flex-col items-center gap-1 py-3 text-xs text-muted"+ >+ <UIcon+ name="i-lucide-inbox"+ class="size-5"+ />+ <span>{{ t('timeTracking.empty') }}</span>+ </div>+ </template><divv-if="canLogTime"@@ -192,7 +194,7 @@ const onSubmitManual = async (payload: TimeEntryFormPayload) => {watch(() => props.taskId,(id) => {- if (id) store.fetchEntriesForTask(id)+ if (id && canViewTimeTracking.value) store.fetchEntriesForTask(id)},{ immediate: true },)@@ -202,6 +204,8 @@ onMounted(() => {})useEventListener(document, 'visibilitychange', () => {- if (!document.hidden && props.taskId) store.fetchEntriesForTask(props.taskId)+ if (!document.hidden && props.taskId && canViewTimeTracking.value) {+ store.fetchEntriesForTask(props.taskId)+ }})</script>diff --git a/web/src/components/features/tasks/parts/TaskTimeTrackingEntry.vue b/web/src/components/features/tasks/parts/TaskTimeTrackingEntry.vueindex b327c07..b3d2afd 100644--- a/web/src/components/features/tasks/parts/TaskTimeTrackingEntry.vue+++ b/web/src/components/features/tasks/parts/TaskTimeTrackingEntry.vue@@ -1,6 +1,6 @@<template><div class="flex flex-col gap-1 px-2 py-1.5 rounded bg-elevated/50 text-sm">- <div class="flex items-center justify-between gap-2">+ <div class="flex lg:items-center flex-col lg:flex-row justify-between gap-2"><div class="flex flex-col min-w-0 flex-1"><div class="flex items-center gap-2 text-xs text-muted"><span class="font-mono">{{ formattedStarted }}</span>@@ -17,7 +17,7 @@:label="formatDuration(entry.durationSeconds ?? 0)"color="neutral"variant="subtle"- size="xs"+ size="sm"/><UBadgev-else@@ -26,6 +26,7 @@variant="subtle"size="xs"/>+ <div class="w-full flex justify-end gap-2"><UButtonv-if="entry.endedAt && !editing && canEdit"icon="i-lucide-pencil"@@ -42,6 +43,8 @@size="xs"@click="emit('delete', entry.id)"/>+ </div>+</div></div>@@ -79,10 +82,10 @@ const emit = defineEmits<{const { t } = useI18n()const editing = ref(false)const userStore = useUserStore()-const { canLogTime, canManageAllTime } = useGoalPermissions()+const { canManageAllTime } = useGoalPermissions()const isOwn = computed(() => userStore.payloadData?.id === props.entry.userId)-const canEdit = computed(() => (isOwn.value ? canLogTime.value : canManageAllTime.value))+const canEdit = computed(() => canManageAllTime.value)const formattedStarted = computed(() => new Date(props.entry.startedAt).toLocaleString())const userLabel = computed(() =>diff --git a/web/src/components/features/tasks/parts/TaskTimeTrackingForm.vue b/web/src/components/features/tasks/parts/TaskTimeTrackingForm.vueindex 5a1abec..a609d3f 100644--- a/web/src/components/features/tasks/parts/TaskTimeTrackingForm.vue+++ b/web/src/components/features/tasks/parts/TaskTimeTrackingForm.vue@@ -108,24 +108,29 @@ const emit = defineEmits<{const { t } = useI18n()+const fromDate = (d: Date): { date: CalendarDate; time: Time } => ({+ date: new CalendarDate(d.getFullYear(), d.getMonth() + 1, d.getDate()),+ time: new Time(d.getHours(), d.getMinutes()),+})+const fromIso = (iso: string | undefined): { date?: CalendarDate; time?: Time } => {if (!iso) return {}- const d = new Date(iso)- return {- date: new CalendarDate(d.getFullYear(), d.getMonth() + 1, d.getDate()),- time: new Time(d.getHours(), d.getMinutes()),- }+ return fromDate(new Date(iso))}-const initialStart = fromIso(props.initialStartedAt)-const initialEnd = fromIso(props.initialEndedAt)+const isEditMode = props.initialStartedAt !== undefined+const defaultStart = fromDate(new Date(Date.now() - 60 * 60 * 1000))+const defaultEnd = fromDate(new Date())++const initialStart = isEditMode ? fromIso(props.initialStartedAt) : defaultStart+const initialEnd = isEditMode ? fromIso(props.initialEndedAt) : defaultEndconst startDate = shallowRef<CalendarDate | undefined>(initialStart.date)const endDate = shallowRef<CalendarDate | undefined>(initialEnd.date)const startTime = shallowRef<Time | undefined>(initialStart.time)const endTime = shallowRef<Time | undefined>(initialEnd.time)const description = ref(props.initialDescription ?? '')-const billable = ref(props.initialBillable ?? true)+const billable = ref(isEditMode ? props.initialBillable === true : true)const startOpen = ref(false)const endOpen = ref(false)diff --git a/web/src/components/features/time-reports/TimeReportsFilters.vue b/web/src/components/features/time-reports/TimeReportsFilters.vueindex d9c5422..e9cf6e9 100644--- a/web/src/components/features/time-reports/TimeReportsFilters.vue+++ b/web/src/components/features/time-reports/TimeReportsFilters.vue@@ -7,6 +7,7 @@color="neutral"variant="outline"size="lg"+ class="grow lg:grow-0":ui="activatorStyle"/><template #content>@@ -28,6 +29,7 @@color="neutral"variant="outline"size="lg"+ class="grow lg:grow-0":ui="activatorStyle"/><template #content>@@ -40,13 +42,14 @@</template></UPopover>+ <div class="flex flex-col lg:flex-row w-full lg:w-auto gap-2"><USelectMenuv-if="availableProjects.length > 0"v-model="selectedGoalIds":items="projectOptions"multiple:placeholder="t('timeTracking.reports.allProjects')"- class="min-w-56"+ class="lg:min-w-56 w-full lg:w-auto"size="lg"/>@@ -55,9 +58,11 @@v-model="selectedUser":items="contributorOptions":placeholder="t('timeTracking.reports.allUsers')"- class="min-w-56"+ class="lg:min-w-56 w-full lg:w-auto"size="lg"/>+ </div>+<UCheckboxv-model="billableOnly"diff --git a/web/src/components/features/time-reports/TimeReportsNoPermission.vue b/web/src/components/features/time-reports/TimeReportsNoPermission.vuenew file mode 100644index 0000000..b3ac01e--- /dev/null+++ b/web/src/components/features/time-reports/TimeReportsNoPermission.vue@@ -0,0 +1,20 @@+<template>+ <div class="flex flex-col items-center justify-center gap-3 py-16 px-4 text-center">+ <UIcon+ name="i-lucide-lock"+ class="size-10 text-muted"+ />+ <p class="font-medium text-default">+ {{ t('timeTracking.reports.noPermission') }}+ </p>+ <p class="text-sm text-muted max-w-md">+ {{ t('timeTracking.reports.noPermissionHint') }}+ </p>+ </div>+</template>++<script setup lang="ts">+import { useI18n } from 'vue-i18n'++const { t } = useI18n()+</script>diff --git a/web/src/locales/en.ts b/web/src/locales/en.tsindex d401651..52269f8 100644--- a/web/src/locales/en.ts+++ b/web/src/locales/en.ts@@ -729,6 +729,8 @@ export default {colEntries: 'Entries',empty: 'No data for the selected filters',recentEntries: 'Recent entries',+ noPermission: 'You don\'t have permission to view time reports',+ noPermissionHint: 'Ask a project admin for the time-tracking view permission to access reports.',},},}diff --git a/web/src/locales/ru.ts b/web/src/locales/ru.tsindex edb0c7f..5e70703 100644--- a/web/src/locales/ru.ts+++ b/web/src/locales/ru.ts@@ -661,6 +661,8 @@ export default {colEntries: 'Записей',empty: 'Нет данных по выбранным фильтрам',recentEntries: 'Последние записи',+ noPermission: 'У вас нет прав на просмотр отчётов по времени',+ noPermissionHint: 'Попросите администратора проекта выдать вам право на просмотр учёта времени.',},},}diff --git a/web/src/pages/user/project-time-reports.vue b/web/src/pages/user/project-time-reports.vueindex d90da29..cc31453 100644--- a/web/src/pages/user/project-time-reports.vue+++ b/web/src/pages/user/project-time-reports.vue@@ -4,8 +4,9 @@<UDashboardNavbar :title="t('timeTracking.reports.title')" /></template><template #body>+ <TimeReportsNoPermission v-if="projectId !== null && !canViewReports" /><TimeReportsLayout- v-if="orgId !== null && projectId !== null"+ v-else-if="orgId !== null && projectId !== null":organization-id="orgId":available-projects="visibleProjects":default-goal-ids="defaultGoalIds"@@ -24,6 +25,7 @@ import { TvPermissions } from 'taskview-api'import { useOrganizationStore } from '@/stores/organization.store'import { useGoalsStore } from '@/stores/goals.store'import TimeReportsLayout from '@/components/features/time-reports/TimeReportsLayout.vue'+import TimeReportsNoPermission from '@/components/features/time-reports/TimeReportsNoPermission.vue'const { t } = useI18n()const route = useRoute()@@ -48,4 +50,10 @@ const defaultGoalIds = computed(() => (projectId.value !== null ? [projectId.valconst canManageAll = computed(() => currentGoal.value?.permissions[TvPermissions.TIMETRACKING_CAN_MANAGE_ALL] === true,)++const canViewReports = computed(+ () =>+ currentGoal.value?.permissions[TvPermissions.TIMETRACKING_CAN_VIEW] === true ||+ currentGoal.value?.permissions[TvPermissions.TIMETRACKING_CAN_MANAGE_ALL] === true,+)</script>diff --git a/web/src/pages/user/time-reports.vue b/web/src/pages/user/time-reports.vueindex ba01ff4..4885da0 100644--- a/web/src/pages/user/time-reports.vue+++ b/web/src/pages/user/time-reports.vue@@ -4,8 +4,9 @@<UDashboardNavbar :title="t('timeTracking.reports.title')" /></template><template #body>+ <TimeReportsNoPermission v-if="orgId !== null && visibleProjects.length === 0" /><TimeReportsLayout- v-if="orgId !== null"+ v-else-if="orgId !== null":organization-id="orgId":available-projects="visibleProjects":can-filter-by-user="hasAnyManageAll"@@ -22,6 +23,7 @@ import { TvPermissions } from 'taskview-api'import { useOrganizationStore } from '@/stores/organization.store'import { useGoalsStore } from '@/stores/goals.store'import TimeReportsLayout from '@/components/features/time-reports/TimeReportsLayout.vue'+import TimeReportsNoPermission from '@/components/features/time-reports/TimeReportsNoPermission.vue'const { t } = useI18n()const orgStore = useOrganizationStore()