Skip to content

Commit

Permalink
Merge pull request #13525 from opf/feature/remove-show-storage
Browse files Browse the repository at this point in the history
Backport removal of Storage Show Page to 13.0
  • Loading branch information
mereghost committed Sep 5, 2023
2 parents 329cb85 + 31d9680 commit aacf8fe
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 177 deletions.
8 changes: 5 additions & 3 deletions app/controllers/oauth_clients_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
Expand Down Expand Up @@ -61,7 +63,7 @@ def callback
redirect_user_or_admin(@redirect_uri) do
# If the current user is an admin, we send her directly to the
# settings that she needs to edit.
redirect_to admin_settings_storage_path(@oauth_client.integration)
redirect_to edit_admin_settings_storage_path(@oauth_client.integration)
end
end
end
Expand Down Expand Up @@ -96,7 +98,7 @@ def set_code
redirect_user_or_admin(get_redirect_uri) do
# If the current user is an admin, we send her directly to the
# settings that she needs to edit/fix.
redirect_to admin_settings_storage_path(@oauth_client.integration)
redirect_to edit_admin_settings_storage_path(@oauth_client.integration)
end
end
end
Expand All @@ -118,7 +120,7 @@ def set_redirect_uri

redirect_user_or_admin(nil) do
# Guide the user to the settings that she needs to edit/fix.
redirect_to admin_settings_storage_path(@oauth_client.integration)
redirect_to edit_admin_settings_storage_path(@oauth_client.integration)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
Expand Down Expand Up @@ -82,7 +84,7 @@ def update

if service_result.success?
flash[:notice] = I18n.t(:notice_successful_update)
redirect_to admin_settings_storage_path(@storage)
redirect_to edit_admin_settings_storage_path(@storage)
else
@errors = service_result.errors
render '/storages/admin/storages/automatically_managed_project_folders/edit'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
Expand Down Expand Up @@ -64,7 +66,7 @@ def create # rubocop:disable Metrics/AbcSize
if @storage.automatic_management_unspecified?
redirect_to new_admin_settings_storage_automatically_managed_project_folders_path(@storage)
else
redirect_to admin_settings_storage_path(@storage)
redirect_to edit_admin_settings_storage_path(@storage)
end
else
@errors = service_result.errors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
Expand Down Expand Up @@ -52,10 +54,6 @@ def index
@storages = Storages::Storage.all
end

# Show page with details of one Storage object.
# Called by: Global app/config/routes.rb to serve Web page
def show; end

# Show the admin page to create a new Storage object.
# Sets the attributes provider_type and name as default values and then
# renders the new page (allowing the user to overwrite these values and to
Expand Down Expand Up @@ -109,7 +107,7 @@ def update

