Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions app/components/my/access_token/oauth_client/row_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,7 @@ def name
end

def integration_type
integration_class_name = client_token.oauth_client.integration_type
integration_class = begin
integration_class_name.constantize
rescue NameError
nil
end
integration_class = client_token.oauth_client.integration&.class

return I18n.t("my_account.access_tokens.oauth_client.unknown_integration") unless integration_class

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<%#-- 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.

++#%>

<%=
component_wrapper(tag: :turbo_frame, refresh: :morph) do
render(Primer::OpenProject::SidePanel::Section.new) do |section|
section.with_title { t(".title") }

flex_layout do |container|
if report.present?
container.with_row do
header = summary_header

concat(render(Primer::Beta::Octicon.new(icon: header[:icon], color: header[:icon_color], mr: 2)))
concat(render(Primer::Beta::Text.new(font_weight: :bold)) { header[:text] })
end

container.with_row(mt: 2) do
render(Primer::Beta::Text.new(color: :muted)) { summary_description }
end

container.with_row(mt: 2) do
render(
Primer::Beta::Button.new(
scheme: :link,
color: :default,
font_weight: :bold,
tag: :a,
href: admin_settings_wiki_provider_health_status_report_path(model)
)
) do |button|
button.with_leading_visual_icon(icon: :meter)
t(".open_report")
end
end
else
container.with_row do
primer_form_with(
model:,
url: create_health_status_report_admin_settings_wiki_provider_health_status_report_path(model),
method: :post,
data: { turbo: true }
) do
render(
Primer::Beta::Button.new(
scheme: :link,
color: :default,
font_weight: :bold,
type: :submit
)
) do |button|
button.with_leading_visual_icon(icon: :meter)
t(".run_checks")
end
end
end
end
end
end
end
%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# frozen_string_literal: true

#-- 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.
#++

module Wikis
module Admin
module SidePanel
class HealthStatusComponent < ApplicationComponent
include ApplicationHelper
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers

private

def report
model.health_reports.order(created_at: :asc).last
end

def summary_header
tally = report.tally
case tally
in { failure: 1.. }
{
icon: :alert,
icon_color: :danger,
text: t(".checks.failures", count: tally[:failure])
}
in { warning: 1.. }
{
icon: :alert,
icon_color: :attention,
text: t(".checks.warnings", count: tally[:warning])
}
else
{ icon: :"check-circle", icon_color: :success, text: t(".checks.success") }
end
end

def summary_description
text = if report.healthy?
t(".summary.success")
elsif report.unhealthy?
t(".summary.failure")
else
t(".summary.warning")
end

"#{text} #{t('.last_check', datetime: helpers.format_time(report.created_at))}"
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<%=
component_wrapper do
render(Primer::OpenProject::SidePanel.new) do |panel|
panel.with_section(Wikis::Admin::SidePanel::HealthStatusComponent.new(wiki_provider))
end
end
%>
41 changes: 41 additions & 0 deletions modules/wikis/app/components/wikis/admin/side_panel_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# frozen_string_literal: true

#-- 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.
#++

module Wikis
module Admin
class SidePanelComponent < ApplicationComponent
include ApplicationHelper
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers

alias wiki_provider model
end
end
end
102 changes: 102 additions & 0 deletions modules/wikis/app/controllers/wikis/admin/health_status_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# frozen_string_literal: true

#-- 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.
#++

module Wikis
module Admin
class HealthStatusController < ApplicationController
include OpTurbo::ComponentStream

layout :admin_or_frame_layout

before_action :require_admin
before_action :find_provider

def admin_or_frame_layout
return "turbo_rails/frame" if turbo_frame_request?

"admin"
end

def show
@report = @provider.health_reports.order(created_at: :asc).last

respond_to do |format|
format.html
format.text do
return head :not_found if @report.nil?

timestamp = @report.created_at.iso8601
filename = "#{@provider.name.underscore}_health_report_#{timestamp}.txt"
send_data text_report(timestamp), filename:, type: "text/plain", disposition: :attachment
end
end
end

def create
create_and_store_report

redirect_to admin_settings_wiki_provider_health_status_report_path(@provider), status: :see_other
end

def create_health_status_report
create_and_store_report

update_via_turbo_stream(component: SidePanel::HealthStatusComponent.new(@provider))
respond_to_with_turbo_streams
end

private

def text_report(timestamp)
{
provider: @provider.name,
provider_type: @provider.to_s,
configuration: @provider.non_confidential_configuration,
ran_at: timestamp,
results: @report ? @report.results.map(&:to_h) : []
}.to_yaml(stringify_names: true)
end

def find_provider
@provider = ::Wikis::Provider.visible.find(params[:wiki_provider_id])
end

def create_and_store_report
report = validator.call
report.save!
report
end

def validator
@validator ||= @provider.resolve("validators.connection")
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class WikiProvidersController < ApplicationController
menu_item :wiki_providers

def index
@wiki_providers = Wikis::Provider.visible
@wiki_providers = editable_wiki_providers
end

def new
Expand Down Expand Up @@ -150,13 +150,13 @@ def current_step_name
end

def find_wiki_provider
@wiki_provider = Wikis::XWikiProvider.visible.find(params[:id])
@wiki_provider = editable_wiki_providers.find(params[:id])
end

def continue_from_wizard_params
return if params[:continue_wizard].blank?

Wikis::Provider.visible.find(params[:continue_wizard])
editable_wiki_providers.find(params[:continue_wizard])
end

def wiki_provider_params
Expand All @@ -166,6 +166,10 @@ def wiki_provider_params
def wiki_provider_wizard(wiki_provider)
wiki_provider.resolve("components.setup_wizard", user: current_user)
end

def editable_wiki_providers
Wikis::Provider.visible.where.not(type: InternalProvider.name)
end
end
end
end
2 changes: 2 additions & 0 deletions modules/wikis/app/models/wikis/internal_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def registry_prefix = "internal"

def user_connected?(_user) = true

def configured? = true

def name
model_name.human
end
Expand Down
Loading
Loading