Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Project < ApplicationRecord
include Projects::Versions
include Projects::WorkPackageCustomFields
include Projects::CreationWizard
include Projects::SprintSharing

include ::Scopes::Scoped

Expand Down
49 changes: 49 additions & 0 deletions app/models/projects/sprint_sharing.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 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 Projects::SprintSharing
SPRINT_SHARING_OPTIONS = %w[share_all_projects share_subprojects no_sharing receive_shared].freeze

extend ActiveSupport::Concern

included do
store_attribute :settings, :sprint_sharing, :string

# TODO: Change the store_attribute_unset_values_fallback_to_default to true in the
# config/initializers/store_attribute.rb.
# Otherwise defaults set on the setting declaration are not working correctly:
# `store_attribute :settings, :sprint_sharing, :string, default: "no_sharing"`.
# The method getter override below is required to provide the default value.

def sprint_sharing
super.presence || "no_sharing"
end
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { toggleElement, toggleElementByVisibility } from 'core-app/shared/helpers/dom-helpers';
import { toggleElement, toggleElementByClass, toggleElementByVisibility } from 'core-app/shared/helpers/dom-helpers';
import { ApplicationController } from 'stimulus-use';

export default class OpShowWhenValueSelectedController extends ApplicationController {
Expand Down Expand Up @@ -29,6 +29,8 @@ export default class OpShowWhenValueSelectedController extends ApplicationContro

if (el.dataset.setVisibility === 'true') {
toggleElementByVisibility(el, !disabled);
} else if ('visibilityClass' in el.dataset) {
toggleElementByClass(el, el.dataset.visibilityClass!, !disabled);
} else {
toggleElement(el, !disabled);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<%#-- copyright
OpenProject is an open source project management software.
Copyright (C) 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.

++#%>

<%=
render Primer::OpenProject::PageHeader.new do |header|
header.with_title { t(:label_backlogs) }
header.with_breadcrumbs(
[{ href: project_overview_path(project), text: project.name },
{ href: project_settings_general_path(project), text: I18n.t(:label_project_settings) },
I18n.t(:label_backlogs)]
)

header.with_tab_nav(label: nil) do |tab_nav|
tab_nav.with_tab(
selected: selected_tab == :done_status,
href: project_settings_backlogs_path(project)
) do |t|
t.with_text { t("backlogs.done_status") }
end

if User.current.allowed_in_project?(:share_sprint, project)
tab_nav.with_tab(
selected: selected_tab == :sharing,
href: project_settings_backlog_sharing_path(project)
) do |t|
t.with_text { t("backlogs.sharing") }
end
end
end
end
%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 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 Projects
module Settings
module Backlogs
class SettingsHeaderComponent < ApplicationComponent
include OpPrimer::ComponentHelpers

def initialize(project:, selected_tab:)
super

@project = project
@selected_tab = selected_tab
end

private

attr_reader :project, :selected_tab
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<%#-- copyright
OpenProject is an open source project management software.
Copyright (C) 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.

++#%>

<%=
render(Primer::Beta::Text.new(tag: :div, color: :muted, mb: 3)) do
I18n.t("backlogs.sharing_description")
end
%>

<%=
settings_primer_form_with(
model: project,
url: project_settings_backlog_sharing_path(project),
method: :patch,
data: { controller: "show-when-value-selected" }
) do |f|
render(Projects::Settings::Backlogs::SharingForm.new(f))
end
%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 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 Projects
module Settings
module Backlogs
class SharingFormComponent < ApplicationComponent
include ApplicationHelper
include OpPrimer::ComponentHelpers

def initialize(project:)
super

@project = project
end

private

attr_reader :project
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 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 Projects
class BacklogSettingsContract < ::BaseContract
attribute :sprint_sharing

validate :validate_permissions
validates :sprint_sharing, presence: true
validates :sprint_sharing, inclusion: { in: Project::SPRINT_SHARING_OPTIONS }, allow_blank: true

protected

def validate_permissions
unless user.allowed_in_project?(:share_sprint, model)
errors.add :base, :error_unauthorized
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 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 Projects::Settings::BacklogSharingsController < Projects::SettingsController
menu_item :settings_backlogs

def show; end

def update
call = Projects::UpdateService
.new(model: @project, user: current_user, contract_class: Projects::BacklogSettingsContract)
.call(backlog_settings_params)

if call.success?
flash[:notice] = I18n.t(:notice_successful_update)
redirect_to project_settings_backlog_sharing_path(@project)
else
flash.now[:error] = I18n.t(:notice_unsuccessful_update_with_reason, reason: call.message)
render action: :show, status: :unprocessable_entity
end
end

private

def backlog_settings_params
params.expect(project: %i[sprint_sharing])
end
end
Loading
Loading