Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/13.1' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ulferts committed Dec 7, 2023
2 parents 5c5acf7 + cc1a617 commit 9dfaa57
Show file tree
Hide file tree
Showing 139 changed files with 968 additions and 287 deletions.
160 changes: 82 additions & 78 deletions app/components/work_packages/share/modal_body_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,99 +5,103 @@
render(WorkPackages::Share::InviteUserFormComponent.new(work_package: @work_package))
end

if @shares.blank?
modal_content.with_row(mt: 3) do
render(Primer::Beta::Blankslate.new(border: true)) do |component|
component.with_visual_icon(icon: :people, size: :medium)
component.with_heading(tag: :h2).with_content(I18n.t('work_package.sharing.text_empty_state_header') )
component.with_description do
flex_layout do |flex|
flex.with_row(mb: 2) do
render(Primer::Beta::Text.new(color: :subtle)) { I18n.t('work_package.sharing.text_empty_state_description') }
end
modal_content.with_row(mt: 3,
data: { 'test-selector': 'op-share-wp-active-list',
controller: 'work-packages--share--bulk-selection',
application_target: 'dynamic' }) do
render(Primer::Beta::BorderBox.new(list_id: insert_target_modifier_id)) do |border_box|
border_box.with_header(color: :muted, data: { 'test-selector': 'op-share-wp-header' }) do
grid_layout('op-share-wp-modal-body--header', tag: :div, align_items: :center) do |header_grid|
header_grid.with_area(:counter, tag: :div) do
render(WorkPackages::Share::CounterComponent.new(work_package: @work_package, count: @shares.size))
end
end
end
end
else
modal_content.with_row(mt: 3,
data: { 'test-selector': 'op-share-wp-active-list',
controller: 'work-packages--share--bulk-selection',
application_target: 'dynamic' }) do
render(Primer::Beta::BorderBox.new(list_id: insert_target_modifier_id)) do |border_box|
border_box.with_header(color: :muted, data: { 'test-selector': 'op-share-wp-header' }) do
grid_layout('op-share-wp-modal-body--header', tag: :div, align_items: :center) do |header_grid|
header_grid.with_area(:counter, tag: :div) do
render(WorkPackages::Share::CounterComponent.new(work_package: @work_package, count: @shares.size))
end

header_grid.with_area(:actions,
tag: :div,
data: { 'work-packages--share--bulk-selection-target': 'defaultActions' }) do
flex_layout do |header_actions|
header_actions.with_column(mr: 2) do
render(Primer::Alpha::ActionMenu.new(anchor_align: :end,
select_variant: :single,
color: :muted,
data: { 'test-selector': 'op-share-wp-filter-type' })) do |menu|
menu.with_show_button(scheme: :invisible, color: :muted) do |button|
button.with_trailing_action_icon(icon: "triangle-down")
I18n.t('work_package.sharing.filter.type')
end
type_filter_options.each do |option|
menu.with_item(label: option[:label],
href: filter_url(type_option: option),
method: :get,
tag: :a,
active: type_filter_option_active?(option),
role: "menuitem")
end
header_grid.with_area(:actions,
tag: :div,
data: { 'work-packages--share--bulk-selection-target': 'defaultActions' }) do
flex_layout do |header_actions|
header_actions.with_column(mr: 2) do
render(Primer::Alpha::ActionMenu.new(anchor_align: :end,
select_variant: :single,
dynamic_label: true,
dynamic_label_prefix: I18n.t('work_package.sharing.filter.type'),
color: :muted,
data: { 'test-selector': 'op-share-wp-filter-type' })) do |menu|
menu.with_show_button(scheme: :invisible, color: :muted, data: { 'test-selector': 'op-share-wp-filter-type-button' }) do |button|
button.with_trailing_action_icon(icon: "triangle-down")
I18n.t('work_package.sharing.filter.type')
end
type_filter_options.each do |option|
menu.with_item(label: option[:label],
href: filter_url(type_option: option),
method: :get,
tag: :a,
active: type_filter_option_active?(option),
role: "menuitem")
end
end
end

header_actions.with_column do
render(Primer::Alpha::ActionMenu.new(anchor_align: :end,
select_variant: :single,
color: :muted,
data: { 'test-selector': 'op-share-wp-filter-role' })) do |menu|
menu.with_show_button(scheme: :invisible, color: :muted) do |button|
button.with_trailing_action_icon(icon: "triangle-down")
I18n.t('work_package.sharing.filter.role')
end
options.each do |option|
menu.with_item(label: option[:label],
href: filter_url(role_option: option),
method: :get,
tag: :a,
active: role_filter_option_active?(option),
role: "menuitem")
end
header_actions.with_column do
render(Primer::Alpha::ActionMenu.new(anchor_align: :end,
select_variant: :single,
dynamic_label: true,
dynamic_label_prefix: I18n.t('work_package.sharing.filter.role'),
color: :muted,
data: { 'test-selector': 'op-share-wp-filter-role' })) do |menu|
menu.with_show_button(scheme: :invisible, color: :muted, data: { 'test-selector': 'op-share-wp-filter-role-button' }) do |button|
button.with_trailing_action_icon(icon: "triangle-down")
I18n.t('work_package.sharing.filter.role')
end
options.each do |option|
menu.with_item(label: option[:label],
href: filter_url(role_option: option),
method: :get,
tag: :a,
active: role_filter_option_active?(option),
role: "menuitem")
end
end
end
end
end