if service_result.success?
flash[:notice] = I18n.t(:notice_successful_update)
redirect_to admin_settings_storage_path(@object)
redirect_to edit_admin_settings_storage_path(@object)
else
@errors = service_result.errors
render :edit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ See COPYRIGHT and LICENSE files for more details.
<% html_title t(:label_administration), t("project_module_storages"), @storage.name, t("storages.page_titles.managed_project_folders.title") %>
<% local_assigns[:additional_breadcrumb] = [
link_to(@storage.name, admin_settings_storage_path(@storage)),
link_to(@storage.name, edit_admin_settings_storage_path(@storage)),
t("storages.label_managed_project_folders_breadcrumb")
] %>
<%= toolbar title: t("storages.page_titles.managed_project_folders.title"),
Expand Down Expand Up @@ -98,7 +98,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= styled_button_tag t("storages.buttons.save"), class: "-highlight -with-icon icon-checkmark" %>
<% end %>
<%= link_to admin_settings_storage_path(@storage), class: 'button' do %>
<%= link_to edit_admin_settings_storage_path(@storage), class: 'button' do %>
<%= spot_icon('cancel') %>
<%= content_tag :span, t(:button_cancel) %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- Standard Ruby view, please see the controller for comments -->
<% 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")}" %>
<% local_assigns[:additional_breadcrumb] = [
link_to(@storage.name, admin_settings_storage_path(@storage)),
link_to(@storage.name, edit_admin_settings_storage_path(@storage)),
t("storages.label_oauth_breadcrumb.#{@storage.short_provider_type}")
] %>
<%= toolbar title: "#{t("storages.provider_types.#{@storage.short_provider_type}.name")} #{t("storages.label_oauth_client_details")}" %>
Expand Down
121 changes: 0 additions & 121 deletions modules/storages/app/views/storages/admin/storages/show.html.erb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- Standard Ruby view, please see the controller for comments -->
<% html_title t(:label_administration), t("project_module_storages"), @object.name, "#{t("storages.provider_types.#{@object.short_provider_type}.name")} #{t("storages.label_oauth_application_details")}" %>
<% local_assigns[:additional_breadcrumb] = [
link_to(@object.name, admin_settings_storage_path(@object)),
link_to(@object.name, edit_admin_settings_storage_path(@object)),
t("storages.label_oauth_breadcrumb.openproject")
] %>
<%= toolbar title: "OpenProject #{t("storages.label_oauth_application_details")}" %>
Expand Down Expand Up @@ -84,7 +84,7 @@
</fieldset>

<% if @object.oauth_client %>
<%= link_to t("storages.buttons.done_continue_setup"), admin_settings_storage_path(@object), class: "-highlight -with-icon icon-checkmark button" %>
<%= link_to t("storages.buttons.done_continue_setup"), edit_admin_settings_storage_path(@object), class: "-highlight -with-icon icon-checkmark button" %>
<% else %>
<%= link_to t("storages.buttons.done_continue_setup"), new_admin_settings_storage_oauth_client_path(@object), class: "-highlight -with-icon icon-checkmark button" %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= content_tag(:p,
t("storages.page_titles.project_storage_members.subtitle",
storage_name_link: link_to(@storage.name, admin_settings_storage_path(@storage))).html_safe
storage_name_link: link_to(@storage.name, edit_admin_settings_storage_path(@storage))).html_safe
) %>
<%= render(::Storages::ProjectStorages::Members::TableComponent.new(rows: @memberships, storage: @storage)) %>
4 changes: 3 additions & 1 deletion modules/storages/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
Expand Down Expand Up @@ -29,7 +31,7 @@
OpenProject::Application.routes.draw do
namespace :admin do
namespace :settings do
resources :storages, controller: '/storages/admin/storages' do
resources :storages, controller: '/storages/admin/storages', except: [:show] do
resource :oauth_client, controller: '/storages/admin/oauth_clients', only: %i[new create]
resource :automatically_managed_project_folders, controller: '/storages/admin/automatically_managed_project_folders',
only: %i[new edit update]
Expand Down
38 changes: 8 additions & 30 deletions modules/storages/spec/features/admin_storages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
RSpec.describe 'Admin storages', :storage_server_helpers, js: true do
let(:admin) { create(:admin) }

before do
login_as admin
end
before { login_as admin }

it 'creates, edits and deletes storages', webmock: true do
visit admin_settings_storages_path
Expand Down Expand Up @@ -136,20 +134,7 @@
expect(page).to have_text("●●●●●●●●●●●●●●●●")
######### Step 4: End Automatically managed project folders #########

# Show details of a storage
created_storage = Storages::Storage.find_by(name: 'NC 1')
expect(page).to have_title("Nc 1")
expect(page.find('.title-container')).to have_text('NC 1')
expect(page).to have_text(admin.name)
expect(page).to have_text('https://example.com')
expect(page).to have_text(created_storage.created_at.localtime.strftime("%m/%d/%Y %I:%M %p"))
# Check for client_id of nextcloud client and oauth application
expect(page).to have_text(oauth_app_client_id)
expect(page).to have_text("0123456789")
# Check for the automatically managed project folders settings

