Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

reduce nesting in dialog htmls

Ivan Kuchin68bb12ebea03
diff --git a/app/components/members/delete_member_dialog_component.html.erb b/app/components/members/delete_member_dialog_component.html.erb
index 3bee52ed2d1..7fd28bc2df7 100644
--- a/app/components/members/delete_member_dialog_component.html.erb
+++ b/app/components/members/delete_member_dialog_component.html.erb
@@ -30,17 +30,16 @@ See COPYRIGHT and LICENSE files for more details.
<%= render(Primer::Alpha::Dialog.new(id:, title: scoped_t(:title), size: :large)) do |dialog| %>
<% dialog.with_header(variant: :large) %>
- <% if can_delete_roles? && can_delete_shares? %>
- <% if can_delete? %>
- <% dialog.with_body do %>
+ <% case %>
+ <% when can_delete_roles? && can_delete_shares? %>
+ <% dialog.with_body do %>
+ <% if can_delete? %>
<%= paragraph { scoped_t(:will_remove_the_users_role_html, shared_work_packages_link:) } %>
<%= paragraph do %>
<%= scoped_t(:would_you_like_to_remove_the_shares_too) %>
<%= scoped_t(:will_not_affect_inherited_shares) if inherited_shared_work_packages_count? %>
<% end %>
- <% end %>
- <% else %>
- <% dialog.with_body do %>
+ <% else %>
<%= paragraph { scoped_t(:can_remove_direct_but_not_shared_role) } %>
<%= paragraph { scoped_t(:also_user_has_shares_html, shared_work_packages_link:) } %>
<%= paragraph do %>
@@ -55,31 +54,27 @@ See COPYRIGHT and LICENSE files for more details.
<%= button(scheme: :danger, tag: :a, href: delete_url(project: true), data: { method: :delete }) { t(:button_remove_member) } %>
<%= button(scheme: :danger, tag: :a, href: delete_url(project: true, work_package_shares_role_id: "all"), data: { method: :delete }) { t(:button_remove_member_and_shares) } %>
<% end %>
- <% else %>
- <% if can_delete_roles? %>
+ <% when can_delete_roles? %>
+ <% dialog.with_body do %>
<% if can_delete? %>
- <% dialog.with_body do %>
- <%= paragraph { scoped_t(:will_remove_all_access_priveleges) } %>
- <% end %>
+ <%= paragraph { scoped_t(:will_remove_all_access_priveleges) } %>
<% else %>
- <% dialog.with_body do %>
- <%= paragraph { scoped_t(:can_remove_direct_but_not_shared_role) } %>
- <% end %>
+ <%= paragraph { scoped_t(:can_remove_direct_but_not_shared_role) } %>
<% end %>
+ <% end %>
- <% dialog.with_footer do %>
- <%= button(data: { close_dialog_id: id }) { t(:button_cancel) } %>
- <%= button(scheme: :danger, tag: :a, href: delete_url(project: true), data: { method: :delete }) { t(:button_remove) } %>
- <% end %>
- <% else %>
- <% dialog.with_body do %>
- <%= paragraph { scoped_t(:cannot_delete_group_member) } %>
- <%= paragraph { scoped_t(:cannot_delete_group_member_note_html, administration_settings_link:) } %>
- <% end %>
+ <% dialog.with_footer do %>
+ <%= button(data: { close_dialog_id: id }) { t(:button_cancel) } %>
+ <%= button(scheme: :danger, tag: :a, href: delete_url(project: true), data: { method: :delete }) { t(:button_remove) } %>
+ <% end %>
+ <% else %>
+ <% dialog.with_body do %>
+ <%= paragraph { scoped_t(:cannot_delete_group_member) } %>
+ <%= paragraph { scoped_t(:cannot_delete_group_member_note_html, administration_settings_link:) } %>
+ <% end %>
- <% dialog.with_footer do %>
- <%= button(data: { close_dialog_id: id }) { t(:button_cancel) } %>
- <% end %>
+ <% dialog.with_footer do %>
+ <%= button(data: { close_dialog_id: id }) { t(:button_cancel) } %>
<% end %>
<% end %>
<% end %>
diff --git a/app/components/members/delete_work_package_shares_dialog_component.html.erb b/app/components/members/delete_work_package_shares_dialog_component.html.erb
index 6b21644d98b..9e6e445ce23 100644
--- a/app/components/members/delete_work_package_shares_dialog_component.html.erb
+++ b/app/components/members/delete_work_package_shares_dialog_component.html.erb
@@ -30,83 +30,79 @@ See COPYRIGHT and LICENSE files for more details.
<%= render(Primer::Alpha::Dialog.new(id:, title: scoped_t(:title), size: :large)) do |dialog| %>
<% dialog.with_header(variant: :large) %>
- <% if other_shared_work_packages_count? %>
- <% if direct_shared_work_packages_count? %>
+ <% case %>
+ <% when direct_shared_work_packages_count? && other_shared_work_packages_count? %>
+ <% dialog.with_body do %>
<% if inherited_shared_work_packages_count? %>
- <% dialog.with_body do %>
- <%= paragraph do %>
- <%= scoped_t(:shared_with_this_user_html, all_shared_work_packages_link:) %>
- <%= scoped_t(:shared_with_permission_html, shared_work_packages_link:, shared_role_name:) %>
- <% end %>
- <%= paragraph do %>
- <%= scoped_t(:revoke_all_or_with_role, shared_role_name:) %>
- <%= scoped_t(:will_not_affect_inherited_shares) %>
- <% end %>
+ <%= paragraph do %>
+ <%= scoped_t(:shared_with_this_user_html, all_shared_work_packages_link:) %>
+ <%= scoped_t(:shared_with_permission_html, shared_work_packages_link:, shared_role_name:) %>
<% end %>
+ <%= paragraph do %>
+ <%= scoped_t(:revoke_all_or_with_role, shared_role_name:) %>
+ <%= scoped_t(:will_not_affect_inherited_shares) %>
+ <% end %>
+ <% elsif principal.is_a?(Group) %>
+ <%= paragraph do %>
+ <%= scoped_t(:shared_with_this_group_html, all_shared_work_packages_link:) %>
+ <%= scoped_t(:shared_with_permission_html, shared_work_packages_link:, shared_role_name:) %>
+ <% end %>
+ <%= paragraph { scoped_t(:revoke_all_or_with_role, shared_role_name:) } %>
<% else %>
- <% dialog.with_body do %>
- <%= paragraph do %>
- <% if principal.is_a?(Group) %>
- <%= scoped_t(:shared_with_this_group_html, all_shared_work_packages_link:) %>
- <% else %>
- <%= scoped_t(:shared_with_this_user_html, all_shared_work_packages_link:) %>
- <% end %>
- <%= scoped_t(:shared_with_permission_html, shared_work_packages_link:, shared_role_name:) %>
- <% end %>
- <%= paragraph { scoped_t(:revoke_all_or_with_role, shared_role_name:) } %>
+ <%= paragraph do %>
+ <%= scoped_t(:shared_with_this_user_html, all_shared_work_packages_link:) %>
+ <%= scoped_t(:shared_with_permission_html, shared_work_packages_link:, shared_role_name:) %>
<% end %>
+ <%= paragraph { scoped_t(:revoke_all_or_with_role, shared_role_name:) } %>
<% end %>
+ <% end %>
- <% dialog.with_footer do %>
- <%= button(data: { close_dialog_id: id }) { t(:button_cancel) } %>
- <%= button(scheme: :danger, tag: :a, href: delete_url(work_package_shares_role_id: "all"), data: { method: :delete }) { t(:button_revoke_all) } %>
- <%= button(scheme: :danger, tag: :a, href: delete_url(work_package_shares_role_id: shared_role_id), data: { method: :delete }) { t(:button_revoke_only, shared_role_name:) } %>
- <% end %>
- <% else %>
- <% dialog.with_body do %>
- <%= paragraph { scoped_t(:cannot_remove_inherited_with_role, shared_role_name:) } %>
- <%= paragraph { scoped_t(:cannot_remove_inherited_note_html, administration_settings_link:) } %>
- <% end %>
-
- <% dialog.with_footer do %>
- <%= button(data: { close_dialog_id: id }) { t(:button_cancel) } %>
- <% end %>
+ <% dialog.with_footer do %>
+ <%= button(data: { close_dialog_id: id }) { t(:button_cancel) } %>
+ <%= button(scheme: :danger, tag: :a, href: delete_url(work_package_shares_role_id: "all"), data: { method: :delete }) { t(:button_revoke_all) } %>
+ <%= button(scheme: :danger, tag: :a, href: delete_url(work_package_shares_role_id: shared_role_id), data: { method: :delete }) { t(:button_revoke_only, shared_role_name:) } %>
<% end %>
- <% else %>
- <% if direct_shared_work_packages_count? %>
+ <% when direct_shared_work_packages_count? %>
+ <% dialog.with_body do %>
<% if inherited_shared_work_packages_count? %>
- <% dialog.with_body do %>
- <%= paragraph do %>
- <%= scoped_t(:shared_with_this_user_html, all_shared_work_packages_link:) %>
- <%= scoped_t(:will_revoke_access_but_for_inherited) %>
- <% end %>
+ <%= paragraph do %>
+ <%= scoped_t(:shared_with_this_user_html, all_shared_work_packages_link:) %>
+ <%= scoped_t(:will_revoke_access_but_for_inherited) %>
+ <% end %>
+ <% elsif principal.is_a?(Group) %>
+ <%= paragraph do %>
+ <%= scoped_t(:shared_with_this_group_html, all_shared_work_packages_link:) %>
+ <%= scoped_t(:will_revoke_access_to_all) %>
<% end %>
<% else %>
- <% dialog.with_body do %>
- <%= paragraph do %>
- <% if principal.is_a?(Group) %>
- <%= scoped_t(:shared_with_this_group_html, all_shared_work_packages_link:) %>
- <% else %>
- <%= scoped_t(:shared_with_this_user_html, all_shared_work_packages_link:) %>
- <% end %>
- <%= scoped_t(:will_revoke_access_to_all) %>
- <% end %>
+ <%= paragraph do %>
+ <%= scoped_t(:shared_with_this_user_html, all_shared_work_packages_link:) %>
+ <%= scoped_t(:will_revoke_access_to_all) %>
<% end %>
<% end %>
+ <% end %>
- <% dialog.with_footer do %>
- <%= button(data: { close_dialog_id: id }) { t(:button_cancel) } %>
- <%= button(scheme: :danger, tag: :a, href: delete_url(work_package_shares_role_id: "all"), data: { method: :delete }) { t(:button_revoke_access) } %>
- <% end %>
- <% else %>
- <% dialog.with_body do %>
- <%= paragraph { scoped_t(:cannot_remove_inherited, shared_role_name:) } %>
- <%= paragraph { scoped_t(:cannot_remove_inherited_note_html, administration_settings_link:) } %>
- <% end %>
+ <% dialog.with_footer do %>
+ <%= button(data: { close_dialog_id: id }) { t(:button_cancel) } %>
+ <%= button(scheme: :danger, tag: :a, href: delete_url(work_package_shares_role_id: "all"), data: { method: :delete }) { t(:button_revoke_access) } %>
+ <% end %>
+ <% when other_shared_work_packages_count? %>
+ <% dialog.with_body do %>
+ <%= paragraph { scoped_t(:cannot_remove_inherited_with_role, shared_role_name:) } %>
+ <%= paragraph { scoped_t(:cannot_remove_inherited_note_html, administration_settings_link:) } %>
+ <% end %>
- <% dialog.with_footer do %>
- <%= button(data: { close_dialog_id: id }) { t(:button_cancel) } %>
- <% end %>
+ <% dialog.with_footer do %>
+ <%= button(data: { close_dialog_id: id }) { t(:button_cancel) } %>
+ <% end %>
+ <% else %>
+ <% dialog.with_body do %>
+ <%= paragraph { scoped_t(:cannot_remove_inherited, shared_role_name:) } %>
+ <%= paragraph { scoped_t(:cannot_remove_inherited_note_html, administration_settings_link:) } %>
+ <% end %>
+
+ <% dialog.with_footer do %>
+ <%= button(data: { close_dialog_id: id }) { t(:button_cancel) } %>
<% end %>
<% end %>
<% end %>