Skip to content

Commit

Permalink
rework interface for managing members
Browse files Browse the repository at this point in the history
  • Loading branch information
toy committed Mar 18, 2024
1 parent fdd858d commit a50bc24
Show file tree
Hide file tree
Showing 19 changed files with 1,084 additions and 93 deletions.
85 changes: 85 additions & 0 deletions app/components/members/delete_member_dialog_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<%#-- copyright
OpenProject is an open source project management software.
Copyright (C) 2012-2024 the OpenProject GmbH
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2013 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
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 %>
<%= render(Primer::Beta::Text.new(tag: "p")) { scoped_t(:will_remove_the_users_role_html, shared_work_packages_link:) } %>
<%= render(Primer::Beta::Text.new(tag: "p")) 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 %>
<%= render(Primer::Beta::Text.new(tag: "p")) { scoped_t(:can_remove_direct_but_not_shared_role) } %>
<%= render(Primer::Beta::Text.new(tag: "p")) { scoped_t(:also_user_has_shares_html, shared_work_packages_link:) } %>
<%= render(Primer::Beta::Text.new(tag: "p")) do %>
<%= scoped_t(:remove_just_user_or_shares_too) %>
<%= scoped_t(:will_not_affect_inherited_shares) if inherited_shared_work_packages_count? %>
<% end %>
<% end %>
<% end %>

