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

Implement enterprise modal for sharing

Oliver Günther411ac363bf01
diff --git a/Gemfile b/Gemfile
index c0bb815f2d3..314c64783da 100644
--- a/Gemfile
+++ b/Gemfile
@@ -188,7 +188,7 @@ gem 'aws-sdk-core', '~> 3.107'
# File upload via fog + screenshots on travis
gem 'aws-sdk-s3', '~> 1.91'
-gem 'openproject-token', '~> 3.0.1'
+gem 'openproject-token', '~> 4.0'
gem 'plaintext', '~> 0.3.2'
diff --git a/Gemfile.lock b/Gemfile.lock
index 0d29092bf93..eda38d29683 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -686,7 +686,7 @@ GEM
activesupport (>= 5.0.0)
openproject-octicons (>= 19.7.0)
view_component (>= 3.1, < 4.0)
- openproject-token (3.0.1)
+ openproject-token (4.0.0)
activemodel
os (1.1.4)
ox (2.14.17)
@@ -1127,7 +1127,7 @@ DEPENDENCIES
openproject-reporting!
openproject-storages!
openproject-team_planner!
- openproject-token (~> 3.0.1)
+ openproject-token (~> 4.0)
openproject-two_factor_authentication!
openproject-webhooks!
openproject-xls_export!
diff --git a/app/components/work_packages/share/modal_upsale_component.html.erb b/app/components/work_packages/share/modal_upsale_component.html.erb
new file mode 100644
index 00000000000..2d5f3269a0d
--- /dev/null
+++ b/app/components/work_packages/share/modal_upsale_component.html.erb
@@ -0,0 +1,17 @@
+<%=
+ component_wrapper(tag: 'turbo-frame') do
+ 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))
+ component.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"
+ component.with_secondary_action(href:) do
+ flex_layout(justify_content: :center) do |flex|
+ flex.with_column(mr: 1) { I18n.t("admin.enterprise.enterprise_link") }
+ flex.with_column { render(Primer::Beta::Octicon.new(icon: :'link-external')) }
+ end
+ end
+ end
+ end
+%>
diff --git a/app/components/work_packages/share/modal_upsale_component.rb b/app/components/work_packages/share/modal_upsale_component.rb
new file mode 100644
index 00000000000..498494814fd
--- /dev/null
+++ b/app/components/work_packages/share/modal_upsale_component.rb
@@ -0,0 +1,41 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 WorkPackages
+ module Share
+ class ModalUpsaleComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def self.wrapper_key
+ "work_package_share_list"
+ end
+ end
+ end
+end
diff --git a/app/controllers/work_packages/shares_controller.rb b/app/controllers/work_packages/shares_controller.rb
index 9b54db9928d..3b399d3e408 100644
--- a/app/controllers/work_packages/shares_controller.rb
+++ b/app/controllers/work_packages/shares_controller.rb
@@ -34,6 +34,7 @@ class WorkPackages::SharesController < ApplicationController
before_action :find_share, only: %i[destroy update]
before_action :find_project
before_action :authorize
+ before_action :enterprise_check, only: %i[index]
def index
query = load_query
@@ -52,10 +53,10 @@ class WorkPackages::SharesController < ApplicationController
find_or_create_users(send_notification: false) do |member_params|
service_call = WorkPackageMembers::CreateOrUpdateService
- .new(user: current_user)
- .call(entity: @work_package,
- user_id: member_params[:user_id],
- role_ids: find_role_ids(params[:member][:role_id]))
+ .new(user: current_user)
+ .call(entity: @work_package,
+ user_id: member_params[:user_id],
+ role_ids: find_role_ids(params[:member][:role_id]))
overall_result.push(service_call)
end
@@ -95,6 +96,12 @@ class WorkPackages::SharesController < ApplicationController
private
+ def enterprise_check
+ return if EnterpriseToken.allows_to?(:work_package_sharing)
+
+ render WorkPackages::Share::ModalUpsaleComponent.new
+ end
+
def respond_with_replace_modal
replace_via_turbo_stream(
component: WorkPackages::Share::ModalBodyComponent.new(work_package: @work_package, shares: @new_shares || find_shares)
@@ -165,10 +172,10 @@ class WorkPackages::SharesController < ApplicationController
def current_visible_member_count
@current_visible_member_count ||= Member
- .joins(:member_roles)
- .of_work_package(@work_package)
- .merge(MemberRole.only_non_inherited)
- .size
+ .joins(:member_roles)
+ .of_work_package(@work_package)
+ .merge(MemberRole.only_non_inherited)
+ .size
end
def load_query
diff --git a/app/views/projects/settings/modules/_form.html.erb b/app/views/projects/settings/modules/_form.html.erb
index 40c73c1b7ab..e4fceb99cca 100644
--- a/app/views/projects/settings/modules/_form.html.erb
+++ b/app/views/projects/settings/modules/_form.html.erb
@@ -37,7 +37,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= spot_icon('enterprise-addons',
inline: true,
size: '1_25',
- classnames: 'upsale-icon_highlighted') %>
+ classnames: 'upsale-colored') %>
<% end %>
</label>
<div class="form--field-container">
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 3177a6c28c0..134b0336a53 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1858,6 +1858,7 @@ en:
label_enterprise_active_users: "%{current}/%{limit} booked active users"
label_enterprise_edition: "Enterprise edition"
label_enterprise_support: "Enterprise support"
+ label_enterprise_addon: "Enterprise add-on"
label_environment: "Environment"
label_estimates_and_time: "Estimates and time"
label_equals: "is"
@@ -2330,6 +2331,7 @@ en:
create_account: "To access this work package you will need to create an %{instance} account. "
open_work_package: "Open work package"
subject: "You have been shared work package #%{id}"
+ enterprise_text: "Share work packages with users who are not members of the project."
summary:
user: "%{user} shared a work package with you with %{role_rights} rights"
group: "%{user} shared a work package with the group %{group} you are a member of"
diff --git a/frontend/src/global_styles/content/_enterprise.sass b/frontend/src/global_styles/content/_enterprise.sass
index 78631572cfa..76bc9b1956d 100644
--- a/frontend/src/global_styles/content/_enterprise.sass
+++ b/frontend/src/global_styles/content/_enterprise.sass
@@ -52,9 +52,8 @@
justify-content: center
align-items: center
-.upsale-icon
- &_highlighted
- color: $spot-color-feedback-warning-dark
+.upsale-colored
+ color: $spot-color-feedback-warning-dark
.widget-box--blocks--upsale-title
font-weight: 400
diff --git a/lib/redmine/menu_manager/menu_helper.rb b/lib/redmine/menu_manager/menu_helper.rb
index ca403b4ae95..8796224a0cd 100644
--- a/lib/redmine/menu_manager/menu_helper.rb
+++ b/lib/redmine/menu_manager/menu_helper.rb
@@ -229,7 +229,7 @@ module Redmine::MenuManager::MenuHelper
lang: menu_item_locale(item)) do
title_text = ''.html_safe + content_tag(:span, caption, class: 'ellipsis') + badge_for(item)
if item.enterprise_feature.present? && !EnterpriseToken.allows_to?(item.enterprise_feature)
- title_text << (''.html_safe + spot_icon('enterprise-addons', size: '1_25', classnames: 'upsale-icon_highlighted'))
+ title_text << (''.html_safe + spot_icon('enterprise-addons', size: '1_25', classnames: 'upsale-colored'))
end
title_text
end