Disable bulk execute button when no bookmarks selected (#1241)

* feat: disable execute button when no bookmarks selected in bulk edit

* format

---------

Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@gmail.com>
This commit is contained in:
Emanuele Beffa
2026-01-05 17:08:22 +01:00
committed by GitHub
parent cbc8618805
commit 1b90db70c0
2 changed files with 40 additions and 0 deletions

View File

@@ -82,6 +82,7 @@ class BookmarkPage extends HeadlessElement {
this.querySelectorAll(".bulk-edit-checkbox:not(.all) input"),
);
this.selectAcross = this.querySelector("label.select-across");
this.executeButton = this.querySelector("button[name='bulk_execute']");
// Add listeners
this.activeToggle.addEventListener("click", this.onToggleBulkEdit);
@@ -97,6 +98,7 @@ class BookmarkPage extends HeadlessElement {
checkbox.checked = false;
});
this.updateSelectAcross(false);
this.updateExecuteButton();
// Update total number of bookmarks
const totalHolder = this.querySelector("[data-bookmarks-total]");
@@ -119,6 +121,7 @@ class BookmarkPage extends HeadlessElement {
checkbox.checked = allChecked;
});
this.updateSelectAcross(allChecked);
this.updateExecuteButton();
}
onToggleBookmark() {
@@ -127,6 +130,7 @@ class BookmarkPage extends HeadlessElement {
});
this.allCheckbox.checked = allChecked;
this.updateSelectAcross(allChecked);
this.updateExecuteButton();
}
updateSelectAcross(allChecked) {
@@ -137,6 +141,13 @@ class BookmarkPage extends HeadlessElement {
this.selectAcross.querySelector("input").checked = false;
}
}
updateExecuteButton() {
const anyChecked = this.bookmarkCheckboxes.some((checkbox) => {
return checkbox.checked;
});
this.executeButton.disabled = !anyChecked;
}
}
customElements.define("ld-bookmark-page", BookmarkPage);

View File

@@ -319,3 +319,32 @@ class BookmarkPageBulkEditE2ETestCase(LinkdingE2ETestCase):
expect(
self.locate_bulk_edit_bar().get_by_text("All 70 bookmarks")
).to_be_visible()
def test_execute_button_is_disabled_when_no_bookmarks_selected(self):
self.setup_numbered_bookmarks(5)
url = reverse("linkding:bookmarks.index")
self.open(url)
self.locate_bulk_edit_toggle().click()
execute_button = self.locate_bulk_edit_bar().get_by_text("Execute")
# Execute button should be disabled by default
expect(execute_button).to_be_disabled()
# Check a single bookmark - execute button should be enabled
self.locate_bookmark("Bookmark 1").locator("label.bulk-edit-checkbox").click()
expect(execute_button).to_be_enabled()
# Uncheck the bookmark - execute button should be disabled again
self.locate_bookmark("Bookmark 1").locator("label.bulk-edit-checkbox").click()
expect(execute_button).to_be_disabled()
# Check all bookmarks - execute button should be enabled
self.locate_bulk_edit_select_all().click()
expect(execute_button).to_be_enabled()
# Uncheck all bookmarks - execute button should be disabled again
self.locate_bulk_edit_select_all().click()
expect(execute_button).to_be_disabled()