# Edit storage again
page.find('.button--icon.icon-edit').click
expect(page).to have_title("Edit: NC 1")
expect(page).not_to have_select("storages_storage[provider_type]")
expect(page).to have_text("NC 1")
Expand All @@ -175,7 +160,6 @@

# Test the behavior of a failed host validation with code 400 (Bad Request)
# simulating server not running Nextcloud
page.find('.button--icon.icon-edit').click
mock_server_capabilities_response("https://other.example.com", response_code: '400')
page.find_by_id('storages_storage_name').set("Other NC")
page.find_by_id('storages_storage_host').set("https://other.example.com")
Expand Down Expand Up @@ -204,26 +188,17 @@
page.find_by_id('storages_storage_name').set("Other NC")
page.find('button[type=submit]', text: "Save").click

created_storage = Storages::Storage.find_by(name: 'Other NC')
expect(page).to have_title("Other Nc")
expect(page.find('.title-container')).to have_text('Other NC')
expect(page).to have_text(admin.name)
expect(page).to have_text('https://example.com')
expect(page).to have_text(created_storage.created_at.localtime.strftime("%m/%d/%Y %I:%M %p"))

######### Begin Edit Automatically managed project folders #########
page.find('.button--icon.icon-edit').click

#
# Confirm update of host URL with subpath renders correctly Nextcloud/Administration link
mock_server_capabilities_response("https://example.com/with/subpath")
mock_server_config_check_response("https://example.com/with/subpath")
page.find_by_id('storages_storage_host').set("https://example.com/with/subpath")
page.click_button('Save')

# Check for updated host URL
expect(page).to have_text("https://example.com/with/subpath")
expect(page.find_by_id('storages_storage_host').value).to eq("https://example.com/with/subpath")

page.find('.button--icon.icon-edit').click
page.find('a', text: 'Edit automatically managed project folders').click

expect(page).to have_title("Automatically managed project folders")
Expand All @@ -232,9 +207,12 @@
expect(automatically_managed_switch).to be_checked
expect(application_password_input.value).to be_empty
expect(application_password_input['placeholder']).to eq("●●●●●●●●●●●●●●●●")
expect(page).to have_link(text: 'Nextcloud Administration / OpenProject', href: 'https://example.com/with/subpath/settings/admin/openproject')
expect(page).to have_link(
text: 'Nextcloud Administration / OpenProject',
href: 'https://example.com/with/subpath/settings/admin/openproject'
)

# Clicking submit without inputing new application password should show an error
# Clicking submit without inputting new application password should show an error
page.click_button('Save')
# Check that we're still on the same page
expect(page).to have_title("Automatically managed project folders")
Expand Down
6 changes: 4 additions & 2 deletions modules/storages/spec/features/create_file_links_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
Expand Down Expand Up @@ -35,7 +37,7 @@
let(:work_package) { create(:work_package, project:, description: 'Initial description') }

let(:oauth_application) { create(:oauth_application) }
let(:storage) { create(:storage, oauth_application:) }
let(:storage) { create(:nextcloud_storage, oauth_application:) }
let(:oauth_client) { create(:oauth_client, integration: storage) }
let(:oauth_client_token) { create(:oauth_client_token, oauth_client:, user: current_user) }
let(:project_storage) { create(:project_storage, project:, storage:, project_folder_id: nil, project_folder_mode: 'inactive') }
Expand All @@ -62,7 +64,7 @@
stub_request(:get, "#{storage.host}/ocs/v1.php/cloud/user")
.with(
headers: {
'Authorization' => 'Bearer 1234567890-1',
'Authorization' => "Bearer #{oauth_client_token.access_token}",
'Ocs-Apirequest' => 'true',
'Accept' => "application/json"
}
Expand Down

0 comments on commit aacf8fe

Please sign in to comment.