diff --git a/bookmarks/frontend/components/bookmark-page.js b/bookmarks/frontend/components/bookmark-page.js index d1677eb..465e825 100644 --- a/bookmarks/frontend/components/bookmark-page.js +++ b/bookmarks/frontend/components/bookmark-page.js @@ -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); diff --git a/bookmarks/tests_e2e/e2e_test_bookmark_page_bulk_edit.py b/bookmarks/tests_e2e/e2e_test_bookmark_page_bulk_edit.py index fb5a8dd..0d0ca31 100644 --- a/bookmarks/tests_e2e/e2e_test_bookmark_page_bulk_edit.py +++ b/bookmarks/tests_e2e/e2e_test_bookmark_page_bulk_edit.py @@ -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()