Replace link with button in flag unflag actions

This commit is contained in:
cyrillefr
2025-04-18 14:18:01 +02:00
parent a6046155a2
commit 50076504b5
3 changed files with 24 additions and 19 deletions

View File

@@ -1811,8 +1811,11 @@ table {
color: $delete; color: $delete;
} }
.dropdown-pane a { .dropdown-pane {
a,
button {
color: $text-medium; color: $text-medium;
}
} }
// 17. Activity // 17. Activity

View File

@@ -8,7 +8,8 @@
<span class="icon-flag flag-disable"></span> <span class="icon-flag flag-disable"></span>
</button> </button>
<span class="dropdown-pane" id="flag-drop-<%= dom_id(flaggable) %>" data-dropdown data-auto-focus="true"> <span class="dropdown-pane" id="flag-drop-<%= dom_id(flaggable) %>" data-dropdown data-auto-focus="true">
<%= link_to t("shared.flag"), polymorphic_path(flaggable, action: :flag), method: :put, remote: true %> <%= button_to t("shared.flag"), polymorphic_path(flaggable, action: :flag),
method: :put, remote: true %>
</span> </span>
<% end %> <% end %>
@@ -21,7 +22,8 @@
<span class="icon-flag flag-active"></span> <span class="icon-flag flag-active"></span>
</button> </button>
<span class="dropdown-pane" id="unflag-drop-<%= dom_id(flaggable) %>" data-dropdown data-auto-focus="true"> <span class="dropdown-pane" id="unflag-drop-<%= dom_id(flaggable) %>" data-dropdown data-auto-focus="true">
<%= link_to t("shared.unflag"), polymorphic_path(flaggable, action: :unflag), method: :put, remote: true %> <%= button_to t("shared.unflag"), polymorphic_path(flaggable, action: :unflag),
method: :put, remote: true %>
</span> </span>
<% end %> <% end %>
</span> </span>

View File

@@ -27,18 +27,18 @@ shared_examples "flaggable" do |factory_name, admin: false|
within "##{dom_id(flaggable)} .flag-content" do within "##{dom_id(flaggable)} .flag-content" do
click_button "Flag as inappropriate" click_button "Flag as inappropriate"
click_link "Flag as inappropriate" within("form") { click_button "Flag as inappropriate" }
expect(page).to have_button "Unflag" expect(page).to have_button "Unflag"
expect(page).to have_link "Unflag", visible: :hidden expect(page).to have_button "Unflag", visible: :hidden
expect(page).not_to have_link "Flag as inappropriate", visible: :all expect(page).not_to have_button "Flag as inappropriate", visible: :all
end end
refresh refresh
within "##{dom_id(flaggable)} .flag-content" do within "##{dom_id(flaggable)} .flag-content" do
expect(page).to have_link "Unflag", visible: :hidden expect(page).to have_button "Unflag", visible: :hidden
expect(page).not_to have_link "Flag as inappropriate", visible: :all expect(page).not_to have_button "Flag as inappropriate", visible: :all
end end
end end
@@ -52,18 +52,18 @@ shared_examples "flaggable" do |factory_name, admin: false|
expect(page).to have_button "Unflag" expect(page).to have_button "Unflag"
click_button "Unflag" click_button "Unflag"
click_link "Unflag" within("form") { click_button "Unflag" }
expect(page).not_to have_button "Unflag" expect(page).not_to have_button "Unflag"
expect(page).to have_link "Flag as inappropriate", visible: :hidden expect(page).to have_button "Flag as inappropriate", visible: :hidden
expect(page).not_to have_link "Unflag", visible: :all expect(page).not_to have_button "Unflag", visible: :all
end end
visit path visit path
within "##{dom_id(flaggable)} .flag-content" do within "##{dom_id(flaggable)} .flag-content" do
expect(page).to have_link "Flag as inappropriate", visible: :hidden expect(page).to have_button "Flag as inappropriate", visible: :hidden
expect(page).not_to have_link "Unflag", visible: :all expect(page).not_to have_button "Unflag", visible: :all
end end
end end
@@ -73,12 +73,12 @@ shared_examples "flaggable" do |factory_name, admin: false|
within "##{dom_id(flaggable)} .flag-content" do within "##{dom_id(flaggable)} .flag-content" do
click_button "Flag as inappropriate" click_button "Flag as inappropriate"
click_link "Flag as inappropriate" within("form") { click_button "Flag as inappropriate" }
expect(page).to have_button "Unflag" expect(page).to have_button "Unflag"
click_button "Unflag" click_button "Unflag"
click_link "Unflag" within("form") { click_button "Unflag" }
expect(page).not_to have_button "Unflag" expect(page).not_to have_button "Unflag"
end end
@@ -86,8 +86,8 @@ shared_examples "flaggable" do |factory_name, admin: false|
visit path visit path
within "##{dom_id(flaggable)} .flag-content" do within "##{dom_id(flaggable)} .flag-content" do
expect(page).to have_link "Flag as inappropriate", visible: :hidden expect(page).to have_button "Flag as inappropriate", visible: :hidden
expect(page).not_to have_link "Unflag", visible: :all expect(page).not_to have_button "Unflag", visible: :all
end end
end end
@@ -99,7 +99,7 @@ shared_examples "flaggable" do |factory_name, admin: false|
within "##{dom_id(flaggable)} > .comment-body .flag-content" do within "##{dom_id(flaggable)} > .comment-body .flag-content" do
click_button "Flag as inappropriate" click_button "Flag as inappropriate"
click_link "Flag as inappropriate" within("form") { click_button "Flag as inappropriate" }
expect(page).to have_button "Unflag" expect(page).to have_button "Unflag"
end end