Skip to content

Commit

Permalink
allow guests to download documents (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
Amoki authored Oct 31, 2023
1 parent 9d8f1fa commit 2cc4b78
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="files-action-bar">
<BIMDataButton
:disabled="!project.isAdmin && files.some(f => f.user_permission < 100)"
:disabled="project.isGuest || !project.isAdmin && files.some(f => f.user_permission < 100)"
width="120px"
color="high"
ghost
Expand All @@ -12,7 +12,7 @@
<span>{{ $t("t.delete") }}</span>
</BIMDataButton>
<BIMDataButton
:disabled="!project.isAdmin && files.some(f => f.user_permission < 100)"
:disabled="project.isGuest || !project.isAdmin && files.some(f => f.user_permission < 100)"
width="120px"
color="secondary"
ghost
Expand Down
4 changes: 2 additions & 2 deletions src/components/specific/files/files-table/FilesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:rows="files"
rowKey="id"
:rowHeight="54"
:selectable="!project.isGuest"
:selectable="true"
@selection-changed="$emit('selection-changed', $event)"
:canDragOverRow="isFolder"
@row-drop="onRowDrop"
Expand Down Expand Up @@ -86,7 +86,7 @@
<template #cell-size="{ row: file }">
{{ !isFolder(file) && file.size ? formatBytes(file.size) : "-" }}
</template>
<template v-if="!project.isGuest" #cell-actions="{ row: file }">
<template #cell-actions="{ row: file }">
<FileActionsCell
:filesTable="filesTable"
:project="project"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export default {
key: 3,
text: "FileActionsCell.createModelButtonText",
component: SetAsModelIcon,
disabled: props.project.isGuest || !props.project.isAdmin && props.file.user_permission < FILE_PERMISSION.READ_WRITE,
action: () => onClick("create-model")
});
} else {
Expand All @@ -170,14 +171,13 @@ export default {
});
}
}
menuItems.value.push({
key: 5,
text: "t.rename",
action: () => onClick("update"),
icon: "edit",
disabled:
!props.project.isAdmin &&
props.project.isGuest || !props.project.isAdmin &&
props.file.user_permission < FILE_PERMISSION.READ_WRITE
});
Expand All @@ -186,9 +186,6 @@ export default {
text: "t.download",
action: () => onClick("download"),
icon: "download",
disabled:
!props.project.isAdmin &&
props.file.user_permission < FILE_PERMISSION.READ_WRITE
});
if (isFolder(props.file) && props.project.isAdmin) {
Expand Down Expand Up @@ -235,7 +232,7 @@ export default {
dataTestId: "btn-delete-doc",
icon: "delete",
disabled:
!props.project.isAdmin &&
props.project.isGuest || !props.project.isAdmin &&
props.file.user_permission < FILE_PERMISSION.READ_WRITE
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="models-action-bar">
<BIMDataButton
:disabled="
!project.isAdmin && models.some(m => m.document?.user_permission < 100)
project.isGuest || !project.isAdmin && models.some(m => m.document?.user_permission < 100)
"
width="120px"
color="high"
Expand All @@ -16,7 +16,7 @@

<BIMDataButton
:disabled="
!project.isAdmin && models.some(m => m.document?.user_permission < 100)
project.isGuest || !project.isAdmin && models.some(m => m.document?.user_permission < 100)
"
width="120px"
ghost
Expand All @@ -36,11 +36,6 @@
</BIMDataButton>

<BIMDataButton
:disabled="
(!project.isAdmin &&
models.some(m => m.document.user_permission < 100)) ||
models.every(m => !m.document)
"
width="120px"
ghost
squared
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
rowKey="id"
:paginated="true"
:perPage="7"
:selectable="!project.isGuest"
:selectable="true"
@selection-changed="$emit('selection-changed', $event)"
>
<template #sub-header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
/>
</template>

<template v-if="model.document && !project.isGuest">
<template v-if="model.document">
<BIMDataButton
class="model-actions-cell__btn"
data-test-id="btn-download-model"
Expand Down
2 changes: 1 addition & 1 deletion src/utils/file-structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ function isFolder(file) {
}

function hasAdminPerm(project, file) {
return project.isAdmin || file.user_permission === 100;
return !project.isGuest && (project.isAdmin || file.user_permission === 100);
}


Expand Down

0 comments on commit 2cc4b78

Please sign in to comment.