diff --git a/cypress/integration/sidebar.js b/cypress/integration/sidebar.js index 7510425db3..b1a487bc8d 100644 --- a/cypress/integration/sidebar.js +++ b/cypress/integration/sidebar.js @@ -2,7 +2,7 @@ const verify_attachment_visibility = (document, is_private) => { cy.visit(`/app/${document}`); const assertion = is_private ? "be.checked" : "not.be.checked"; - cy.findByRole("button", { name: "Add File" }).click(); + cy.get(".add-attachment-btn").click(); cy.get_open_dialog() .find(".file-upload-area") @@ -27,7 +27,7 @@ const attach_file = (file, no_of_files = 1) => { ); } - cy.findByRole("button", { name: "Add File" }).click(); + cy.get(".add-attachment-btn").click(); cy.get_open_dialog().find(".file-upload-area").selectFile(files, { action: "drag-drop", }); @@ -62,11 +62,8 @@ context("Sidebar", () => { }).then((todo) => { cy.visit(`/app/todo/${todo.message.name}`); - // explore icon btn should be hidden as there are no attachments - cy.get(".explore-btn").should("be.hidden"); - attach_file("cypress/fixtures/sample_image.jpg"); - cy.get(".explore-btn").should("be.visible"); + cy.get(".explore-link").should("be.visible"); cy.get(".show-all-btn").should("be.hidden"); // attach 10 images @@ -75,9 +72,8 @@ context("Sidebar", () => { // attach 1 more image to reach attachment limit attach_file("cypress/fixtures/sample_attachments/attachment-11.txt"); - cy.get(".explore-full-btn").should("be.visible"); - cy.get(".attachments-actions").should("be.hidden"); - cy.get(".explore-btn").should("be.hidden"); + cy.get(".add-attachment-btn").should("be.hidden"); + cy.get(".explore-link").should("be.visible"); // test "Show All" button cy.get(".attachment-row").should("have.length", 10); diff --git a/frappe/public/js/frappe/form/sidebar/attachments.js b/frappe/public/js/frappe/form/sidebar/attachments.js index db50b4f202..4c8f37186e 100644 --- a/frappe/public/js/frappe/form/sidebar/attachments.js +++ b/frappe/public/js/frappe/form/sidebar/attachments.js @@ -15,7 +15,8 @@ frappe.ui.form.Attachments = class Attachments { me.new_attachment(); }); - this.parent.find(".explore-btn").click(() => { + this.parent.find(".explore-link").click(() => { + if (!this.frm.attachments.get_attachments()?.length) return; frappe.open_in_new_tab = true; frappe.set_route("List", "File", { attached_to_doctype: this.frm.doctype, @@ -51,8 +52,7 @@ frappe.ui.form.Attachments = class Attachments { this.parent.find(".attachment-row").remove(); var max_reached = this.max_reached(); - this.add_attachment_wrapper.toggle(!max_reached); - this.setup_expanded_explore_button(max_reached); + this.add_attachment_wrapper.find(".add-attachment-btn").toggle(!max_reached); // add attachment objects var attachments = this.get_attachments(); @@ -60,21 +60,6 @@ frappe.ui.form.Attachments = class Attachments { this.setup_show_all_button(attachments); } - setup_expanded_explore_button(max_reached) { - if (!max_reached) { - this.parent.find(".explore-full-btn").addClass("hidden"); - return; - } - - this.parent.find(".explore-full-btn").removeClass("hidden"); - this.parent.find(".explore-full-btn").click(() => { - frappe.set_route("List", "File", { - attached_to_doctype: this.frm.doctype, - attached_to_name: this.frm.docname, - }); - }); - } - setup_show_all_button(attachments) { // show button if there is more to show and user has not clicked on "Show All" let is_slicable = attachments.length > this.attachments_page_length; @@ -124,7 +109,6 @@ frappe.ui.form.Attachments = class Attachments { if (!attachments.length) { // If no attachments in totality this.attachments_label.removeClass("has-attachments"); - this.parent.find(".explore-btn").toggle(false); // hide explore icon button } } @@ -170,8 +154,6 @@ frappe.ui.form.Attachments = class Attachments { $(`
  • `) .append(frappe.get_data_pill(file_label, fileid, remove_action, icon)) .insertAfter(this.add_attachment_wrapper); - - this.parent.find(".explore-btn").toggle(true); // show explore icon button if hidden } get_file_url(attachment) { diff --git a/frappe/public/js/frappe/form/sidebar/review.js b/frappe/public/js/frappe/form/sidebar/review.js index c7a67812c5..10b11bf4d3 100644 --- a/frappe/public/js/frappe/form/sidebar/review.js +++ b/frappe/public/js/frappe/form/sidebar/review.js @@ -132,7 +132,7 @@ frappe.ui.form.Review = class Review { `); - this.reviews.prepend(review_pill); + this.reviews.append(review_pill); this.setup_detail_popover(review_pill, log); }); } diff --git a/frappe/public/js/frappe/form/sidebar/share.js b/frappe/public/js/frappe/form/sidebar/share.js index b7cb1ee81c..ed91b49c26 100644 --- a/frappe/public/js/frappe/form/sidebar/share.js +++ b/frappe/public/js/frappe/form/sidebar/share.js @@ -32,8 +32,12 @@ frappe.ui.form.Share = class Share { } this.shares.show(); + let avatar_group = frappe.avatar_group(shared_users, 5, { align: "left", overlap: true }); + avatar_group.on("click", () => { + this.frm.share_doc(); + }); // REDESIGN-TODO: handle "shared with everyone" - this.shares.append(frappe.avatar_group(shared_users, 5, { align: "left", overlap: true })); + this.shares.append(avatar_group); } show() { var me = this; diff --git a/frappe/public/js/frappe/form/templates/form_sidebar.html b/frappe/public/js/frappe/form/templates/form_sidebar.html index 4fb76ba669..7a8416204a 100644 --- a/frappe/public/js/frappe/form/templates/form_sidebar.html +++ b/frappe/public/js/frappe/form/templates/form_sidebar.html @@ -39,82 +39,79 @@ {% } %}