mirror of
https://github.com/Kozea/Radicale.git
synced 2026-05-07 20:12:45 +00:00
UI: Show title and description in sharing dialogs
This commit is contained in:
+29
-27
@@ -54,7 +54,7 @@ def test_create_and_delete_share_by_key(
|
||||
).to_have_count(0)
|
||||
|
||||
page.click('button[data-name="sharebytoken"]')
|
||||
page.click('#newshare button[data-name="submit"]')
|
||||
page.click('#createeditsharescene button[data-name="submit"]')
|
||||
expect(
|
||||
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden)")
|
||||
).to_have_count(1)
|
||||
@@ -80,7 +80,7 @@ def test_create_and_delete_share_by_key(
|
||||
).to_have_count(0)
|
||||
page.click('button[data-name="sharebytoken"]')
|
||||
page.click('label[for="newshare_attr_permissions_rw"]')
|
||||
page.click('#newshare button[data-name="submit"]')
|
||||
page.click('#createeditsharescene button[data-name="submit"]')
|
||||
expect(
|
||||
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden)")
|
||||
).to_have_count(1)
|
||||
@@ -121,7 +121,7 @@ def test_create_and_delete_share_by_map(
|
||||
page.click('button[data-name="sharebymap"]')
|
||||
page.locator('input[data-name="shareuser"]').fill("max")
|
||||
page.locator('input[data-name="sharehref"]').fill("1234")
|
||||
page.click('#newshare button[data-name="submit"]')
|
||||
page.click('#createeditsharescene button[data-name="submit"]')
|
||||
expect(
|
||||
page.locator("tr[data-name='sharemaprowtemplate']:not(.hidden)")
|
||||
).to_have_count(1)
|
||||
@@ -139,7 +139,7 @@ def test_create_and_delete_share_by_map(
|
||||
page.click('label[for="newshare_attr_permissions_rw"]')
|
||||
page.locator('input[data-name="shareuser"]').fill("max")
|
||||
page.locator('input[data-name="sharehref"]').fill("1234")
|
||||
page.click('#newshare button[data-name="submit"]')
|
||||
page.click('#createeditsharescene button[data-name="submit"]')
|
||||
expect(
|
||||
page.locator("tr[data-name='sharemaprowtemplate']:not(.hidden)")
|
||||
).to_have_count(1)
|
||||
@@ -204,7 +204,7 @@ def test_share_with_property_overrides(
|
||||
page.click('label[for="newshare_attr_color_enabled"]')
|
||||
page.locator('input[data-name="color_override"]').fill("#00ff00")
|
||||
|
||||
page.click('#newshare button[data-name="submit"]')
|
||||
page.click('#createeditsharescene button[data-name="submit"]')
|
||||
|
||||
# Verify the share was created
|
||||
expect(
|
||||
@@ -249,7 +249,7 @@ def test_share_journal_no_overrides(
|
||||
expect(page.locator('input[data-name="color_override_enabled"]')).to_be_hidden()
|
||||
|
||||
# Create the share
|
||||
page.click('#newshare button[data-name="submit"]')
|
||||
page.click('#createeditsharescene button[data-name="submit"]')
|
||||
|
||||
# Verify the share was created
|
||||
expect(
|
||||
@@ -267,7 +267,7 @@ def test_edit_share_by_token(
|
||||
|
||||
# Create RO share
|
||||
page.click('button[data-name="sharebytoken"]')
|
||||
page.click('#newshare button[data-name="submit"]')
|
||||
page.click('#createeditsharescene button[data-name="submit"]')
|
||||
expect(
|
||||
page.locator(
|
||||
"tr[data-name='sharetokenrowtemplate']:not(.hidden) span[data-name='ro']"
|
||||
@@ -276,9 +276,9 @@ def test_edit_share_by_token(
|
||||
|
||||
# Edit to RW
|
||||
page.click('tr:not(.hidden) button[data-name="edit"]')
|
||||
expect(page.locator("#newshare h1")).to_have_text("Edit Share")
|
||||
expect(page.locator("#createeditsharescene h1")).to_have_text("Edit Share")
|
||||
page.click('label[for="newshare_attr_permissions_rw"]')
|
||||
page.click('#newshare button[data-name="submit"]')
|
||||
page.click('#createeditsharescene button[data-name="submit"]')
|
||||
|
||||
# Verify RW
|
||||
expect(
|
||||
@@ -300,7 +300,7 @@ def test_edit_share_by_map(
|
||||
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"]')
|
||||
page.click('#createeditsharescene button[data-name="submit"]')
|
||||
expect(
|
||||
page.locator(
|
||||
"tr[data-name='sharemaprowtemplate']:not(.hidden) span[data-name='ro']"
|
||||
@@ -309,14 +309,14 @@ def test_edit_share_by_map(
|
||||
|
||||
# Edit map share
|
||||
page.click('tr:not(.hidden) button[data-name="edit"]')
|
||||
expect(page.locator("#newshare h1")).to_have_text("Edit Share")
|
||||
expect(page.locator("#createeditsharescene h1")).to_have_text("Edit Share")
|
||||
expect(page.locator('input[data-name="shareuser"]')).to_be_disabled()
|
||||
expect(page.locator('input[data-name="sharehref"]')).to_be_disabled()
|
||||
|
||||
# Change permissions and enabled status
|
||||
page.click('label[for="newshare_attr_permissions_rw"]')
|
||||
page.uncheck('#newshare input[data-name="enabled"]')
|
||||
page.click('#newshare button[data-name="submit"]')
|
||||
page.uncheck('#createeditsharescene input[data-name="enabled"]')
|
||||
page.click('#createeditsharescene button[data-name="submit"]')
|
||||
|
||||
# Verify changes
|
||||
expect(
|
||||
@@ -327,8 +327,10 @@ def test_edit_share_by_map(
|
||||
# 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('#newshare input[data-name="enabled"]')).not_to_be_checked()
|
||||
page.click('#newshare button[data-name="cancel"]')
|
||||
expect(
|
||||
page.locator('#createeditsharescene input[data-name="enabled"]')
|
||||
).not_to_be_checked()
|
||||
page.click('#createeditsharescene button[data-name="cancel"]')
|
||||
|
||||
|
||||
def test_share_by_map_validation(
|
||||
@@ -344,21 +346,21 @@ def test_share_by_map_validation(
|
||||
# Try empty user
|
||||
page.locator('input[data-name="shareuser"]').fill("")
|
||||
page.locator('input[data-name="sharehref"]').fill("1234")
|
||||
page.click('#newshare button[data-name="submit"]')
|
||||
expect(page.locator('#newshare [data-name="error"]:not(.hidden)')).to_contain_text(
|
||||
"Share User is empty"
|
||||
)
|
||||
page.click('#createeditsharescene button[data-name="submit"]')
|
||||
expect(
|
||||
page.locator('#createeditsharescene [data-name="error"]:not(.hidden)')
|
||||
).to_contain_text("Share User is empty")
|
||||
|
||||
# Try logged in user
|
||||
page.locator('input[data-name="shareuser"]').fill("admin")
|
||||
page.click('#newshare button[data-name="submit"]')
|
||||
expect(page.locator('#newshare [data-name="error"]:not(.hidden)')).to_contain_text(
|
||||
"Share User cannot be admin"
|
||||
)
|
||||
page.click('#createeditsharescene button[data-name="submit"]')
|
||||
expect(
|
||||
page.locator('#createeditsharescene [data-name="error"]:not(.hidden)')
|
||||
).to_contain_text("Share User cannot be admin")
|
||||
|
||||
# Valid user
|
||||
page.locator('input[data-name="shareuser"]').fill("max")
|
||||
page.click('#newshare button[data-name="submit"]')
|
||||
page.click('#createeditsharescene button[data-name="submit"]')
|
||||
|
||||
# Verify success
|
||||
expect(
|
||||
@@ -397,7 +399,7 @@ def test_create_and_delete_share_by_bday(
|
||||
expect(page.locator("input#newshare_attr_permissions_ro")).to_be_disabled()
|
||||
expect(page.locator("input#newshare_attr_permissions_rw")).to_be_disabled()
|
||||
|
||||
page.click('#newshare button[data-name="submit"]')
|
||||
page.click('#createeditsharescene button[data-name="submit"]')
|
||||
expect(
|
||||
page.locator("tr[data-name='sharemaprowtemplate']:not(.hidden)")
|
||||
).to_have_count(1)
|
||||
@@ -463,7 +465,7 @@ def test_bday_section_hidden_for_calendar(
|
||||
expect(page.locator("#sharecollectionscene")).to_be_visible()
|
||||
page.click('button[data-name="sharebymap"]')
|
||||
expect(page.locator("details[data-name='conversions']")).to_be_hidden()
|
||||
page.click('#newshare button[data-name="cancel"]')
|
||||
page.click('#createeditsharescene button[data-name="cancel"]')
|
||||
|
||||
|
||||
def test_bday_section_visible_for_addressbook(
|
||||
@@ -487,7 +489,7 @@ def test_bday_section_visible_for_addressbook(
|
||||
expect(page.locator("#sharecollectionscene")).to_be_visible()
|
||||
page.click('button[data-name="sharebymap"]')
|
||||
expect(page.locator("details[data-name='conversions']")).to_be_visible()
|
||||
page.click('#newshare button[data-name="cancel"]')
|
||||
page.click('#createeditsharescene button[data-name="cancel"]')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -47,7 +47,7 @@ def test_incoming_shares(page: Page, radicale_server: str, permissions: str) ->
|
||||
page.locator('input[data-name="sharehref"]').fill("mapped")
|
||||
if permissions == "rw":
|
||||
page.check("#newshare_attr_permissions_rw")
|
||||
page.click('#newshare button[data-name="submit"]')
|
||||
page.click('#createeditsharescene button[data-name="submit"]')
|
||||
expect(
|
||||
page.locator("tr[data-name='sharemaprowtemplate']:not(.hidden)")
|
||||
).to_have_count(1)
|
||||
|
||||
@@ -149,8 +149,8 @@
|
||||
|
||||
<section id="sharecollectionscene" class="container hidden">
|
||||
<h1>Sharing</h1>
|
||||
<p>Manage sharing for collection <span class="title" data-name="title">title</span>
|
||||
</p>
|
||||
<p>Manage sharing for collection <span class="title" data-name="title">title</span></p>
|
||||
<p data-name="description"></p>
|
||||
<div data-name="sharebytoken">
|
||||
<details open>
|
||||
<summary>By Token</summary>
|
||||
@@ -257,8 +257,10 @@
|
||||
<span class="error hidden" data-name="error"></span>
|
||||
</section>
|
||||
|
||||
<section id="newshare" class="container hidden">
|
||||
<section id="createeditsharescene" class="container hidden">
|
||||
<h1>New Share</h1>
|
||||
<p class="title" data-name="title"></p>
|
||||
<p data-name="description"></p>
|
||||
<form>
|
||||
<details open data-name="sharemapfields" class="hidden">
|
||||
<summary>Map Target</summary>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
import { Share, add_share_by_map, add_share_by_token, get_property_key, update_share_by_map, update_share_by_token } from "../api/sharing.js";
|
||||
import { CollectionType, Permission } from "../models/collection.js";
|
||||
import { extract_title } from "../utils/collection_utils.js";
|
||||
import { extract_title, update_title_and_description } from "../utils/collection_utils.js";
|
||||
import { collectionsCache } from "../utils/collections_cache.js";
|
||||
import { ErrorHandler } from "../utils/error.js";
|
||||
import { FormValidator, validate_href, validate_non_empty, validate_not_empty_or_equals } from "../utils/form_validator.js";
|
||||
@@ -48,7 +48,9 @@ export class CreateEditShareScene {
|
||||
this._edit = !!share;
|
||||
this._pathMapped = collection.href;
|
||||
|
||||
this._html_scene = get_element_by_id("newshare");
|
||||
this._html_scene = get_element_by_id("createeditsharescene");
|
||||
this._title = get_element(this._html_scene, "[data-name=title]");
|
||||
this._description = get_element(this._html_scene, "[data-name=description]");
|
||||
this._form = /** @type {HTMLFormElement} */ (get_element(this._html_scene, "form"));
|
||||
this._sharemapfields = get_element(this._html_scene, "[data-name=sharemapfields]");
|
||||
this._shareuser_input = /** @type {HTMLInputElement} */ (get_element(this._html_scene, "[data-name=shareuser]"));
|
||||
@@ -405,6 +407,8 @@ export class CreateEditShareScene {
|
||||
this._errorHandler.clearError();
|
||||
}
|
||||
this._on_permissions_change();
|
||||
|
||||
update_title_and_description(this._collection, this._title, this._description);
|
||||
}
|
||||
|
||||
hide() {
|
||||
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
import { Collection, Permission } from "../models/collection.js";
|
||||
import { extract_title } from "../utils/collection_utils.js";
|
||||
|
||||
import { update_title_and_description } from "../utils/collection_utils.js";
|
||||
import { ErrorHandler } from "../utils/error.js";
|
||||
import { get_element, get_element_by_id } from "../utils/misc.js";
|
||||
import { displayPermissionsOrConversion } from "../utils/permissions.js";
|
||||
@@ -60,6 +61,7 @@ export class ShareCollectionScene {
|
||||
this._errorHandler = new ErrorHandler(this._error_form);
|
||||
|
||||
this._title = get_element(this._html_scene, "[data-name=title]");
|
||||
this._description = get_element(this._html_scene, "[data-name=description]");
|
||||
}
|
||||
|
||||
_oncancel() {
|
||||
@@ -114,7 +116,7 @@ export class ShareCollectionScene {
|
||||
if (this._share_by_map_div) this._share_by_map_div.classList.add("hidden");
|
||||
}
|
||||
|
||||
this._title.textContent = this._collection.displayname || this._collection.href;
|
||||
update_title_and_description(this._collection, this._title, this._description);
|
||||
update_share_list(this._user, this._password, this._collection, this._errorHandler);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,3 +29,21 @@ export function extract_title(collection) {
|
||||
} else
|
||||
return collection.href;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../models/collection.js").Collection} collection
|
||||
* @param {HTMLElement} title_element
|
||||
* @param {HTMLElement} description_element
|
||||
*/
|
||||
export function update_title_and_description(
|
||||
collection,
|
||||
title_element,
|
||||
description_element) {
|
||||
title_element.textContent = collection.displayname || collection.href;
|
||||
if (collection.description && collection.description.length > 0) {
|
||||
description_element.classList.remove("hidden");
|
||||
description_element.textContent = collection.description;
|
||||
} else {
|
||||
description_element.classList.add("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user