Skip to content

Commit

Permalink
Merge branch 'release/15.0' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
openprojectci committed Nov 9, 2024
2 parents f42f640 + 8729517 commit bc24a90
Show file tree
Hide file tree
Showing 104 changed files with 974 additions and 470 deletions.
2 changes: 1 addition & 1 deletion app/components/activities/item_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ See COPYRIGHT and LICENSE files for more details.
<li class="op-activity-list--item-detail"><%= detail %></li>
<% end -%>
<% if time_entry_url.present? -%>
<li class="op-activity-list--item-detail"><%= link_to "Details", @event.event_url %></li>
<li class="op-activity-list--item-detail"><%= link_to I18n.t(:label_details), @event.event_url %></li>
<% end -%>
</ul>
<% elsif noop? -%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,17 @@ class IndexComponent < ApplicationComponent
include OpPrimer::ComponentHelpers
include OpTurbo::Streamable

def initialize(work_package:, filter: :all)
def initialize(work_package:, last_server_timestamp:, filter: :all)
super

@work_package = work_package
@filter = filter
@last_server_timestamp = last_server_timestamp
end

private

attr_reader :work_package, :filter
attr_reader :work_package, :filter, :last_server_timestamp

def wrapper_data_attributes
{
Expand All @@ -59,7 +60,8 @@ def wrapper_data_attributes
"work-packages--activities-tab--index-user-id-value": User.current.id,
"work-packages--activities-tab--index-work-package-id-value": work_package.id,
"work-packages--activities-tab--index-polling-interval-in-ms-value": polling_interval,
"work-packages--activities-tab--index-notification-center-path-name-value": notifications_path
"work-packages--activities-tab--index-notification-center-path-name-value": notifications_path,
"work-packages--activities-tab--index-last-server-timestamp-value": last_server_timestamp
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ def journal_sorting_desc?
end

def journals
work_package.journals.includes(:user, :notifications).reorder(version: journal_sorting)
work_package
.journals
.includes(:user, :notifications)
.reorder(version: journal_sorting)
.with_sequence_version
end

def journal_with_notes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
if show_comment_container?
journal_container.with_row do
render(border_box_container(
id: "activity-anchor-#{journal.version}",
id: "activity-anchor-#{journal.sequence_version}",
padding: :condensed,
"aria-label": I18n.t("activities.work_packages.activity_tab.commented")
)) do |border_box_component|
Expand Down Expand Up @@ -52,10 +52,10 @@
data: {
turbo: false,
action: "click->work-packages--activities-tab--index#setAnchor:prevent",
"work-packages--activities-tab--index-id-param": journal.version
"work-packages--activities-tab--index-id-param": journal.sequence_version
}
)) do
"##{journal.version}"
"##{journal.sequence_version}"
end
end
header_end_container.with_column(ml: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def activity_url
end

def activity_anchor
"#activity-#{journal.version}"
"#activity-#{journal.sequence_version}"
end

def updated?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<%=
component_wrapper(class: "work-packages-activities-tab-journals-item-component-details") do
flex_layout(my: 0, border: :left, classes: "work-packages-activities-tab-journals-item-component-details--journal-details-container") do |details_container|
flex_layout(
my: 0,
border: :left,
classes: "work-packages-activities-tab-journals-item-component-details--journal-details-container",
data: { initial: journal.initial? }
) do |details_container|
case filter
when :only_comments
render_empty_line(details_container) unless journal.notes.blank? && !journal.noop?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def render_details_header(details_container)
flex_layout: true,
justify_content: :space_between,
classes: "work-packages-activities-tab-journals-item-component-details--journal-details-header-container",
id: "activity-anchor-#{journal.version}"
id: "activity-anchor-#{journal.sequence_version}"
) do |header_container|
render_header_start(header_container)
render_header_end(header_container)
Expand Down Expand Up @@ -192,9 +192,9 @@ def render_activity_link(container)
underline: false,
font_size: :small,
data: { turbo: false, action: "click->work-packages--activities-tab--index#setAnchor:prevent",
"work-packages--activities-tab--index-id-param": journal.version }
"work-packages--activities-tab--index-id-param": journal.sequence_version }
)) do
"##{journal.version}"
"##{journal.sequence_version}"
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
&--journal-details-container
margin-left: 19px
min-height: 20px
// applied by the stimulus controller in specific UI states
&--border-removed
border-left: none!important
&--hidden
display: none!important
&--journal-details-container--empty--last--asc
display: none!important
&--journal-details-header-container
Expand Down
42 changes: 26 additions & 16 deletions app/controllers/work_packages/activities_tab_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,25 @@ def index
render(
WorkPackages::ActivitiesTab::IndexComponent.new(
work_package: @work_package,
filter: @filter
filter: @filter,
last_server_timestamp: get_current_server_timestamp
),
layout: false
)
end

