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
Remove residues of Cells
Dombi Attilafb0d0493ceac
diff --git a/Gemfile b/Gemfileindex e0fd0f1e9bc..cfb15027002 100644--- a/Gemfile+++ b/Gemfile@@ -160,9 +160,6 @@ gem 'prawn-markup', '~> 0.3.0'# prawn implicitly depends on matrix gem no longer in ruby core with 3.1gem 'matrix', '~> 0.4.2'-gem 'cells-erb', '~> 0.1.0'-gem 'cells-rails', '~> 0.1.4'-gem 'meta-tags', '~> 2.18.0'gem "paper_trail", "~> 12.3"diff --git a/Gemfile.lock b/Gemfile.lockindex dff83f53be6..9f246557ea3 100644--- a/Gemfile.lock+++ b/Gemfile.lock@@ -337,17 +337,6 @@ GEMcarrierwave_direct (2.1.0)carrierwave (>= 1.0.0)fog-aws- cells (4.1.7)- declarative-builder (< 0.2.0)- declarative-option (< 0.2.0)- tilt (>= 1.4, < 3)- uber (< 0.2.0)- cells-erb (0.1.0)- cells (~> 4.0)- erbse (>= 0.1.1)- cells-rails (0.1.5)- actionpack (>= 5.0)- cells (>= 4.1.6, < 5.0.0)closure_tree (7.4.0)activerecord (>= 4.2.10)with_advisory_lock (>= 4.0.0)@@ -373,9 +362,6 @@ GEMdeckar01-task_list (2.3.2)html-pipelinedeclarative (0.0.20)- declarative-builder (0.1.0)- declarative-option (< 0.2.0)- declarative-option (0.1.0)delayed_cron_job (0.9.0)fugit (>= 1.5)delayed_job (4.1.11)@@ -425,8 +411,6 @@ GEMactivemodelequivalent-xml (0.6.0)nokogiri (>= 1.4.3)- erbse (0.1.4)- templeerubi (1.12.0)escape_utils (1.3.0)et-orbi (1.2.7)@@ -906,7 +890,6 @@ GEMsys-filesystem (1.4.3)ffi (~> 1.1)table_print (1.5.7)- temple (0.10.1)test-prof (1.2.1)thor (1.2.2)tilt (2.1.0)@@ -991,8 +974,6 @@ DEPENDENCIEScapybara-screenshot (~> 1.0.17)carrierwave (~> 1.3.1)carrierwave_direct (~> 2.1.0)- cells-erb (~> 0.1.0)- cells-rails (~> 0.1.4)closure_tree (~> 7.4.0)colored2commonmarker (~> 0.23.9)diff --git a/app/cells/rails_cell.rb b/app/cells/rails_cell.rbdeleted file mode 100644index 7f9509218ca..00000000000--- a/app/cells/rails_cell.rb+++ /dev/null@@ -1,75 +0,0 @@-class RailsCell < Cell::ViewModel- include Escaped- include ERB::Util- include ApplicationHelper- include ActionView::Helpers::TranslationHelper- include SecureHeaders::ViewHelpers-- # Delegate to action_view- delegate :content_for,- :content_tag,- :tag_options,- to: :action_view-- delegate :request, to: :controller-- self.view_paths = ['app/cells/views']-- # We don't include ActionView::Helpers wholesale because- # this would override Cell's own render method and- # subsequently break everything.-- ##- # Defines options for this cell which can be used within the cell's template.- # Options are passed to the cell during the render call.- #- # @param names [Array<String> | Hash<String, Any>] Either a list of names for options whose- # default value is empty or a hash mapping- # option names to default values.- def self.options(*names)- default_values = {}-- if names.size == 1 && names.first.is_a?(Hash)- default_values = names.first- names = default_values.keys- end-- names.each do |name|- define_method(name) do- options[name] || default_values[name]- end- end- end-- def show- # Set the _request from AS::Controller that doesn't get passed into the rails cell.- # Workaround for when using middlewares such as SecureHeaders that relies on it,- # but don't use the request method itself.- @_request = request-- # Prepare the model for rendering- prepare-- render- end-- def prepare- # Nothing to do by default- end-- def controller- context[:controller]- end-- def action_view- context[:action_view] || controller.view_context- end-- def form_authenticity_token(**args)- controller.send(:form_authenticity_token, **args)- end-- def protect_against_forgery?- controller.send(:protect_against_forgery?)- end-enddiff --git a/app/cells/row_cell.rb b/app/cells/row_cell.rbdeleted file mode 100644index 3d03c38573a..00000000000--- a/app/cells/row_cell.rb+++ /dev/null@@ -1,53 +0,0 @@-##-# Abstract cell. Subclass this for a concrete row cell.-class RowCell < RailsCell- include RemovedJsHelpersHelper-- def table- options[:table]- end-- delegate :columns, to: :table-- def column_value(column)- value = send column-- escaped(value)- end-- def escaped(value)- if value.html_safe?- value- else- h(value)- end- end-- def row_css_id- nil- end-- def row_css_class- ""- end-- def column_css_class(column)- column_css_classes[column]- end-- def column_css_classes- entries = columns.map { |name| [name, name] }-- entries.to_h- end-- def button_links- []- end-- def checkmark(condition)- if condition- op_icon 'icon icon-checkmark'- end- end-enddiff --git a/app/cells/table_cell.rb b/app/cells/table_cell.rbdeleted file mode 100644index d55057cd6a8..00000000000--- a/app/cells/table_cell.rb+++ /dev/null@@ -1,188 +0,0 @@-##-# Abstract cell. Subclass this for a concrete table.-class TableCell < RailsCell- include UsersHelper- include SortHelper- include PaginationHelper- include WillPaginate::ActionView-- options :groups, :roles, :status, :project- options show_inline_create: true- options table_id: nil-- class << self- ##- # Names used by sort logic meaning these names- # will be used directly in the generated SQL queries.- #- # This will also generate getters for these columns- # on the RowCell class for this TableCell. The getters- # are calling the same methods on the model for the Row.- # E.g.:- #- # Users::TableCell.columns :weight- # model = Struct.new(:weight).new 42- # row_cell = Users::Table::RowCell.new model- # row_cell.weight == model.weight- def columns(*names)- return Array(@columns) if names.empty?-- @columns = names.map(&:to_sym)- rc = row_class-- names.each do |name|- rc.property name- end- end-- ##- # Define which of the registered columns are sortable- # Applies only if +sortable?+ is true- def sortable_columns(*names)- if names.present?- @sortable_columns = names.map(&:to_sym)- # set available criteria- return- end-- # return all columns unless defined otherwise- if @sortable_columns.nil?- columns- else- Array(@sortable_columns)- end- end-- def add_column(name)- @columns = Array(@columns) + [name]- row_class.property name- end-- def row_class- mod = namespace || "Table"- class_name = "RowCell"-- "#{mod}::#{class_name}".constantize- rescue NameError- raise(- NameError,- "#{mod}::#{class_name} required by #{mod}::TableCell not defined. " +- "Expected to be defined in `app/cells/#{mod.underscore}/#{class_name.underscore}.rb`."- )- end-- def namespace- name.split("::")[0..-2].join("::").presence- end- end-- def prepare- initialize_sorted_model if sortable?- end-- def initialize_sorted_model- sort_init *initial_sort.map(&:to_s)- sort_update sortable_columns.map(&:to_s)- @model = paginate_collection apply_sort(model)- end-- def apply_sort(model)- case model- when ActiveRecord::QueryMethods- sort_collection(model, sort_clause)- when Queries::BaseQuery- model- .order(@sort_criteria.to_query_hash)- .results- else- raise ArgumentError, "Cannot sort the given model class #{model.class}"- end- end-- ##- # Sorts the data to be displayed.- #- # @param query [ActiveRecord::QueryMethods] An active record collection.- # @param sort_clause [String] The SQL used as the sort clause.- def sort_collection(query, sort_clause)- query- .reorder(sort_clause)- .order(Arel.sql(initial_order))- end-- def paginate_collection(query)- query- .page(page_param(controller.params))- .per_page(per_page_param)- end-- def rows- model- end-- def columns- self.class.columns- end-- def sortable_columns- self.class.sortable_columns- end-- def render_row(row)- cell(self.class.row_class, row, table: self).call- end-- def initial_sort- [columns.first, :asc]- end-- def initial_order- initial_sort.join(' ')- end-- def paginated?- rows.respond_to? :total_entries- end-- def build_sort_header(column, options)- sort_header_tag(column, options)- end-- def button_header- content_tag :div, '', class: 'generic-table--empty-header'- end-- def inline_create_link- nil- end-- def sortable?- true- end-- def sortable_column?(column)- sortable? && sortable_columns.include?(column.to_sym)- end-- ##- # An array listing each column and its respective options.- #- # @return Array<Array>- def headers- columns.map { |name| [name.to_s, {}] }- end-- def empty_row_message- I18n.t :no_results_title_text- end-- # required by the sort helper-- delegate :controller_name, to: :controller-- delegate :action_name, to: :controller-- def options- super- end-enddiff --git a/app/cells/views/row/show.erb b/app/cells/views/row/show.erbdeleted file mode 100644index 83860e3ff02..00000000000--- a/app/cells/views/row/show.erb+++ /dev/null@@ -1,41 +0,0 @@-<%#-- 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.--++#%>--<tr <%= "id=\"#{row_css_id}\"" if row_css_id %> class="<%= row_css_class %>">- <% columns.each do |column| %>- <td class="<%= column_css_class(column) %>">- <%= column_value(column) %>- </td>- <% end %>- <td class="buttons">- <% button_links.each do |link| %>- <%= link %>- <% end %>- </td>-</tr>diff --git a/app/cells/views/table/show.erb b/app/cells/views/table/show.erbdeleted file mode 100644index 6f378a6fbbe..00000000000--- a/app/cells/views/table/show.erb+++ /dev/null@@ -1,82 +0,0 @@-<%#-- 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.--++#%>--<div class="generic-table--container">- <div class="generic-table--results-container">- <table class="generic-table">- <colgroup>- <% headers.each do |_name, _options| %>- <col opHighlightCol>- <% end %>- <col>- </colgroup>- <thead>- <tr>- <% headers.each do |name, options| %>- <% if sortable_column?(name) %>- <%= sort_header_tag name, options %>- <% else %>- <th>- <div class="generic-table--sort-header-outer">- <div class="generic-table--sort-header">- <span>- <%= options[:caption] %>- </span>- </div>- </div>- </th>- <% end %>- <% end %>- <th>- <%# last column for buttons %>- <div class="generic-table--empty-header"></div>- </th>- </tr>- </thead>- <tbody>- <% if rows.empty? %>- <tr class="generic-table--empty-row">- <td colspan="<%= headers.length + 1 %>"><%= empty_row_message %></td>- </tr>- <% end %>- <% for row in rows do -%>- <%= render_row row %>- <% end -%>- </tbody>- </table>- <% if inline_create_link && show_inline_create %>- <div class="wp-inline-create-button">- <%= inline_create_link %>- </div>- <% end %>- </div>-</div>-<% if paginated? %>- <%= pagination_links_full rows %>-<% end %>diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rbindex 0e422ff267f..bf2983a8d6b 100644--- a/app/controllers/members_controller.rb+++ b/app/controllers/members_controller.rb@@ -37,8 +37,6 @@ class MembersController < ApplicationControllersearch_for User, :search_in_projectsearch_options_for User, lambda { |*| { project: @project } }- include CellsHelper-def indexset_index_data!enddiff --git a/app/helpers/cells_helper.rb b/app/helpers/cells_helper.rbdeleted file mode 100644index c6c67e39ff0..00000000000--- a/app/helpers/cells_helper.rb+++ /dev/null@@ -1,10 +0,0 @@-module CellsHelper- def rails_cell(name, model, **args)- args[:context] = {- controller: try(:controller),- action_view: self- }-- cell name, model, args- end-enddiff --git a/frontend/src/app/core/setup/globals/global-listeners/settings.ts b/frontend/src/app/core/setup/globals/global-listeners/settings.tsindex d334829566b..4ad1be516de 100644--- a/frontend/src/app/core/setup/globals/global-listeners/settings.ts+++ b/frontend/src/app/core/setup/globals/global-listeners/settings.ts@@ -26,7 +26,7 @@ export function listenToSettingChanges() {}});- /* Javascript for Settings::TextSettingCell */+ /* Javascript for Settings::TextSettingComponent */const langSelectSwitchData = function (select:any) {const self = jQuery(select);const id:string = self.attr('id') || '';@@ -60,7 +60,7 @@ export function listenToSettingChanges() {data.editor.setData(storedValue);data.textArea.attr('name', `settings[${data.settingName}][${data.newLang}]`);});- /* end Javascript for Settings::TextSettingCell */+ /* end Javascript for Settings::TextSettingComponent */jQuery('.admin-settings--form').submit(() => {/* Update consent time if consent required */diff --git a/lib/open_project/patches/declarative_option.rb b/lib/open_project/patches/declarative_option.rbdeleted file mode 100644index 7dfd350c627..00000000000--- a/lib/open_project/patches/declarative_option.rb+++ /dev/null@@ -1,48 +0,0 @@-#-- 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 OpenProject::Patches::DeclarativeOption- extend ActiveSupport::Concern-- included do- private-- # Override Declarative::Option to avoid ruby 2.7.1 warnings about using the last argument as keyword parameter.- def lambda_for_proc(value, options)- return ->(context, **args) { context.instance_exec(**args, &value) } if options[:instance_exec]-- value- end- end-end--OpenProject::Patches.patch_gem_version 'declarative-option', '0.1.0' do- unless Declarative::Option.included_modules.include?(OpenProject::Patches::DeclarativeOption)- Declarative::Option.include OpenProject::Patches::DeclarativeOption- end-enddiff --git a/lib/open_project/plugins/acts_as_op_engine.rb b/lib/open_project/plugins/acts_as_op_engine.rbindex dc22cd4a295..7fbe28328e7 100644--- a/lib/open_project/plugins/acts_as_op_engine.rb+++ b/lib/open_project/plugins/acts_as_op_engine.rb@@ -62,13 +62,6 @@ module OpenProject::Pluginsapp.config.i18n.load_path += Dir[config.root.join('config', 'locales', 'crowdin', '*.{rb,yml}').to_s]end- current_engine = self- config.to_prepare do- pathname = current_engine.root.join("app/cells/views")-- ::RailsCell.view_paths << pathname.to_path if pathname.exist?- end-# adds our factories to factory girl's load pathinitializer "#{engine_name}.register_factories", after: 'factory_bot.set_factory_paths' do |_app|FactoryBot.definition_file_paths << File.expand_path("#{root}/spec/factories") if defined?(FactoryBot)diff --git a/spec/cells/rails_cell_spec.rb b/spec/components/rails_component_spec.rbsimilarity index 74%rename from spec/cells/rails_cell_spec.rbrename to spec/components/rails_component_spec.rbindex 61ff8071aaf..d37ed97ca44 100644--- a/spec/cells/rails_cell_spec.rb+++ b/spec/components/rails_component_spec.rb@@ -27,7 +27,7 @@#++require 'spec_helper'-describe RailsCell do+describe RailsComponent, type: :component dolet(:controller) { double(ApplicationController) }let(:action_view) { ActionView::Base.new(ActionView::LookupContext.new(''), {}, controller) }let(:model) { double('model', foo: '<strong>Some HTML here!</strong>') }@@ -38,25 +38,30 @@ describe RailsCell do{ context: }end- let(:test_cell) do- Class.new(described_class) do- property :foo+ class TestComponent < described_class+ include ViewComponent::InlineTemplate- def link- link_to "<strong>HTML</strong>", '/foo/bar'- end+ property :foo++ erb_template <<~ERB+ <%= foo %>+ ERB++ def link+ link_to "<strong>HTML</strong>", '/foo/bar'+ end- def content- content_tag(:div) do- content_tag(:span) do- "<script>foo</script>"- end+ def content+ content_tag(:div) do+ content_tag(:span) do+ "<script>foo</script>"endendend+end- let(:instance) { test_cell.new model, options }+ let(:component) { TestComponent.new(model, **options) }before doallow(controller).to receive(:view_context).and_return(action_view)@@ -64,27 +69,24 @@ describe RailsCell doshared_examples 'uses action_view helpers' dodescribe '#link' do- subject { instance.link }-+ subject { component.link }it 'uses link_to from rails with escaping' do- expect(subject.to_s).to eq %(<a href="/foo/bar"><strong>HTML</strong></a>)+ expect(subject).to eq %(<a href="/foo/bar"><strong>HTML</strong></a>)endenddescribe '#foo' do- subject { instance.foo }-+ subject { component.call }it 'escapes the property' do- expect(subject.to_s).to eq "<strong>Some HTML here!</strong>"+ render_inline component+ expect(subject).to include "<strong>Some HTML here!</strong>"endenddescribe '#content' do- subject { instance.content }-+ subject { component.content }it 'uses content_tag from rails with escaping', :aggregate_failures do- expect(action_view).to receive(:content_tag).twice.and_call_original- expect(subject.to_s).to eq "<div><span><script>foo</script></span></div>"+ expect(subject).to eq "<div><span><script>foo</script></span></div>"endendend