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,9 +1811,12 @@ table {
color: $delete;
}
.dropdown-pane a {
.dropdown-pane {
a,
button {
color: $text-medium;
}
}
// 17. Activity
// ------------

View File

@@ -8,7 +8,8 @@
<span class="icon-flag flag-disable"></span>
</button>
<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>
<% end %>
@@ -21,7 +22,8 @@
<span class="icon-flag flag-active"></span>
</button>
<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>
<% end %>
</span>

View File

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