Adds the missing translation keys

This commit is contained in:
Marcello Rocha
2024-07-22 17:47:41 +02:00
parent ee9f1315c9
commit 61aefa6f9d
5 changed files with 53 additions and 19 deletions
@@ -33,6 +33,8 @@ module Storages
module StorageInteraction
module Nextcloud
class RenameFileCommand
include Snitch
def self.call(storage:, auth_strategy:, file_id:, name:)
new(storage).call(auth_strategy:, file_id:, name:)
end
@@ -41,22 +43,30 @@ module Storages
@storage = storage
end
# rubocop:disable Metrics/AbcSize
def call(auth_strategy:, file_id:, name:)
validate_input_data(file_id:, name:).on_failure { |failure| return failure }
origin_user_id = Util.origin_user_id(caller: self.class, storage: @storage, auth_strategy:)
.on_failure { |failure| return failure }
.result
with_tagged_logger do
info "Validating user remote ID"
origin_user_id = Util.origin_user_id(caller: self.class, storage: @storage, auth_strategy:)
.on_failure { |failure| return failure }
.result
info = FileInfoQuery.call(storage: @storage, auth_strategy:, file_id:)
.on_failure { |failure| return failure }
.result
info "Getting the folder information"
info = FileInfoQuery.call(storage: @storage, auth_strategy:, file_id:)
.on_failure { |failure| return failure }
.result
make_request(auth_strategy, origin_user_id, info, name).on_failure { |failure| return failure }
info "Renaming the folder #{info.location} to #{name}"
make_request(auth_strategy, origin_user_id, info, name).on_failure { |failure| return failure }
FileInfoQuery.call(storage: @storage, auth_strategy:, file_id:)
.map { |file_info| Util.storage_file_from_file_info(file_info) }
info "Retrieving updated file info for the #{name} folder"
FileInfoQuery.call(storage: @storage, auth_strategy:, file_id:)
.map { |file_info| Util.storage_file_from_file_info(file_info) }
end
end
# rubocop:enable Metrics/AbcSize
private
@@ -85,7 +95,7 @@ module Storages
ServiceResult.failure(result: :error,
errors: StorageError.new(code: :error,
data: StorageErrorData.new(source: self.class),
log_message: "Invalid input data!"))
log_message: "file_id or name is blank"))
else
ServiceResult.success
end
@@ -132,7 +132,7 @@ module Storages
users_to_add.each do |user|
add_user_to_group.call(storage: @storage, user:).error_and do |error|
add_error(:add_user_to_group, error, options: { user:, group: @storage.group, reason: error.log_message })
format_and_log_error(error, group: @storage.group, user:)
format_and_log_error(error, group: @storage.group, user:, reason: error.log_message)
end
end
end
@@ -141,7 +141,7 @@ module Storages
users_to_remove.each do |user|
remove_user_from_group.call(storage: @storage, user:).error_and do |error|
add_error(:remove_user_from_group, error, options: { user:, group: @storage.group, reason: error.log_message })
format_and_log_error(error, group: @storage.group, user:)
format_and_log_error(error, group: @storage.group, user:, reason: error.log_message)
end
end
end
@@ -239,7 +239,7 @@ module Storages
format_and_log_error(service_result.errors, folder_id: file_id, folder_name: name)
add_error(:rename_project_folder, service_result.errors,
options: { project_folder_name: name, project_folder_id: file_id }).fail!
options: { current_path:, project_folder_name: name, project_folder_id: file_id }).fail!
end
end
+28 -6
View File
@@ -72,23 +72,45 @@ en:
services:
attributes:
storages/nextcloud_group_folder_properties_sync_service:
add_user_to_group: 'Add User to Group:'
create_folder: 'Managed Project Folder Creation:'
ensure_root_folder_permissions: 'Setting Basic Permissions:'
ensure_root_folder_permissions: 'Set Base Folder Permissions:'
hide_inactive_folders: 'Hide Inactive Folders Step:'
remote_folders: 'Reading contents of the group folder:'
remove_user_from_group: 'Revoke User from Group:'
rename_project_folder: 'Renaming managed project Folder:'
remote_folders: 'Read contents of the group folder:'
remove_user_from_group: 'Remove User from Group:'
rename_project_folder: 'Rename managed project Folder:'
errors:
models:
storages/nextcloud_group_folder_properties_sync_service:
attributes:
add_user_to_group:
conflict: 'The user %{user} could not be added to the %{group} group for the following reason: %{reason}'
failed_to_add: 'The user %{user} could not be added to the %{group} group for the following reason: %{reason}'
create_folder:
conflict: The %{folder_name} already exists on %{parent_location}.
not_found: "%{parent_location} wasn't found."
ensure_root_folder_permissions:
not_found: "%{group_folder} wasn't found. Please check your Nextcloud Group Folder setup."
permission_not_set: could not set permissions on %{group_folder}.
hide_inactive_folders:
permission_not_set: could not set permissions on %{path}.
remote_folders:
not_allowed: The %{username} doesn't have access to the %{group_folder}. Please check the folder permissions on Nextcloud
not_allowed: The %{username} doesn't have access to the %{group_folder}. Please check the folder permissions on Nextcloud.
not_found: "%{group_folder} wasn't found. Please check your Nextcloud setup."
remove_user_from_group:
conflict: 'The user %{user} could not be removed from the %{group} group for the following reason: %{reason}'
failed_to_remove: 'The user %{user} could not be removed from the %{group} group for the following reason: %{reason}'
rename_project_folder:
forbidden: OpenProject user does not have access to %{current_path} folder.
not_found: "%{current_path} wasn't found."
set_folders_permissions:
permission_not_set: could not set permissions on %{path}.
error: An unexpected error occurred. Please ensure that you Nextcloud instance is reachable and check OpenProject worker logs for more information
unauthorized: OpenProject could not sync with Nextcloud. Please check you storage and Nextcloud configuration
group_does_not_exist: "%{group} does not exit. Check your Nextcloud instance configuration."
insufficient_privileges: OpenProject does not have enough privileges to add %{user} to %{group}. Check you group settings in Nextcloud.
not_allowed: Nextcloud block the request.
unauthorized: OpenProject could not sync with Nextcloud. Please check you storage and Nextcloud configuration.
user_does_not_exist: "%{user} does not exist in Nextcloud."
storages:
buttons:
complete_without_setup: Complete without it
@@ -922,6 +922,7 @@ RSpec.describe Storages::NextcloudGroupFolderPropertiesSyncService, :webmock do
.with(group: "OpenProject",
user: "Obi-Wan",
error_code: :error,
reason: "Outbound request failed",
data: { status: 302, body: "" })
end
end
@@ -956,6 +957,7 @@ RSpec.describe Storages::NextcloudGroupFolderPropertiesSyncService, :webmock do
.with(group: "OpenProject",
user: "Darth Maul",
error_code: :failed_to_remove,
reason: /SubAdmin/,
data: { status: 200, body: remove_user_from_group_response })
end
end