-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13866 from opf/implementation/50212-convert-the-e…
…dit-page-to-primer-design [#50212] Convert file storage edit view to primer design
- Loading branch information
Showing
32 changed files
with
1,444 additions
and
212 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
app/components/open_project/common/clipboard_copy_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<%= | ||
render(Primer::Beta::Text.new(tag: :div, flex_items: :center, display: :flex)) do | ||
concat(render(Primer::Alpha::TextField.new(**text_field_options))) | ||
concat(render(Primer::Beta::ClipboardCopy.new(**clipboard_copy_options))) | ||
end | ||
%> |
72 changes: 72 additions & 0 deletions
72
app/components/open_project/common/clipboard_copy_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# frozen_string_literal: true | ||
|
||
#-- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2012-2023 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 OpenProject::Common | ||
class ClipboardCopyComponent < ApplicationComponent | ||
include OpPrimer::ComponentHelpers | ||
|
||
options visually_hide_label: true, | ||
readonly: true, | ||
required: false | ||
|
||
def text_field_options | ||
{ name: options[:name], | ||
label: options[:label], | ||
classes: "rounded-right-0", | ||
visually_hide_label:, | ||
value: value_to_copy, | ||
inset: true, | ||
readonly:, | ||
required: } | ||
end | ||
|
||
def clipboard_copy_options | ||
{ value: value_to_copy, | ||
aria: { label: clipboard_copy_aria_label }, | ||
classes: clipboard_copy_classes } | ||
end | ||
|
||
private | ||
|
||
def clipboard_copy_classes | ||
%w[Button Button--iconOnly Button--secondary Button--medium rounded-left-0 border-left-0].tap do |classes| | ||
classes << "mt-4" unless visually_hide_label | ||
end | ||
end | ||
|
||
def clipboard_copy_aria_label | ||
options[:clipboard_copy_aria_label] || I18n.t('button_copy_to_clipboard') | ||
end | ||
|
||
def value_to_copy | ||
options[:value_to_copy] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
@import "storages/admin/storage_list_component" | ||
@import "storages/admin/storage_view_component" |
36 changes: 36 additions & 0 deletions
36
...onents/storages/admin/forms/automatically_managed_project_folders_form_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<%= | ||
render(Primer::Beta::Text.new(tag: :div, test_selector: 'storage-automatically-managed-project-folders-form')) do | ||
primer_form_with( | ||
model: storage, | ||
url: admin_settings_storage_automatically_managed_project_folders_path(storage), | ||
method: :patch, | ||
data: { | ||
controller: "storages--automatically-managed-project-folders-form", | ||
'application-target': "dynamic", | ||
'storages--automatically-managed-project-folders-form-is-automatically-managed-value': storage.automatically_managed?, | ||
} | ||
) do |form| | ||
flex_layout do |project_folders_form| | ||
project_folders_form.with_row(mb: 3) do | ||
render(Primer::Beta::Text.new(font_weight: :semibold)) { I18n.t(:'storages.label_managed_project_folders.automatically_managed_folders') } | ||
end | ||
|
||
project_folders_form.with_row(mb: 3) do | ||
render(Primer::Beta::Text.new(font_weight: :light)) { I18n.t("storages.page_titles.managed_project_folders.subtitle") } | ||
end | ||
|
||
project_folders_form.with_row(mb: 3) do | ||
render(Storages::Admin::ManagedProjectFolders::AutomaticallyManagedCheckbox.new(form, storage:)) | ||
end | ||
|
||
project_folders_form.with_row(mb: 3, data: { 'storages--automatically-managed-project-folders-form-target': "applicationPasswordInput" }) do | ||
render(Storages::Admin::ManagedProjectFolders::ApplicationPasswordInput.new(form, storage:)) | ||
end | ||
|
||
project_folders_form.with_row do | ||
render(Storages::Admin::SaveOrCancelForm.new(form, storage:, submit_label: I18n.t("storages.buttons.done_complete_setup"))) | ||
end | ||
end | ||
end | ||
end | ||
%> |
52 changes: 52 additions & 0 deletions
52
...p/components/storages/admin/forms/automatically_managed_project_folders_form_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
|
||
#-- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2012-2023 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 Storages::Admin::Forms | ||
class AutomaticallyManagedProjectFoldersFormComponent < ApplicationComponent | ||
include OpPrimer::ComponentHelpers | ||
alias_method :storage, :model | ||
|
||
private | ||
|
||
def storage_provider_credentials_copy_instructions | ||
"#{I18n.t('storages.instructions.copy_from')}: #{provider_credentials_instructions_link}".html_safe | ||
end | ||
|
||
def provider_credentials_instructions_link | ||
render( | ||
Primer::Beta::Link.new( | ||
href: Storages::Peripherals::StorageInteraction::Nextcloud::Util.join_uri_path(storage.host, | ||
'settings/admin/openproject'), | ||
target: '_blank' | ||
) | ||
) { I18n.t("storages.instructions.#{storage.short_provider_type}.integration") } | ||
end | ||
end | ||
end |
19 changes: 19 additions & 0 deletions
19
modules/storages/app/components/storages/admin/forms/general_info_form_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<%= | ||
render(Primer::Beta::Text.new(tag: :div, test_selector: 'storage-general-info-form')) do | ||
primer_form_with( | ||
model: storage, | ||
url: admin_settings_storage_path(storage), | ||
method: :patch | ||
) do |form| | ||
flex_layout do |general_info_row| | ||
general_info_row.with_row(mb: 3) do | ||
render(Storages::Admin::StorageProviderForm.new(form, storage:)) | ||
end | ||
|
||
general_info_row.with_row do | ||
render(Storages::Admin::SaveOrCancelForm.new(form, storage:)) | ||
end | ||
end | ||
end | ||
end | ||
%> |
36 changes: 36 additions & 0 deletions
36
modules/storages/app/components/storages/admin/forms/general_info_form_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
#-- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2012-2023 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 Storages::Admin::Forms | ||
class GeneralInfoFormComponent < ApplicationComponent | ||
include OpPrimer::ComponentHelpers | ||
alias_method :storage, :model | ||
end | ||
end |
26 changes: 26 additions & 0 deletions
26
modules/storages/app/components/storages/admin/forms/oauth_client_form_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<%= | ||
render(Primer::Beta::Text.new(tag: :div, test_selector: 'storage-oauth-client-form')) do | ||
primer_form_with( | ||
model: oauth_client, | ||
url: admin_settings_storage_oauth_client_path(storage) | ||
) do |form| | ||
flex_layout do |oauth_client_row| | ||
oauth_client_row.with_row(mb: 3) do | ||
render(Primer::Beta::Text.new(font_weight: :semibold)) { I18n.t("storages.file_storage_view.#{storage.short_provider_type}_oauth") } | ||
end | ||
|
||
oauth_client_row.with_row(mb: 3) do | ||
render(Primer::Beta::Text.new(font_weight: :light)) { storage_provider_credentials_copy_instructions } | ||
end | ||
|
||
oauth_client_row.with_row(mb: 3) do | ||
render(Storages::Admin::OAuthClientForm.new(form, storage:)) | ||
end | ||
|
||
oauth_client_row.with_row do | ||
render(Storages::Admin::SaveOrCancelForm.new(form, storage:)) | ||
end | ||
end | ||
end | ||
end | ||
%> |
59 changes: 59 additions & 0 deletions
59
modules/storages/app/components/storages/admin/forms/oauth_client_form_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# frozen_string_literal: true | ||
|
||
#-- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2012-2023 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 Storages::Admin::Forms | ||
class OAuthClientFormComponent < ApplicationComponent | ||
include OpPrimer::ComponentHelpers | ||
|
||
attr_reader :storage | ||
alias_method :oauth_client, :model | ||
|
||
def initialize(oauth_client:, storage:, **options) | ||
super(oauth_client, **options) | ||
@storage = storage | ||
end | ||
|
||
private | ||
|
||
def storage_provider_credentials_copy_instructions | ||
"#{I18n.t('storages.instructions.copy_from')}: #{provider_credentials_instructions_link}".html_safe | ||
end | ||
|
||
def provider_credentials_instructions_link | ||
render( | ||
Primer::Beta::Link.new( | ||
href: Storages::Peripherals::StorageInteraction::Nextcloud::Util.join_uri_path(storage.host, | ||
'settings/admin/openproject'), | ||
target: '_blank' | ||
) | ||
) { I18n.t("storages.instructions.#{@storage.short_provider_type}.integration") } | ||
end | ||
end | ||
end |
40 changes: 40 additions & 0 deletions
40
...rages/app/components/storages/admin/oauth_application_credentials_copy_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<%= | ||
render(Primer::Beta::Text.new(tag: :div, test_selector: 'storage-openproject-oauth-application-form')) do | ||
flex_layout(flex_items: :center) do |credentials_row| | ||
credentials_row.with_row(mb: 3, test_selector: 'storage-openproject_oauth_application_warning') do | ||
render(Primer::Beta::Flash.new(icon: :alert, scheme: :warning)) do | ||
I18n.t('storages.instructions.oauth_application_details', oauth_application_details_link: oauth_application_details_link).html_safe | ||
end | ||
end | ||
|
||
credentials_row.with_row(mb: 3) do | ||
render( | ||
OpenProject::Common::ClipboardCopyComponent.new( | ||
name: :openproject_oauth_application_uid, | ||
visually_hide_label: false, | ||
value_to_copy: oauth_application.uid, | ||
label: I18n.t('storages.label_openproject_oauth_application_id'), | ||
required: true | ||
) | ||
) | ||
end | ||
|
||
credentials_row.with_row(mb: 3) do | ||
render( | ||
OpenProject::Common::ClipboardCopyComponent.new( | ||
name: :openproject_oauth_application_secret, | ||
visually_hide_label: false, | ||
value_to_copy: oauth_application.secret, | ||
label: I18n.t('storages.label_openproject_oauth_application_secret'), | ||
required: true | ||
) | ||
) | ||
end | ||
|
||
credentials_row.with_row do | ||
concat(render(Primer::Beta::Button.new(scheme: :primary, tag: :a, href: edit_admin_settings_storage_path(storage))) { I18n.t('storages.buttons.done_continue') }) | ||
concat(render(Primer::Beta::Button.new(scheme: :default, tag: :a, href: edit_admin_settings_storage_path(storage))) { I18n.t('button_cancel') }) | ||
end | ||
end | ||
end | ||
%> |
Oops, something went wrong.