Improved ACL handling #157

This commit is contained in:
the-djmaze 2024-02-13 10:44:38 +01:00
parent 7e304daee0
commit 306d3ec7b5
8 changed files with 110 additions and 116 deletions

View file

@ -402,8 +402,6 @@ export class FolderModel extends AbstractModel {
}
),
canBeEdited: () => !this.type() && this.exists/* && this.selectable()*/,
isSystemFolder: () => this.type()
| (FolderUserStore.allowKolab() && !!this.kolabType() & !SettingsUserStore.unhideKolabFolders()),
@ -484,8 +482,7 @@ export class FolderModel extends AbstractModel {
}
edit() {
// this.canBeEdited() && this.editing(true);
this.canBeEdited() && showScreenPopup(FolderPopupView, [this]);
showScreenPopup(FolderPopupView, [this]);
}
unedit() {

View file

@ -15,6 +15,7 @@
}
.folder-name {
cursor: pointer;
word-break: break-all;
white-space: pre-wrap;
}
@ -24,10 +25,6 @@
opacity: 0.6;
}
.folder-name.can-be-edited {
cursor: pointer;
}
select {
width: auto;
}

View file

@ -1,8 +1,7 @@
import { addObservablesTo } from 'External/ko';
import { AbstractViewPopup } from 'Knoin/AbstractViews';
import { addObservablesTo } from 'External/ko';
import Remote from 'Remote/User/Fetch';
import { FolderUserStore } from 'Stores/User/Folder';
export class FolderPopupView extends AbstractViewPopup {
constructor() {
@ -10,7 +9,7 @@ export class FolderPopupView extends AbstractViewPopup {
addObservablesTo(this, {
folder: null // FolderModel
});
this.ACLAllowed = FolderUserStore.hasCapability('ACL');
this.ACL = ko.observableArray();
}
@ -26,19 +25,14 @@ export class FolderPopupView extends AbstractViewPopup {
beforeShow(folder) {
this.ACL([]);
folder.editing(true);
this.folder(folder);
Remote.request('FolderACL', (iError, data) => {
this.ACLAllowed && Remote.request('FolderACL', (iError, data) => {
if (!iError && data.Result) {
this.ACL(
Object.entries(data.Result).map(([key, value]) => {
value.identifier = key;
return value;
})
);
this.ACL(Object.values(data.Result));
}
}, {
folder: folder.fullName
});
!folder.type() && folder.exists && folder.selectable() && folder.editing(true);
this.folder(folder);
}
}