Skip to content

Commit

Permalink
Merge branch 'release/15.1' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
openprojectci committed Dec 6, 2024
2 parents d0fe86f + 0b31ada commit 05afd6d
Show file tree
Hide file tree
Showing 19 changed files with 173 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
size: :large,
id: DIALOG_ID)) do |d|
d.with_header(variant: :large)
d.with_body(classes: "Overlay-body_autocomplete_height") do
d.with_body(classes: body_classes) do
render(WorkPackageRelationsTab::AddWorkPackageChildFormComponent.new(
work_package: @work_package
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ def dialog_title
child_label = t("#{I18N_NAMESPACE}.relations.label_child_singular")
t("#{I18N_NAMESPACE}.label_add_x", x: child_label)
end

def body_classes
"Overlay-body_autocomplete_height"
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
size: :large,
id: DIALOG_ID)) do |d|
d.with_header(variant: :large)
d.with_body(classes: "Overlay-body_autocomplete_height") do
d.with_body(classes: body_classes) do
render(WorkPackageRelationsTab::WorkPackageRelationFormComponent.new(
work_package: @work_package,
relation: @relation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ def dialog_title
t("#{I18N_NAMESPACE}.label_add_x", x: relation_label)
end
end

def body_classes
@relation.persisted? ? nil : "Overlay-body_autocomplete_height"
end
end
3 changes: 2 additions & 1 deletion app/helpers/journals_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def back_to_activity_page_url(activity_page)
in ["users", user_id]
user_url(user_id)
in ["work_packages", work_package_id]
work_package_url(work_package_id)
# Sometimes the parameter provided is erroneous (having an extra ') for unknown reasons.
work_package_url(work_package_id.chomp("'"))
else
nil
end
Expand Down
6 changes: 1 addition & 5 deletions config/initializers/03-db_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

if (db_config = ActiveRecord::Base.configurations.configs_for(env_name: env)[0]) &&
db_config.configuration_hash["adapter"]&.start_with?("mysql")
warn <<~ERROR
abort <<~ERROR
======= INCOMPATIBLE DATABASE DETECTED =======
Your database is set up for use with a MySQL or MySQL-compatible variant.
This installation of OpenProject no longer supports these variants.
Expand All @@ -45,8 +45,4 @@
==============================================
ERROR

# rubocop:disable Rails/Exit
Kernel.exit 1
# rubocop:enable Rails/Exit
end
File renamed without changes.
53 changes: 53 additions & 0 deletions config/initializers/05-check_db_encoding.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#-- 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.
#++

if ENV["OPENPROJECT_SKIP_DB_ENCODING_CHECK"].blank?
icu_incompatible_encodings = %w[
EUC_JIS_2004
LATIN10
MULE_INTERNAL
SQL_ASCII
WIN874
]

database_encoding = ActiveRecord::Base.connection.select_value("SHOW SERVER_ENCODING")

if database_encoding.in?(icu_incompatible_encodings)
abort <<~ERROR
INCOMPATIBLE DATABASE ENCODING DETECTED
Your database encoding is #{database_encoding}, which is incompatible with ICU
collation used in OpenProject v15.
Please check the instructions on how to change database encoding:
https://www.openproject.org/docs/installation-and-operations/misc/changing-database-encoding/
This check can be skipped by setting environment variable OPENPROJECT_SKIP_DB_ENCODING_CHECK=true
ERROR
end
end
21 changes: 18 additions & 3 deletions db/migrate/20240920152544_set_versions_name_collation.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
class SetVersionsNameCollation < ActiveRecord::Migration[7.1]
def up
execute <<-SQL.squish
CREATE COLLATION IF NOT EXISTS versions_name (provider = icu, locale = 'und-u-kn-true');
SQL
begin
execute <<-SQL.squish
CREATE COLLATION IF NOT EXISTS versions_name (provider = icu, locale = 'und-u-kn-true');
SQL
rescue StandardError => e
raise unless e.message.include?("encoding")

abort <<~MESSAGE
\e[31mERROR:\e[0m Failed to create an ICU collation with current database encoding.
You need to change the database encoding before proceeding.
Please check the instructions on how to do it:
https://www.openproject.org/docs/installation-and-operations/misc/changing-database-encoding/
Original error:
#{e.message}
MESSAGE
end

change_column :versions, :name, :string, collation: "versions_name"
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Changing database encoding

This instructions are primarily intended to help with an error encountered when migrating to OpenProject 15.
The error happens when migration tries to create an ICU collation and database encoding doesn't support it.
We suggest to use unicode encoding for maximum compatibility.

## Preconditions

* Credentials with the permission to create a database in the database server the OpenProject installation is running against.
* Shell access to the OpenProject server.

## 1. Create a database dump

This and following steps assume that you are using built in `openproject` command.

```shell
openproject run backup
```

Ensure it finished successfully and note down the path after `Generating database backup` that should normally be
in form `/var/db/openproject/backup/postgresql-dump-<DATE_TIME_DIGITS>.pgdump`.

See also [Backing up your OpenProject installation page](../../operation/backing-up).

## 2. Create a new database with different encoding

Note down the database connection URL that should be in form `postgres://<USERNAME>:<PASSWORD>@<HOST>:<PORT>/<DATABASE>`:

```shell
openproject config:get DATABASE_URL
```

Create new database using `psql` command, after deciding on the name, for example `openproject-unicode`:

```shell
psql '<DATABASE_URL>' -c 'CREATE DATABASE "<NEW_DATABASE_NAME>" ENCODING UNICODE'
```

Options for `CREATE DATABASE` can be found at [PostgreSQL documentation page](https://www.postgresql.org/docs/current/sql-createdatabase.html).

Or alternatively using `createdb` command:

```shell
su postgres -c createdb -E UNICODE -O <dbusernamer> openproject_backup
```

Instructions for `createdb` command can be found at [PostgreSQL documentation page](https://www.postgresql.org/docs/17/app-createdb.html).

## 3. Restore the dump to the new database

To get the new database URL you need to replace the old database name with the new database name in the connection URL that you got in the previous step.
For example if it was `postgres://openproject:hard-password@some-host:5432/openproject` and new database name was chosen to be `openproject-unicode`, then
new database URL will be `postgres://openproject:hard-password@some-host:5432/openproject-unicode`.

```shell
pg_restore -d '<NEW_DATABASE_URL>' '<PATH_TO_THE_DATABASE_DUMP>'
```

See also [Restoring an OpenProject backup](../../operation/restoring/).

## 4. Change configuration to use the new database

Using the new database URL from previous step:

```shell
openproject config:set DATABASE_URL=<NEW_DATABASE_URL>
```

See also [Configuring a custom database server page](../../configuration/database/).
2 changes: 1 addition & 1 deletion frontend/src/assets/images/15_1_features.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ export default class FormController extends Controller<HTMLFormElement> {
return result.job_id;
}

generateExportURL():string {
const actionURL = this.element.getAttribute('action') as string;
const searchParams = this.getExportParams();
const append = actionURL.includes('?') ? '&' : '?';
return `${actionURL}${append}${searchParams.toString()}`;
}

submitForm(evt:CustomEvent) {
evt.preventDefault(); // Don't submit
const formatURL = this.element.getAttribute('action');
const searchParams = this.getExportParams();
const exportURL = `${formatURL}?${searchParams.toString()}`;
this.requestExport(exportURL)
this.requestExport(this.generateExportURL())
.then((job_id) => this.showJobModal(job_id))
.catch((error:HttpErrorResponse) => this.handleError(error));
}
Expand Down
2 changes: 1 addition & 1 deletion spec/features/members/error_messages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

require "spec_helper"

RSpec.describe "Group memberships through groups page" do
RSpec.describe "Group memberships through groups page", :js, :with_cuprite do
shared_let(:admin) { create(:admin) }
let!(:project) { create(:project, name: "Project 1", identifier: "project1") }

Expand Down
6 changes: 0 additions & 6 deletions spec/features/members/pagination_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@
members_page.set_items_per_page! 2

members_page.visit!
SeleniumHubWaiter.wait
expect(members_page).to have_user "Alice Alison" # members are sorted by last name desc
members_page.add_user! "Peter Pan", as: "Manager"

SeleniumHubWaiter.wait
members_page.go_to_page! 2
expect(members_page).to have_user "Peter Pan"
end
Expand All @@ -82,12 +80,10 @@
members_page.set_items_per_page! 1

members_page.visit!
SeleniumHubWaiter.wait
members_page.remove_user! "Alice Alison"
expect_and_dismiss_flash message: "Removed Alice Alison from project"
expect(members_page).to have_user "Bob Bobbit"

SeleniumHubWaiter.wait
members_page.go_to_page! 2
expect(members_page).to have_user "Peter Pan"
end
Expand All @@ -98,13 +94,11 @@
members_page.set_items_per_page! 1

members_page.visit!
SeleniumHubWaiter.wait
members_page.go_to_page! 2
members_page.edit_user! "Bob Bobbit", add_roles: ["Developer"]
expect(page).to have_text "Successful update"
expect(members_page).to have_user "Bob Bobbit", roles: ["Developer", "Manager"]

SeleniumHubWaiter.wait
members_page.go_to_page! 1
expect(members_page).to have_user "Alice Alison"
end
Expand Down
3 changes: 2 additions & 1 deletion spec/features/work_packages/export_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def export!
context "with activated options" do
let(:query) do
create(
:query, user: current_user, project:,
:query, id: 1234, user: current_user, project:,
display_sums: true,
include_subprojects: true,
show_hierarchies: true,
Expand All @@ -135,6 +135,7 @@ def export!
end
let(:expected_params) do
default_expected_params.merge({
query_id: "1234",
showSums: "true",
includeSubprojects: "true",
showHierarchies: "true"
Expand Down
2 changes: 2 additions & 0 deletions spec/helpers/journals_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
"unsupported_gizmo" => nil,
"users/5" => "http://test.host/users/5",
"work_packages/42" => "http://test.host/work_packages/42",
# Sometimes the url is erroneous (having an extra ') for unknown reasons.
"work_packages/42'" => "http://test.host/work_packages/42",
nil => nil
}.each do |activity_page, expected_url|
context "when activity page is #{activity_page.inspect}" do
Expand Down
2 changes: 1 addition & 1 deletion spec/support/pages/groups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def group(group_name)
end
end

class Group < Pages::Page
class Group < Page
include ::Components::Autocompleter::NgSelectAutocompleteHelpers
attr_reader :id

Expand Down
12 changes: 3 additions & 9 deletions spec/support/pages/members.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ def initialize(project_identifier)
@project_identifier = project_identifier
end

def visit!
super

self
end

def path
"/projects/#{project_identifier}/members"
end
Expand All @@ -61,7 +55,7 @@ def open_filters!
def search_for_name(name)
fill_in "name", with: name
find(".simple-filters--controls input[type=submit]").click
wait_for_network_idle
wait_for_reload
end

def expect_menu_item(text, selected: false)
Expand Down Expand Up @@ -193,7 +187,7 @@ def edit_user!(name, add_roles: [], remove_roles: [])
Array(remove_roles).each { |role| uncheck role }

click_on "Change"
wait_for_network_idle
wait_for_reload
end

def has_group_membership?(user_name)
Expand Down Expand Up @@ -276,7 +270,7 @@ def expect_role(role_name, present: true)

def go_to_page!(number)
find(".op-pagination--pages a", text: number.to_s).click
wait_for_network_idle
wait_for_reload
end
end
end
4 changes: 2 additions & 2 deletions spec/support/pages/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def current_page?
def visit!
raise "No path defined" unless path

visit path
visit(path)

self
wait_for_reload
end

def reload!
Expand Down

0 comments on commit 05afd6d

Please sign in to comment.