Skip to content

Commit

Permalink
Address CR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dombesz committed Dec 17, 2024
1 parent 7aee3c1 commit a96fdd1
Show file tree
Hide file tree
Showing 18 changed files with 141 additions and 31 deletions.
4 changes: 2 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1235,12 +1235,12 @@ en:
type:
type_and_class_name_mismatch: "must be a Project::Gate"
date:
non_continuous_dates: "cant be earlier than the previous %{step}'s end date."
non_continuous_dates: "can't be earlier than the previous %{step}'s end date."
project/stage:
attributes:
date_range:
start_date_must_be_before_end_date: "start date must be before the end date."
non_continuous_dates: "cant be earlier than the previous %{step}'s end date."
non_continuous_dates: "can't be earlier than the previous %{step}'s end date."
incomplete: "is incomplete."
type:
type_and_class_name_mismatch: "must be a Project::Stage"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/turbo/turbo-global-listeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function addTurboGlobalListeners() {
const element = event.target as HTMLElement;

// In case the element is an OpenProject custom dom element, morphing is prevented.
if (element.tagName.startsWith('OPCE-')) {
if (element.tagName.toUpperCase().startsWith('OPCE-')) {
event.preventDefault();
}
});
Expand Down
29 changes: 29 additions & 0 deletions lib/primer/open_project/forms/date_picker.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
<%#-- 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(FormControl.new(input: @input, tag: :"primer-datepicker-field")) do %>
<%= content_tag(:div, **@field_wrap_arguments) do %>
<%# leading spinner implies a leading visual %>
Expand Down
28 changes: 28 additions & 0 deletions lib/primer/open_project/forms/date_picker.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# 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 Primer
module OpenProject
module Forms
Expand Down
28 changes: 28 additions & 0 deletions lib/primer/open_project/forms/dsl/range_date_picker_input.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# 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 Primer
module OpenProject
module Forms
Expand Down
28 changes: 28 additions & 0 deletions lib/primer/open_project/forms/dsl/single_date_picker_input.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# 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 Primer
module OpenProject
module Forms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ class EditComponent < ApplicationComponent
include ApplicationHelper
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers

def life_cycle_steps
model.life_cycle_steps.active.eager_load(:definition).order(position: :asc)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%=
render(Primer::Alpha::Dialog.new(title: t("label_life_cycle_step_plural"),
size: :large,
id: "edit-project-life-cycles-dialog")) do |d|
id: dialog_id)) do |d|
d.with_header(variant: :large)
d.with_body(classes: "Overlay-body_autocomplete_height") do
render(::ProjectLifeCycles::Sections::EditComponent.new(model))
Expand All @@ -10,7 +10,7 @@
component_collection do |footer_collection|
footer_collection.with_component(Primer::ButtonComponent.new(
data: {
'close-dialog-id': "edit-project-life-cycles-dialog"
"close-dialog-id": dialog_id
}
)) do
t("button_cancel")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class EditDialogComponent < ApplicationComponent
include ApplicationHelper
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers

def dialog_id
"edit-project-life-cycles-dialog"
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,14 @@ def not_set?
end

def render_value
case model
when Project::Gate
render(Primer::Beta::Text.new) do
concat helpers.format_date(model.date)
end
when Project::Stage
render(Primer::Beta::Text.new) do
concat [
helpers.format_date(model.start_date),
helpers.format_date(model.end_date)
].join(" - ")
end
render(Primer::Beta::Text.new) do
concat [
model.start_date,
model.end_date
]
.compact
.map { |d| helpers.format_date(d) }
.join(" - ")
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

flex_layout do |details_container|
@life_cycle_steps.each_with_index do |life_cycle_step, i|
margin = i == @life_cycle_steps.size - 1 ? 0 : 3
margin = i == @life_cycle_steps.size - 1 ? 0 : 3
details_container.with_row(mb: margin) do
render(ProjectLifeCycles::Sections::ProjectLifeCycles::ShowComponent.new(
life_cycle_step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def initialize(project:)
super

@project = project
@life_cycle_steps =
@project.life_cycle_steps.active.eager_load(:definition).order(position: :asc)
@life_cycle_steps = @project.available_life_cycle_steps
end

private
Expand Down
3 changes: 1 addition & 2 deletions modules/overviews/lib/overviews/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ class Engine < ::Rails::Engine
OpenProject::AccessControl.permission(:view_project)
.controller_actions
.push(
"overviews/overviews/show",
"overviews/overviews/project_life_cycles_sidebar"
"overviews/overviews/show"
)

OpenProject::AccessControl.permission(:view_project_attributes)
Expand Down
4 changes: 2 additions & 2 deletions spec/contracts/project_life_cycle_steps/base_contract_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
let(:contract) { described_class.new(project, user) }
let(:project) { build_stubbed(:project) }

context "with authorised user" do
context "with authorized user" do
let(:user) { build_stubbed(:user) }
let(:project) { build_stubbed(:project, available_life_cycle_steps: steps) }
let(:steps) { [] }
Expand Down Expand Up @@ -145,7 +145,7 @@
end
end

context "with unauthorised user" do
context "with unauthorized user" do
let(:user) { build_stubbed(:user) }

it_behaves_like "contract user is unauthorized"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
expect(page).to have_text("Project lifecycle")
end
end
end

describe "with Edit project permissions" do
let(:permissions) { [:view_project, :view_project_stages_and_gates, :edit_project] }

Check notice on line 66 in spec/features/projects/life_cycle/overview_page/dialog/permission_spec.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] spec/features/projects/life_cycle/overview_page/dialog/permission_spec.rb#L66 <Style/SymbolArray>

Use `%i` or `%I` for an array of symbols.
Raw output
spec/features/projects/life_cycle/overview_page/dialog/permission_spec.rb:66:25: C: Style/SymbolArray: Use `%i` or `%I` for an array of symbols.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

RSpec.describe "Edit project custom fields on project overview page", :js do
include_context "with seeded projects, members and project custom fields"

let(:overview_page) { Pages::Projects::Show.new(project) }

describe "with insufficient View attributes permissions" do
Expand Down
3 changes: 3 additions & 0 deletions spec/models/project/stage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@
.and_return([])

expect(subject.working_days_count).to eq(0)

expect(Day).to have_received(:working).with(no_args)
expect(Day).to have_received(:from_range).with(from: subject.start_date, to: subject.end_date)
end
end
end
4 changes: 2 additions & 2 deletions spec/support/pages/projects/show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ def visit_page

def expect_no_visible_sidebar
expect_angular_frontend_initialized
expect(page).to have_no_css(".op-grid-page--grid-container")
expect(page).to have_no_css(".op-grid-page--sidebar")
end

def expect_visible_sidebar
expect_angular_frontend_initialized
expect(page).to have_css(".op-grid-page--grid-container")
expect(page).to have_css(".op-grid-page--sidebar")
end

def within_project_attributes_sidebar(&)
Expand Down

0 comments on commit a96fdd1

Please sign in to comment.