<% dialog.with_footer do %>
<%= render(Primer::Beta::Button.new(data: { close_dialog_id: id })) { t(:button_cancel) } %>
<%= render(Primer::Beta::Button.new(scheme: :danger, tag: :a, href: delete_url(project: true), data: { method: :delete })) { t(:button_remove_member) } %>
<%= render(Primer::Beta::Button.new(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? %>
<% if can_delete? %>
<% dialog.with_body do %>
<%= render(Primer::Beta::Text.new(tag: "p")) { scoped_t(:will_remove_all_access_priveleges) } %>
<% end %>
<% else %>
<% dialog.with_body do %>
<%= render(Primer::Beta::Text.new(tag: "p")) { scoped_t(:can_remove_direct_but_not_shared_role) } %>
<% end %>
<% end %>

<% dialog.with_footer do %>
<%= render(Primer::Beta::Button.new(data: { close_dialog_id: id })) { t(:button_cancel) } %>
<%= render(Primer::Beta::Button.new(scheme: :danger, tag: :a, href: delete_url(project: true), data: { method: :delete })) { t(:button_remove) } %>
<% end %>
<% else %>
<% dialog.with_body do %>
<%= render(Primer::Beta::Text.new(tag: "p")) { scoped_t(:cannot_delete_group_member) } %>
<%= render(Primer::Beta::Text.new(tag: "p")) { scoped_t(:cannot_delete_group_member_note_html, administration_settings_link:) } %>
<% end %>

<% dialog.with_footer do %>
<%= render(Primer::Beta::Button.new(data: { close_dialog_id: id })) { t(:button_cancel) } %>
<% end %>
<% end %>
<% end %>
<% end %>
59 changes: 59 additions & 0 deletions app/components/members/delete_member_dialog_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2024 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See COPYRIGHT and LICENSE files for more details.
#++

module Members
class DeleteMemberDialogComponent < ::ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
options :row

delegate :shared_work_packages_link,
:administration_settings_link,
:can_delete?,
:can_delete_roles?,
:can_delete_shares?,
to: :row

delegate :principal,
:inherited_shared_work_packages_count?,
to: :model

def scoped_t(key, **)
t(key, scope: "members.delete_member_dialog", **)
end

def id
"principal-#{principal.id}-delete-member-dialog"
end

def delete_url(project: nil, work_package_shares_role_id: nil)
url_for(controller: "/members", action: "destroy_by_principal", principal_id: principal, project:,
work_package_shares_role_id:)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<%#-- copyright
OpenProject is an open source project management software.
Copyright (C) 2012-2024 the OpenProject GmbH
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2013 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
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? %>
<% if inherited_shared_work_packages_count? %>
<% dialog.with_body do %>
<%= render(Primer::Beta::Text.new(tag: "p")) 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 %>
<%= render(Primer::Beta::Text.new(tag: "p")) do %>
<%= scoped_t(:revoke_all_or_with_role, shared_role_name:) %>
<%= scoped_t(:will_not_affect_inherited_shares) %>
<% end %>
<% end %>
<% else %>
<% dialog.with_body do %>
<%= render(Primer::Beta::Text.new(tag: "p")) 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 %>
<%= render(Primer::Beta::Text.new(tag: "p")) { scoped_t(:revoke_all_or_with_role, shared_role_name:) } %>
<% end %>
<% end %>

<% dialog.with_footer do %>
<%= render(Primer::Beta::Button.new(data: { close_dialog_id: id })) { t(:button_cancel) } %>
<%= render(Primer::Beta::Button.new(scheme: :danger, tag: :a, href: delete_url(work_package_shares_role_id: "all"), data: { method: :delete })) { t(:button_revoke_all) } %>
<%= render(Primer::Beta::Button.new(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 %>
<%= render(Primer::Beta::Text.new(tag: "p")) { scoped_t(:cannot_remove_inherited_with_role, shared_role_name:) } %>
<%= render(Primer::Beta::Text.new(tag: "p")) { scoped_t(:cannot_remove_inherited_note_html, administration_settings_link:) } %>
<% end %>

<% dialog.with_footer do %>
<%= render(Primer::Beta::Button.new(data: { close_dialog_id: id })) { t(:button_cancel) } %>
<% end %>
<% end %>
<% else %>
<% if direct_shared_work_packages_count? %>
<% if inherited_shared_work_packages_count? %>
<% dialog.with_body do %>
<%= render(Primer::Beta::Text.new(tag: "p")) do %>
<%= scoped_t(:shared_with_this_user_html, all_shared_work_packages_link:) %>
<%= scoped_t(:will_revoke_access_but_for_inherited) %>
<% end %>
<% end %>
<% else %>
<% dialog.with_body do %>
<%= render(Primer::Beta::Text.new(tag: "p")) 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 %>
<% end %>
<% end %>

<% dialog.with_footer do %>
<%= render(Primer::Beta::Button.new(data: { close_dialog_id: id })) { t(:button_cancel) } %>
<%= render(Primer::Beta::Button.new(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 %>
<%= render(Primer::Beta::Text.new(tag: "p")) { scoped_t(:cannot_remove_inherited, shared_role_name:) } %>
<%= render(Primer::Beta::Text.new(tag: "p")) { scoped_t(:cannot_remove_inherited_note_html, administration_settings_link:) } %>
<% end %>

<% dialog.with_footer do %>
<%= render(Primer::Beta::Button.new(data: { close_dialog_id: id })) { t(:button_cancel) } %>
<% end %>
<% end %>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2024 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See COPYRIGHT and LICENSE files for more details.
#++

module Members
class DeleteWorkPackageSharesDialogComponent < ::ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
options :row

delegate :table,
:shared_work_packages_link,
:all_shared_work_packages_link,
:administration_settings_link,
to: :row

delegate :shared_role_id,
:shared_role_name,
to: :table

delegate :principal,
:other_shared_work_packages_count?,
:direct_shared_work_packages_count?,
:inherited_shared_work_packages_count?,
to: :model

def scoped_t(key, **)
t(key, scope: "members.delete_work_package_shares_dialog", **)
end

def id
"principal-#{principal.id}-delete-work-package-shares-dialog"
end

def delete_url(work_package_shares_role_id: nil)
url_for(controller: "/members", action: "destroy_by_principal", principal_id: principal, work_package_shares_role_id:)
end
end
end
Loading

0 comments on commit a50bc24

Please sign in to comment.