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
Integrate with file storages such as Nextcloud
Wieland Lindenthalcf730431dbc9
diff --git a/Gemfile.lock b/Gemfile.lockindex b7b9b4f411e..e97c6c46c34 100644--- a/Gemfile.lock+++ b/Gemfile.lock@@ -155,6 +155,11 @@ PATHopenproject-reporting (1.0.0)costs+PATH+ remote: modules/storages+ specs:+ openproject-storages (1.0.0)+PATHremote: modules/team_plannerspecs:@@ -1061,6 +1066,7 @@ DEPENDENCIESopenproject-pdf_export!openproject-recaptcha!openproject-reporting!+ openproject-storages!openproject-team_planner!openproject-token (~> 2.2.0)openproject-two_factor_authentication!diff --git a/Gemfile.modules b/Gemfile.modulesindex fccc77bbe19..743616d2932 100644--- a/Gemfile.modules+++ b/Gemfile.modules@@ -46,6 +46,7 @@ group :opf_plugins dogem 'budgets', path: 'modules/budgets'gem 'openproject-team_planner', path: 'modules/team_planner'gem 'openproject-calendar', path: 'modules/calendar'+ gem 'openproject-storages', path: 'modules/storages'gem 'openproject-bim', path: 'modules/bim'enddiff --git a/config/initializers/menus.rb b/config/initializers/menus.rbindex 970a6e5913c..4eee276cee7 100644--- a/config/initializers/menus.rb+++ b/config/initializers/menus.rb@@ -407,6 +407,12 @@ Redmine::MenuManager.map :admin_menu do |menu|if: Proc.new { User.current.admin? },caption: :label_setting_plural,parent: :admin_backlogs++ menu.push :storages_settings,+ { controller: '/storages/admin/storages', action: :index },+ if: Proc.new { User.current.admin? },+ caption: :project_module_storages,+ icon: 'icon2 icon-hosting'endRedmine::MenuManager.map :project_menu do |menu|@@ -475,7 +481,8 @@ Redmine::MenuManager.map :project_menu do |menu|categories: :label_work_package_category_plural,repository: :label_repository,time_entry_activities: :enumeration_activities,- storage: :label_required_disk_storage+ storage: :label_required_disk_storage,+ storages: :'storages.storage'}.each do |key, caption|menu.push :"settings_#{key}",{ controller: "/projects/settings/#{key}", action: 'show' },diff --git a/db/migrate/20220113144323_create_storage.rb b/db/migrate/20220113144323_create_storage.rbnew file mode 100644index 00000000000..edffc7fa7ca--- /dev/null+++ b/db/migrate/20220113144323_create_storage.rb@@ -0,0 +1,14 @@+class CreateStorage < ActiveRecord::Migration[6.1]+ def change+ create_table :storages do |t|+ t.string :provider_type+ t.string :name+ t.bigint :creator_id, null: false, foreign_key: true+ t.string :identifier, null: false++ t.timestamps++ t.index :identifier+ end+ end+enddiff --git a/db/migrate/20220113144759_create_file_links.rb b/db/migrate/20220113144759_create_file_links.rbnew file mode 100644index 00000000000..2ca0014e67f--- /dev/null+++ b/db/migrate/20220113144759_create_file_links.rb@@ -0,0 +1,18 @@+class CreateFileLinks < ActiveRecord::Migration[6.1]+ def change+ create_table :file_links do |t|+ t.references :storage, foreign_key: true+ t.bigint :creator, null: false, foreign_key: true+ t.bigint :container, null: false, foreign_key: true+ t.string :container_type+ t.string :origin_id+ t.string :origin_name+ t.string :origin_mime_type+ t.timestamp :origin_created_at+ t.timestamp :origin_updated_at+ t.string :origin_last_modified_by_name++ t.timestamps+ end+ end+enddiff --git a/modules/storages/app/cells/storages/row_cell.rb b/modules/storages/app/cells/storages/row_cell.rbnew file mode 100644index 00000000000..240d8ded196--- /dev/null+++ b/modules/storages/app/cells/storages/row_cell.rb@@ -0,0 +1,41 @@+module Storages+ class RowCell < ::RowCell+ include ::IconsHelper+ include ::AvatarHelper+ include ::Redmine::I18n++ def name+ model.name+ end++ def provider_type+ model.provider_type+ end++ def creator+ icon = avatar model.creator, size: :mini+ icon + model.creator.name+ end++ def button_links+ [edit_link, delete_link]+ end++ def delete_link+ link_to '',+ storage_path(model),+ class: 'icon icon-delete',+ data: { confirm: I18n.t(:text_are_you_sure) },+ title: I18n.t(:button_delete),+ method: :delete+ end++ def edit_link+ link_to '',+ edit_storage_path(model),+ class: 'icon icon-edit',+ accesskey: accesskey(:edit),+ title: I18n.t(:button_edit)+ end+ end+enddiff --git a/modules/storages/app/cells/storages/table_cell.rb b/modules/storages/app/cells/storages/table_cell.rbnew file mode 100644index 00000000000..dfade383dcc--- /dev/null+++ b/modules/storages/app/cells/storages/table_cell.rb@@ -0,0 +1,35 @@+module Storages+ class TableCell < ::TableCell+ include ::IconsHelper+ columns :name, :provider_type, :creator, :created_at++ def initial_sort+ %i[created_at asc]+ end++ def sortable?+ false+ end++ def inline_create_link+ link_to(new_storage_path,+ class: 'wp-inline-create--add-link',+ title: I18n.t('storages.label_new_storage')) do+ op_icon('icon icon-add')+ end+ end++ def empty_row_message+ I18n.t 'storages.no_results'+ end++ def headers+ [+ ['name', { caption: Storages::Storage.human_attribute_name(:name) }],+ ['provider_type', { caption: I18n.t('storages.provider_types.label') }],+ ['creator', { caption: I18n.t('storages.label_creator') }],+ ['created_at', { caption: Storages::Storage.human_attribute_name(:created_at) }]+ ]+ end+ end+enddiff --git a/modules/storages/app/controllers/storages/admin/storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages_controller.rbnew file mode 100644index 00000000000..520a704d4c1--- /dev/null+++ b/modules/storages/app/controllers/storages/admin/storages_controller.rb@@ -0,0 +1,83 @@+#-- encoding: UTF-8++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2021 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.+#++++class Storages::Admin::StoragesController < ApplicationController+ layout 'admin'+ before_action :require_admin+ menu_item :storages_settings++ def index+ @storages = Storages::Storage.all+ render 'storages/admin/index'+ end++ def show+ @storage = Storages::Storage.find_by id: params[:id]+ render 'storages/admin/show'+ end++ def new+ @storage = Storages::Storage.new(provider_type: 'nextcloud', name: I18n.t('storages.provider_types.nextcloud'))+ render 'storages/admin/new'+ end++ def create+ combined_params = permitted_storage_params+ .to_h+ .reverse_merge(creator_id: current_user.id)++ @storage = Storages::Storage.create combined_params+ redirect_to storage_path(@storage)+ end++ def update+ # tbd+ end++ def delete+ # tbd+ end++ def default_breadcrumb+ t(:project_module_storages)+ end++ def show_local_breadcrumb+ true+ end++ private++ def permitted_storage_params+ params+ .require(:storages_storage)+ .permit('name', 'provider_type')+ end+enddiff --git a/modules/storages/app/models/storages/file_link.rb b/modules/storages/app/models/storages/file_link.rbnew file mode 100644index 00000000000..a2adef330a1--- /dev/null+++ b/modules/storages/app/models/storages/file_link.rb@@ -0,0 +1,35 @@+#-- encoding: UTF-8++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2021 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.+#++++class Storages::FileLink < ApplicationRecord+ belongs_to :storage+ belongs_to :creator, foreign_key: 'creator_id', class_name: User+ belongs_to :container, foreign_key: 'container_id', class_name: WorkPackage # This needs to become more flexible in the future+enddiff --git a/modules/storages/app/models/storages/storage.rb b/modules/storages/app/models/storages/storage.rbnew file mode 100644index 00000000000..121c9fddc3c--- /dev/null+++ b/modules/storages/app/models/storages/storage.rb@@ -0,0 +1,39 @@+#-- encoding: UTF-8++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2021 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.+#++++class Storages::Storage < ApplicationRecord+ has_many :file_links, class_name: 'Storages::FileLink'+ belongs_to :creator, class_name: 'User'+ has_secure_token :identifier++ PROVIDER_TYPES = %w[nextcloud].freeze++ validates_uniqueness_of :name+enddiff --git a/modules/storages/app/views/storages/admin/_form.html.erb b/modules/storages/app/views/storages/admin/_form.html.erbnew file mode 100644index 00000000000..f1beb786da2--- /dev/null+++ b/modules/storages/app/views/storages/admin/_form.html.erb@@ -0,0 +1,46 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) 2012-2021 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.++++#%>++<%= error_messages_for_contract @storage, @errors %>++<section class="form--section">+ <div class="form--field -required">+ <%= f.select :provider_type,+ Storages::Storage::PROVIDER_TYPES.map { |provider_type| [I18n.t("storages.provider_types.#{provider_type}"), provider_type] },+ selected: 'nextcloud',+ container_class: '-slim' %>+ </div>+ <div class="form--field -required">+ <%= f.text_field :name, required: true, size: 25, container_class: '-slim' %>+ <span class="form--field-instructions">+ <%= t('storages.instructions.name') %>+ </span>+ </div>+</section>+diff --git a/modules/storages/app/views/storages/admin/index.html.erb b/modules/storages/app/views/storages/admin/index.html.erbnew file mode 100644index 00000000000..ce7b7c9fdd2--- /dev/null+++ b/modules/storages/app/views/storages/admin/index.html.erb@@ -0,0 +1,15 @@+<% html_title t(:label_administration), t("project_module_storages") %>++<%= toolbar title: t("project_module_storages") do %>+ <li class="toolbar-item">+ <%= link_to new_storage_path,+ { class: 'button -alt-highlight',+ aria: { label: t(:'storages.label_new_storage') },+ title: t(:'ifc_models.label_new_storage') } do %>+ <%= op_icon('button--icon icon-add') %>+ <span class="button--text"><%= ::Storages::Storage.model_name.human %></span>+ <% end %>+ </li>+<% end %>++<%= rails_cell ::Storages::TableCell, @storages %>\ No newline at end of filediff --git a/modules/storages/app/views/storages/admin/new.html.erb b/modules/storages/app/views/storages/admin/new.html.erbnew file mode 100644index 00000000000..c473093ce73--- /dev/null+++ b/modules/storages/app/views/storages/admin/new.html.erb@@ -0,0 +1,9 @@+<% html_title t(:label_administration), t("project_module_storages") %>+<% local_assigns[:additional_breadcrumb] = t('storages.label_new_storage') %>+<%= toolbar title: t("storages.label_new_storage") %>++<%= labelled_tabular_form_for @storage, url: storages_path(@storage) do |f| -%>+ <%= error_messages_for_contract @storage, @errors %>+ <%= render :partial => 'storages/admin/form', locals: { f: f } %>+ <%= styled_button_tag t(:button_create), class: "-highlight -with-icon icon-checkmark" %>+<% end %>diff --git a/modules/storages/app/views/storages/admin/show.html.erb b/modules/storages/app/views/storages/admin/show.html.erbnew file mode 100644index 00000000000..ee090e979b9--- /dev/null+++ b/modules/storages/app/views/storages/admin/show.html.erb@@ -0,0 +1,59 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) 2012-2021 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('project_module_storages'), t(@storage.name) -%>+<% local_assigns[:additional_breadcrumb] = @storage.name %>++<%= toolbar title: "#{t('project_module_storages')} - #{@storage.name}",+ title_class: 'no-padding-bottom' do %>+ <li class="toolbar-item">+ <%= link_to edit_storage_path(@storage),+ class: 'button' do %>+ <%= op_icon('button--icon icon-edit') %>+ <span class="button--text"><%= t(:button_edit) %></span>+ <% end %>+ </li>+ <li class="toolbar-item">+ <%= link_to storage_path(@storage),+ method: :delete,+ data: { confirm: I18n.t(:text_are_you_sure) },+ class: 'button -danger' do %>+ <%= op_icon('button--icon icon-delete') %>+ <span class="button--text"><%= t(:button_delete) %></span>+ <% end %>+ </li>+<% end %>++<ul>+<li><%= @storage.id %></li>+<li><%= @storage.name %></li>+<li><%= @storage.provider_type %></li>+<li><%= @storage.creator.name %></li>+<li><%= @storage.created_at %></li>+<li><%= @storage.identifier %></li>+</ul>\ No newline at end of filediff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.ymlnew file mode 100644index 00000000000..c94e10d5d2e--- /dev/null+++ b/modules/storages/config/locales/en.yml@@ -0,0 +1,30 @@+# English strings go here+en:+ permission_view_file_links: "View file links"+ permission_manage_file_links: "Manage file links"+ permission_manage_storage_in_project: "Manage file storage in project"+ project_module_storages: "File storages"++ activerecord:+ models:+ storages/storage: "Storage"+ attributes:+ storages/storage:+ name: "Name"+ creator: "Creator"+ provider_type: "Provider type"++ storages:+ instructions:+ name: "Please use a short name. It will get used as a tab title in the work package view."+ label_creator: "Creator"+ label_file_link: "File link"+ label_file_links: "File links"+ label_name: "Name"+ label_new_storage: "New storage"+ label_storage: "Storage"+ label_storages: "Storages"+ no_results: "No storage setup, yet."+ provider_types:+ label: "Provider type"+ nextcloud: "Nextcloud"diff --git a/modules/storages/config/locales/js-en.yml b/modules/storages/config/locales/js-en.ymlnew file mode 100644index 00000000000..b8aff290128--- /dev/null+++ b/modules/storages/config/locales/js-en.yml@@ -0,0 +1,4 @@+# English strings go here+en:+ js:+ storages:\ No newline at end of filediff --git a/modules/storages/config/routes.rb b/modules/storages/config/routes.rbnew file mode 100644index 00000000000..e35676948c9--- /dev/null+++ b/modules/storages/config/routes.rb@@ -0,0 +1,5 @@+OpenProject::Application.routes.draw do+ scope 'admin/settings' do+ resources :storages, controller: 'storages/admin/storages'+ end+enddiff --git a/modules/storages/lib/open_project/storages.rb b/modules/storages/lib/open_project/storages.rbnew file mode 100644index 00000000000..7ddc63563e2--- /dev/null+++ b/modules/storages/lib/open_project/storages.rb@@ -0,0 +1,33 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2021 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+ module Storages+ require 'open_project/storages/engine'+ end+enddiff --git a/modules/storages/lib/open_project/storages/engine.rb b/modules/storages/lib/open_project/storages/engine.rbnew file mode 100644index 00000000000..0d8e424aaf4--- /dev/null+++ b/modules/storages/lib/open_project/storages/engine.rb@@ -0,0 +1,49 @@+# OpenProject Team Planner module+#+# Copyright (C) 2021 OpenProject GmbH+#+# 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.++module OpenProject::Storages+ class Engine < ::Rails::Engine+ engine_name :openproject_storages++ include OpenProject::Plugins::ActsAsOpEngine++ register 'openproject-storages',+ author_url: 'https://www.openproject.org',+ bundled: true,+ settings: {},+ name: 'OpenProject Storages' do+ project_module :storages, dependencies: :work_package_tracking do+ permission :view_file_links,+ {},+ dependencies: %i[view_work_packages]+ permission :manage_file_links,+ {},+ dependencies: %i[view_file_links]+ permission :manage_storage_in_project,+ {},+ dependencies: %i[select_project_modules]+ end++ # Menu extensions+ menu :project_menu,+ :storages,+ { controller: '/storages/storages', action: 'index' },+ caption: :'storages.label_storage'+ end+ end+enddiff --git a/modules/storages/lib/openproject-storages.rb b/modules/storages/lib/openproject-storages.rbnew file mode 100644index 00000000000..8c1dd3f9db1--- /dev/null+++ b/modules/storages/lib/openproject-storages.rb@@ -0,0 +1 @@+require 'open_project/storages'diff --git a/modules/storages/openproject-storages.gemspec b/modules/storages/openproject-storages.gemspecnew file mode 100644index 00000000000..13cf6236263--- /dev/null+++ b/modules/storages/openproject-storages.gemspec@@ -0,0 +1,13 @@+# encoding: UTF-8++Gem::Specification.new do |s|+ s.name = 'openproject-storages'+ s.version = '1.0.0'+ s.authors = 'OpenProject GmbH'+ s.email = '[email protected]'+ s.summary = 'OpenProject Storages'+ s.description = 'Allows linking work packages to files in external storages, such as Nextcloud.'+ s.license = 'GPLv3'++ s.files = Dir['{app,config,db,lib}/**/*']+enddiff --git a/modules/storages/spec/contracts/views/create_contract_file_link_spec.rb b/modules/storages/spec/contracts/views/create_contract_file_link_spec.rbnew file mode 100644index 00000000000..34dba0586de--- /dev/null+++ b/modules/storages/spec/contracts/views/create_contract_file_link_spec.rb@@ -0,0 +1,68 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2021 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.+#++++require 'spec_helper'+require 'contracts/shared/model_contract_shared_context'+require 'contracts/views/shared_contract_examples'++describe Views::CreateContract do+ # it_behaves_like 'view contract', true do+ # let(:view) do+ # View.new(query: view_query,+ # type: view_type)+ # end+ # let(:view_type) do+ # 'team_planner'+ # end+ # let(:permissions) { %i[view_work_packages save_queries manage_team_planner] }+ #+ # subject(:contract) do+ # described_class.new(view, current_user)+ # end+ #+ # describe 'validation' do+ # context 'with the type being nil' do+ # let(:view_type) { nil }+ #+ # it_behaves_like 'contract is invalid', type: :inclusion+ # end+ #+ # context 'with the type not being one of the configured' do+ # let(:view_type) { 'blubs' }+ #+ # it_behaves_like 'contract is invalid', type: :inclusion+ # end+ #+ # context 'without the :manage_team_planner permission' do+ # let(:permissions) { %i[view_work_packages save_queries] }+ #+ # it_behaves_like 'contract is invalid', base: :error_unauthorized+ # end+ # end+ # end+enddiff --git a/modules/storages/spec/features/shared_context.rb b/modules/storages/spec/features/shared_context.rbnew file mode 100644index 00000000000..a67ebde2cf1--- /dev/null+++ b/modules/storages/spec/features/shared_context.rb@@ -0,0 +1,36 @@+#-- encoding: UTF-8++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2021 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.+#++++require 'spec_helper'+require_relative '../support/pages/storage_tab'++shared_context 'with storages full access' do+ current_user { user }+enddiff --git a/modules/storages/spec/permissions/manage_storage_in_project_spec.rb b/modules/storages/spec/permissions/manage_storage_in_project_spec.rbnew file mode 100644index 00000000000..18b6e4ded0f--- /dev/null+++ b/modules/storages/spec/permissions/manage_storage_in_project_spec.rb@@ -0,0 +1,36 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2021 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.+#++++require 'spec_helper'+require 'support/permission_specs'++# describe Storages::BlaBlaController, 'manage_storage_in_proejct permission', type: :controller do+# include PermissionSpecs+#+# check_permission_required_for('team_planner/team_planner#index', :view_team_planner)+# enddiff --git a/modules/storages/spec/requests/api/v3/views/create_resource_spec.rb b/modules/storages/spec/requests/api/v3/views/create_resource_spec.rbnew file mode 100644index 00000000000..739483ab4cd--- /dev/null+++ b/modules/storages/spec/requests/api/v3/views/create_resource_spec.rb@@ -0,0 +1,104 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2020 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.++require 'spec_helper'++describe ::API::V3::Views::ViewsAPI,+ 'create',+ content_type: :json,+ type: :request do+ # include API::V3::Utilities::PathHelper+ #+ # shared_let(:permitted_user) { FactoryBot.create(:user) }+ # shared_let(:role) do+ # FactoryBot.create(:role,+ # permissions: %w[view_work_packages+ # view_file_links])+ # end+ # shared_let(:project) do+ # FactoryBot.create(:project,+ # members: { permitted_user => role })+ # end+ #+ # let(:additional_setup) do+ # # to be overwritten by some specs+ # end+ #+ # let(:body) do+ # {+ # _links: {+ # query: {+ # href: api_v3_paths.query(public_query.id)+ # }+ # }+ # }.to_json+ # end+ #+ # let(:send_request) do+ # post api_v3_paths.views_type('team_planner'), body+ # end+ #+ # current_user { permitted_user }+ #+ # subject(:response) { last_response }+ #+ # before do+ # additional_setup+ #+ # send_request+ # end+ #+ # describe 'POST /api/v3/views/team_planner' do+ # context 'with a user allowed to save the query' do+ # it 'returns 201 CREATED' do+ # expect(response.status)+ # .to eq(201)+ # end+ #+ # it 'returns the view' do+ # expect(response.body)+ # .to be_json_eql('Views::TeamPlanner'.to_json)+ # .at_path('_type')+ #+ # expect(response.body)+ # .to be_json_eql(View.last.id.to_json)+ # .at_path('id')+ # end+ # end+ #+ # context 'with a user not allowed to manage team planners' do+ # let(:additional_setup) do+ # role.update_attribute(:permissions,+ # %w[view_work_packages+ # save_queries+ # manage_public_queries])+ # end+ #+ # it_behaves_like 'unauthorized access'+ # end+ # end+enddiff --git a/modules/storages/spec/routing/storages_routing_spec.rb b/modules/storages/spec/routing/storages_routing_spec.rbnew file mode 100644index 00000000000..6f9402e09f3--- /dev/null+++ b/modules/storages/spec/routing/storages_routing_spec.rb@@ -0,0 +1,37 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2021 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.+#++++require 'spec_helper'++describe 'Storages routing', type: :routing do+ # it 'routes to team_planner#index' do+ # expect(subject)+ # .to route(:get, '/projects/foobar/team_planner/state')+ # .to(controller: 'team_planner/team_planner', action: 'index', project_id: 'foobar', state: 'state')+ # end+enddiff --git a/modules/storages/spec/support/pages/storage_tab.rb b/modules/storages/spec/support/pages/storage_tab.rbnew file mode 100644index 00000000000..92e3517b85a--- /dev/null+++ b/modules/storages/spec/support/pages/storage_tab.rb@@ -0,0 +1,126 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2021 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.+#++++require 'support/pages/page'++module Pages+ class StorageTab < ::Pages::Page+ # attr_reader :project+ #+ # def initialize(project)+ # super()+ #+ # @project = project+ # end+ #+ # def path+ # project_team_planner_path(project)+ # end+ #+ # def expect_title(title = 'Unnamed team planner')+ # expect(page).to have_selector '.editable-toolbar-title--fixed', text: title+ # end+ #+ # def expect_empty_state(present: true)+ # expect(page).to have_conditional_selector(present, '.op-team-planner--no-data', text: 'Add assignees to set up your team planner.')+ # end+ #+ # def expect_assignee(user, present: true)+ # name = user.is_a?(User) ? user.name : user.to_s+ # expect(page).to have_conditional_selector(present, '.fc-resource', text: name, wait: 10)+ # end+ #+ # def add_item(assignee, start_date, end_date)+ # script = <<~JS+ # var event = new CustomEvent(+ # 'teamPlannerSelectDate',+ # {+ # detail: {+ # assignee: arguments[0],+ # start: arguments[1],+ # end: arguments[2]+ # }+ # });+ #+ # document.dispatchEvent(event);+ # JS+ #+ # page.execute_script(script, assignee, start_date, end_date)+ # ::Pages::SplitWorkPackageCreate.new project: project+ # end+ #+ # def remove_assignee(user)+ # page.find(%([data-qa-remove-assignee="#{user.id}"])).click+ # end+ #+ # def within_lane(user, &block)+ # raise ArgumentError.new("Expected instance of principal") unless user.is_a?(Principal)+ #+ # type = ::API::V3::Principals::PrincipalType.for(user)+ # href = ::API::V3::Utilities::PathHelper::ApiV3Path.send(type, user.id)+ #+ # page.within(%(.fc-timeline-lane[data-resource-id="#{href}"]), &block)+ # end+ #+ # def expect_event(work_package, present: true)+ # expect(page).to have_conditional_selector(present, '.fc-event', text: work_package.subject)+ # end+ #+ # def open_split_view(work_package)+ # page+ # .find('.fc-event', text: work_package.subject)+ # .click+ #+ # ::Pages::SplitWorkPackage.new(work_package, project)+ # end+ #+ # def add_assignee(name)+ # click_add_user+ # search_user_to_add name+ # select_user_to_add name+ # end+ #+ # def click_add_user+ # # Close the existing, if it is open+ # is_open = page.all('[data-qa-selector="tp-add-assignee"] input').first+ # page.find('[data-qa-selector="tp-assignee-add-button"]').click unless is_open+ # end+ #+ # def select_user_to_add(name)+ # select_autocomplete page.find('[data-qa-selector="tp-add-assignee"]'),+ # query: name,+ # results_selector: 'body'+ # end+ #+ # def search_user_to_add(name)+ # search_autocomplete page.find('[data-qa-selector="tp-add-assignee"]'),+ # query: name,+ # results_selector: 'body'+ # end+ # end+end