Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 125x 125x 398x 212x 210x 125x | // @implements UC-COMMENT-006.1, UC-COMMENT-007.1
import { useAuthStore } from '@/stores/auth'
import { usePermissions } from '@/composables/usePermissions'
/**
* Whether the current user manages the comments of an entity — deleting
* anybody's comment, blocking users from commenting. Mirrors the backend rule
* (flows-api utils/commentAccess.js canManageComments): edit rights on the
* entity (`entities-{id}:update`) while acting in its own flow, or platform
* admin. The backend enforces it either way; this only decides which actions
* to offer.
*/
export function useCommentManagement() {
const authStore = useAuthStore()
const { hasPermission } = usePermissions()
function canManageComments(
entity: { id: string; flowId: string; visibility?: string } | null | undefined
): boolean {
if (!entity) return false
if (authStore.isPlatformAdmin) return true
return (
entity.flowId === authStore.currentFlow &&
hasPermission(`entities-${entity.id}:update`, entity)
)
}
return { canManageComments }
}
|