Skip to content

Commit bc3c2df

Browse files
authored
Merge pull request #2014 from maxberger/master
Misc improvements to UI
2 parents aba1417 + ad320a2 commit bc3c2df

File tree

5 files changed

+113
-90
lines changed

5 files changed

+113
-90
lines changed

.github/workflows/test.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,28 @@ jobs:
198198
run: pip install tox
199199
- name: Lint
200200
run: tox -c pyproject.toml -e flake8,mypy,isort
201+
202+
integ-test:
203+
timeout-minutes: 60
204+
runs-on: ubuntu-latest
205+
needs: test-ubuntu-python-newest
206+
steps:
207+
- uses: actions/checkout@v4
208+
- uses: actions/setup-python@v5
209+
with:
210+
python-version: '3.12'
211+
- name: Install uv
212+
run: pip install uv
213+
- name: Install Playwright Browsers
214+
run: uv run --extra integ_test playwright install --with-deps
215+
- name: Run Integration Tests
216+
run: uv run --extra integ_test pytest --junitxml=pytest-results.xml integ_tests
217+
- uses: mikepenz/action-junit-report@v6
218+
if: ${{ failure() && (github.event.pull_request.head.repo.full_name != github.repository) }}
219+
with:
220+
report_paths: 'pytest-results.xml'
221+
annotate_only: true # forked repo cannot write to checks so just do annotations
222+
- uses: mikepenz/action-junit-report@v6
223+
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
224+
with:
225+
report_paths: 'pytest-results.xml'

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ coverage.xml
2323
.vscode
2424
.sass-cache
2525
Gemfile.lock
26-
26+
pytest-results.xml
2727
pytestdebug.log
2828
uv.lock

integ_tests/test_sharing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def test_create_and_delete_share_by_key(page: Page, radicale_server: str) -> Non
2929
expect(
3030
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden) img[alt='RO']")
3131
).to_be_visible()
32+
page.once("dialog", lambda dialog: dialog.accept())
3233
page.click('tr:not(.hidden) button[data-name="delete"]', strict=True)
3334
expect(
3435
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden)")
@@ -40,6 +41,7 @@ def test_create_and_delete_share_by_key(page: Page, radicale_server: str) -> Non
4041
expect(
4142
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden) img[alt='RW']")
4243
).to_be_visible()
44+
page.once("dialog", lambda dialog: dialog.accept())
4345
page.click('tr:not(.hidden) button[data-name="delete"]', strict=True)
4446
expect(
4547
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden)")

radicale/web/internal_data/DeleteCollectionScene.js

Lines changed: 79 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -25,97 +25,98 @@ import { LoadingScene } from "./LoadingScene.js";
2525
import { delete_collection } from "./api.js";
2626

