Files
speckle-server/packages/frontend-2/components/settings/workspaces/General/EditAvatar.vue
T
Kristaps Fabians Geikins c54d15fd93 feat: authz frontend foundation + reworked errors (#4275)
* feat: authz frontend foundation + reworked errors

* lint fixes

* test fix

* fixed noCache() util
2025-03-27 16:13:35 +02:00

50 lines
1.2 KiB
Vue

<template>
<UserAvatarEditable
v-model:edit-mode="editMode"
:model-value="workspace.logo"
:placeholder="workspace.name"
name="edit-avatar"
:disabled="loading || disabled"
:size="size"
:rounded="false"
light-style
@save="onSave"
/>
</template>
<script setup lang="ts">
import { graphql } from '~~/lib/common/generated/gql'
import type { SettingsWorkspacesGeneralEditAvatar_WorkspaceFragment } from '~~/lib/common/generated/gql/graphql'
import type { MaybeNullOrUndefined } from '@speckle/shared'
import type { UserAvatarSize } from '@speckle/ui-components'
import { useUpdateWorkspace } from '~~/lib/settings/composables/management'
graphql(`
fragment SettingsWorkspacesGeneralEditAvatar_Workspace on Workspace {
id
logo
name
}
`)
const props = defineProps<{
workspace: SettingsWorkspacesGeneralEditAvatar_WorkspaceFragment
size: UserAvatarSize
disabled?: boolean
}>()
const { mutate, loading } = useUpdateWorkspace()
const editMode = ref(false)
const onSave = async (newVal: MaybeNullOrUndefined<string>) => {
if (props.workspace.logo === newVal) return
if (loading.value) return
await mutate({
id: props.workspace.id,
logo: newVal || ''
})
editMode.value = false
}
</script>