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
Add upsale page for attribute help texts
Oliver Günther8a3ff8ec5287
diff --git a/app/assets/images/enterprise/attribute-help-texts.png b/app/assets/images/enterprise/attribute-help-texts.pngnew file mode 100644index 00000000000..93f80cb6fd9Binary files /dev/null and b/app/assets/images/enterprise/attribute-help-texts.png differdiff --git a/app/controllers/attribute_help_texts_controller.rb b/app/controllers/attribute_help_texts_controller.rbindex 87672b834fe..4357c3c678e 100644--- a/app/controllers/attribute_help_texts_controller.rb+++ b/app/controllers/attribute_help_texts_controller.rb@@ -31,9 +31,9 @@ class AttributeHelpTextsController < ApplicationControllermenu_item :attribute_help_textsbefore_action :require_admin+ before_action :require_ee_token, except: %i[upsale]before_action :find_entry, only: %i(edit update destroy)before_action :find_type_scope- before_action :require_enterprise_token_grantdef new@attribute_help_text = AttributeHelpText.new type: @attribute_scope@@ -41,6 +41,8 @@ class AttributeHelpTextsController < ApplicationControllerdef edit; end+ def upsale; end+def updatecall = ::AttributeHelpTexts::UpdateService.new(user: current_user, model: @attribute_help_text)@@ -86,6 +88,12 @@ class AttributeHelpTextsController < ApplicationControllerprotected+ def require_ee_token+ unless EnterpriseToken.allows_to?(:attribute_help_texts)+ redirect_to upsale_attribute_help_texts_path+ end+ end+def default_breadcrumbif action_name == 'index't('attribute_help_texts.label_plural')@@ -130,8 +138,4 @@ class AttributeHelpTextsController < ApplicationController@attribute_scope = AttributeHelpText.const_get(submodule)end-- def require_enterprise_token_grant- render_404 unless EnterpriseToken.allows_to?(:attribute_help_texts)- endenddiff --git a/app/views/attribute_help_texts/upsale.html.erb b/app/views/attribute_help_texts/upsale.html.erbnew file mode 100644index 00000000000..7545b7a778f--- /dev/null+++ b/app/views/attribute_help_texts/upsale.html.erb@@ -0,0 +1,38 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) 2012-2022 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.++++#%>++<% html_title t(:label_administration), t(:'attribute_help_texts.label_plural') %>++<%= render template: 'common/upsale',+ locals: {+ feature_title: t(:'attribute_help_texts.label_plural'),+ feature_description: t('attribute_help_texts.enterprise.description'),+ feature_reference: 'enterprise-attribute-help-texts',+ feature_image: 'enterprise/attribute-help-texts.png'+ } %>diff --git a/config/initializers/menus.rb b/config/initializers/menus.rbindex 627fa034ccf..e73b3222612 100644--- a/config/initializers/menus.rb+++ b/config/initializers/menus.rb@@ -269,9 +269,7 @@ Redmine::MenuManager.map :admin_menu do |menu|{ controller: '/attribute_help_texts' },caption: :'attribute_help_texts.label_plural',icon: 'icon2 icon-help2',- if: Proc.new {- User.current.admin? && EnterpriseToken.allows_to?(:attribute_help_texts)- }+ if: Proc.new { User.current.admin? }menu.push :enumerations,{ controller: '/enumerations' },diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 0ca7b246fb4..08db2497ca0 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -106,6 +106,8 @@ en:show_preview: 'Preview text'add_new: 'Add help text'edit: "Edit help text for %{attribute_caption}"+ enterprise:+ description: 'Hovering on a sidebar menu item displays attribute help text that help you and your users better understand what each item does.'auth_sources:index:diff --git a/config/routes.rb b/config/routes.rbindex 3fb0e2bf94f..6d94943e17a 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -351,7 +351,9 @@ OpenProject::Application.routes.draw dopost 'design/themes' => 'custom_styles#update_themes', as: 'update_design_themes'resource :custom_style, only: %i[update show create], path: 'design'- resources :attribute_help_texts, only: %i(index new create edit update destroy)+ resources :attribute_help_texts, only: %i(index new create edit update destroy) do+ get :upsale, to: 'attribute_help_texts#upsale', on: :collection, as: :upsale+ endresources :groups, except: %i[show] domember dodiff --git a/spec/controllers/attribute_help_texts_controller_spec.rb b/spec/controllers/attribute_help_texts_controller_spec.rbindex 832867d59c7..96ff7be9f2a 100644--- a/spec/controllers/attribute_help_texts_controller_spec.rb+++ b/spec/controllers/attribute_help_texts_controller_spec.rb@@ -3,7 +3,7 @@ require 'spec_helper'describe AttributeHelpTextsController, type: :controller dolet(:user) { build_stubbed :admin }let(:model) { build :work_package_help_text }- let(:relation_columns_allowed) { true }+ let(:enterprise_token) { true }let(:find_expectation) doallow(AttributeHelpText)@@ -13,7 +13,7 @@ describe AttributeHelpTextsController, type: :controller doendbefore do- with_enterprise_token(relation_columns_allowed ? :attribute_help_texts : nil)+ with_enterprise_token(enterprise_token ? :attribute_help_texts : nil)login_as userend@@ -30,10 +30,10 @@ describe AttributeHelpTextsController, type: :controller doendcontext 'with help texts disallowed by the enterprise token' do- let(:relation_columns_allowed) { false }+ let(:enterprise_token) { false }- it 'returns 404' do- expect(response.status).to be 404+ it 'redirects to upsale' do+ expect(response).to redirect_to upsale_attribute_help_texts_pathendendend@@ -53,10 +53,10 @@ describe AttributeHelpTextsController, type: :controller doendcontext 'with help texts disallowed by the enterprise token' do- let(:relation_columns_allowed) { false }+ let(:enterprise_token) { false }- it 'returns 404' do- expect(response.status).to be 404+ it 'redirects to upsale' do+ expect(response).to redirect_to upsale_attribute_help_texts_pathendend@@ -135,14 +135,14 @@ describe AttributeHelpTextsController, type: :controller doendcontext 'with help texts disallowed by the enterprise token' do- let(:relation_columns_allowed) { false }+ let(:enterprise_token) { false }before docallend- it 'returns 404' do- expect(response.status).to be 404+ it 'redirects to upsale' do+ expect(response).to redirect_to upsale_attribute_help_texts_pathendendenddiff --git a/spec/features/admin/attribute_help_texts_spec.rb b/spec/features/admin/attribute_help_texts_spec.rbindex ab21ec7a772..a57b4fbc544 100644--- a/spec/features/admin/attribute_help_texts_spec.rb+++ b/spec/features/admin/attribute_help_texts_spec.rb@@ -35,11 +35,11 @@ describe 'Attribute help texts', js: true dolet(:modal) { Components::AttributeHelpTextModal.new(instance) }let(:editor) { Components::WysiwygEditor.new }let(:image_fixture) { UploadedFile.load_from('spec/fixtures/files/image.png') }- let(:relation_columns_allowed) { true }+ let(:enterprise_token) { true }describe 'Work package help texts' dobefore do- with_enterprise_token(relation_columns_allowed ? :attribute_help_texts : nil)+ with_enterprise_token(enterprise_token ? :attribute_help_texts : nil)login_as(admin)visit attribute_help_texts_path@@ -152,12 +152,11 @@ describe 'Attribute help texts', js: true doendcontext 'with help texts disallowed by the enterprise token' do- let(:relation_columns_allowed) { false }+ let(:enterprise_token) { false }it 'hides CRUD to attribute help texts' do- expect(page)- .to have_selector(".errorExplanation",- text: "The page you were trying to access doesn't exist or has been removed.")+ expect(page).to have_current_path /upsale/+ expect(page).to have_text I18n.t('attribute_help_texts.enterprise.description')endendenddiff --git a/spec/features/menu_items/admin_menu_item_spec.rb b/spec/features/menu_items/admin_menu_item_spec.rbindex a558b958ef7..9ad032651e1 100644--- a/spec/features/menu_items/admin_menu_item_spec.rb+++ b/spec/features/menu_items/admin_menu_item_spec.rb@@ -44,8 +44,8 @@ describe 'Admin menu items', js: true dovisit admin_index_pathexpect(page).to have_selector('[data-qa-selector="menu-blocks--container"]')- expect(page).to have_selector('[data-qa-selector="menu-block"]', count: 17)- expect(page).to have_selector('[data-qa-selector="op-menu--item-action"]', count: 18) # All plus 'overview'+ expect(page).to have_selector('[data-qa-selector="menu-block"]', count: 18)+ expect(page).to have_selector('[data-qa-selector="op-menu--item-action"]', count: 19) # All plus 'overview'endend@@ -57,10 +57,10 @@ describe 'Admin menu items', js: true dovisit admin_index_pathexpect(page).to have_selector('[data-qa-selector="menu-blocks--container"]')- expect(page).to have_selector('[data-qa-selector="menu-block"]', count: 16)+ expect(page).to have_selector('[data-qa-selector="menu-block"]', count: 17)expect(page).not_to have_selector('[data-qa-selector="menu-block"]', text: I18n.t('timelines.admin_menu.colors'))- expect(page).to have_selector('[data-qa-selector="op-menu--item-action"]', count: 17) # All plus 'overview'+ expect(page).to have_selector('[data-qa-selector="op-menu--item-action"]', count: 18) # All plus 'overview'expect(page).not_to have_selector('[data-qa-selector="op-menu--item-action"]', text: I18n.t('timelines.admin_menu.colors'))endend