-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(DavClient): Provide proper feedback for dav requests
Before this commit there is no error handling whatsover for this requests and the user won't get any visual feedback whatsover irrespective of what goes down at the server level. Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
- Loading branch information
Showing
2 changed files
with
145 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,38 +59,33 @@ | |
</td> | ||
<td class="state-column"> | ||
<AclStateButton :state="getState(OC.PERMISSION_READ, { | ||
permissions: model.permissions, | ||
mask: 31, | ||
})" | ||
:read-only="true" /> | ||
permissions: model.permissions, | ||
mask: 31, | ||
})" :read-only="true" /> | ||
</td> | ||
<td class="state-column"> | ||
<AclStateButton :state="getState(OC.PERMISSION_UPDATE, { | ||
permissions: model.permissions, | ||
mask: 31, | ||
})" | ||
:read-only="true" /> | ||
permissions: model.permissions, | ||
mask: 31, | ||
})" :read-only="true" /> | ||
</td> | ||
<td v-if="model.type === 'dir'" class="state-column"> | ||
<AclStateButton :state="getState(OC.PERMISSION_CREATE, { | ||
permissions: model.permissions, | ||
mask: 31, | ||
})" | ||
:read-only="true" /> | ||
permissions: model.permissions, | ||
mask: 31, | ||
})" :read-only="true" /> | ||
</td> | ||
<td class="state-column"> | ||
<AclStateButton :state="getState(OC.PERMISSION_DELETE, { | ||
permissions: model.permissions, | ||
mask: 31, | ||
})" | ||
:read-only="true" /> | ||
permissions: model.permissions, | ||
mask: 31, | ||
})" :read-only="true" /> | ||
</td> | ||
<td class="state-column"> | ||
<AclStateButton :state="getState(OC.PERMISSION_SHARE, { | ||
permissions: model.permissions, | ||
mask: 31, | ||
})" | ||
:read-only="true" /> | ||
permissions: model.permissions, | ||
mask: 31, | ||
})" :read-only="true" /> | ||
</td> | ||
</tr> | ||
</tbody> | ||
|
@@ -103,41 +98,29 @@ | |
{{ getFullDisplayName(item.mappingDisplayName, item.mappingType) }} | ||
</td> | ||
<td class="state-column"> | ||
<AclStateButton :state="getState(OC.PERMISSION_READ, item)" | ||
:inherited="item.inherited" | ||
:disabled="loading" | ||
@update="changePermission(item, OC.PERMISSION_READ, $event)" /> | ||
<AclStateButton :state="getState(OC.PERMISSION_READ, item)" :inherited="item.inherited" | ||
:disabled="loading" @update="changePermission(item, OC.PERMISSION_READ, $event)" /> | ||
Check failure on line 102 in src/components/SharingSidebarView.vue GitHub Actions / NPM lint
|
||
</td> | ||
<td class="state-column"> | ||
<AclStateButton :state="getState(OC.PERMISSION_UPDATE, item)" | ||
:inherited="item.inherited" | ||
:disabled="loading" | ||
@update="changePermission(item, OC.PERMISSION_UPDATE, $event)" /> | ||
<AclStateButton :state="getState(OC.PERMISSION_UPDATE, item)" :inherited="item.inherited" | ||
:disabled="loading" @update="changePermission(item, OC.PERMISSION_UPDATE, $event)" /> | ||
Check failure on line 106 in src/components/SharingSidebarView.vue GitHub Actions / NPM lint
|
||
</td> | ||
<td v-if="model.type === 'dir'" class="state-column"> | ||
<AclStateButton :state="getState(OC.PERMISSION_CREATE, item)" | ||
:inherited="item.inherited" | ||
:disabled="loading" | ||
@update="changePermission(item, OC.PERMISSION_CREATE, $event)" /> | ||
<AclStateButton :state="getState(OC.PERMISSION_CREATE, item)" :inherited="item.inherited" | ||
:disabled="loading" @update="changePermission(item, OC.PERMISSION_CREATE, $event)" /> | ||
</td> | ||
<td class="state-column"> | ||
<AclStateButton :state="getState(OC.PERMISSION_DELETE, item)" | ||
:inherited="item.inherited" | ||
:disabled="loading" | ||
@update="changePermission(item, OC.PERMISSION_DELETE, $event)" /> | ||
<AclStateButton :state="getState(OC.PERMISSION_DELETE, item)" :inherited="item.inherited" | ||
:disabled="loading" @update="changePermission(item, OC.PERMISSION_DELETE, $event)" /> | ||
</td> | ||
<td class="state-column"> | ||
<AclStateButton :state="getState(OC.PERMISSION_SHARE, item)" | ||
:inherited="item.inherited" | ||
:disabled="loading" | ||
@update="changePermission(item, OC.PERMISSION_SHARE, $event)" /> | ||
<AclStateButton :state="getState(OC.PERMISSION_SHARE, item)" :inherited="item.inherited" | ||
:disabled="loading" @update="changePermission(item, OC.PERMISSION_SHARE, $event)" /> | ||
</td> | ||
<td class="state-column"> | ||
<NcButton v-if="item.inherited === false" | ||
type="tertiary" | ||
<NcButton v-if="item.inherited === false" type="tertiary" | ||
:v-tooltip="t('groupfolders', 'Remove access rule')" | ||
:aria-label="t('groupfolders', 'Remove access rule')" | ||
@click="removeAcl(item)"> | ||
:aria-label="t('groupfolders', 'Remove access rule')" @click="removeAcl(item)"> | ||
<template #icon> | ||
<Close :size="16" /> | ||
</template> | ||
|
@@ -146,23 +129,15 @@ | |
</tr> | ||
</tbody> | ||
</table> | ||
<NcButton v-if="isAdmin && !loading && !showAclCreate" | ||
@click="toggleAclCreate"> | ||
<NcButton v-if="isAdmin && !loading && !showAclCreate" @click="toggleAclCreate"> | ||
<template #icon> | ||
<Plus :size="16" /> | ||
</template> | ||
{{ t('groupfolders', 'Add advanced permission rule') }} | ||
</NcButton> | ||
<NcSelect v-if="isAdmin && !loading && showAclCreate" | ||
ref="select" | ||
v-model="value" | ||
:options="options" | ||
:loading="isSearching" | ||
:filterable="false" | ||
:placeholder="t('groupfolders', 'Select a user or group')" | ||
:get-option-key="() => 'unique'" | ||
@input="createAcl" | ||
@search="searchMappings"> | ||
<NcSelect v-if="isAdmin && !loading && showAclCreate" ref="select" v-model="value" :options="options" | ||
:loading="isSearching" :filterable="false" :placeholder="t('groupfolders', 'Select a user or group')" | ||
:get-option-key="() => 'unique'" @input="createAcl" @search="searchMappings"> | ||
<template #option="option"> | ||
<NcAvatar :user="option.id" :is-no-user="option.type !== 'user'" /> | ||
{{ option.label }} | ||
|
@@ -185,6 +160,7 @@ import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js' | |
import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip.js' | ||
import Plus from 'vue-material-design-icons/Plus.vue' | ||
import Close from 'vue-material-design-icons/Close.vue' | ||
import { showError } from '@nextcloud/dialogs' | ||
|
||
let searchRequestCancelSource = null | ||
|
||
|
@@ -355,7 +331,7 @@ export default { | |
}) | ||
|
||
}, | ||
changePermission(item, permission, $event) { | ||
async changePermission(item, permission, $event) { | ||
const index = this.list.indexOf(item) | ||
const inherit = $event === STATES.INHERIT_ALLOW || $event === STATES.INHERIT_DENY || $event === STATES.INHERIT_DEFAULT | ||
const allow = $event === STATES.SELF_ALLOW | ||
|
@@ -374,109 +350,117 @@ export default { | |
} | ||
item.inherited = false | ||
Vue.set(this.list, index, item) | ||
client.propPatch(this.model, this.list.filter(rule => !rule.inherited)).then(() => { | ||
// TODO block UI during save | ||
}) | ||
// TODO: Block UI during save | ||
try { | ||
await client.propPatch(this.model, this.list.filter(rule => !rule.inherited)) | ||
console.debug('Permissions updated successfully') | ||
} catch (error) { | ||
console.error('Failed to save changes:', error) | ||
showError(error) | ||
} finally { | ||
// TODO: Unblock the UI after the operation completes | ||
} | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
#groupfolder-acl-container { | ||
margin-bottom: 20px; | ||
} | ||
#groupfolder-acl-container { | ||
margin-bottom: 20px; | ||
} | ||
|
||
.groupfolder-entry { | ||
height: 44px; | ||
white-space: normal; | ||
display: inline-flex; | ||
align-items: center; | ||
position: relative; | ||
} | ||
.groupfolder-entry { | ||
height: 44px; | ||
white-space: normal; | ||
display: inline-flex; | ||
align-items: center; | ||
position: relative; | ||
} | ||
|
||
.avatar.icon-group-white { | ||
display: inline-block; | ||
background-color: var(--color-primary-element, #0082c9); | ||
padding: 16px; | ||
} | ||
.avatar.icon-group-white { | ||
display: inline-block; | ||
background-color: var(--color-primary-element, #0082c9); | ||
padding: 16px; | ||
} | ||
|
||
.groupfolder-entry .username { | ||
padding: 0 8px; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
text-overflow: ellipsis; | ||
} | ||
.groupfolder-entry .username { | ||
padding: 0 8px; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
table { | ||
width: 100%; | ||
margin-top: -44px; | ||
margin-bottom: 5px; | ||
} | ||
table { | ||
width: 100%; | ||
margin-top: -44px; | ||
margin-bottom: 5px; | ||
} | ||
|
||
table td, table th { | ||
padding: 0 | ||
} | ||
table td, | ||
table th { | ||
padding: 0 | ||
} | ||
|
||
thead th { | ||
height: 44px; | ||
} | ||
thead th { | ||
height: 44px; | ||
} | ||
|
||
thead th:first-child, | ||
tbody tr td:first-child { | ||
width: 24px; | ||
padding: 0; | ||
padding-left: 4px; | ||
} | ||
thead th:first-child, | ||
tbody tr td:first-child { | ||
width: 24px; | ||
padding: 0; | ||
padding-left: 4px; | ||
} | ||
|
||
table .avatardiv { | ||
margin-top: 6px; | ||
} | ||
table .avatardiv { | ||
margin-top: 6px; | ||
} | ||
|
||
table thead th:nth-child(2), | ||
table .username { | ||
padding-left: 13px; | ||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
max-width: 0; | ||
min-width: 50px; | ||
} | ||
table thead th:nth-child(2), | ||
table .username { | ||
padding-left: 13px; | ||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
max-width: 0; | ||
min-width: 50px; | ||
} | ||
|
||
.state-column { | ||
text-align: center; | ||
width: 44px !important; | ||
padding: 3px; | ||
} | ||
.state-column { | ||
text-align: center; | ||
width: 44px !important; | ||
padding: 3px; | ||
} | ||
|
||
thead .state-column { | ||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
} | ||
thead .state-column { | ||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
} | ||
|
||
table button { | ||
height: 26px; | ||
width: 24px !important; | ||
display: block; | ||
border-radius: 50%; | ||
margin: auto; | ||
} | ||
table button { | ||
height: 26px; | ||
width: 24px !important; | ||
display: block; | ||
border-radius: 50%; | ||
margin: auto; | ||
} | ||
|
||
a.icon-close { | ||
display: inline-block; | ||
height: 24px; | ||
width: 100%; | ||
vertical-align: middle; | ||
background-size: 12px; | ||
opacity: .7; | ||
float: right; | ||
} | ||
a.icon-close { | ||
display: inline-block; | ||
height: 24px; | ||
width: 100%; | ||
vertical-align: middle; | ||
background-size: 12px; | ||
opacity: .7; | ||
float: right; | ||
} | ||
|
||
a.icon-close:hover { | ||
opacity: 1; | ||
} | ||
a.icon-close:hover { | ||
opacity: 1; | ||
} | ||
|
||
.multiselect { | ||
margin-left: 44px; | ||
width: calc(100% - 44px); | ||
} | ||
.multiselect { | ||
margin-left: 44px; | ||
width: calc(100% - 44px); | ||
} | ||
</style> |