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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Move I18n out of the work package scope and properly load permissions
Klaus Zanders884b71f7603e
diff --git a/app/components/shares/bulk_selection_counter_component.html.erb b/app/components/shares/bulk_selection_counter_component.html.erbindex 7066f1e08f6..9c45cb13e06 100644--- a/app/components/shares/bulk_selection_counter_component.html.erb+++ b/app/components/shares/bulk_selection_counter_component.html.erb@@ -2,7 +2,7 @@concat(render(Primer::Alpha::CheckBox.new(name: 'toggle_all',value: nil,- label: I18n.t('work_package.sharing.label_toggle_all'),+ label: I18n.t('sharing.label_toggle_all'),visually_hide_label: true,data: { 'shares--bulk-selection-target': 'toggleAll',action: 'shares--bulk-selection#toggle' }))@@ -10,7 +10,7 @@concat(render(Primer::Beta::Text.new(ml: 2, data: { 'shares--bulk-selection-target': 'sharedCounter' })) do- I18n.t('work_package.sharing.count', count:)+ I18n.t('sharing.count', count:)end)diff --git a/app/components/shares/counter_component.rb b/app/components/shares/counter_component.rbindex 9bd01472efb..145ee3b8c53 100644--- a/app/components/shares/counter_component.rb+++ b/app/components/shares/counter_component.rb@@ -29,7 +29,7 @@# ++module Shares- class CounterComponent < ApplicationComponent+ class CounterComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponentinclude ApplicationHelperinclude OpTurbo::Streamableinclude OpPrimer::ComponentHelpersdiff --git a/app/components/shares/invite_user_form_component.html.erb b/app/components/shares/invite_user_form_component.html.erbindex 605a51d8f0e..917b9c8ce54 100644--- a/app/components/shares/invite_user_form_component.html.erb+++ b/app/components/shares/invite_user_form_component.html.erb@@ -27,7 +27,7 @@invite_form.with_area('submit') dorender(Primer::Beta::Button.new(scheme: :primary, type: :submit)) do- I18n.t('work_package.sharing.share')+ I18n.t('sharing.share')endend@@ -44,8 +44,9 @@user_limit_row.with_column dorender(Primer::Beta::Text.new(color: :danger)) doI18n.t(- "work_package.sharing.warning_user_limit_reached#{'_admin' if User.current.admin?}",- upgrade_url: OpenProject::Enterprise.upgrade_url+ "sharing.warning_user_limit_reached#{'_admin' if User.current.admin?}",+ upgrade_url: OpenProject::Enterprise.upgrade_url,+ entity: @entity.model_name.human).html_safeendend@@ -64,7 +65,7 @@no_selected_user_row.with_column dorender(Primer::Beta::Text.new(color: :danger)) do- I18n.t("work_package.sharing.warning_no_selected_user")+ I18n.t("sharing.warning_no_selected_user", entity: @entity.model_name.human)endendend@@ -95,7 +96,7 @@endendelse- render(Primer::Alpha::Banner.new(icon: :info)) { I18n.t('work_package.sharing.permissions.denied') }+ render(Primer::Alpha::Banner.new(icon: :info)) { I18n.t('sharing.denied', entity: @entity.model_name.human(count: 2)) }endend%>diff --git a/app/components/shares/modal_body_component.html.erb b/app/components/shares/modal_body_component.html.erbindex 63a2929c222..97de19aeae1 100644--- a/app/components/shares/modal_body_component.html.erb+++ b/app/components/shares/modal_body_component.html.erb@@ -29,12 +29,12 @@render(Primer::Alpha::ActionMenu.new(anchor_align: :end,select_variant: :single,dynamic_label: true,- dynamic_label_prefix: I18n.t('work_package.sharing.filter.type'),+ dynamic_label_prefix: I18n.t('sharing.filter.type'),color: :muted,data: { 'test-selector': 'op-share-dialog-filter-type' })) do |menu|menu.with_show_button(scheme: :invisible, color: :muted, data: { 'test-selector': 'op-share-dialog-filter-type-button' }) do |button|button.with_trailing_action_icon(icon: "triangle-down")- I18n.t('work_package.sharing.filter.type')+ I18n.t('sharing.filter.type')endtype_filter_options.each do |option|menu.with_item(label: option[:label],@@ -51,12 +51,12 @@render(Primer::Alpha::ActionMenu.new(anchor_align: :end,select_variant: :single,dynamic_label: true,- dynamic_label_prefix: I18n.t('work_package.sharing.filter.role'),+ dynamic_label_prefix: I18n.t('sharing.filter.role'),color: :muted,data: { 'test-selector': 'op-share-dialog-filter-role' })) do |menu|menu.with_show_button(scheme: :invisible, color: :muted, data: { 'test-selector': 'op-share-dialog-filter-role-button' }) do |button|button.with_trailing_action_icon(icon: "triangle-down")- I18n.t('work_package.sharing.filter.role')+ I18n.t('sharing.filter.role')end@available_roles.each do |role_hash|menu.with_item(label: role_hash[:label],@@ -87,7 +87,7 @@render(Primer::Beta::IconButton.new(icon: "trash",type: :submit,scheme: :danger,- "aria-label": I18n.t('work_package.sharing.remove'),+ "aria-label": I18n.t('sharing.remove'),test_selector: 'op-share-dialog--bulk-remove'))end)diff --git a/app/components/shares/modal_body_component.rb b/app/components/shares/modal_body_component.rbindex 2bd0b31a578..741c2fd5eba 100644--- a/app/components/shares/modal_body_component.rb+++ b/app/components/shares/modal_body_component.rb@@ -75,12 +75,12 @@ module Shares@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")+ config[:heading_text] = I18n.t("sharing.text_empty_state_header")+ config[:description_text] = I18n.t("sharing.text_empty_state_description", entity: @entity.class.model_name.human)elseconfig[: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")+ config[:heading_text] = I18n.t("sharing.text_empty_search_header")+ config[:description_text] = I18n.t("sharing.text_empty_search_description")endendend@@ -88,19 +88,19 @@ module Sharesdef type_filter_optionsif project_scoped_entity?[- { label: I18n.t("work_package.sharing.filter.project_member"),+ { label: I18n.t("sharing.filter.project_member"),value: { principal_type: "User", project_member: true } },- { label: I18n.t("work_package.sharing.filter.not_project_member"),+ { label: I18n.t("sharing.filter.not_project_member"),value: { principal_type: "User", project_member: false } },- { label: I18n.t("work_package.sharing.filter.project_group"),+ { label: I18n.t("sharing.filter.project_group"),value: { principal_type: "Group", project_member: true } },- { label: I18n.t("work_package.sharing.filter.not_project_group"),+ { label: I18n.t("sharing.filter.not_project_group"),value: { principal_type: "Group", project_member: false } }]else[- { label: "User", value: { principal_type: "User" } },- { label: "Group", value: { principal_type: "Group" } }+ { label: I18n.t("sharing.filter.user"), value: { principal_type: "User" } },+ { label: I18n.t("sharing.filter.group"), value: { principal_type: "Group" } }]enddiff --git a/app/components/shares/modal_upsale_component.html.erb b/app/components/shares/modal_upsale_component.html.erbindex 2d5f3269a0d..9f6cc4ae3e2 100644--- a/app/components/shares/modal_upsale_component.html.erb+++ b/app/components/shares/modal_upsale_component.html.erb@@ -3,6 +3,7 @@render Primer::Beta::Blankslate.new(border: true) do |component|component.with_visual_icon(icon: :'op-enterprise-addons', classes: 'upsale-colored')component.with_heading(tag: :h2, classes: 'upsale-colored').with_content(I18n.t(:label_enterprise_addon))+ # TODO: Generalize this textcomponent.with_description { I18n.t('mail.sharing.work_packages.enterprise_text') }href = "#{OpenProject::Static::Links.links[:upsale][:href]}/?utm_source=unknown&utm_medium=community-edition&utm_campaign=work-package-sharing-modal"diff --git a/app/components/shares/share_counter_component.html.erb b/app/components/shares/share_counter_component.html.erbindex 855f3733038..04f3ac8250c 100644--- a/app/components/shares/share_counter_component.html.erb+++ b/app/components/shares/share_counter_component.html.erb@@ -1,3 +1,3 @@<%- concat(render(Primer::Beta::Text.new) { I18n.t('work_package.sharing.count', count:) })+ concat(render(Primer::Beta::Text.new) { I18n.t('sharing.count', count:) })%>diff --git a/app/components/shares/share_row_component.html.erb b/app/components/shares/share_row_component.html.erbindex c85ae11c010..f633f52876b 100644--- a/app/components/shares/share_row_component.html.erb+++ b/app/components/shares/share_row_component.html.erb@@ -3,7 +3,7 @@grid_layout(grid_css_classes, tag: :div, align_items: :center, classes: 'ellipsis') do |user_row_grid|user_row_grid.with_area(:selection, tag: :div) doif share_editable?- render(Primer::Alpha::CheckBox.new(name: "share_ids", value: share.id, label: "#{principal.name}",+ render(Primer::Alpha::CheckBox.new(name: "share_ids", value: share.id, label: principal.name,visually_hide_label: true, scheme: :array,data: {'shares--bulk-selection-target': 'shareCheckbox',@@ -32,7 +32,7 @@render(Primer::Beta::IconButton.new(icon: "trash",type: :submit,scheme: :danger,- "aria-label": I18n.t('work_package.sharing.remove'),+ "aria-label": I18n.t('sharing.remove'),test_selector: 'op-share-dialog--remove'))endenddiff --git a/app/components/shares/user_details_component.html.erb b/app/components/shares/user_details_component.html.erbindex 6ad99a05915..f9c64eaacb7 100644--- a/app/components/shares/user_details_component.html.erb+++ b/app/components/shares/user_details_component.html.erb@@ -9,20 +9,20 @@if manager_mode?if user_is_a_group?if project_group?- render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("work_package.sharing.user_details.project_group")}+ render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("sharing.user_details.project_group")}else- render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("work_package.sharing.user_details.not_project_group")}+ render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("sharing.user_details.not_project_group")}endelseif user_in_non_active_status?if user.locked?concat(render(Primer::Beta::Octicon.new(icon: :lock, color: :muted, mr: 1)))- concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("work_package.sharing.user_details.locked") })+ concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("sharing.user_details.locked") })elsif user.invited?if invite_resent?- concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("work_package.sharing.user_details.invite_resent") })+ concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("sharing.user_details.invite_resent") })else- concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t('work_package.sharing.user_details.invited') })+ concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t('sharing.user_details.invited') })concat(form_with(url: resend_invite_path, method: :post) dorender(Primer::Beta::Button.new(type: :submit, px: 0, scheme: :link)) { I18n.t('work_package.sharing.user_details.resend_invite') }@@ -34,31 +34,31 @@if part_of_a_group?if part_of_a_shared_group?if project_member?- concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("work_package.sharing.user_details.additional_privileges_project_or_group") })+ concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("sharing.user_details.additional_privileges_project_or_group") })else- concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("work_package.sharing.user_details.additional_privileges_group") })+ concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("sharing.user_details.additional_privileges_group") })endelseif inherited_project_member?- concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("work_package.sharing.user_details.additional_privileges_project_or_group") })+ concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("sharing.user_details.additional_privileges_project_or_group") })elsif project_member?- concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("work_package.sharing.user_details.additional_privileges_project") })+ concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("sharing.user_details.additional_privileges_project") })else- concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("work_package.sharing.user_details.not_project_member") })+ concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("sharing.user_details.not_project_member") })endendelseif project_member?- concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("work_package.sharing.user_details.additional_privileges_project") })+ concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("sharing.user_details.additional_privileges_project") })else- concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("work_package.sharing.user_details.not_project_member") })+ concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("sharing.user_details.not_project_member") })endendendendelseif user.invited?- concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("work_package.sharing.user_details.invited")})+ concat(render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("sharing.user_details.invited")})endendenddiff --git a/app/controllers/shares_controller.rb b/app/controllers/shares_controller.rbindex 9f5f2fe07d2..34fd4094c55 100644--- a/app/controllers/shares_controller.rb+++ b/app/controllers/shares_controller.rb@@ -314,17 +314,18 @@ class SharesController < ApplicationControllerenddef available_roles- # TODO: Optimize loading of roles- if @entity.is_a?(WorkPackage)+ @available_roles ||= if @entity.is_a?(WorkPackage)+ role_mapping = WorkPackageRole.unscoped.pluck(:builtin, :id).to_h+[- { label: I18n.t("work_package.sharing.permissions.edit"),- value: WorkPackageRole.find_by(builtin: Role::BUILTIN_WORK_PACKAGE_EDITOR).id,+ { label: I18n.t("work_package.permissions.edit"),+ value: role_mapping[Role::BUILTIN_WORK_PACKAGE_EDITOR],description: I18n.t("work_package.sharing.permissions.edit_description") },- { label: I18n.t("work_package.sharing.permissions.comment"),- value: WorkPackageRole.find_by(builtin: Role::BUILTIN_WORK_PACKAGE_COMMENTER).id,- description: I18n.t("work_package.sharing.permissions.comment_description") },+ { label: I18n.t("work_package.permissions.comment"),+ value: role_mapping[Role::BUILTIN_WORK_PACKAGE_COMMENTER],+ description: I18n.t("work_package.permissions.comment_description") },{ label: I18n.t("work_package.sharing.permissions.view"),- value: WorkPackageRole.find_by(builtin: Role::BUILTIN_WORK_PACKAGE_VIEWER).id,+ value: role_mapping[Role::BUILTIN_WORK_PACKAGE_VIEWER],description: I18n.t("work_package.sharing.permissions.view_description"),default: true }]diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 80e31ee4641..913f6970303 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -3617,54 +3617,56 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}work_based_help_text: "% Complete is automatically derived from Work and Remaining work."status_based_help_text: "% Complete is set by work package status."migration_warning_text: "In work-based progress calculation mode, % Complete cannot be manually set and is tied to Work. The existing value has been kept but cannot be edited. Please input Work first."- sharing:- count:- zero: "0 users"- one: "1 user"- other: "%{count} users"- filter:- project_member: "Project member"- not_project_member: "Not project member"- project_group: "Project group"- not_project_group: "Not project group"- role: "Role"- type: "Type"- label_search: "Search for users to invite"- label_search_placeholder: "Search by user or email address"- label_toggle_all: "Toggle all shares"- permissions:- comment: "Comment"- comment_description: "Can view and comment this work package."- denied: "You don't have permissions to share work packages."- edit: "Edit"- edit_description: "Can view, comment and edit this work package."- view: "View"- 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: "Not shared"- 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: >- 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.- warning_user_limit_reached_admin: >- Adding additional users will exceed the current limit. Please <a href="%{upgrade_url}">upgrade your plan</a> to be able to ensure external users are able to access this work package.- warning_no_selected_user: "Please select users to share this work package with"- warning_locked_user: "The user %{user} is locked and cannot be shared with"- user_details:- locked: "Locked user"- invited: "Invite sent. "- resend_invite: "Resend."- invite_resent: "Invite has been resent"- not_project_member: "Not a project member"- project_group: "Group members might have additional privileges (as project members)"- not_project_group: "Group (shared with all members)"- additional_privileges_project: "Might have additional privileges (as project member)"- additional_privileges_group: "Might have additional privileges (as group member)"- additional_privileges_project_or_group: "Might have additional privileges (as project or group member)"+ permissions:+ comment: "Comment"+ comment_description: "Can view and comment this work package."+ edit: "Edit"+ edit_description: "Can view, comment and edit this work package."+ view: "View"+ view_description: "Can view this work package."+ sharing:+ count:+ zero: "0 users"+ one: "1 user"+ other: "%{count} users"+ filter:+ project_member: "Project member"+ not_project_member: "Not project member"+ project_group: "Project group"+ not_project_group: "Not project group"+ user: "User"+ group: "Group"+ role: "Role"+ type: "Type"+ denied: "You don't have permissions to share %{entities}."+ label_search: "Search for users to invite"+ label_search_placeholder: "Search by user or email address"+ label_toggle_all: "Toggle all shares"+ 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 %{entity} has not been shared with anyone yet."+ text_empty_state_header: "Not shared"+ 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 %{entity}."+ 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: >+ 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 %{entity}.+ warning_user_limit_reached_admin: >+ Adding additional users will exceed the current limit. Please <a href="%{upgrade_url}">upgrade your plan</a> to be able to ensure external users are able to access this %{entity}.+ warning_no_selected_user: "Please select users to share this %{entity} with"+ warning_locked_user: "The user %{user} is locked and cannot be shared with"+ user_details:+ locked: "Locked user"+ invited: "Invite sent. "+ resend_invite: "Resend."+ invite_resent: "Invite has been resent"+ not_project_member: "Not a project member"+ project_group: "Group members might have additional privileges (as project members)"+ not_project_group: "Group (shared with all members)"+ additional_privileges_project: "Might have additional privileges (as project member)"+ additional_privileges_group: "Might have additional privileges (as group member)"+ additional_privileges_project_or_group: "Might have additional privileges (as project or group member)"working_days:info: >