Skip to content

Commit

Permalink
bugfix(fe2): Fix conditioning around posting comments in viewer (#2246)
Browse files Browse the repository at this point in the history
* Test fix

* Update

* Testing

* Updates from testing

* various fixes

---------

Co-authored-by: Kristaps Fabians Geikins <fabians@speckle.systems>
  • Loading branch information
andrewwallacespeckle and fabis94 authored May 8, 2024
1 parent ec78d31 commit 3ecf0a3
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions packages/frontend-2/components/auth/LoginPanel.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<Component
:is="concreteComponent"
v-if="!isLoggedIn"
fancy-glow
no-shadow
class="max-w-lg mx-auto w-full"
Expand Down Expand Up @@ -43,6 +44,7 @@
</div>
</div>
</Component>
<div v-else />
</template>
<script setup lang="ts">
import { useQuery } from '@vue/apollo-composable'
Expand All @@ -67,6 +69,7 @@ const props = withDefaults(
}
)
const { isLoggedIn } = useActiveUser()
const { inviteToken } = useAuthManager()
const router = useRouter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</svg>
</template>
<template #cta>
<div v-if="small" class="mt-3">
<div v-if="small && canPostComment" class="mt-3">
<FormButton
size="sm"
:icon-left="PlusIcon"
Expand All @@ -49,6 +49,7 @@
</template>
<script setup lang="ts">
import { PlusIcon } from '@heroicons/vue/24/solid'
import { useCheckViewerCommentingAccess } from '~/lib/viewer/composables/commentManagement'
defineEmits<{
(e: 'new-discussion'): void
Expand All @@ -57,4 +58,6 @@ defineEmits<{
defineProps<{
small?: boolean
}>()
const canPostComment = useCheckViewerCommentingAccess()
</script>
3 changes: 2 additions & 1 deletion packages/frontend-2/components/viewer/AnchoredPoints.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ const onThreadExpandedChange = (isExpanded: boolean) => {
}
const shouldShowNewThread = computed(
() => !isEmbedEnabled.value && !state.ui.measurement.enabled.value
() =>
!isEmbedEnabled.value && !state.ui.measurement.enabled.value && canPostComment.value
)
const allThreadsChronologicalOrder = computed(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,15 @@ const isPostingNewThread = ref(false)
// width: 320
// })
const createThread = useSubmitComment()
const { isLoggedIn } = useActiveUser()
const onThreadClick = () => {
const newIsExpanded = !props.modelValue.isExpanded
if (!props.canPostComment) {
emit('login')
if (!isLoggedIn.value || !props.canPostComment) {
if (!isLoggedIn.value) {
emit('login')
}
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
</FormButton>
</div>
<div
v-if="!canReply && !isEmbedEnabled"
v-if="!canReply && !isEmbedEnabled && !isLoggedIn"
class="p-3 flex flex-col items-center justify-center bg-foundation-2"
>
<FormButton full-width @click="$emit('login')">Reply</FormButton>
Expand Down Expand Up @@ -229,7 +229,7 @@ const { isEmbedEnabled } = useEmbed()
const threadId = computed(() => props.modelValue.id)
const { copy } = useClipboard()
const { activeUser } = useActiveUser()
const { activeUser, isLoggedIn } = useActiveUser()
const { isSmallerOrEqualSm } = useIsSmallerOrEqualThanBreakpoint()
const archiveComment = useArchiveComment()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export function useCheckViewerCommentingAccess() {
}
} = useInjectedViewerState()
const { activeUser } = useActiveUser()

return computed(() => {
if (!activeUser.value) return false

Expand Down

0 comments on commit 3ecf0a3

Please sign in to comment.