Merge pull request #2025 from maxberger/master

Add support for managing incoming shares via map
This commit is contained in:
Peter Bieringer
2026-03-15 07:57:46 +01:00
committed by GitHub
17 changed files with 747 additions and 159 deletions

122
integ_tests/test_scenes.py Normal file
View File

@@ -0,0 +1,122 @@
# This file is part of Radicale - CalDAV and CardDAV server
# Copyright © 2026-2026 Max Berger <max@berger.name>
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Radicale. If not, see <http://www.gnu.org/licenses/>.
"""
Integration tests for scene navigation
"""
import pathlib
from typing import Any, Generator
import pytest
from playwright.sync_api import Page, expect
from integ_tests.common import create_collection, login, start_radicale_server
@pytest.fixture
def radicale_server(tmp_path: pathlib.Path) -> Generator[str, Any, None]:
yield from start_radicale_server(tmp_path)
def test_navigation_create_collection_cancel(page: Page, radicale_server: str) -> None:
login(page, radicale_server)
expect(page.locator("#collectionsscene")).to_be_visible()
page.click('a[data-name="new"]')
expect(page.locator("#createcollectionscene")).to_be_visible()
page.click('#createcollectionscene button[data-name="cancel"]')
expect(page.locator("#createcollectionscene")).to_be_hidden()
expect(page.locator("#collectionsscene")).to_be_visible()
def test_navigation_create_collection_submit(page: Page, radicale_server: str) -> None:
login(page, radicale_server)
expect(page.locator("#collectionsscene")).to_be_visible()
page.click('a[data-name="new"]')
expect(page.locator("#createcollectionscene")).to_be_visible()
page.locator('#createcollectionscene input[data-name="displayname"]').fill(
"Nav Test Col"
)
page.click('#createcollectionscene button[data-name="submit"]')
expect(page.locator("#createcollectionscene")).to_be_hidden()
expect(page.locator("#collectionsscene")).to_be_visible()
expect(page.locator("article:has-text('Nav Test Col')")).to_be_visible()
def test_navigation_delete_collection_cancel(page: Page, radicale_server: str) -> None:
login(page, radicale_server)
create_collection(page, radicale_server)
expect(page.locator("#collectionsscene")).to_be_visible()
page.hover("article:not(.hidden)")
page.click('article:not(.hidden) a[data-name="delete"]', force=True)
expect(page.locator("#deletecollectionscene")).to_be_visible()
page.click('#deletecollectionscene button[data-name="cancel"]')
expect(page.locator("#deletecollectionscene")).to_be_hidden()
expect(page.locator("#collectionsscene")).to_be_visible()
def test_navigation_delete_collection_confirm(page: Page, radicale_server: str) -> None:
login(page, radicale_server)
create_collection(page, radicale_server)
expect(page.locator("#collectionsscene")).to_be_visible()
page.hover("article:not(.hidden)")
page.click('article:not(.hidden) a[data-name="delete"]', force=True)
expect(page.locator("#deletecollectionscene")).to_be_visible()
# We need to fill the confirmation text
confirmation_text = page.locator(
"#deletecollectionscene [data-name='deleteconfirmationtext']"
).inner_text()
page.locator("#deletecollectionscene input[data-name='confirmationtxt']").fill(
confirmation_text
)
page.click('#deletecollectionscene button[data-name="delete"]')
expect(page.locator("#deletecollectionscene")).to_be_hidden()
expect(page.locator("#collectionsscene")).to_be_visible()
expect(page.locator("article:not(.hidden)")).to_have_count(0)
def test_navigation_refresh_button(page: Page, radicale_server: str) -> None:
login(page, radicale_server)
expect(page.locator("#collectionsscene")).to_be_visible()
page.click('#logoutview a[data-name="refresh"]')
# It shows LoadingScene briefly then back to CollectionsScene
expect(page.locator("#collectionsscene")).to_be_visible()
def test_login_logout_login(page: Page, radicale_server: str) -> None:
# 1. First login
login(page, radicale_server)
expect(page.locator("#collectionsscene")).to_be_visible()
# 2. Logout
page.click('#logoutview a[data-name="logout"]')
expect(page.locator("#loginscene")).to_be_visible()
expect(page.locator("#collectionsscene")).to_be_hidden()
# 3. Second login
login(page, radicale_server)
expect(page.locator("#collectionsscene")).to_be_visible()

View File

