hide create project buttons and modal depending on the permission

This commit is contained in:
Gregor Vostrak
2024-10-28 13:37:39 +01:00
parent eb4debe481
commit cd7573dcf1
11 changed files with 29 additions and 2 deletions

View File

@@ -28,6 +28,7 @@ import type {
import { useClientsStore } from '@/utils/useClients';
import TimePicker from '@/packages/ui/src/Input/TimePicker.vue';
import { getOrganizationCurrencyString } from '@/utils/money';
import { canCreateProjects } from '@/utils/permissions';
const projectStore = useProjectsStore();
const { projects } = storeToRefs(projectStore);
const taskStore = useTasksStore();
@@ -134,6 +135,7 @@ async function createTag(tag: string) {
:clients
:createProject
:createClient
:canCreateProject="canCreateProjects()"
:currency="getOrganizationCurrencyString()"
class="mt-1"
size="xlarge"

View File

@@ -25,6 +25,7 @@ import TimeTrackerRunningInDifferentOrganizationOverlay from '@/packages/ui/src/
import { useClientsStore } from '@/utils/useClients';
import { getOrganizationCurrencyString } from '@/utils/money';
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
import { canCreateProjects } from '@/utils/permissions';
const page = usePage<{
auth: {
@@ -113,6 +114,7 @@ const { tags } = storeToRefs(useTagsStore());
<TimeTrackerControls
:createProject
:enableEstimatedTime="isAllowedToPerformPremiumAction()"
:canCreateProject="canCreateProjects()"
:createClient
:clients
:tags

View File

@@ -66,6 +66,7 @@ import { getCurrentOrganizationId } from '@/utils/useUser';
import { useTimeEntriesStore } from '@/utils/useTimeEntries';
import TimeEntryMassActionRow from '@/packages/ui/src/TimeEntry/TimeEntryMassActionRow.vue';
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
import { canCreateProjects } from '@/utils/permissions';
const startDate = useSessionStorage<string>(
'reporting-start-date',
@@ -340,6 +341,7 @@ async function clearSelectionAndState() {
</div>
<TimeEntryMassActionRow
:selected-time-entries="selectedTimeEntries"
:canCreateProject="canCreateProjects()"
:enableEstimatedTime="isAllowedToPerformPremiumAction()"
@submit="clearSelectionAndState"
:delete-selected="deleteSelected"
@@ -366,6 +368,7 @@ async function clearSelectionAndState() {
<TimeEntryRow
:selected="selectedTimeEntries.includes(entry)"
@selected="selectedTimeEntries.push(entry)"
:canCreateProject="canCreateProjects()"
@unselected="
selectedTimeEntries = selectedTimeEntries.filter(
(item) => item.id !== entry.id

View File

@@ -29,6 +29,7 @@ import { getOrganizationCurrencyString } from '@/utils/money';
import TimeEntryMassActionRow from '@/packages/ui/src/TimeEntry/TimeEntryMassActionRow.vue';
import type { UpdateMultipleTimeEntriesChangeset } from '@/packages/api/src';
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
import { canCreateProjects } from '@/utils/permissions';
const timeEntriesStore = useTimeEntriesStore();
const { timeEntries, allTimeEntriesLoaded } = storeToRefs(timeEntriesStore);
@@ -142,6 +143,7 @@ function deleteSelected() {
<TimeEntryMassActionRow
:selected-time-entries="selectedTimeEntries"
:enableEstimatedTime="isAllowedToPerformPremiumAction()"
:canCreateProject="canCreateProjects()"
@submit="clearSelectionAndState"
:all-selected="selectedTimeEntries.length === timeEntries.length"
@select-all="selectedTimeEntries = [...timeEntries]"
@@ -166,6 +168,7 @@ function deleteSelected() {
v-model:selected="selectedTimeEntries"
:createProject
:enableEstimatedTime="isAllowedToPerformPremiumAction()"
:canCreateProject="canCreateProjects()"
:clients
:createClient
:updateTimeEntry

View File

@@ -40,6 +40,7 @@ const props = defineProps<{
currency: string;
selectedTimeEntries: TimeEntry[];
enableEstimatedTime: boolean;
canCreateProject: boolean;
}>();
const emit = defineEmits<{
selected: [TimeEntry[]];
@@ -121,6 +122,7 @@ function onSelectChange(event: Event) {
:clients
:createProject
:createClient
:canCreateProject
:projects="projects"
:tasks="tasks"
:showBadgeBorder="false"
@@ -177,6 +179,7 @@ function onSelectChange(event: Event) {
<TimeEntryRow
:projects="projects"
:enableEstimatedTime
:canCreateProject
:tasks="tasks"
:selected="
!!selectedTimeEntries.find(

View File

@@ -38,6 +38,7 @@ const props = defineProps<{
createClient: (client: CreateClientBody) => Promise<Client | undefined>;
currency: string;
enableEstimatedTime: boolean;
canCreateProject: boolean;
}>();
const groupedTimeEntries = computed(() => {
@@ -161,6 +162,7 @@ function unselectAllTimeEntries(value: TimeEntriesGroupedByType[]) {
<template v-for="entry in value" :key="entry.id">
<TimeEntryAggregateRow
:createProject
:canCreateProject
:enableEstimatedTime
:selected-time-entries="selectedTimeEntries"
@selected="
@@ -197,6 +199,7 @@ function unselectAllTimeEntries(value: TimeEntriesGroupedByType[]) {
<TimeEntryRow
:createClient
:enableEstimatedTime
:canCreateProject
:createProject
:projects="projects"
:selected="

View File

@@ -33,6 +33,7 @@ const props = defineProps<{
) => Promise<void>;
currency: string;
enableEstimatedTime: boolean;
canCreateProject: boolean;
}>();
const emit = defineEmits<{
@@ -55,6 +56,7 @@ const showMassUpdateModal = ref(false);
:createClient
:updateTimeEntries
:enableEstimatedTime
:canCreateProject
:currency
:time-entries="selectedTimeEntries"
@submit="emit('submit')"

View File

@@ -36,6 +36,7 @@ const props = defineProps<{
) => Promise<void>;
currency: string;
enableEstimatedTime: boolean;
canCreateProject: boolean;
}>();
const emit = defineEmits<{
@@ -156,6 +157,7 @@ watch(removeAllTags, () => {
:createProject
:createClient
:currency="currency"
:canCreateProject
class="mt-1"
empty-placeholder="Select project..."
allow-reset

View File

@@ -38,6 +38,7 @@ const props = defineProps<{
showMember?: boolean;
showDate?: boolean;
selected?: boolean;
canCreateProject: boolean;
enableEstimatedTime: boolean;
}>();
@@ -111,6 +112,7 @@ function onSelectChange(event: Event) {
<TimeTrackerProjectTaskDropdown
:createProject
:createClient
:canCreateProject
:clients
:projects="projects"
:tasks="tasks"

View File

@@ -34,6 +34,7 @@ const props = defineProps<{
isActive: boolean;
currency: string;
enableEstimatedTime: boolean;
canCreateProject: boolean;
}>();
const emit = defineEmits<{
@@ -110,6 +111,7 @@ function updateTimeEntryDescription() {
class="flex items-center w-[130px] @2xl:w-auto shrink min-w-0">
<TimeTrackerProjectTaskDropdown
:createClient
:canCreateProject
:clients
:createProject
:currency="currency"

View File

@@ -64,6 +64,7 @@ const props = withDefaults(
emptyPlaceholder: string;
allowReset: boolean;
enableEstimatedTime: boolean;
canCreateProject: boolean;
}>(),
{
showBadgeBorder: true,
@@ -532,7 +533,7 @@ const showCreateProject = ref(false);
</script>
<template>
<div v-if="projects.length === 0">
<div v-if="projects.length === 0 && canCreateProject">
<Badge
@click="showCreateProject = true"
size="large"
@@ -689,7 +690,9 @@ const showCreateProject = ref(false);
</template>
</template>
</div>
<div class="hover:bg-card-background-active rounded-b-lg">
<div
v-if="canCreateProject"
class="hover:bg-card-background-active rounded-b-lg">
<button
@click="
open = false;