Skip to content

Commit

Permalink
Merge branch 'release/13.1' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
akabiru committed Dec 19, 2023
2 parents a718b6f + a1c0b7b commit ef1d5b9
Show file tree
Hide file tree
Showing 23 changed files with 173 additions and 263 deletions.
2 changes: 1 addition & 1 deletion app/contracts/oauth_clients/create_contract.rb
Expand Up @@ -31,7 +31,7 @@ class CreateContract < ::ModelContract
include ActiveModel::Validations

attribute :client_id, writable: true
validates :client_id, presence: true, length: { maximum: 255 }
validates :client_id, presence: { message: I18n.t('oauth_client.errors.client_id_blank') }, length: { maximum: 255 }

attribute :client_secret, writable: true
validates :client_secret, presence: true, length: { maximum: 255 }
Expand Down
7 changes: 3 additions & 4 deletions app/services/oauth_clients/create_service.rb
Expand Up @@ -36,10 +36,9 @@ module OAuthClients
class CreateService < ::BaseServices::Create
protected

def before_perform(params, _service_result)
OAuthClient.where(integration: params[:integration]).delete_all

super
def after_validate(params, contract_call)
OAuthClient.where(integration: params[:integration]).delete_all if contract_call.success?
super(params, contract_call)
end
end
end
1 change: 1 addition & 0 deletions config/locales/en.yml
Expand Up @@ -3513,6 +3513,7 @@ en:
oauth_returned_json_error: "OAuth2 returned a JSON error"
oauth_returned_http_error: "OAuth2 returned a network error"
oauth_returned_standard_error: "OAuth2 returned an internal error"
client_id_blank: "ID can't be blank."
wrong_token_type_returned: "OAuth2 returned a wrong type of token, expecting AccessToken::Bearer"
oauth_issue_contact_admin: "OAuth2 reported an error. Please contact your system administrator."
oauth_client_not_found: "OAuth2 client not found in 'callback' endpoint (redirect_uri)."
Expand Down
98 changes: 59 additions & 39 deletions docs/glossary/README.md

Large diffs are not rendered by default.

Expand Up @@ -220,8 +220,6 @@
&.ui-widget-content
background: none
border: none
.editor
color: var(--body-font-color)
.ui-dialog-buttonpane.ui-widget-content
background: none
background-color: none
Expand All @@ -230,17 +228,15 @@
.ui-dialog-titlebar-close
overflow: hidden

.dark #task_editor label
color: #FFFFFF

.light #task_editor label
color: #000000

.dark div
color: #FFFFFF
.dark
#task_editor label, .subject, .assigned_to_id, div
color: #FFFFFF
option
color: var(--body-font-color)

.light div
color: #000000
.light
#task_editor label, .subject, .assigned_to_id, div
color: var(--body-font-color)

/* item editor */

Expand Down

This file was deleted.

Expand Up @@ -43,7 +43,7 @@ def form_url

