Fix: Permissions on workspace dashboard

This commit is contained in:
Mike
2024-08-23 17:54:20 +02:00
committed by GitHub
parent 976bb680f0
commit a22a2fe52f
5 changed files with 16 additions and 7 deletions
@@ -40,6 +40,7 @@
<CommonLoadingBar :loading="showLoadingBar" class="my-2" />
<ProjectsDashboardEmptyState
v-if="showEmptyState"
:is-guest="isGuest"
@create-project="openNewProject = true"
/>
<template v-else-if="projects?.items?.length">
@@ -14,9 +14,9 @@
</div>
</template>
<script setup lang="ts">
import { useActiveUser } from '~~/lib/auth/composables/activeUser'
defineProps<{
isGuest: boolean
}>()
defineEmits(['create-project'])
const { isGuest } = useActiveUser()
</script>
@@ -22,7 +22,7 @@
v-bind="bind"
v-on="on"
/>
<FormButton v-if="!isGuest" @click="openNewProject = true">
<FormButton v-if="!isWorkspaceGuest" @click="openNewProject = true">
New project
</FormButton>
</div>
@@ -32,6 +32,7 @@
<ProjectsDashboardEmptyState
v-if="showEmptyState"
:is-guest="isWorkspaceGuest"
@create-project="openNewProject = true"
/>
@@ -49,7 +50,6 @@
<script setup lang="ts">
import { MagnifyingGlassIcon, Squares2X2Icon } from '@heroicons/vue/24/outline'
import { useQuery, useQueryLoading } from '@vue/apollo-composable'
import { useActiveUser } from '~~/lib/auth/composables/activeUser'
import type { Optional, StreamRoles } from '@speckle/shared'
import {
workspacePageQuery,
@@ -64,6 +64,7 @@ import type {
} from '~~/lib/common/generated/gql/graphql'
import { skipLoggingErrorsIfOneFieldError } from '~/lib/common/helpers/graphql'
import { workspaceRoute, workspacesRoute } from '~/lib/common/helpers/route'
import { Roles } from '@speckle/shared'
graphql(`
fragment WorkspaceProjectList_ProjectCollection on ProjectCollection {
@@ -78,7 +79,6 @@ graphql(`
const selectedRoles = ref(undefined as Optional<StreamRoles[]>)
const openNewProject = ref(false)
const { isGuest } = useActiveUser()
const areQueriesLoading = useQueryLoading()
const props = defineProps<{
@@ -148,6 +148,8 @@ const showLoadingBar = computed(() => {
return areQueriesLoading.value && (!!search.value || !projects.value?.items?.length)
})
const isWorkspaceGuest = computed(() => workspace.value?.role === Roles.Workspace.Guest)
const clearSearch = () => {
search.value = ''
selectedRoles.value = []
@@ -28,8 +28,8 @@
class="max-w-[104px]"
/>
<FormButton
v-if="isWorkspaceAdmin"
color="outline"
:disabled="!isWorkspaceAdmin"
@click="showInviteDialog = !showInviteDialog"
>
Invite
@@ -119,6 +119,12 @@ export function useCreateProject() {
.mutate({
mutation: createProjectMutation,
variables: { input },
errorPolicy: 'all',
context: {
skipLoggingErrors: (err) =>
err.graphQLErrors?.length === 1 &&
err.graphQLErrors.some((e) => e.path?.includes('invitedTeam'))
},
update: (cache, { data }) => {
const newProject = data?.projectMutations.create