Add upsale page for attribute help texts

feature/43118-access-project-dropdown-entries-via-arrow-keys
Oliver Günther 2 years ago
parent e3117d2520
commit 8a3ff8ec52
  1. BIN
      app/assets/images/enterprise/attribute-help-texts.png
  2. 14
      app/controllers/attribute_help_texts_controller.rb
  3. 38
      app/views/attribute_help_texts/upsale.html.erb
  4. 4
      config/initializers/menus.rb
  5. 2
      config/locales/en.yml
  6. 4
      config/routes.rb
  7. 22
      spec/controllers/attribute_help_texts_controller_spec.rb
  8. 11
      spec/features/admin/attribute_help_texts_spec.rb
  9. 8
      spec/features/menu_items/admin_menu_item_spec.rb

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

@ -31,9 +31,9 @@ class AttributeHelpTextsController < ApplicationController
menu_item :attribute_help_texts
before_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_grant
def new
@attribute_help_text = AttributeHelpText.new type: @attribute_scope
@ -41,6 +41,8 @@ class AttributeHelpTextsController < ApplicationController
def edit; end
def upsale; end
def update
call = ::AttributeHelpTexts::UpdateService
.new(user: current_user, model: @attribute_help_text)
@ -86,6 +88,12 @@ class AttributeHelpTextsController < ApplicationController
protected
def require_ee_token
unless EnterpriseToken.allows_to?(:attribute_help_texts)
redirect_to upsale_attribute_help_texts_path
end
end
def default_breadcrumb
if 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)
end
end

@ -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'
} %>

@ -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' },

@ -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:

@ -351,7 +351,9 @@ OpenProject::Application.routes.draw do
post '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
end
resources :groups, except: %i[show] do
member do

@ -3,7 +3,7 @@ require 'spec_helper'
describe AttributeHelpTextsController, type: :controller do
let(:user) { build_stubbed :admin }
let(:model) { build :work_package_help_text }
let(:relation_columns_allowed) { true }
let(:enterprise_token) { true }
let(:find_expectation) do
allow(AttributeHelpText)
@ -13,7 +13,7 @@ describe AttributeHelpTextsController, type: :controller do
end
before do
with_enterprise_token(relation_columns_allowed ? :attribute_help_texts : nil)
with_enterprise_token(enterprise_token ? :attribute_help_texts : nil)
login_as user
end
@ -30,10 +30,10 @@ describe AttributeHelpTextsController, type: :controller do
end
context '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_path
end
end
end
@ -53,10 +53,10 @@ describe AttributeHelpTextsController, type: :controller do
end
context '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_path
end
end
@ -135,14 +135,14 @@ describe AttributeHelpTextsController, type: :controller do
end
context 'with help texts disallowed by the enterprise token' do
let(:relation_columns_allowed) { false }
let(:enterprise_token) { false }
before do
call
end
it 'returns 404' do
expect(response.status).to be 404
it 'redirects to upsale' do
expect(response).to redirect_to upsale_attribute_help_texts_path
end
end
end

@ -35,11 +35,11 @@ describe 'Attribute help texts', js: true do
let(: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' do
before 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 do
end
context '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')
end
end
end

@ -44,8 +44,8 @@ describe 'Admin menu items', js: true do
visit admin_index_path
expect(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'
end
end
@ -57,10 +57,10 @@ describe 'Admin menu items', js: true do
visit admin_index_path
expect(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'))
end
end

Loading…
Cancel
Save