def update_streams
set_last_server_timestamp_to_headers

perform_update_streams_from_last_update_timestamp

respond_with_turbo_streams
end

def update_filter
update_via_turbo_stream(
component: WorkPackages::ActivitiesTab::Journals::FilterAndSortingComponent.new(
work_package: @work_package,
filter: @filter
)
)
update_via_turbo_stream(
component: WorkPackages::ActivitiesTab::Journals::IndexComponent.new(
work_package: @work_package,
filter: @filter
)
)
# update the whole tab to reflect the new filtering in all components
# we need to call replace in order to properly re-init the index stimulus component
replace_whole_tab

respond_with_turbo_streams
end
Expand Down Expand Up @@ -115,6 +109,7 @@ def create
call = create_journal_service_call

if call.success? && call.result
set_last_server_timestamp_to_headers
handle_successful_create_call(call)
else
handle_failed_create_call(call) # errors should be rendered in the form
Expand Down Expand Up @@ -213,7 +208,9 @@ def find_project
end

def find_journal
@journal = Journal.find(params[:id])
@journal = Journal
.with_sequence_version
.find(params[:id])
rescue ActiveRecord::RecordNotFound
respond_with_error(I18n.t("label_not_found"))
end
Expand Down Expand Up @@ -284,7 +281,8 @@ def replace_whole_tab
replace_via_turbo_stream(
component: WorkPackages::ActivitiesTab::IndexComponent.new(
work_package: @work_package,
filter: @filter
filter: @filter,
last_server_timestamp: get_current_server_timestamp
)
)
end
Expand All @@ -309,7 +307,9 @@ def create_journal_service_call
end

def generate_time_based_update_streams(last_update_timestamp)
journals = @work_package.journals
journals = @work_package
.journals
.with_sequence_version

if @filter == :only_comments
journals = journals.where.not(notes: "")
Expand Down Expand Up @@ -427,4 +427,14 @@ def grouped_emoji_reactions_for_journal
def allowed_to_edit?(journal)
journal.editable_by?(User.current)
end

def get_current_server_timestamp
# single source of truth for the server timestamp format
Time.current.iso8601(3)
end

def set_last_server_timestamp_to_headers
# Add server timestamp to response in order to let the client be in sync with the server
response.headers["X-Server-Timestamp"] = get_current_server_timestamp
end
end
4 changes: 4 additions & 0 deletions app/models/journal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ class Journal < ApplicationRecord

has_many :notifications, dependent: :destroy

include ::Scopes::Scoped

scopes :with_sequence_version

# Scopes to all journals excluding the initial journal - useful for change
# logs like the history on issue#show
scope :changing, -> { where(["version > 1"]) }
Expand Down
55 changes: 55 additions & 0 deletions app/models/journals/scopes/with_sequence_version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2010-2024 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 Journals::Scopes
module WithSequenceVersion
extend ActiveSupport::Concern

class_methods do
def with_sequence_version
joins(
<<~SQL.squish
JOIN LATERAL (
SELECT
journals_rank.id,
ROW_NUMBER() OVER (ORDER BY version ASC) sequence_version
FROM
journals journals_rank
WHERE
journals_rank.journable_id = journals.journable_id
AND
journals_rank.journable_type = journals.journable_type
) ranked
ON ranked.id = journals.id
SQL
)
.select("*")
end
end
end
end
2 changes: 1 addition & 1 deletion docs/development/development-environment/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ Once the keycloak service is started and running, you can access the keycloak in
and login with initial username and password as `admin`.

Keycloak being an OpenID connect provider, we need to setup an OIDC integration for OpenProject.
[Setup OIDC (keycloak) integration for OpenProject](../../../installation-and-operations/misc/custom-openid-connect-providers/#keycloak)
[Setup OIDC (keycloak) integration for OpenProject](../../../system-admin-guide/authentication/openid-providers/)

Once the above setup is completed, In the root `docker-compose.override.yml` file, uncomment all the environment in `backend` service for keycloak and set the values according to configuration done in keycloak for OpenProject Integration.

Expand Down
Loading

0 comments on commit bc24a90

Please sign in to comment.