2727
/**
28-
* @constructor
2928
* @implements {Scene}
3029
* @param {string} user
3130
* @param {string} password
3231
* @param {Collection} collection
3332
*/
34-
export function DeleteCollectionScene(user, password, collection) {
35-
/** @type {HTMLElement} */ let html_scene = document.getElementById("deletecollectionscene");
36-
/** @type {HTMLElement} */ let title_form = html_scene.querySelector("[data-name=title]");
37-
/** @type {HTMLElement} */ let error_form = html_scene.querySelector("[data-name=error]");
38-
/** @type {HTMLInputElement} */ let confirmation_txt = html_scene.querySelector("[data-name=confirmationtxt]");
39-
/** @type {HTMLElement} */ let delete_confirmation_lbl = html_scene.querySelector("[data-name=deleteconfirmationtext]");
40-
/** @type {HTMLElement} */ let delete_btn = html_scene.querySelector("[data-name=delete]");
41-
/** @type {HTMLElement} */ let cancel_btn = html_scene.querySelector("[data-name=cancel]");
33+
export class DeleteCollectionScene {
34+
constructor(user, password, collection) {
35+
/** @type {HTMLElement} */ let html_scene = document.getElementById("deletecollectionscene");
36+
/** @type {HTMLElement} */ let title_form = html_scene.querySelector("[data-name=title]");
37+
/** @type {HTMLElement} */ let error_form = html_scene.querySelector("[data-name=error]");
38+
/** @type {HTMLInputElement} */ let confirmation_txt = html_scene.querySelector("[data-name=confirmationtxt]");
39+
/** @type {HTMLElement} */ let delete_confirmation_lbl = html_scene.querySelector("[data-name=deleteconfirmationtext]");
40+
/** @type {HTMLElement} */ let delete_btn = html_scene.querySelector("[data-name=delete]");
41+
/** @type {HTMLElement} */ let cancel_btn = html_scene.querySelector("[data-name=cancel]");
4242

43-
delete_confirmation_lbl.innerHTML = DELETE_CONFIRMATION_TEXT;
44-
confirmation_txt.value = "";
45-
confirmation_txt.addEventListener("keydown", onkeydown);
43+
delete_confirmation_lbl.innerHTML = DELETE_CONFIRMATION_TEXT;
44+
confirmation_txt.value = "";
45+
confirmation_txt.addEventListener("keydown", onkeydown);
4646

47-
/** @type {?number} */ let scene_index = null;
48-
/** @type {?XMLHttpRequest} */ let delete_req = null;
49-
let error = "";
47+
/** @type {?number} */ let scene_index = null;
48+
/** @type {?XMLHttpRequest} */ let delete_req = null;
49+
let error = "";
5050

51-
function ondelete() {
52-
let confirmation_text_value = confirmation_txt.value;
53-
if(confirmation_text_value != DELETE_CONFIRMATION_TEXT){
54-
alert("Please type the confirmation text to delete this collection.");
55-
return;
51+
function ondelete() {
52+
let confirmation_text_value = confirmation_txt.value;
53+
if (confirmation_text_value != DELETE_CONFIRMATION_TEXT) {
54+
alert("Please type the confirmation text to delete this collection.");
55+
return;
56+
}
57+
try {
58+
let loading_scene = new LoadingScene();
59+
push_scene(loading_scene, false);
60+
delete_req = delete_collection(user, password, collection, function (error1) {
61+
if (scene_index === null) {
62+
return;
63+
}
64+
delete_req = null;
65+
if (error1) {
66+
error = error1;
67+
pop_scene(scene_index);
68+
} else {
69+
pop_scene(scene_index - 1);
70+
}
71+
});
72+
} catch (err) {
73+
console.error(err);
74+
}
75+
return false;
5676
}
57-
try {
58-
let loading_scene = new LoadingScene();
59-
push_scene(loading_scene, false);
60-
delete_req = delete_collection(user, password, collection, function(error1) {
61-
if (scene_index === null) {
62-
return;
63-
}
64-
delete_req = null;
65-
if (error1) {
66-
error = error1;
67-
pop_scene(scene_index);
68-
} else {
69-
pop_scene(scene_index - 1);
70-
}
71-
});
72-
} catch(err) {
73-
console.error(err);
74-
}
75-
return false;
76-
}
7777

78-
function oncancel() {
79-
try {
80-
pop_scene(scene_index - 1);
81-
} catch(err) {
82-
console.error(err);
78+
function oncancel() {
79+
try {
80+
pop_scene(scene_index - 1);
81+
} catch (err) {
82+
console.error(err);
83+
}
84+
return false;
8385
}
84-
return false;
85-
}
8686

87-
function onkeydown(event){
88-
if (event.keyCode !== 13) {
89-
return;
87+
function onkeydown(event) {
88+
if (event.keyCode !== 13) {
89+
return;
90+
}
91+
ondelete();
9092
}
91-
ondelete();
92-
}
9393

94-
this.show = function() {
95-
this.release();
96-
scene_index = scene_stack.length - 1;
97-
html_scene.classList.remove("hidden");
98-
title_form.textContent = collection.displayname || collection.href;
99-
delete_btn.onclick = ondelete;
100-
cancel_btn.onclick = oncancel;
101-
if(error){
102-
error_form.textContent = "Error: " + error;
103-
error_form.classList.remove("hidden");
104-
}else{
105-
error_form.classList.add("hidden");
106-
}
94+
this.show = function () {
95+
this.release();
96+
scene_index = scene_stack.length - 1;
97+
html_scene.classList.remove("hidden");
98+
title_form.textContent = collection.displayname || collection.href;
99+
delete_btn.onclick = ondelete;
100+
cancel_btn.onclick = oncancel;
101+
if (error) {
102+
error_form.textContent = "Error: " + error;
103+
error_form.classList.remove("hidden");
104+
} else {
105+
error_form.classList.add("hidden");
106+
}
107107

108-
};
109-
this.hide = function() {
110-
html_scene.classList.add("hidden");
111-
cancel_btn.onclick = null;
112-
delete_btn.onclick = null;
113-
};
114-
this.release = function() {
115-
scene_index = null;
116-
if (delete_req !== null) {
117-
delete_req.abort();
118-
delete_req = null;
119-
}
120-
};
108+
};
109+
this.hide = function () {
110+
html_scene.classList.add("hidden");
111+
cancel_btn.onclick = null;
112+
delete_btn.onclick = null;
113+
};
114+
this.release = function () {
115+
scene_index = null;
116+
if (delete_req !== null) {
117+
delete_req.abort();
118+
delete_req = null;
119+
}
120+
};
121+
}
121122
}

radicale/web/internal_data/ShareCollectionScene.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,6 @@ import { Collection } from "./models.js";
2828
import { Scene, pop_scene, scene_stack } from "./scene_manager.js";
2929

3030
/**
31-
* @constructor
32-
* @implements {Scene}
33-
* @param {string} user
34-
* @param {string} password
35-
* @param {Collection} collection The collection on which to edit sharing setting. Must exist.
36-
*/
37-
/**
38-
* @constructor
3931
* @implements {Scene}
4032
* @param {string} user
4133
* @param {string} password
@@ -125,10 +117,10 @@ function add_share_rows(user, password, collection, shares) {
125117
shares.forEach(function (share) {
126118
let pathortoken = share["PathOrToken"] || "";
127119
let pathmapped = share["PathMapped"] || "";
128-
if (
120+
if ((
129121
collection.href.includes(pathmapped) ||
130122
collection.href.includes(pathortoken)
131-
) {
123+
) && (share["ShareType"] === "token")) {
132124
let node = /** @type {HTMLElement} */ (template.cloneNode(true));
133125
node.classList.remove("hidden");
134126
/** @type {HTMLInputElement} */ let pathortoken_form = node.querySelector("[data-name=pathortoken]");
@@ -147,10 +139,13 @@ function add_share_rows(user, password, collection, shares) {
147139
}
148140
/** @type {HTMLElement} */ let delete_btn = node.querySelector("[data-name=delete]");
149141
delete_btn.onclick = function () {
142+
if (!confirm("Are you sure you want to delete share " + pathortoken + "?")) {
143+
return;
144+
}
150145
delete_share_by_token(
151146
user,
152147
password,
153-
share["PathOrToken"],
148+
pathortoken,
154149
function () {
155150
update_share_list(user, password, collection);
156151
},

0 commit comments

Comments
 (0)