Skip to content

Commit

Permalink
MINOR: rework comment permissions (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
Amoki authored Nov 30, 2023
1 parent a04b12a commit 01fb8f3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
14 changes: 5 additions & 9 deletions src/components/bcf-topic-overview/BcfTopicOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ export default {
type: Object,
required: true,
},
currentUserEmail: {
type: String,
required: false,
},
},
emits: [
"back",
Expand All @@ -293,11 +297,6 @@ export default {
const topicLabels = computed(() => Array.from(props.topic.labels ?? []).sort());
const currentUserEmail = ref("");
const loadCurrentUserEmail = async () => {
currentUserEmail.value = (await service.fetchCurrentUser()).email ?? "";
};
const deleteTopic = async () => {
try {
showDeleteModal.value = false;
Expand All @@ -312,11 +311,8 @@ export default {
}
};
onMounted(() => loadCurrentUserEmail())
return {
// References
currentUserEmail,
loading,
priorityColor,
showDeleteModal,
Expand All @@ -330,4 +326,4 @@ export default {
};
</script>
<style scoped lang="scss" src="./BcfTopicOverview.scss"></style>
<style scoped lang="scss" src="./BcfTopicOverview.scss"></style>
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default {
},
currentUserEmail: {
type: String,
required: true,
required: false,
},
},
emis: ["comment-created", "comment-updated", "comment-deleted", "view-comment-snapshot"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</div>

<div class="topic-comment__header__right">
<template v-if="currentUserEmail === comment.author">
<template v-if="canEditComment(comment)">
<div class="topic-comment__header__right__actions flex">
<template v-if="showMenu">
<BIMDataButton ghost rounded icon @click="onOpenEdit">
Expand Down Expand Up @@ -163,7 +163,7 @@ export default {
},
currentUserEmail: {
type: String,
required: true,
required: false,
},
},
emits: ["comment-updated", "comment-deleted", "view-comment-snapshot"],
Expand Down Expand Up @@ -221,6 +221,13 @@ export default {
viewpoint.value = await viewer.getViewpoint();
};
const canEditComment = comment => {
if (!props.currentUserEmail) {
return false;
}
return currentUserEmail === comment.author;
}
const submitUpdate = async () => {
try {
if (props.comment.comment === text.value && !viewpoint.value) {
Expand Down Expand Up @@ -307,6 +314,7 @@ export default {
closeMenu,
createViewpoint,
deleteViewpoint,
canEditComment,
highlightViewer,
onOpenDelete,
onOpenEdit,
Expand Down

0 comments on commit 01fb8f3

Please sign in to comment.