Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into task/48717-replace-del…
Browse files Browse the repository at this point in the history
…ayedjob
  • Loading branch information
ba1ash committed Feb 27, 2024
2 parents 2267a0a + 47b5cc8 commit e054adb
Show file tree
Hide file tree
Showing 88 changed files with 8,654 additions and 135 deletions.
11 changes: 5 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,10 @@ GEM
activerecord (>= 4.0.0, < 7.2)
aws-eventstream (1.3.0)
aws-partitions (1.894.0)
aws-sdk-core (3.191.2)
aws-sdk-core (3.191.3)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
base64
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.77.0)
aws-sdk-core (~> 3, >= 3.191.0)
Expand Down Expand Up @@ -566,16 +565,16 @@ GEM
fugit (>= 1.1)
railties (>= 6.0.0)
thor (>= 0.14.1)
google-apis-core (0.13.0)
google-apis-core (0.14.0)
addressable (~> 2.5, >= 2.5.1)
googleauth (~> 1.9)
httpclient (>= 2.8.1, < 3.a)
mini_mime (~> 1.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
rexml
google-apis-gmail_v1 (0.38.0)
google-apis-core (>= 0.12.0, < 2.a)
google-apis-gmail_v1 (0.39.0)
google-apis-core (>= 0.14.0, < 2.a)
google-cloud-env (2.1.1)
faraday (>= 1.0, < 3.a)
googleauth (1.11.0)
Expand Down Expand Up @@ -663,7 +662,7 @@ GEM
language_server-protocol (3.17.0.3)
launchy (2.5.2)
addressable (~> 2.8)
lefthook (1.6.1)
lefthook (1.6.3)
letter_opener (1.9.0)
launchy (>= 2.2, < 3)
listen (3.8.0)
Expand Down
4 changes: 3 additions & 1 deletion app/components/application_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def initialize(model = nil, **options)
@options = options
end

delegate :url_helpers, to: 'Rails.application.routes'
def url_helpers
@url_helpers ||= OpenProject::StaticRouting::StaticUrlHelpers.new
end

class << self
##
Expand Down
4 changes: 4 additions & 0 deletions app/models/user_preference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ def theme
super.presence || Setting.user_default_theme
end

def high_contrast_theme?
theme.end_with?('high_contrast')
end

def time_zone
super.presence || Setting.user_default_timezone.presence
end
Expand Down
48 changes: 38 additions & 10 deletions app/services/copy/concerns/copy_attachments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,36 @@ module Concerns
module CopyAttachments
##
# Tries to copy the given attachment between containers
def copy_attachments(container_type, from_id:, to_id:)
def copy_attachments(container_type, from:, to:, references: [])
Attachment
.where(container_type:, container_id: from_id)
.where(container_type:, container_id: from.id)
.find_each do |source|
copy = Attachment
.new(attachment_copy_attributes(source, to_id))
source.file.copy_to(copy)
copy_attachment(from:, to:, references:, source:)
end

if to.changed? && !to.save
Rails.logger.error { "Failed to update copied attachment references in to #{to}: #{to.errors.full_messages}" }
end
end

def copy_attachment(source:, from:, to:, references:)
copy = Attachment
.new(attachment_copy_attributes(source, to.id))
source.file.copy_to(copy)

unless copy.save
Rails.logger.error { "Attachments ##{source.id} could not be copy: #{copy.errors.full_messages} " }
end
rescue StandardError => e
Rails.logger.error { "Failed to copy attachments from ##{from_id} to ##{to_id}: #{e}" }
if copy.save
update_references(
attachment_source: source.id,
attachment_target: copy.id,
model_source: from,
model_target: to,
references:
)
else
Rails.logger.error { "Attachments ##{source.id} could not be copy: #{copy.errors.full_messages} " }
end
rescue StandardError => e
Rails.logger.error { "Failed to copy attachments from #{from} to #{to}: #{e}" }
end

def attachment_copy_attributes(source, to_id)
Expand All @@ -27,6 +43,18 @@ def attachment_copy_attributes(source, to_id)
.merge('author_id' => user.id,
'container_id' => to_id)
end

def update_references(attachment_source:, attachment_target:, model_source:, model_target:, references:)
references.each do |reference|
text = model_source.send(reference)
next if text.nil?

replaced = text.gsub("/api/v3/attachments/#{attachment_source}/content",
"/api/v3/attachments/#{attachment_target}/content")

model_target.send(:"#{reference}=", replaced)
end
end
end
end
end
7 changes: 6 additions & 1 deletion app/services/wiki_pages/copy_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ def writable_attributes
end

def copy_wiki_page_attachments(copy)
copy_attachments('WikiPage', from_id: model.id, to_id: copy.id)
copy_attachments(
'WikiPage',
from: model,
to: copy,
references: %i[text]
)
end
end
7 changes: 6 additions & 1 deletion app/services/work_packages/copy_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ def copy_watchers(copied)
end

def copy_work_package_attachments(copy)
copy_attachments('WorkPackage', from_id: work_package.id, to_id: copy.id)
copy_attachments(
'WorkPackage',
from: work_package,
to: copy,
references: %i[description]
)
end
end
26 changes: 16 additions & 10 deletions app/views/custom_styles/_inline_css_logo.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,25 @@ See COPYRIGHT and LICENSE files for more details.

<% cache(CustomStyle.current) do %>
<style type="text/css">
<% logo_url = asset_path("logo_openproject_white_big.png") %>
<% if apply_custom_styles? %>
<%
if CustomStyle.current.logo.present?
logo_url = custom_style_logo_path(digest: CustomStyle.current.digest, filename: CustomStyle.current.logo_identifier)
elsif CustomStyle.current.theme_logo.present?
logo_url = asset_path(CustomStyle.current.theme_logo)
end
%>
<% end %>
<%
logo_url = asset_path("logo_openproject_white_big.png")
high_contrast_logo_url = asset_path("logo_openproject.png")

if apply_custom_styles?
if CustomStyle.current.logo.present?
logo_url = custom_style_logo_path(digest: CustomStyle.current.digest, filename: CustomStyle.current.logo_identifier)
elsif CustomStyle.current.theme_logo.present?
logo_url = asset_path(CustomStyle.current.theme_logo)
end
end
%>

.op-logo--link {
background-image: url(<%= logo_url %>);
}

.op-logo--link_high_contrast {
background-image: url(<%= high_contrast_logo_url %>);
}
</style>
<% end %>
28 changes: 28 additions & 0 deletions config/constants/settings/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,34 @@ class Definition
format: :string,
default: nil
},
httpx_connect_timeout: {
description: '',
format: :float,
writable: false,
allowed: (0..),
default: 3
},
httpx_read_timeout: {
description: '',
format: :float,
writable: false,
allowed: (0..),
default: 3
},
httpx_write_timeout: {
description: '',
format: :float,
writable: false,
allowed: (0..),
default: 3
},
httpx_keep_alive_timeout: {
description: '',
format: :float,
writable: false,
allowed: (0..),
default: 20
},
rate_limiting: {
default: {},
description: 'Configure rate limiting for various endpoint rules. See configuration documentation for details.'
Expand Down
Loading

0 comments on commit e054adb

Please sign in to comment.