@@ -48,7 +48,9 @@ def test_create_and_delete_share_by_key(page: Page, radicale_server: str) -> Non
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden)")
).to_have_count(1)
expect(
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden) img[alt='RO']")
page.locator(
"tr[data-name='sharetokenrowtemplate']:not(.hidden) span[data-name='ro']"
)
).to_be_visible()
page.once("dialog", lambda dialog: dialog.accept())
page.click('tr:not(.hidden) button[data-name="delete"]', strict=True)
@@ -62,7 +64,9 @@ def test_create_and_delete_share_by_key(page: Page, radicale_server: str) -> Non
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden)")
).to_have_count(1)
expect(
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden) img[alt='RW']")
page.locator(
"tr[data-name='sharetokenrowtemplate']:not(.hidden) span[data-name='rw']"
)
).to_be_visible()
page.once("dialog", lambda dialog: dialog.accept())
page.click('tr:not(.hidden) button[data-name="delete"]', strict=True)
@@ -89,7 +93,9 @@ def test_create_and_delete_share_by_map(page: Page, radicale_server: str) -> Non
page.locator("tr[data-name='sharemaprowtemplate']:not(.hidden)")
).to_have_count(1)
expect(
page.locator("tr[data-name='sharemaprowtemplate']:not(.hidden) img[alt='RO']")
page.locator(
"tr[data-name='sharemaprowtemplate']:not(.hidden) span[data-name='ro']"
)
).to_be_visible()
page.once("dialog", lambda dialog: dialog.accept())
page.click('tr:not(.hidden) button[data-name="delete"]', strict=True)
@@ -105,7 +111,9 @@ def test_create_and_delete_share_by_map(page: Page, radicale_server: str) -> Non
page.locator("tr[data-name='sharemaprowtemplate']:not(.hidden)")
).to_have_count(1)
expect(
page.locator("tr[data-name='sharemaprowtemplate']:not(.hidden) img[alt='RW']")
page.locator(
"tr[data-name='sharemaprowtemplate']:not(.hidden) span[data-name='rw']"
)
).to_be_visible()
page.once("dialog", lambda dialog: dialog.accept())
page.click('tr:not(.hidden) button[data-name="delete"]', strict=True)
@@ -196,7 +204,9 @@ def test_edit_share_by_token(page: Page, radicale_server: str) -> None:
page.click('button[data-name="sharebytoken"]')
page.click('#newshare button[data-name="submit"]')
expect(
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden) img[alt='RO']")
page.locator(
"tr[data-name='sharetokenrowtemplate']:not(.hidden) span[data-name='ro']"
)
).to_be_visible()
# Edit to RW
@@ -207,7 +217,9 @@ def test_edit_share_by_token(page: Page, radicale_server: str) -> None:
# Verify RW
expect(
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden) img[alt='RW']")
page.locator(
"tr[data-name='sharetokenrowtemplate']:not(.hidden) span[data-name='rw']"
)
).to_be_visible()
@@ -223,7 +235,9 @@ def test_edit_share_by_map(page: Page, radicale_server: str) -> None:
page.locator('input[data-name="sharehref"]').fill("mapped")
page.click('#newshare button[data-name="submit"]')
expect(
page.locator("tr[data-name='sharemaprowtemplate']:not(.hidden) img[alt='RO']")
page.locator(
"tr[data-name='sharemaprowtemplate']:not(.hidden) span[data-name='ro']"
)
).to_be_visible()
# Edit map share
@@ -234,17 +248,19 @@ def test_edit_share_by_map(page: Page, radicale_server: str) -> None:
# Change permissions and enabled status
page.click('label[for="newshare_attr_permissions_rw"]')
page.uncheck('input[data-name="enabled"]')
page.uncheck('#newshare input[data-name="enabled"]')
page.click('#newshare button[data-name="submit"]')
# Verify changes
expect(
page.locator("tr[data-name='sharemaprowtemplate']:not(.hidden) img[alt='RW']")
page.locator(
"tr[data-name='sharemaprowtemplate']:not(.hidden) span[data-name='rw']"
)
).to_be_visible()
# If disabled, it might not show up or show differently, but our current UI doesn't visually distinguish enabled/disabled in the list yet
# Let's verify by re-opening edit scene
page.click('tr:not(.hidden) button[data-name="edit"]')
expect(page.locator('input[data-name="enabled"]')).not_to_be_checked()
expect(page.locator('#newshare input[data-name="enabled"]')).not_to_be_checked()
page.click('#newshare button[data-name="cancel"]')
@@ -279,3 +295,109 @@ def test_share_by_map_validation(page: Page, radicale_server: str) -> None:
expect(
page.locator("tr[data-name='sharemaprowtemplate']:not(.hidden)")
).to_have_count(1)
def test_incoming_shares(page: Page, radicale_server: str) -> None:
# 1. Admin logs in and creates a map share for 'max'
login(page, radicale_server)
create_collection(page, radicale_server)
page.hover("article:not(.hidden)")
page.click('article:not(.hidden) a[data-name="share"]', force=True, strict=True)
page.click('button[data-name="sharebymap"]')
page.locator('input[data-name="shareuser"]').fill("max")
page.locator('input[data-name="sharehref"]').fill("mapped")
page.click('#newshare button[data-name="submit"]')
expect(
page.locator("tr[data-name='sharemaprowtemplate']:not(.hidden)")
).to_have_count(1)
page.click('#sharecollectionscene button[data-name="cancel"]')
# 2. Admin logs out
page.click('a[data-name="logout"]')
# 3. Max logs in
page.fill('#loginscene input[data-name="user"]', "max")
page.fill('#loginscene input[data-name="password"]', "maxpassword")
page.click('button:has-text("Next")')
# 4. Max sees the incoming share
page.click('a[data-name="incomingshares"]')
expect(page.locator("#incomingsharingscene")).to_be_visible()
expect(
page.locator("tr[data-name='incomingsharerowtemplate']:not(.hidden)")
).to_have_count(1)
expect(
page.locator(
"tr[data-name='incomingsharerowtemplate']:not(.hidden) input[data-name='pathortoken']"
)
).to_have_value("mapped")
# 5. Max enables and shows the share
# Initially, it's disabled and not shown (security by default)
expect(
page.locator(
"tr[data-name='incomingsharerowtemplate']:not(.hidden) input[data-name='enabled']"
)
).not_to_be_checked()
expect(
page.locator(
"tr[data-name='incomingsharerowtemplate']:not(.hidden) input[data-name='shown']"
)
).not_to_be_checked()
expect(
page.locator(
"tr[data-name='incomingsharerowtemplate']:not(.hidden) input[data-name='shown']"
)
).to_be_disabled()
# Enable it
page.check(
"tr[data-name='incomingsharerowtemplate']:not(.hidden) input[data-name='enabled']"
)
expect(
page.locator(
"tr[data-name='incomingsharerowtemplate']:not(.hidden) input[data-name='shown']"
)
).not_to_be_disabled()
# Show it
page.check(
"tr[data-name='incomingsharerowtemplate']:not(.hidden) input[data-name='shown']"
)
expect(
page.locator(
"tr[data-name='incomingsharerowtemplate']:not(.hidden) input[data-name='shown']"
)
).to_be_checked()
# 6. Assert no error was shown
expect(page.locator('#incomingsharingscene span[data-name="error"]')).to_be_hidden()
page.click('#incomingsharingscene button[data-name="cancel"]')
expect(page.locator("#incomingsharingscene")).to_be_hidden()
def test_no_incoming_shares_message(page: Page, radicale_server: str) -> None:
# 1. Max logs in
page.goto(radicale_server)
page.fill('#loginscene input[data-name="user"]', "max")
page.fill('#loginscene input[data-name="password"]', "maxpassword")
page.click('button:has-text("Next")')
# 2. Max goes to incoming shares scene
page.click('a[data-name="incomingshares"]')
expect(page.locator("#incomingsharingscene")).to_be_visible()
# 3. Verify that the table is hidden and the message is visible
expect(page.locator("#incomingsharingscene table")).to_be_hidden()
expect(
page.locator('#incomingsharingscene [data-name="nosharesmessage"]')
).to_be_visible()
expect(
page.locator('#incomingsharingscene [data-name="nosharesmessage"]')
).to_have_text("No incoming shares")
page.click('#incomingsharingscene button[data-name="cancel"]')
expect(page.locator("#incomingsharingscene")).to_be_hidden()

