Skip to content

Commit

Permalink
[#53620] rework of oauth app index page to primer
Browse files Browse the repository at this point in the history
  • Loading branch information
Kharonus committed Sep 11, 2024
1 parent ec234d2 commit 8945bcc
Show file tree
Hide file tree
Showing 20 changed files with 246 additions and 270 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<%=
component_wrapper do
flex_layout(align_items: :center, justify_content: :space_between) do |oauth_application_container|
oauth_application_container.with_column(flex_layout: true) do |application_information|
application_information.with_column(mr: 2) do
render(Primer::Beta::Link.new(href: oauth_application_path(@application), font_weight: :bold)) do
@application.name
end
end

application_information.with_column(mr: 2) do
render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) do
if @application.builtin?
t("oauth.application.builtin")
else
t(:label_created_by, user: @application.owner)
end
end
end

unless @application.builtin?
application_information.with_column do
render(Primer::Beta::Label.new) do
@application.confidential? ? t("oauth.application.confidential") : t("oauth.application.non_confidential")
end
end
end
end

# Actions
oauth_application_container.with_column do
render(Primer::Alpha::ToggleSwitch.new(
src: toggle_oauth_application_path(@application),
csrf_token: form_authenticity_token,
checked: @application.enabled?
))
end
end
end
%>
43 changes: 43 additions & 0 deletions app/components/oauth/applications/application_row_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#-- 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 OAuth
module Applications
class ApplicationRowComponent < ApplicationComponent
include ApplicationHelper
include OpPrimer::ComponentHelpers
include OpTurbo::Streamable

def initialize(application:)
@application = application

super
end
end
end
end
49 changes: 49 additions & 0 deletions app/components/oauth/applications/index_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<%=
component_wrapper do
flex_layout do |index_container|
index_container.with_row do
render(border_box_container(mb: 4)) do |component|
component.with_header(font_weight: :bold) do
render(Primer::Beta::Text.new) do
t("oauth.header.builtin_applications")
end
end

if @built_in_applications.empty?
component.with_row do
render(Primer::Beta::Text.new) do
t("oauth.empty_application_lists")
end
end
end

@built_in_applications.each do |application|
component.with_row { render(OAuth::Applications::ApplicationRowComponent.new(application:)) }
end
end
end

index_container.with_row do
render(border_box_container(mb: 4)) do |component|
component.with_header(font_weight: :bold) do
render(Primer::Beta::Text.new) do
t("oauth.header.other_applications")
end
end

if @other_applications.empty?
component.with_row do
render(Primer::Beta::Text.new) do
t("oauth.empty_application_lists")
end
end
end

@other_applications.each do |application|
component.with_row { render(OAuth::Applications::ApplicationRowComponent.new(application:)) }
end
end
end
end
end
%>
44 changes: 44 additions & 0 deletions app/components/oauth/applications/index_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#-- 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 OAuth
module Applications
class IndexComponent < ApplicationComponent
include ApplicationHelper
include OpPrimer::ComponentHelpers
include OpTurbo::Streamable

def initialize(oauth_applications:)
@built_in_applications = oauth_applications.select(&:builtin?)
@other_applications = oauth_applications.reject(&:builtin?)

super
end
end
end
end
114 changes: 0 additions & 114 deletions app/components/oauth/applications/row_component.rb

This file was deleted.

78 changes: 0 additions & 78 deletions app/components/oauth/applications/table_component.rb

This file was deleted.

Loading

0 comments on commit 8945bcc

Please sign in to comment.