def submit_button_options
{
label: I18n.t("storages.buttons.done_complete_setup"),
label: submit_button_label,
data: { 'storages--automatically-managed-project-folders-form-target': 'submitButton' }.tap do |data_hash|
# For create action, break from Turbo Frame and follow full page redirect
data_hash[:turbo] = false if new_record?
Expand All @@ -57,6 +57,14 @@ def cancel_button_options

private

def submit_button_label
if storage.automatically_managed?
I18n.t("storages.buttons.done_complete_setup")
else
I18n.t("storages.buttons.complete_without_setup")
end
end

def application_password_display_options
{}.tap do |options_hash|
options_hash[:display] = :none unless storage.automatically_managed?
Expand Down
Expand Up @@ -3,11 +3,7 @@
primer_form_with(
model: oauth_client,
url: admin_settings_storage_oauth_client_path(storage),
method: form_method,
data: {
controller: 'storages--oauth-client-form',
application_target: 'dynamic'
}
method: form_method
) do |form|
flex_layout do |oauth_client_row|
oauth_client_row.with_row(mb: 3) do
Expand All @@ -19,24 +15,7 @@
end

oauth_client_row.with_row(mb: 3) do
render(
Storages::Admin::OAuthClientForm.new(
form,
storage:,
client_id_input_options: {
data: {
'storages--oauth-client-form-target': 'clientId',
action: 'input->storages--oauth-client-form#toggleSubmitButtonDisabled'
}
},
client_secret_input_options: {
data: {
'storages--oauth-client-form-target': 'clientSecret',
action: 'input->storages--oauth-client-form#toggleSubmitButtonDisabled'
}
}
)
)
render(Storages::Admin::OAuthClientForm.new(form,storage:,))
end

oauth_client_row.with_row do
Expand All @@ -45,10 +24,6 @@
form,
storage:,
submit_button_options: {
disabled: submit_button_disabled?,
data: {
'storages--oauth-client-form-target': 'submitButton',
},
test_selector: 'storage-oauth-client-submit-button'
},
cancel_button_options: {
Expand Down
Expand Up @@ -48,10 +48,6 @@ def cancel_button_path
storage.persisted? ? edit_admin_settings_storage_path(storage) : admin_settings_storages_path
end

def submit_button_disabled?
!oauth_client_configured?
end

def storage_provider_credentials_instructions
I18n.t("storages.instructions.#{storage.short_provider_type}.oauth_configuration",
application_link_text: send(:"#{storage.short_provider_type}_integration_link")).html_safe
Expand All @@ -77,9 +73,5 @@ def first_time_configuration?
def default_form_method
first_time_configuration? ? :post : :patch
end

def oauth_client_configured?
oauth_client.present? && oauth_client.client_id.present? && oauth_client.client_secret.present?
end
end
end
Expand Up @@ -3,11 +3,7 @@
primer_form_with(
model: oauth_client,
url: finish_setup_admin_settings_storage_oauth_client_path(storage),
method: :post,
data: {
controller: 'storages--oauth-client-form',
application_target: 'dynamic'
}
method: :post
) do |form|
flex_layout do |oauth_client_row|
oauth_client_row.with_row(mb: 3) do
Expand Down Expand Up @@ -44,10 +40,7 @@
submit_button_options: {
disabled: submit_button_disabled? || @options[:is_complete],
label: I18n.t('storages.buttons.done_complete_setup'),
data: {
'storages--oauth-client-form-target': 'submitButton',
turbo: false
},
data: { turbo: false },
test_selector: 'storage-oauth-client-submit-button'
},
cancel_button_options: {
Expand Down
Expand Up @@ -61,7 +61,7 @@ def submit_button_options
private

def submit_button_path
options[:submit_button_path] || edit_admin_settings_storage_path(storage)
options[:submit_button_path] || show_oauth_application_admin_settings_storage_path(storage)
end
end
end
Expand Up @@ -58,6 +58,7 @@ def edit_icon_button_options
def edit_icon_button_data_options
{}.tap do |data_h|
data_h[:confirm] = I18n.t("storages.confirm_replace_oauth_client") if oauth_client_configured?
data_h[:turbo_stream] = true
end
end

Expand Down
Expand Up @@ -28,13 +28,7 @@
if storage.new_record? || openproject_oauth_application_section_closed?
render(Storages::Admin::OAuthApplicationInfoComponent.new(oauth_application:, storage:))
else
render(
Storages::Admin::OAuthApplicationInfoCopyComponent.new(
oauth_application:,
storage:,
submit_button_path: show_oauth_application_admin_settings_storage_path(storage)
)
)
render(Storages::Admin::OAuthApplicationInfoCopyComponent.new(oauth_application:, storage:))
end
end
end
Expand Down
Expand Up @@ -37,7 +37,6 @@ class Storages::Admin::OAuthClientsController < ApplicationController
before_action :require_admin

before_action :find_storage
before_action :delete_current_oauth_client, only: %i[create update]

# menu_item is defined in the Redmine::MenuManager::MenuController
# module, included from ApplicationController.
Expand All @@ -54,7 +53,6 @@ def new
.result

respond_to do |format|
format.html
format.turbo_stream
end
end
Expand All @@ -67,7 +65,7 @@ def create

service_result.on_failure do
respond_to do |format|
format.html { render :new }
format.turbo_stream { render :new }
end
end

Expand Down Expand Up @@ -155,8 +153,4 @@ def oauth_client_params
def find_storage
@storage = ::Storages::Storage.find(params[:storage_id])
end

def delete_current_oauth_client
::OAuthClients::DeleteService.new(user: User.current, model: @storage.oauth_client).call if @storage.oauth_client
end
end
Expand Up @@ -188,8 +188,7 @@ def replace_oauth_application
@oauth_application = service_result.result

if service_result.success?
flash[:notice] = I18n.t('storages.notice_oauth_application_replaced')
render :show_oauth_application
render :replace_oauth_application
else
render :edit
end
Expand Down
Expand Up @@ -27,23 +27,6 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<%= turbo_stream.update :storage_openproject_oauth_section do %>
<%=
render(
Storages::Admin::OAuthApplicationInfoComponent.new(
oauth_application: @oauth_application,
storage: @storage,
)
)
%>
<% end %>
<%= turbo_stream.update :storage_redirect_uri_section do %>
<%= render(Storages::Admin::RedirectUriComponent.new(oauth_client: @oauth_client, storage: @storage)) %>
<% end %>
<% if @storage.provider_type_nextcloud? && @storage.oauth_client.blank? %>
<%= turbo_stream.update :storage_oauth_client_section do %>
<%= render(Storages::Admin::Forms::OAuthClientFormComponent.new(oauth_client: @oauth_client, storage: @storage)) %>
<% end %>
<%= turbo_stream.update :storage_oauth_client_section do %>
<%= render(Storages::Admin::Forms::OAuthClientFormComponent.new(oauth_client: @oauth_client, storage: @storage)) %>
<% end %>
Expand Up @@ -31,7 +31,6 @@ See COPYRIGHT and LICENSE files for more details.
<%= render(Storages::Admin::GeneralInfoComponent.new(@storage)) %>
<% end %>
<% if @storage.provider_type_nextcloud? %>
<%= turbo_stream.update :storage_openproject_oauth_section do %>
<%=
Expand All @@ -41,8 +40,7 @@ See COPYRIGHT and LICENSE files for more details.
storage: @storage,
submit_button_options: {
data: { turbo_stream: true }
},
submit_button_path: new_admin_settings_storage_oauth_client_path(@storage)
}
)
)
%>
Expand Down
Expand Up @@ -27,10 +27,20 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<% html_title t(:label_administration), t("project_module_storages"), @storage.name, "#{t("storages.provider_types.#{@storage.short_provider_type}.name")} #{t("storages.label_oauth_client_details")}" %>
<%=
render(OpTurbo::FrameComponent.new(id: :storage_oauth_client_section)) do
render(Storages::Admin::Forms::OAuthClientFormComponent.new(oauth_client: @oauth_client, storage: @storage))
end
%>
<%= turbo_stream.update :storage_general_info_section do %>
<%= render(Storages::Admin::GeneralInfoComponent.new(@storage)) %>
<% end %>
<%= turbo_stream.update :storage_openproject_oauth_section do %>
<%=
render(
Storages::Admin::OAuthApplicationInfoCopyComponent.new(
oauth_application: @oauth_application,
storage: @storage,
submit_button_options: {
data: { turbo_stream: true }
}
)
)
%>
<% end %>

0 comments on commit ef1d5b9

Please sign in to comment.