View File

@@ -501,4 +501,20 @@ button.inline {
#logoutview span {
padding: 0 5px;
}
}
}
.pill {
display: inline-block;
padding: 0.25em 0.6em;
font-size: 75%;
font-weight: 700;
line-height: 1;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: 0.375rem;
background-color: #6c757d;
color: #fff;
margin: 0 2px;
width: 1.4em;
}

View File

@@ -66,6 +66,9 @@
<a href="" class="blue" data-name="upload" title="Upload an addressbook or calendar">
<img src="css/icons/upload.svg" class="icon" alt="⬆️">
</a>
<a href="" class="blue" data-name="incomingshares" title="Incoming Shares">
<img src="css/icons/share.svg" class="icon" alt="🔗">
</a>
</div>
<article data-name="collectiontemplate" class="hidden">
<div class="colorbar" data-name="color"></div>
@@ -156,8 +159,7 @@
<button type="button" class="blue inline" data-name="edit"><img src="css/icons/edit.svg"
class="small_icon" alt="Edit"></button>
</td>
<td><img src="css/icons/edit.svg" class="med_icon" alt="RW" data-name="rw" /><img src="css/icons/eye.svg"
class="med_icon" alt="RO" data-name="ro" /></td>
<td><span class="pill" data-name="rw">rw</span><span class="pill" data-name="ro">ro</span></td>
<td><input type="text" data-name="pathortoken" value="" readonly=""
onfocus="this.setSelectionRange(0, 99999);" class="inline"></td>
<td>
@@ -182,8 +184,7 @@
<button type="button" class="blue inline" data-name="edit"><img src="css/icons/edit.svg"
class="small_icon" alt="Edit"></button>
</td>
<td><img src="css/icons/edit.svg" class="med_icon" alt="RW" data-name="rw" /><img src="css/icons/eye.svg"
class="med_icon" alt="RO" data-name="ro" /></td>
<td><span class="pill" data-name="rw">rw</span><span class="pill" data-name="ro">ro</span></td>
<td><input type="text" data-name="pathortoken" value="" readonly=""
onfocus="this.setSelectionRange(0, 99999);" class="inline"></td>
<td>
@@ -207,6 +208,38 @@
<span class="error hidden" data-name="error"></span>
</section>
<section id="incomingsharingscene" class="container hidden">
<h1>Incoming Shares</h1>
<p>Manage shares that others have shared with you.</p>
<table>
<thead>
<tr>
<th>Path</th>
<th>Owner</th>
<th title="Permissions">🔑</th>
<th title="Enabled">✔️</th>
<th title="Shown">👁️</th>
</tr>
</thead>
<tbody data-name="incomingsharesbody">
<tr data-name="incomingsharerowtemplate" class="hidden">
<td><input type="text" data-name="pathortoken" value="" readonly=""
onfocus="this.setSelectionRange(0, 99999);" class="inline"></td>
<td data-name="owner"></td>
<td data-name="permissions"><span class="pill" data-name="rw">rw</span><span class="pill"
data-name="ro">ro</span></td>
<td><input type="checkbox" data-name="enabled"></td>
<td><input type="checkbox" data-name="shown"></td>
</tr>
</tbody>
</table>
<p class="hidden" data-name="nosharesmessage">No incoming shares</p>
<form>
<button type="button" class="green" data-name="cancel">Close</button>
</form>
<span class="error hidden" data-name="error"></span>
</section>
<section id="newshare" class="container hidden">
<h1>New Share</h1>
<form>
@@ -219,9 +252,9 @@
</fieldset>
<fieldset>
<legend>Attributes</legend>
<input type="checkbox" data-name="enabled" checked="true" id="newshare_attr_enabled" /><label
<input type="checkbox" data-name="enabled" checked id="newshare_attr_enabled" /><label
for="newshare_attr_enabled">Enabled</label>
<input type="checkbox" data-name="hidden" checked="false" id="newshare_attr_hidden" /><label
<input type="checkbox" data-name="hidden" id="newshare_attr_hidden" /><label
for="newshare_attr_hidden">Hidden</label>
</fieldset>
<fieldset>

View File