header_grid.with_area(:actions,
tag: :div,
hidden: true, # Prevent flicker on initial render
data: { 'work-packages--share--bulk-selection-target': 'bulkActions' }) do
if sharing_manageable?
concat(
render(WorkPackages::Share::BulkPermissionButtonComponent.new(work_package: @work_package))
)
header_grid.with_area(:actions,
tag: :div,
hidden: true, # Prevent flicker on initial render
data: { 'work-packages--share--bulk-selection-target': 'bulkActions' }) do
if sharing_manageable?
concat(
render(WorkPackages::Share::BulkPermissionButtonComponent.new(work_package: @work_package))
)

concat(
form_with(url: work_package_shares_bulk_path,
method: :delete,
data: { 'work-packages--share--bulk-selection-target': 'bulkForm' }) do
render(Primer::Beta::Button.new(type: :submit, scheme: :invisible)) { I18n.t('work_package.sharing.remove') }
end
)
end
concat(
form_with(url: work_package_shares_bulk_path(@work_package),
method: :delete,
data: { 'work-packages--share--bulk-selection-target': 'bulkForm' }) do
render(Primer::Beta::Button.new(type: :submit, scheme: :invisible)) { I18n.t('work_package.sharing.remove') }
end
)
end
end
end
end

if @shares.blank?
border_box.with_row do
render(Primer::Beta::Blankslate.new) do |component|
component.with_visual_icon(icon: blankslate_config[:icon], size: :medium)
component.with_heading(tag: :h2).with_content(blankslate_config[:heading_text])
component.with_description do
flex_layout do |flex|
flex.with_row(mb: 2) do
render(Primer::Beta::Text.new(color: :subtle)) { blankslate_config[:description_text] }
end
end
end
end
end
else
@shares.each do |share|
render(WorkPackages::Share::ShareRowComponent.new(share: share, container: border_box))
end
Expand Down
18 changes: 16 additions & 2 deletions app/components/work_packages/share/modal_body_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ def insert_target_modifier_id
'op-share-wp-active-shares'
end

def blankslate_config
@blankslate_config ||= {}.tap do |config|
if params[:filters].blank?
config[:icon] = :people
config[:heading_text] = I18n.t('work_package.sharing.text_empty_state_header')
config[:description_text] = I18n.t('work_package.sharing.text_empty_state_description')
else
config[:icon] = :search
config[:heading_text] = I18n.t('work_package.sharing.text_empty_search_header')
config[:description_text] = I18n.t('work_package.sharing.text_empty_search_description')
end
end
end

