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

Add include_gon to base template

Oliver Günther8984b989c646
diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb
index af916cd2a23..6f4b8b3273a 100644
--- a/app/controllers/admin/settings_controller.rb
+++ b/app/controllers/admin/settings_controller.rb
@@ -34,8 +34,6 @@ module Admin
before_action :require_admin
before_action :find_plugin, only: %i[show_plugin update_plugin]
- helper_method :gon
-
current_menu_item [:show] do
:settings
end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index efcfbc1aeca..3de4ba826da 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -39,6 +39,7 @@ class ApplicationController < ActionController::Base
class_attribute :accept_key_auth_actions
helper_method :render_to_string
+ helper_method :gon
protected
diff --git a/app/controllers/attribute_help_texts_controller.rb b/app/controllers/attribute_help_texts_controller.rb
index b9bcfbfed5c..7d3e463d066 100644
--- a/app/controllers/attribute_help_texts_controller.rb
+++ b/app/controllers/attribute_help_texts_controller.rb
@@ -37,8 +37,6 @@ class AttributeHelpTextsController < ApplicationController
before_action :find_type_scope
before_action :require_enterprise_token_grant
- helper_method :gon
-
def new
@attribute_help_text = AttributeHelpText.new type: @attribute_scope
end
diff --git a/app/controllers/custom_actions_controller.rb b/app/controllers/custom_actions_controller.rb
index 87d740b3546..fb18c69874c 100644
--- a/app/controllers/custom_actions_controller.rb
+++ b/app/controllers/custom_actions_controller.rb
@@ -38,8 +38,6 @@ class CustomActionsController < ApplicationController
layout 'admin'
- helper_method :gon
-
def index
@custom_actions = CustomAction.order_by_position
end
diff --git a/app/controllers/custom_fields_controller.rb b/app/controllers/custom_fields_controller.rb
index d46e2d28147..9c0bf8e6e3d 100644
--- a/app/controllers/custom_fields_controller.rb
+++ b/app/controllers/custom_fields_controller.rb
@@ -31,8 +31,6 @@
class CustomFieldsController < ApplicationController
layout 'admin'
- helper_method :gon
-
before_action :require_admin
before_action :find_custom_field, only: %i(edit update destroy delete_option reorder_alphabetical)
before_action :prepare_custom_option_position, only: %i(update create)
diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb
index da399ccc51a..da5e5f02d7c 100644
--- a/app/controllers/enterprises_controller.rb
+++ b/app/controllers/enterprises_controller.rb
@@ -31,8 +31,6 @@ class EnterprisesController < ApplicationController
layout 'admin'
menu_item :enterprise
- helper_method :gon
-
before_action :augur_content_security_policy
before_action :chargebee_content_security_policy
before_action :youtube_content_security_policy
@@ -44,7 +42,7 @@ class EnterprisesController < ApplicationController
@current_token = EnterpriseToken.current
@token = @current_token || EnterpriseToken.new
- write_augur_to_gon
+ helpers.write_augur_to_gon
if !@current_token.present?
write_trial_key_to_gon
@@ -108,11 +106,6 @@ class EnterprisesController < ApplicationController
end
end
- def write_augur_to_gon
- gon.augur_url = OpenProject::Configuration.enterprise_trial_creation_host
- gon.token_version = OpenProject::Token::VERSION
- end
-
def default_breadcrumb
t(:label_enterprise_edition)
end
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index e45351943f4..b10a69d1673 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -32,8 +32,6 @@ class GroupsController < ApplicationController
include GroupsHelper
layout 'admin'
- helper_method :gon
-
before_action :require_admin, except: %i[show]
before_action :find_group, only: %i[destroy update show create_memberships destroy_membership
edit_membership add_users]
diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb
index 2518cfee591..eef49a10eb1 100644
--- a/app/controllers/my_controller.rb
+++ b/app/controllers/my_controller.rb
@@ -35,8 +35,6 @@ class MyController < ApplicationController
layout 'my'
- helper_method :gon
-
before_action :require_login
before_action :set_current_user
before_action :check_password_confirmation, only: %i[update_account]
diff --git a/app/controllers/placeholder_users_controller.rb b/app/controllers/placeholder_users_controller.rb
index 8b7c3230960..14dbc204981 100644
--- a/app/controllers/placeholder_users_controller.rb
+++ b/app/controllers/placeholder_users_controller.rb
@@ -31,8 +31,6 @@
class PlaceholderUsersController < ApplicationController
layout 'admin'
- helper_method :gon
-
before_action :authorize_global, except: %i[show]
before_action :find_placeholder_user, only: %i[show
diff --git a/app/controllers/types_controller.rb b/app/controllers/types_controller.rb
index 6426a406274..a78ce9aa375 100644
--- a/app/controllers/types_controller.rb
+++ b/app/controllers/types_controller.rb
@@ -34,7 +34,6 @@ class TypesController < ApplicationController
layout 'admin'
before_action :require_admin
- helper_method :gon
def index
@types = ::Type.page(page_param).per_page(per_page_param)
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 00d7e84c366..3e6f4cc994c 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -31,8 +31,6 @@
class UsersController < ApplicationController
layout 'admin'
- helper_method :gon
-
before_action :authorize_global, except: %i[show deletion_info destroy]
before_action :find_user, only: %i[show
diff --git a/app/helpers/enterprise_helper.rb b/app/helpers/enterprise_helper.rb
new file mode 100644
index 00000000000..d6a7478ae6c
--- /dev/null
+++ b/app/helpers/enterprise_helper.rb
@@ -0,0 +1,6 @@
+module EnterpriseHelper
+ def write_augur_to_gon
+ gon.augur_url = OpenProject::Configuration.enterprise_trial_creation_host
+ gon.token_version = OpenProject::Token::VERSION
+ end
+end
diff --git a/app/helpers/hide_sections_helper.rb b/app/helpers/hide_sections_helper.rb
index 22937f5bf4e..2ec81f3ebc1 100644
--- a/app/helpers/hide_sections_helper.rb
+++ b/app/helpers/hide_sections_helper.rb
@@ -31,14 +31,10 @@
module HideSectionsHelper
def initialize_hide_sections_with(all, active)
gon.push(
- hide_sections: {
+ hideSections: {
all: all,
active: active
}
)
-
- nonced_javascript_tag do
- include_gon(need_tag: false, nonce: content_security_policy_script_nonce, camel_case: true, camel_depth: 15)
- end
end
end
diff --git a/app/views/common/_tabs.html.erb b/app/views/common/_tabs.html.erb
index 15f77fb2f74..f0945ba41d4 100644
--- a/app/views/common/_tabs.html.erb
+++ b/app/views/common/_tabs.html.erb
@@ -27,9 +27,6 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<% gon.contentTabs = { tabs: tabs.to_json.html_safe, selected: selected_tab.to_json.html_safe } %>
-<%= nonced_javascript_tag do %>
- <%= include_gon(need_tag: false) -%>
-<% end %>
<content-tabs></content-tabs>
diff --git a/app/views/common/upsale.html.erb b/app/views/common/upsale.html.erb
index 9f577a35007..c937d4c2d17 100644
--- a/app/views/common/upsale.html.erb
+++ b/app/views/common/upsale.html.erb
@@ -1,5 +1,6 @@
-<div class="upsale-notification">
+<% write_augur_to_gon %>
+<div class="upsale-notification">
<h2><%= feature_title %></h2>
<% if feature_description.empty? %>
<p class="upsale--feature-reference">
diff --git a/app/views/custom_actions/_form.html.erb b/app/views/custom_actions/_form.html.erb
index 2adda82c4dc..f1fef43df02 100644
--- a/app/views/custom_actions/_form.html.erb
+++ b/app/views/custom_actions/_form.html.erb
@@ -1,4 +1,4 @@
-<%= initialize_hide_sections_with @custom_action.all_actions.map { |a| { key: a.key, label: a.human_name } },
+<% initialize_hide_sections_with @custom_action.all_actions.map { |a| { key: a.key, label: a.human_name } },
@custom_action.actions.map { |a| { key: a.key, label: a.human_name } } %>
<div class="form--field -required">
diff --git a/app/views/enterprises/show.html.erb b/app/views/enterprises/show.html.erb
index 68171d32b89..ca07e2f73d9 100644
--- a/app/views/enterprises/show.html.erb
+++ b/app/views/enterprises/show.html.erb
@@ -2,10 +2,6 @@
<%= toolbar title: t("admin.enterprise.upgrade_to_ee") %>
-<%= nonced_javascript_tag do %>
- <%= include_gon(need_tag: false) -%>
-<% end %>
-
<%= error_messages_for 'token' %>
<% if @current_token.present? %>
diff --git a/app/views/layouts/_common_head.html.erb b/app/views/layouts/_common_head.html.erb
index 66c9f97834f..1cb58073b30 100644
--- a/app/views/layouts/_common_head.html.erb
+++ b/app/views/layouts/_common_head.html.erb
@@ -29,6 +29,9 @@
<%= render 'common/favicons' %>
+<%# Allow gon output when necessary %>
+<%= include_gon(nonce: content_security_policy_script_nonce) %>
+
<%# Include CLI assets (development) or prod build assets %>
<%= include_frontend_assets %>
diff --git a/app/views/layouts/angular/angular.html.erb b/app/views/layouts/angular/angular.html.erb
index 62bc28efd2f..2b672c38c0a 100644
--- a/app/views/layouts/angular/angular.html.erb
+++ b/app/views/layouts/angular/angular.html.erb
@@ -29,9 +29,6 @@ See COPYRIGHT and LICENSE files for more details.
<%= content_for :header_tags do %>
<% html_title(*local_assigns[:page_title]) if local_assigns[:page_title].present? %>
- <%= nonced_javascript_tag do %>
- <%= include_gon(need_tag: false) -%>
- <% end %>
<!-- plug-in specific tags -->
<%= call_hook :view_work_package_overview_attributes %>
<% end -%>
diff --git a/app/views/layouts/angular/notifications.html.erb b/app/views/layouts/angular/notifications.html.erb
index f6f6a4f2689..ffa7c987dcc 100644
--- a/app/views/layouts/angular/notifications.html.erb
+++ b/app/views/layouts/angular/notifications.html.erb
@@ -27,12 +27,6 @@ See docs/COPYRIGHT.rdoc for more details.
++#%>
-<%= content_for :header_tags do %>
- <%= nonced_javascript_tag do %>
- <%= include_gon(need_tag: false) -%>
- <% end %>
-<% end -%>
-
<%= content_for :content_body do %>
<openproject-base></openproject-base>
<% end -%>
diff --git a/app/views/search/index.html.erb b/app/views/search/index.html.erb
index 44e4a2bebeb..11354133539 100644
--- a/app/views/search/index.html.erb
+++ b/app/views/search/index.html.erb
@@ -29,7 +29,7 @@ See COPYRIGHT and LICENSE files for more details.
<% content_for :header_tags do %>
<%= call_hook :search_index_head %>
- <%= include_gon(nonce: content_security_policy_script_nonce) %>
+
<% end %>
<global-search-title></global-search-title>
diff --git a/frontend/src/app/features/enterprise/free-trial-button/free-trial-button.component.ts b/frontend/src/app/features/enterprise/free-trial-button/free-trial-button.component.ts
index 1407581078a..8f7fc77a3f1 100644
--- a/frontend/src/app/features/enterprise/free-trial-button/free-trial-button.component.ts
+++ b/frontend/src/app/features/enterprise/free-trial-button/free-trial-button.component.ts
@@ -26,7 +26,12 @@
// See COPYRIGHT and LICENSE files for more details.
//++
-import { Component, Injector } from '@angular/core';
+import {
+ ChangeDetectionStrategy,
+ Component,
+ Injector,
+ OnInit,
+} from '@angular/core';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { EnterpriseTrialModalComponent } from 'core-app/features/enterprise/enterprise-modal/enterprise-trial.modal';
import { OpModalService } from 'core-app/shared/components/modal/modal.service';
@@ -38,8 +43,9 @@ export const freeTrialButtonSelector = 'free-trial-button';
selector: freeTrialButtonSelector,
templateUrl: './free-trial-button.component.html',
styleUrls: ['./free-trial-button.component.sass'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
})
-export class FreeTrialButtonComponent {
+export class FreeTrialButtonComponent implements OnInit {
public text = {
button_trial: this.I18n.t('js.admin.enterprise.upsale.button_start_trial'),
};
@@ -50,6 +56,10 @@ export class FreeTrialButtonComponent {
public eeTrialService:EnterpriseTrialService) {
}
+ ngOnInit() {
+ console.warn('HELLO');
+ }
+
public openTrialModal() {
// cancel request and open first modal window
this.eeTrialService.cancelled = true;
diff --git a/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb b/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb
index c3099c92328..1f1c49a9d67 100644
--- a/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb
+++ b/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb
@@ -31,8 +31,6 @@
module Bim
module IfcModels
class IfcModelsController < BaseController
- helper_method :gon
-
before_action :find_project_by_project_id,
only: %i[index new create show defaults edit update destroy direct_upload_finished]
before_action :find_ifc_model_object, only: %i[edit update destroy]
diff --git a/modules/bim/app/controllers/bim/ifc_models/ifc_viewer_controller.rb b/modules/bim/app/controllers/bim/ifc_models/ifc_viewer_controller.rb
index 39970efe6c1..c242565b75e 100644
--- a/modules/bim/app/controllers/bim/ifc_models/ifc_viewer_controller.rb
+++ b/modules/bim/app/controllers/bim/ifc_models/ifc_viewer_controller.rb
@@ -31,8 +31,6 @@
module Bim
module IfcModels
class IfcViewerController < BaseController
- helper_method :gon
-
before_action :find_project_by_project_id
before_action :authorize
before_action :find_all_ifc_models
diff --git a/modules/bim/app/views/bim/ifc_models/ifc_viewer/show.html.erb b/modules/bim/app/views/bim/ifc_models/ifc_viewer/show.html.erb
index 9c38baa0495..7cd5e1601ff 100644
--- a/modules/bim/app/views/bim/ifc_models/ifc_viewer/show.html.erb
+++ b/modules/bim/app/views/bim/ifc_models/ifc_viewer/show.html.erb
@@ -29,7 +29,6 @@ See COPYRIGHT and LICENSE files for more details.
<% content_for :header_tags do %>
<% provision_gon_for_ifc_model(@ifc_models, @shown_model_ids) %>
- <%= include_gon(nonce: content_security_policy_script_nonce) %>
<% end %>
<% unconverted = @shown_ifc_models.reject(&:converted?) %>
diff --git a/modules/meeting/app/controllers/meeting_contents_controller.rb b/modules/meeting/app/controllers/meeting_contents_controller.rb
index de9156d6a62..7b321187fa5 100644
--- a/modules/meeting/app/controllers/meeting_contents_controller.rb
+++ b/modules/meeting/app/controllers/meeting_contents_controller.rb
@@ -39,8 +39,6 @@ class MeetingContentsController < ApplicationController
helper :watchers
helper :meetings
- helper_method :gon
-
before_action :find_meeting, :find_content
before_action :authorize
diff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rb
index 17b26b6f2ba..261e3ef3763 100644
--- a/modules/meeting/app/controllers/meetings_controller.rb
+++ b/modules/meeting/app/controllers/meetings_controller.rb
@@ -35,7 +35,6 @@ class MeetingsController < ApplicationController
helper :watchers
helper :meeting_contents
- helper_method :gon
include WatchersHelper
include PaginationHelper