@@ -146,11 +146,12 @@ export class Share {
* @param {function(Array<Share>, ?string):void} callback
*/
export function reload_sharing_list(user, password, collection, callback) {
let body = collection ? { PathMapped: collection.href } : {};
call_sharing_api(
user,
password,
"all/list",
{ PathMapped: collection.href },
body,
function (response) {
let parsed = JSON.parse(response);
let shares = (parsed["Content"] || []).map(data => new Share(data));
@@ -411,3 +412,41 @@ export function update_share_by_map(
}
);
}
/**
* Update a shared map entry as the recipient user.
* Only sends fields the non-owner user is allowed to change: PathOrToken, EnabledByUser, HiddenByUser.
* @param {string} user
* @param {string} password
* @param {Share} share
* @param {function(?string):void} callback
*/
export function update_incoming_share(
user,
password,
share,
callback,
) {
call_sharing_api(
user,
password,
"map/update",
{
PathOrToken: share.PathOrToken,
Enabled: share.EnabledByUser,
Hidden: share.HiddenByUser,
},
function (response) {
let json_response = JSON.parse(response);
if (json_response["Status"] !== "success") {
callback(json_response["Status"] || "Unknown error");
} else {
callback(null);
}
},
null,
function (error) {
callback(error);
}
);
}

View File

@@ -20,8 +20,11 @@
*/
import { LoginScene } from "./scenes/LoginScene.js";
import { LoadingScene } from "./scenes/LoadingScene.js";
import { push_scene } from "./scenes/scene_manager.js";
// Hide startup loading message
document.getElementById("loadingscene").classList.add("hidden");
push_scene(new LoginScene(), false);
// This works because the LoadingScene is the one that is already active in index.html,
// and all other scenes are hidden.
new LoadingScene().hide();
push_scene(new LoginScene());

View File

@@ -27,8 +27,9 @@ import { Collection, CollectionType } from "../models/collection.js";
import { bytesToHumanReadable } from "../utils/misc.js";
import { CreateEditCollectionScene } from "./CreateEditCollectionScene.js";
import { DeleteCollectionScene } from "./DeleteCollectionScene.js";
import { IncomingSharingScene } from "./IncomingSharingScene.js";
import { LoadingScene } from "./LoadingScene.js";
import { Scene, pop_scene, push_scene, scene_stack } from "./scene_manager.js";
import { Scene, is_current_scene, pop_scene, push_scene } from "./scene_manager.js";
import { ShareCollectionScene, maybe_enable_sharing_options } from "./ShareCollectionScene.js";
import { UploadCollectionScene } from "./UploadCollectionScene.js";
@@ -39,25 +40,25 @@ export class CollectionsScene {
/**
* @param {string} user
* @param {string} password
* @param {Collection} collection The collection to show sharing options for.
* @param {Collection} principal_collection The princial collection
* @param {function(string):void} onerror Called when an error occurs, before the
* scene is popped.
*/
constructor(user, password, collection, onerror) {
constructor(user, password, principal_collection, onerror) {
/** @type {HTMLElement} */ let html_scene = document.getElementById("collectionsscene");
/** @type {HTMLElement} */ let template = html_scene.querySelector("[data-name=collectiontemplate]");
/** @type {HTMLElement} */ let new_btn = html_scene.querySelector("[data-name=new]");
/** @type {HTMLElement} */ let upload_btn = html_scene.querySelector("[data-name=upload]");
/** @type {HTMLElement} */ let incomingshares_btn = html_scene.querySelector("[data-name=incomingshares]");
/** @type {?number} */ let scene_index = null;
/** @type {?XMLHttpRequest} */ let collections_req = null;
/** @type {?Array<Collection>} */ let collections = null;
/** @type {?Array<Collection>} */ let child_collections = null;
/** @type {Array<HTMLElement>} */ let nodes = [];
function onnew() {
try {
let create_collection_scene = new CreateEditCollectionScene(user, password, collection);
push_scene(create_collection_scene, false);
let create_collection_scene = new CreateEditCollectionScene(user, password, principal_collection);
push_scene(create_collection_scene);
} catch (err) {
console.error(err);
}
@@ -66,50 +67,72 @@ export class CollectionsScene {
function onupload() {
try {
let upload_scene = new UploadCollectionScene(user, password, collection);
push_scene(upload_scene, false);
let upload_scene = new UploadCollectionScene(user, password, principal_collection);
push_scene(upload_scene);
} catch (err) {
console.error(err);
}
return false;
}
function onincomingshares() {
try {
let incoming_sharing_scene = new IncomingSharingScene(user, password);
push_scene(incoming_sharing_scene);
} catch (err) {
console.error(err);
}
return false;
}
/**
* @param {Collection} collection
*/
function onedit(collection) {
try {
let edit_collection_scene = new CreateEditCollectionScene(user, password, collection);
push_scene(edit_collection_scene, false);
push_scene(edit_collection_scene);
} catch (err) {
console.error(err);
}
return false;
}
/**
* @param {Collection} collection
*/
function onshare(collection) {
try {
let share_collection_scene = new ShareCollectionScene(user, password, collection);
push_scene(share_collection_scene, false);
push_scene(share_collection_scene);
} catch (err) {
console.error(err);
}
return false;
}
/**
* @param {Collection} collection
*/
function ondelete(collection) {
try {
let delete_collection_scene = new DeleteCollectionScene(user, password, collection);
push_scene(delete_collection_scene, false);
push_scene(delete_collection_scene);
} catch (err) {
console.error(err);
}
return false;
}
/**
* @param {any[]} collections
*/
function show_collections(collections) {
/** @type {HTMLElement} */ let navBar = document.querySelector("#logoutview");
let heightOfNavBar = navBar.offsetHeight + "px";
html_scene.style.marginTop = heightOfNavBar;
html_scene.style.height = "calc(100vh - " + heightOfNavBar + ")";
collections.forEach(function (collection) {
collections.forEach(function (/** @type {Collection} */ collection) {
/** @type {HTMLElement} */ let node = /** @type {HTMLElement} */(template.cloneNode(true));
node.classList.remove("hidden");
/** @type {HTMLElement} */ let title_form = node.querySelector("[data-name=title]");
@@ -171,18 +194,18 @@ export class CollectionsScene {
function update() {
let loading_scene = new LoadingScene();
push_scene(loading_scene, false);
collections_req = get_collections(user, password, collection, function (collections1, error) {
if (scene_index === null) {
push_scene(loading_scene);
collections_req = get_collections(user, password, principal_collection, function (child_collections_, error) {
if (!is_current_scene(loading_scene)) {
return;
}
collections_req = null;
if (error) {
onerror(error);
pop_scene(scene_index - 1);
pop_scene();
} else {
collections = collections1;
pop_scene(scene_index);
child_collections = child_collections_;
pop_scene();
}
});
}
@@ -191,20 +214,21 @@ export class CollectionsScene {
html_scene.classList.remove("hidden");
new_btn.onclick = onnew;
upload_btn.onclick = onupload;
if (collections === null) {
incomingshares_btn.onclick = onincomingshares;
if (child_collections === null) {
update();
discover_server_features(user, password, maybe_enable_sharing_options);
} else {
// from update loading scene
show_collections(collections);
show_collections(child_collections);
}
};
this.hide = function () {
html_scene.classList.add("hidden");
scene_index = scene_stack.length - 1;
new_btn.onclick = null;
upload_btn.onclick = null;
collections = null;
incomingshares_btn.onclick = null;
child_collections = null;
// remove collection
nodes.forEach(function (node) {
node.parentNode.removeChild(node);
@@ -212,12 +236,11 @@ export class CollectionsScene {
nodes = [];
};
this.release = function () {
scene_index = null;
if (collections_req !== null) {
collections_req.abort();
collections_req = null;
}
collections = null;
child_collections = null;
};
}
}

View File

@@ -26,7 +26,7 @@ import { ErrorHandler } from "../utils/error.js";
import { FormValidator, validate_color, validate_href } from "../utils/form_validator.js";
import { cleanHREFinput, onCleanHREFinput, random_hex, random_uuid } from "../utils/misc.js";
import { LoadingScene } from "./LoadingScene.js";
import { Scene, pop_scene, push_scene, scene_stack } from "./scene_manager.js";
import { Scene, is_current_scene, pop_scene, pop_to_parent, push_scene } from "./scene_manager.js";
/**
* @implements {Scene}
@@ -55,7 +55,6 @@ export class CreateEditCollectionScene {
/** @type {HTMLElement} */ let cancel_btn = html_scene.querySelector("[data-name=cancel]");
/** @type {?number} */ let scene_index = null;
/** @type {?XMLHttpRequest} */ let create_edit_req = null;
/** @type {?HTMLSelectElement} */ let saved_type_form = null;
@@ -130,18 +129,18 @@ export class CreateEditCollectionScene {
sane_color = COLOR_RE.exec(sane_color)[1];
}
let loading_scene = new LoadingScene();
push_scene(loading_scene, false);
push_scene(loading_scene);
let collection = new Collection(href, type, displayname, description, sane_color, 0, 0, source);
let callback = function (error1) {
if (scene_index === null) {
if (!is_current_scene(loading_scene)) {
return;
}
create_edit_req = null;
if (error1) {
errorHandler.setError(error1);
pop_scene(scene_index);
pop_scene();
} else {
pop_scene(scene_index - 1);
pop_to_parent();
}
};
if (edit) {
@@ -157,7 +156,7 @@ export class CreateEditCollectionScene {
function oncancel() {
try {
pop_scene(scene_index - 1);
pop_scene();
} catch (err) {
console.error(err);
}
@@ -179,7 +178,6 @@ export class CreateEditCollectionScene {
this.show = function () {
this.release();
scene_index = scene_stack.length - 1;
// Clone type_form because it's impossible to hide options without removing them
saved_type_form = type_form;
type_form = /** @type {HTMLSelectElement} */ (type_form.cloneNode(true));
@@ -205,7 +203,6 @@ export class CreateEditCollectionScene {
cancel_btn.onclick = null;
};
this.release = function () {
scene_index = null;
if (create_edit_req !== null) {
create_edit_req.abort();
create_edit_req = null;

View File

@@ -24,7 +24,7 @@ import { CollectionType } from "../models/collection.js";
import { ErrorHandler } from "../utils/error.js";
import { FormValidator, validate_href, validate_not_empty_or_equals } from "../utils/form_validator.js";
import { onCleanHREFinput, random_uuid } from "../utils/misc.js";
import { Scene, pop_scene, scene_stack } from "./scene_manager.js";
import { Scene, is_current_scene, pop_scene } from "./scene_manager.js";
/**
* @implements {Scene}
@@ -35,10 +35,10 @@ export class CreateEditShareScene {
* @param {string} password
* @param {import("../models/collection.js").Collection} collection
* @param {string} shareType
* @param {function():void} onclose
* @param {Share} [share] If provided, the scene will be in edit mode.
*/
constructor(user, password, collection, shareType, onclose, share) {
constructor(user, password, collection, shareType, share) {
let self = this;
let edit = !!share;
let pathMapped = collection.href;
/** @type {HTMLElement} */ let html_scene = document.getElementById("newshare");
@@ -76,14 +76,10 @@ export class CreateEditShareScene {
color_override_input.disabled = !color_override_enabled.checked;
};
/** @type {?number} */ let scene_index = null;
function oncancel() {
try {
if (scene_index !== null) {
pop_scene(scene_index - 1);
}
if (onclose) onclose();
pop_scene();
} catch (err) {
console.error(err);
}
@@ -112,14 +108,13 @@ export class CreateEditShareScene {
}
let callback = function (/** @type {string} */ error) {
if (scene_index === null) {
if (!is_current_scene(self)) {
return;
}
if (error) {
errorHandler.setError(error);
} else {
pop_scene(scene_index - 1);
if (onclose) onclose();
pop_scene();
}
};
@@ -157,7 +152,6 @@ export class CreateEditShareScene {
this.show = function () {
this.release();
scene_index = scene_stack.length - 1;
html_scene.classList.remove("hidden");
cancel_btn.onclick = oncancel;
form.onsubmit = onsubmit;
@@ -232,7 +226,6 @@ export class CreateEditShareScene {
};
this.release = function () {
scene_index = null;
};
}
}

View File

@@ -25,7 +25,7 @@ import { Collection } from "../models/collection.js";
import { ErrorHandler } from "../utils/error.js";
import { FormValidator, validate_equals } from "../utils/form_validator.js";
import { LoadingScene } from "./LoadingScene.js";
import { Scene, pop_scene, push_scene, scene_stack } from "./scene_manager.js";
import { Scene, is_current_scene, pop_scene, pop_to_parent, push_scene } from "./scene_manager.js";
/**
* @implements {Scene}
@@ -49,7 +49,6 @@ export class DeleteCollectionScene {
confirmation_txt.value = "";
confirmation_txt.addEventListener("keydown", onkeydown);
/** @type {?number} */ let scene_index = null;
/** @type {?XMLHttpRequest} */ let delete_req = null;
let errorHandler = new ErrorHandler(error_form);
@@ -63,18 +62,17 @@ export class DeleteCollectionScene {
}
try {
let loading_scene = new LoadingScene();
push_scene(loading_scene, false);
push_scene(loading_scene);
delete_req = delete_collection(user, password, collection, function (error1) {
if (scene_index === null) {
if (!is_current_scene(loading_scene)) {
return;
}
delete_req = null;
delete_req = null;
if (error1) {
errorHandler.setError(error1);
pop_scene(scene_index);
pop_scene();
} else {
pop_scene(scene_index - 1);
pop_to_parent();
}
});
} catch (err) {
@@ -85,7 +83,7 @@ export class DeleteCollectionScene {
function oncancel() {
try {
pop_scene(scene_index - 1);
pop_scene();
} catch (err) {
console.error(err);
}
@@ -101,7 +99,6 @@ export class DeleteCollectionScene {
this.show = function () {
this.release();
scene_index = scene_stack.length - 1;
html_scene.classList.remove("hidden");
title_form.textContent = collection.displayname || collection.href;
delete_btn.onclick = ondelete;
@@ -114,7 +111,6 @@ export class DeleteCollectionScene {
delete_btn.onclick = null;
};
this.release = function () {
scene_index = null;
if (delete_req !== null) {
delete_req.abort();
delete_req = null;

View File

@@ -0,0 +1,188 @@
/**
* This file is part of Radicale Server - Calendar Server
* Copyright © 2017-2024 Unrud <unrud@outlook.com>
* Copyright © 2023-2024 Matthew Hana <matthew.hana@gmail.com>
* Copyright © 2024-2025 Peter Bieringer <pb@bieringer.de>
* Copyright © 2026-2026 Max Berger <max@berger.name>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Share, reload_sharing_list, update_incoming_share } from "../api/sharing.js";
import { ErrorHandler } from "../utils/error.js";
import { displayPermissions } from "../utils/permissions.js";
import { LoadingScene } from "./LoadingScene.js";
import { Scene, is_current_scene, pop_scene, push_scene } from "./scene_manager.js";
/**
* @implements {Scene}
*/
export class IncomingSharingScene {
/**
* @param {string} user
* @param {string} password
*/
constructor(user, password) {
/** @type {HTMLElement} */ let html_scene = document.getElementById("incomingsharingscene");
/** @type {HTMLElement} */ let cancel_btn = html_scene.querySelector("[data-name=cancel]");
/** @type {HTMLElement} */ let error_element = html_scene.querySelector("[data-name=error]");
/** @type {HTMLElement} */ let tbody = html_scene.querySelector("tbody[data-name=incomingsharesbody]");
/** @type {HTMLElement} */ let template = tbody.querySelector("[data-name=incomingsharerowtemplate]");
/** @type {HTMLElement} */ let table = html_scene.querySelector("table");
/** @type {HTMLElement} */ let noshares_message = html_scene.querySelector("[data-name=nosharesmessage]");
let error_handler = new ErrorHandler(error_element);
/** @type {Array<HTMLElement>} */ let nodes = [];
/** @type {?Array<Object>} */ let shares_cache = null;
function on_cancel() {
pop_scene();
}
/**
* @param {Share} share
* @param {HTMLElement} node
*/
function toggle_share(share, node) {
let enabled_cb = /** @type {HTMLInputElement} */ (node.querySelector("[data-name=enabled]"));
let shown_cb = /** @type {HTMLInputElement} */ (node.querySelector("[data-name=shown]"));
// disable checkboxes while updating
enabled_cb.disabled = true;
shown_cb.disabled = true;
let old_enabled = share.EnabledByUser;
let old_hidden = share.HiddenByUser;
share.EnabledByUser = enabled_cb.checked;
share.HiddenByUser = !shown_cb.checked;
error_handler.clearError();
update_incoming_share(user, password, share, function (error) {
enabled_cb.disabled = false;
shown_cb.disabled = !share.EnabledByUser;
if (error) {
error_handler.setError(error);
enabled_cb.checked = old_enabled;
shown_cb.checked = !old_hidden;
shown_cb.disabled = !old_enabled;
}
});
}
/**
* @param {Share[]} shares
*/
function render_shares(shares) {
// clear old nodes
nodes.forEach(function (node) {
node.parentNode.removeChild(node);
});
nodes = [];
let prefix = "/" + user + "/";
let filtered_shares = shares.filter(share => share.ShareType === "map" && share.PathOrToken.startsWith(prefix));
if (filtered_shares.length === 0) {
table.classList.add("hidden");
noshares_message.classList.remove("hidden");
} else {
table.classList.remove("hidden");
noshares_message.classList.add("hidden");
}
filtered_shares.forEach(function (share) {
let node = /** @type {HTMLElement} */(template.cloneNode(true));
node.classList.remove("hidden");
let pathortoken = /** @type {HTMLInputElement} */ (node.querySelector("[data-name=pathortoken]"));
let owner_td = node.querySelector("[data-name=owner]");
let permissions_td = /** @type {HTMLElement} */ (node.querySelector("[data-name=permissions]"));
let enabled_cb = /** @type {HTMLInputElement} */ (node.querySelector("[data-name=enabled]"));
let shown_cb = /** @type {HTMLInputElement} */ (node.querySelector("[data-name=shown]"));
let displayPath = share.PathOrToken.substring(prefix.length);
if (displayPath.endsWith("/")) {
displayPath = displayPath.substring(0, displayPath.length - 1);
}
pathortoken.value = displayPath;
owner_td.textContent = share.Owner;
displayPermissions(share.Permissions, permissions_td);
let enabled = share.EnabledByUser !== null ? share.EnabledByUser : true;
let shown = share.HiddenByUser !== null ? !share.HiddenByUser : true;
enabled_cb.checked = enabled;
shown_cb.checked = shown;
shown_cb.disabled = !enabled;
enabled_cb.onchange = function () { toggle_share(share, node); };
shown_cb.onchange = function () { toggle_share(share, node); };
nodes.push(node);
tbody.appendChild(node);
});
}
function update() {
let loading_scene = new LoadingScene();
push_scene(loading_scene);
error_handler.clearError();
reload_sharing_list(user, password, null, function (shares, error) {
if (!is_current_scene(loading_scene)) {
return;
}
if (error) {
error_handler.setError(error);
pop_scene();
} else {
shares_cache = shares;
pop_scene();
}
});
}
this.show = function () {
html_scene.classList.remove("hidden");
cancel_btn.onclick = on_cancel;
if (shares_cache === null) {
update();
} else {
render_shares(shares_cache);
}
};
this.hide = function () {
html_scene.classList.add("hidden");
cancel_btn.onclick = null;
error_handler.clearError();
};
this.release = function () {
error_handler.clearError();
nodes.forEach(function (node) {
if (node.parentNode) {
node.parentNode.removeChild(node);
}
});
nodes = [];
shares_cache = null;
};
}
}

View File

@@ -26,13 +26,13 @@ import { Scene } from "./scene_manager.js";
*/
export class LoadingScene {
constructor() {
let html_scene = document.getElementById("loadingscene");
this.show = function () {
html_scene.classList.remove("hidden");
};
this.hide = function () {
html_scene.classList.add("hidden");
};
this.release = function () { };
this.html_scene = document.getElementById("loadingscene");
}
show() {
this.html_scene.classList.remove("hidden");
}
hide() {
this.html_scene.classList.add("hidden");
}
release() { }
}

View File

@@ -20,11 +20,11 @@
*/
import { get_principal } from "../api/api.js";
import { CollectionsScene } from "./CollectionsScene.js";
import { LoadingScene } from "./LoadingScene.js";
import { Scene, pop_scene, push_scene, scene_stack } from "./scene_manager.js";
import { ErrorHandler } from "../utils/error.js";
import { FormValidator, validate_non_empty } from "../utils/form_validator.js";
import { CollectionsScene } from "./CollectionsScene.js";
import { LoadingScene } from "./LoadingScene.js";
import { Scene, is_current_scene, pop_scene, pop_to_root, push_scene, replace_scene } from "./scene_manager.js";
/**
* @constructor
* @implements {Scene}
@@ -41,7 +41,6 @@ export class LoginScene {
/** @type {HTMLElement} */ let logout_btn = logout_view.querySelector("[data-name=logout]");
/** @type {HTMLElement} */ let refresh_btn = logout_view.querySelector("[data-name=refresh]");
/** @type {?number} */ let scene_index = null;
let user = "";
/** @type {?XMLHttpRequest} */ let principal_req = null;
let errorHandler = new ErrorHandler(error_form);
@@ -71,25 +70,25 @@ export class LoginScene {
logout_user_form.textContent = user + "'s Collections";
// Fetch principal
let loading_scene = new LoadingScene();
push_scene(loading_scene, false);
principal_req = get_principal(user, password, function (collection, error1) {
if (scene_index === null) {
push_scene(loading_scene);
principal_req = get_principal(user, password, function (principal_collection, error1) {
if (!is_current_scene(loading_scene)) {
return;
}
principal_req = null;
if (error1) {
errorHandler.setError(error1);
pop_scene(scene_index);
pop_scene();
} else {
// show collections
let saved_user = user;
user = "";
let collections_scene = new CollectionsScene(
saved_user, password, collection, function (error1) {
saved_user, password, principal_collection, function (error1) {
errorHandler.setError(error1);
user = saved_user;
});
push_scene(collections_scene, true);
replace_scene(collections_scene);
}
});
} catch (err) {
@@ -98,18 +97,15 @@ export class LoginScene {
return false;
}
function onlogout() {
let onlogout = function () {
try {
if (scene_index === null) {
return false;
}
user = "";
pop_scene(scene_index);
pop_to_root();
} catch (err) {
console.error(err);
}
return false;
}
};
function remove_logout() {
@@ -120,10 +116,10 @@ export class LoginScene {
}
function refresh() {
//The easiest way to refresh is to push a LoadingScene onto the stack and then pop it
//forcing the scene below it, the Collections Scene to refresh itself.
push_scene(new LoadingScene(), false);
pop_scene(scene_stack.length - 2);
// The easiest way to refresh is to push a LoadingScene onto the stack and then pop it
// forcing the scene below it, the Collections Scene to refresh itself.
push_scene(new LoadingScene());
pop_scene();
}
this.show = function () {
@@ -131,7 +127,6 @@ export class LoginScene {
fill_form();
form.onsubmit = onlogin;
html_scene.classList.remove("hidden");
scene_index = scene_stack.length - 1;
user_form.focus();
};
this.hide = function () {
@@ -140,7 +135,6 @@ export class LoginScene {
form.onsubmit = null;
};
this.release = function () {
scene_index = null;
// cancel pending requests
if (principal_req !== null) {
principal_req.abort();

View File

@@ -27,8 +27,9 @@ import {
} from "../api/sharing.js";
import { Collection } from "../models/collection.js";
import { ErrorHandler } from "../utils/error.js";
import { displayPermissions } from "../utils/permissions.js";
import { CreateEditShareScene } from "./CreateEditShareScene.js";
import { Scene, pop_scene, push_scene, scene_stack } from "./scene_manager.js";
import { Scene, pop_scene, push_scene } from "./scene_manager.js";
/**
* @implements {Scene}
@@ -40,7 +41,6 @@ export class ShareCollectionScene {
* @param {Collection} collection The collection on which to edit sharing setting. Must exist.
*/
constructor(user, password, collection) {
/** @type {?number} */ let scene_index = null;
let html_scene = document.getElementById("sharecollectionscene");
@@ -65,7 +65,7 @@ export class ShareCollectionScene {
function oncancel() {
try {
pop_scene(scene_index - 1);
pop_scene();
} catch (err) {
console.error(err);
}
@@ -73,22 +73,17 @@ export class ShareCollectionScene {
}
function onsharebytoken() {
let create_edit_share_scene = new CreateEditShareScene(user, password, collection, "token", function () {
update_share_list(user, password, collection, errorHandler);
});
push_scene(create_edit_share_scene, false);
let create_edit_share_scene = new CreateEditShareScene(user, password, collection, "token");
push_scene(create_edit_share_scene);
}
function onsharebymap() {
let create_edit_share_scene = new CreateEditShareScene(user, password, collection, "map", function () {
update_share_list(user, password, collection, errorHandler);
});
push_scene(create_edit_share_scene, false);
let create_edit_share_scene = new CreateEditShareScene(user, password, collection, "map");
push_scene(create_edit_share_scene);
}
this.show = function () {
this.release();
scene_index = scene_stack.length - 1;
html_scene.classList.remove("hidden");
cancel_btn.onclick = oncancel;
if (server_features.sharing && server_features.sharing.PermittedCreateCollectionByToken) {
@@ -129,7 +124,6 @@ export class ShareCollectionScene {
cancel_btn.onclick = null;
};
this.release = function () {
scene_index = null;
};
}
}
@@ -181,24 +175,12 @@ function add_share_row_node(user, password, collection, share, template, delete_
}
let permissions = (share["Permissions"] || "").toLowerCase();
if (permissions === "rw") {
node
.querySelector("[data-name=ro]")
.parentNode.removeChild(node.querySelector("[data-name=ro]"));
} else if (permissions === "r") {
node
.querySelector("[data-name=rw]")
.parentNode.removeChild(node.querySelector("[data-name=rw]"));
} else {
console.warn("Unknown permissions", permissions);
}
displayPermissions(permissions, node);
/** @type {HTMLElement} */ let edit_btn = node.querySelector("[data-name=edit]");
edit_btn.onclick = function () {
let create_edit_share_scene = new CreateEditShareScene(user, password, collection, share.ShareType, function () {
update_share_list(user, password, collection, errorHandler);
}, share);
push_scene(create_edit_share_scene, false);
let create_edit_share_scene = new CreateEditShareScene(user, password, collection, share.ShareType, share);
push_scene(create_edit_share_scene);
};
/** @type {HTMLElement} */ let delete_btn = node.querySelector("[data-name=delete]");

View File

@@ -24,7 +24,7 @@ import { Collection } from "../models/collection.js";
import { ErrorHandler } from "../utils/error.js";
import { FormValidator, validate_files, validate_href } from "../utils/form_validator.js";
import { cleanHREFinput, onCleanHREFinput, random_uuid } from "../utils/misc.js";
import { Scene, pop_scene, scene_stack } from "./scene_manager.js";
import { Scene, pop_scene } from "./scene_manager.js";
/**
* @implements {Scene}
@@ -62,7 +62,6 @@ export class UploadCollectionScene {
validator.addValidator(href_form, validate_href(href_form, "HREF"));
validator.addValidator(uploadfile_form, validate_files(uploadfile_form, "file"));
/** @type {?number} */ let scene_index = null;
/** @type {?XMLHttpRequest} */ let upload_req = null;
/** @type {Array<string>} */ let results = [];
/** @type {?Array<HTMLElement>} */ let nodes = null;
@@ -128,7 +127,7 @@ export class UploadCollectionScene {
function onclose() {
try {
pop_scene(scene_index - 1);
pop_scene();
} catch (err) {
console.error(err);
}
@@ -187,7 +186,6 @@ export class UploadCollectionScene {
}
this.show = function () {
scene_index = scene_stack.length - 1;
html_scene.classList.remove("hidden");
close_btn.onclick = onclose;
};
@@ -216,7 +214,6 @@ export class UploadCollectionScene {
nodes = null;
};
this.release = function () {
scene_index = null;
if (upload_req !== null) {
upload_req.abort();
upload_req = null;

View File

@@ -42,44 +42,89 @@ export class Scene {
/**
* @type {Array<Scene>}
*/
export let scene_stack = [];
let scene_stack = [];
/**
* Push scene onto stack.
* @param {Scene} scene
* @param {boolean} replace Replace the scene on top of the stack.
*/
export function push_scene(scene, replace) {
export function push_scene(scene) {
if (scene_stack.length >= 1) {
scene_stack[scene_stack.length - 1].hide();
if (replace) {
scene_stack.pop().release();
}
}
scene_stack.push(scene);
scene.show();
}
/**
* Remove scenes from stack.
* @param {number} index New top of stack
* Replace the current scene with a new one.
* @param {Scene} scene
*/
export function pop_scene(index) {
if (scene_stack.length - 1 <= index) {
export function replace_scene(scene) {
if (scene_stack.length >= 1) {
scene_stack[scene_stack.length - 1].hide();
scene_stack.pop().release();
}
scene_stack.push(scene);
scene.show();
}
/**
* Remove the current scene from the stack.
*/
export function pop_scene() {
if (scene_stack.length === 0) {
return;
}
scene_stack[scene_stack.length - 1].hide();
while (scene_stack.length - 1 > index) {
let old_length = scene_stack.length;
scene_stack.pop().release();
if (scene_stack.length >= 1) {
scene_stack[scene_stack.length - 1].show();
}
}
/**
* Pop the current scene and the one below it.
* Useful for returning to the parent of the caller.
*/
export function pop_to_parent() {
if (scene_stack.length === 0) {
return;
}
scene_stack[scene_stack.length - 1].hide();
scene_stack.pop().release();
if (scene_stack.length >= 1) {
scene_stack.pop().release();
if (old_length - 1 === index + 1) {
break;
}
}
if (scene_stack.length >= 1) {
let scene = scene_stack[scene_stack.length - 1];
scene.show();
} else {
throw "Scene stack is empty";
scene_stack[scene_stack.length - 1].show();
}
}
/**
* Pop all scenes until only the root scene remains.
* If the stack is empty, nothing happens.
*/
export function pop_to_root() {
if (scene_stack.length === 0) {
return;
}
// Pop all scenes until only the first one remains
while (scene_stack.length > 1) {
scene_stack[scene_stack.length - 1].hide();
scene_stack.pop().release();
}
// The root scene is now at the top (index 0) and should be shown
if (scene_stack.length === 1) {
scene_stack[0].show(); // Ensure the root scene is visible
}
}
/**
* Check if the given scene is the current top scene.
* @param {Scene} scene
* @returns {boolean}
*/
export function is_current_scene(scene) {
return scene_stack.length > 0 && scene_stack[scene_stack.length - 1] === scene;
}

View File

@@ -0,0 +1,38 @@
/**
* This file is part of Radicale Server - Calendar Server
* Copyright © 2026-2026 Max Berger <max@berger.name>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @param {string} permissions
* @param {HTMLElement} node
*/
export function displayPermissions(permissions, node) {
permissions = (permissions || "").toLowerCase();
if (permissions === "rw") {
const roElement = node.querySelector("[data-name=ro]");
if (roElement) {
roElement.parentNode.removeChild(roElement);
}
} else if (permissions === "r") {
const rwElement = node.querySelector("[data-name=rw]");
if (rwElement) {
rwElement.parentNode.removeChild(rwElement);
}
} else {
console.warn("Unknown permissions", permissions);
}
}