def type_filter_options
[
{ label: I18n.t('work_package.sharing.filter.project_member'),
Expand Down Expand Up @@ -93,7 +107,7 @@ def role_filter_option_active?(_option)
end

def filter_url(type_option: nil, role_option: nil)
return work_package_shares_path if type_option.nil? && role_option.nil?
return work_package_shares_path(@work_package) if type_option.nil? && role_option.nil?

args = {}
filter = []
Expand All @@ -103,7 +117,7 @@ def filter_url(type_option: nil, role_option: nil)

args[:filters] = filter.to_json unless filter.empty?

work_package_shares_path(args)
work_package_shares_path(@work_package, **args)
end

def apply_role_filter(_option)
Expand Down
6 changes: 3 additions & 3 deletions app/models/users/permission_checks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ def all_permissions_for(context)
def allowed_based_on_permission_context?(permission, project: nil, entity: nil) # rubocop:disable Metrics/PerceivedComplexity, Metrics/AbcSize
permissions = Authorization.permissions_for(permission, raise_on_unknown: true)

entity_blank_or_not_project_scoped = (entity.blank? || !entity.respond_to?(:project) || (entity.respond_to?(:project) && entity.project.blank?))
entity_is_work_package_or_list = ((entity.is_a?(WorkPackage) && entity.persisted?) || (entity.is_a?(Enumerable) && entity.all?(WorkPackage)))
entity_is_project_scoped_and_project_is_present = (entity.respond_to?(:project) && entity.project.present?)
entity_blank_or_not_project_scoped = entity.blank? || !entity.respond_to?(:project) || (entity.respond_to?(:project) && entity.project.blank?)
entity_is_work_package_or_list = (entity.is_a?(WorkPackage) && entity.persisted?) || (entity.is_a?(Enumerable) && entity.all?(WorkPackage))
entity_is_project_scoped_and_project_is_present = entity.respond_to?(:project) && entity.project.present?

permissions.any? do |perm|
if perm.global?
Expand Down
3 changes: 2 additions & 1 deletion app/services/authorization/user_permissible_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ def allowed_in_entity?(permission, entities_to_check, entity_class)
end
end

def allowed_in_any_entity?(permission, entity_class, in_project: nil)
def allowed_in_any_entity?(permission, entity_class, in_project: nil) # rubocop:disable Metrics/PerceivedComplexity
perms = contextual_permissions(permission, context_name(entity_class))
return false unless authorizable_user?
return false if in_project && !(in_project.active? || in_project.being_archived?)
return true if admin_and_all_granted_to_admin?(perms)

# entity_class.allowed_to will also check whether the user has the permission via a membership in the project.
Expand Down
14 changes: 13 additions & 1 deletion app/views/sharing_mailer/shared_work_package.text.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
<%= I18n.t('mail.salutation', user: @shared_with_user.firstname) %>
<%= I18n.t('mail.sharing.work_packages.summary', user: @sharer) %>
<%=
if @group
I18n.t("mail.sharing.work_packages.summary.group",
user: @sharer,
group: @group,
role_rights: @role_rights)
else
I18n.t("mail.sharing.work_packages.summary.user",
user: @sharer,
role_rights: @role_rights)
end
%>
<%= "-" * 100 %>
<%= "=" * (('# ' + @work_package.id.to_s + @work_package.subject).length + 4) %>
Expand Down
4 changes: 3 additions & 1 deletion config/locales/crowdin/af.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3050,8 +3050,10 @@ af:
view_description: "Can view this work package."
remove: "Remove"
share: "Share"
text_empty_search_description: "There are no users with the current filter criteria."
text_empty_search_header: "We couldn't find any matching results."
text_empty_state_description: "The work package has not been shared with anyone yet."
text_empty_state_header: "No shared users"
text_empty_state_header: "No shared members."
text_user_limit_reached: "Adding additional users will exceed the current limit. Please contact an administrator to increase the user limit to ensure external users are able to access this work package."
text_user_limit_reached_admins: 'Adding additional users will exceed the current limit. Please <a href="%{upgrade_url}">upgrade your plan</a> to be able to add more users.'
warning_user_limit_reached: >
Expand Down
4 changes: 3 additions & 1 deletion config/locales/crowdin/ar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3168,8 +3168,10 @@ ar:
view_description: "Can view this work package."
remove: "Remove"
share: "Share"
text_empty_search_description: "There are no users with the current filter criteria."
text_empty_search_header: "We couldn't find any matching results."
text_empty_state_description: "The work package has not been shared with anyone yet."
text_empty_state_header: "No shared users"
text_empty_state_header: "No shared members."
text_user_limit_reached: "Adding additional users will exceed the current limit. Please contact an administrator to increase the user limit to ensure external users are able to access this work package."
text_user_limit_reached_admins: 'Adding additional users will exceed the current limit. Please <a href="%{upgrade_url}">upgrade your plan</a> to be able to add more users.'
warning_user_limit_reached: >
Expand Down
4 changes: 3 additions & 1 deletion config/locales/crowdin/az.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3050,8 +3050,10 @@ az:
view_description: "Can view this work package."
remove: "Remove"
share: "Share"
text_empty_search_description: "There are no users with the current filter criteria."
text_empty_search_header: "We couldn't find any matching results."
text_empty_state_description: "The work package has not been shared with anyone yet."
text_empty_state_header: "No shared users"
text_empty_state_header: "No shared members."
text_user_limit_reached: "Adding additional users will exceed the current limit. Please contact an administrator to increase the user limit to ensure external users are able to access this work package."
text_user_limit_reached_admins: 'Adding additional users will exceed the current limit. Please <a href="%{upgrade_url}">upgrade your plan</a> to be able to add more users.'
warning_user_limit_reached: >
Expand Down
4 changes: 3 additions & 1 deletion config/locales/crowdin/be.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3110,8 +3110,10 @@ be:
view_description: "Can view this work package."
remove: "Remove"
share: "Share"
text_empty_search_description: "There are no users with the current filter criteria."
text_empty_search_header: "We couldn't find any matching results."
text_empty_state_description: "The work package has not been shared with anyone yet."
text_empty_state_header: "No shared users"
text_empty_state_header: "No shared members."
text_user_limit_reached: "Adding additional users will exceed the current limit. Please contact an administrator to increase the user limit to ensure external users are able to access this work package."
text_user_limit_reached_admins: 'Adding additional users will exceed the current limit. Please <a href="%{upgrade_url}">upgrade your plan</a> to be able to add more users.'
warning_user_limit_reached: >
Expand Down
4 changes: 3 additions & 1 deletion config/locales/crowdin/bg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3050,8 +3050,10 @@ bg:
view_description: "Can view this work package."
remove: "Remove"
share: "Share"
text_empty_search_description: "There are no users with the current filter criteria."
text_empty_search_header: "We couldn't find any matching results."
text_empty_state_description: "The work package has not been shared with anyone yet."
text_empty_state_header: "No shared users"
text_empty_state_header: "No shared members."
text_user_limit_reached: "Adding additional users will exceed the current limit. Please contact an administrator to increase the user limit to ensure external users are able to access this work package."
text_user_limit_reached_admins: 'Adding additional users will exceed the current limit. Please <a href="%{upgrade_url}">upgrade your plan</a> to be able to add more users.'
warning_user_limit_reached: >
Expand Down
Loading

0 comments on commit 9dfaa57

Please sign in to comment.