Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#51229] Remove feature flags for storage_primer_design and storage_one_drive_integration #14242

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,17 @@ def create # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
end

service_result.on_success do
if OpenProject::FeatureDecisions.storage_primer_design_active?
if @storage.provider_type_nextcloud?
prepare_storage_for_automatic_management_form

respond_to do |format|
format.turbo_stream { render :create }
end
elsif @storage.provider_type_one_drive?
flash[:notice] = I18n.t(:'storages.notice_successful_storage_connection')
redirect_to admin_settings_storages_path
else
raise "Unsupported provider type: #{@storage.short_provider_type}"
end
else
flash[:notice] = I18n.t(:notice_successful_create)
if @storage.provider_type_nextcloud?
prepare_storage_for_automatic_management_form

if @storage.provider_type_nextcloud? && @storage.automatic_management_unspecified?
prepare_storage_for_automatic_management_form
redirect_to new_admin_settings_storage_automatically_managed_project_folders_path(@storage)
else
redirect_to edit_admin_settings_storage_path(@storage)
respond_to do |format|
format.turbo_stream { render :create }
end
elsif @storage.provider_type_one_drive?
flash[:notice] = I18n.t(:'storages.notice_successful_storage_connection')
redirect_to admin_settings_storages_path
else
raise "Unsupported provider type: #{@storage.short_provider_type}"
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,9 @@ def new
# Set default parameters using a "service".
# See also: storages/services/storages/storages/set_attributes_services.rb
# That service inherits from ::BaseServices::SetAttributes
model_class = OpenProject::FeatureDecisions.storage_primer_design_active? ? Storages::Storage : Storages::NextcloudStorage
@storage = ::Storages::Storages::SetAttributesService
.new(user: current_user,
model: model_class.new,
model: Storages::Storage.new,
contract_class: EmptyContract)
.call
.result
Expand Down Expand Up @@ -105,32 +104,13 @@ def create # rubocop:disable Metrics/AbcSize
@oauth_application = oauth_application(service_result)

service_result.on_failure do
if OpenProject::FeatureDecisions.storage_primer_design_active?
respond_to do |format|
format.turbo_stream { render :select_provider }
end
else
render :new
respond_to do |format|
format.turbo_stream { render :select_provider }
end
end

service_result.on_success do
if OpenProject::FeatureDecisions.storage_primer_design_active?
respond_to { |format| format.turbo_stream }
else
case @storage.provider_type
when ::Storages::Storage::PROVIDER_TYPE_ONE_DRIVE
flash.now[:notice] = I18n.t(:notice_successful_create)
render '/storages/admin/storages/one_drive/edit'
when ::Storages::Storage::PROVIDER_TYPE_NEXTCLOUD
if @oauth_application.present?
flash.now[:notice] = I18n.t(:notice_successful_create)
render :show_oauth_application
end
else
raise "Unknown provider type: #{storage_params['provider_type']}"
end
end
respond_to { |format| format.turbo_stream }
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,85 +29,4 @@ 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") %>

<% if OpenProject::FeatureDecisions.storage_primer_design_active? %>
<%=
render(Storages::Admin::StorageViewComponent.new(@storage, automatically_managed_project_folders_section_open: true))
%>
<% else %>
<% local_assigns[:additional_breadcrumb] = [
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"),
subtitle: t("storages.page_titles.managed_project_folders.subtitle")
%>

<%= error_messages_for @storage %>

<%= labelled_tabular_form_for @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 |f| -%>
<div class="form--field -required">
<%= styled_label_tag :automatically_managed, class: "-bold -flex" do %>
<%= t(:"storages.label_managed_project_folders.automatically_managed_folders") %>
<% end %>

<div class="form--field-container -horizontal">
<label class="form--field-inline-buttons-container">
<%= angular_component_tag 'spot-switch',
inputs: {
id: "storages_#{@storage.short_provider_type}_storage_automatically_managed",
name: "storages_#{@storage.short_provider_type}_storage[automatically_managed]",
checked: @storage.automatically_managed?,
},
data: {
action: 'change->storages--automatically-managed-project-folders-form#updateDisplay',
}
%>
</label>
</div>
</div>

<div class="form--field -required"
data-storages--automatically-managed-project-folders-form-target="applicationPasswordInput">
<label class="form--label -bold"> <%= t(:"storages.label_managed_project_folders.application_password") %> </label>
<div class="form--field-container -horizontal">
<%= f.text_field :password,
container_class: "-middle",
no_label: true,
value: nil, # IMPORTANT: We don't want to show the password in the form
placeholder: @storage.password.present? ? "●●●●●●●●●●●●●●●●" : nil
%>
</div>
<p class="form--field-instructions -xwide">
<%= t(:"storages.instructions.managed_project_folders_application_password") %>
<a
href="<%= Storages::Peripherals::StorageInteraction::Nextcloud::Util
.join_uri_path(@storage.oauth_application.integration.host, 'settings/admin/openproject') %>"
target="_blank"
class="spot-link"
>
<span><%= t("storages.instructions.#{@storage.short_provider_type}.integration") %></span>
</a>
</p>
</div>

<div class="form--field">
<% case action_name %>
<% when 'new' %>
<%= styled_button_tag t("storages.buttons.done_complete_setup"), class: "-highlight -with-icon icon-checkmark" %>
<% else %>
<%= styled_button_tag t("storages.buttons.save"), class: "-highlight -with-icon icon-checkmark" %>
<% end %>

<%= link_to edit_admin_settings_storage_path(@storage), class: 'button' do %>
<%= spot_icon('cancel') %>
<%= content_tag :span, t(:button_cancel) %>
<% end %>
</div>
<% end %>
<% end %>
<%= render(Storages::Admin::StorageViewComponent.new(@storage, automatically_managed_project_folders_section_open: true)) %>
118 changes: 31 additions & 87 deletions modules/storages/app/views/storages/admin/storages/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,98 +30,42 @@ See COPYRIGHT and LICENSE files for more details.
<% html_title t(:label_administration), t("project_module_storages"), t('label_edit_x', x: @storage.name) %>
<% local_assigns[:additional_breadcrumb] = @storage.name %>

<% if OpenProject::FeatureDecisions.storage_primer_design_active? %>
<%= render(Primer::OpenProject::PageHeader.new) do |header| %>
<% header.with_title(test_selector: 'storage-name-title') do %>
<%= render OpTurbo::FrameComponent.new(@storage, context: :edit_storage_header) do %>
<%= @storage.name %>
<% end %>
<% end %>

<% header.with_back_button(href: admin_settings_storages_path, 'aria-label': I18n.t("button_back")) %>

<% header.with_parent_link(href: admin_settings_storages_path, 'aria-label': I18n.t("button_back")) do %>
<%= t(:project_module_storages) %>
<% end %>

<% header.with_actions do %>
<%=
primer_form_with(
model: @storage,
url: admin_settings_storage_path(@storage),
method: :delete
) do |_form|
render(
Primer::Beta::Button.new(
scheme: :danger,
size: :medium,
type: :submit,
aria: { label: I18n.t("storages.label_delete_storage") },
data: { confirm: I18n.t('storages.delete_warning.storage') },
test_selector: 'storage-delete-button'
)
) do |button|
button.with_leading_visual_icon(icon: :trash)
I18n.t('button_delete')
end
end
%>
<%= render(Primer::OpenProject::PageHeader.new) do |header| %>
<% header.with_title(test_selector: 'storage-name-title') do %>
<%= render OpTurbo::FrameComponent.new(@storage, context: :edit_storage_header) do %>
<%= @storage.name %>
<% end %>
<% end %>

<%= render(::Storages::Admin::StorageViewComponent.new(@storage)) %>
<% else %>
<%= toolbar title: t('label_edit_x', x: @storage.name) %>
<% header.with_back_button(href: admin_settings_storages_path, 'aria-label': I18n.t("button_back")) %>

<%= render(::Storages::Admin::ConfigurationChecksComponent.new(storage: @storage)) %>

<%= labelled_tabular_form_for @storage, url: admin_settings_storage_path(@storage), as: :storages_storage do |f| -%>
<%= render partial: "storages/admin/storages/#{@storage.short_provider_type}/edit", locals: { f: f } %>
<%= styled_button_tag t(:button_save), class: "-highlight -with-icon icon-checkmark" %>
<% header.with_parent_link(href: admin_settings_storages_path, 'aria-label': I18n.t("button_back")) do %>
<%= t(:project_module_storages) %>
<% end %>

<% if @storage.oauth_application %>
<%= render(AttributeGroups::AttributeGroupComponent.new) do |component| %>
<% component.with_header(title: "OpenProject #{t(:'storages.label_oauth_application_details')}") %>

<% component.with_attributes([
{ key: "OpenProject #{Storages::Admin::LABEL_OAUTH_CLIENT_ID}", value: @storage.oauth_application.uid },
{ key: "OpenProject #{Storages::Admin::LABEL_OAUTH_CLIENT_SECRET}", value: "●●●●●●●●●●●●●●●●" },
]) %>

<%= link_to(t("storages.buttons.replace_openproject_oauth"),
replace_oauth_application_admin_settings_storage_path(@storage),
method: :delete,
data: { confirm: t(:'storages.confirm_replace_oauth_application') },
class: 'button -with-icon icon-reload') %>
<% end %>
<% end %>

<%= render partial: "storages/admin/storages/#{@storage.short_provider_type}/oauth_client_section" %>

<% if @storage.provider_type_nextcloud? %>
<%= render(AttributeGroups::AttributeGroupComponent.new) do |component| %>
<% component.with_header(title: t("storages.page_titles.managed_project_folders.title")) %>

<% if @storage.automatic_management_unspecified? %>
<%= link_to(t("storages.buttons.configure"), new_admin_settings_storage_automatically_managed_project_folders_path(@storage), class: 'button -with-icon icon-add') %>
<% else %>
<% component.with_attribute(
key: t(:"storages.label_managed_project_folders.automatically_managed_folders"),
value: @storage.automatically_managed? ? t(:"storages.label_active") : t(:"storages.label_inactive")
) %>

<% if @storage.automatically_managed? %>
<% component.with_attribute(
key: t(:"storages.label_managed_project_folders.application_password"),
value: "●●●●●●●●●●●●●●●●"
) %>
<% end %>

<%= link_to(t("storages.buttons.edit_automatically_managed_project_folders"),
edit_admin_settings_storage_automatically_managed_project_folders_path(@storage),
class: 'button -with-icon icon-edit') %>
<% end %>
<% end %>
<% header.with_actions do %>
<%=
primer_form_with(
model: @storage,
url: admin_settings_storage_path(@storage),
method: :delete
) do |_form|
render(
Primer::Beta::Button.new(
scheme: :danger,
size: :medium,
type: :submit,
aria: { label: I18n.t("storages.label_delete_storage") },
data: { confirm: I18n.t('storages.delete_warning.storage') },
test_selector: 'storage-delete-button'
)
) do |button|
button.with_leading_visual_icon(icon: :trash)
I18n.t('button_delete')
end
end
%>
<% end %>
<% end %>

<%= render(::Storages::Admin::StorageViewComponent.new(@storage)) %>
52 changes: 10 additions & 42 deletions modules/storages/app/views/storages/admin/storages/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,50 +1,18 @@
<!-- Standard Ruby view, please see the controller for comments -->
<% html_title t(:label_administration), t("project_module_storages") %>

<% if OpenProject::FeatureDecisions.storage_primer_design_active? %>
<%= render(Primer::OpenProject::PageHeader.new) do |header| %>
<% header.with_title do %>
<%= t("project_module_storages") %>
<% end %>

<% header.with_description do %>
<%= t("storages.page_titles.file_storages.subtitle") %>
<% end %>

<% header.with_actions do %>
<%= render(Storages::Admin::NewStorageButtonComponent.new) %>
<% end %>
<%= render(Primer::OpenProject::PageHeader.new) do |header| %>
<% header.with_title do %>
<%= t("project_module_storages") %>
<% end %>

<%= render(::Storages::Admin::StorageListComponent.new(@storages)) %>

<% else %>
<%= toolbar title: t("project_module_storages") do %>
<li class="toolbar-item">
<%= link_to new_admin_settings_storage_path,
{ class: 'button -alt-highlight',
aria: { label: t('storages.label_new_storage') },
title: t('storages.label_new_storage') } do %>
<%= op_icon('button--icon icon-add') %>
<span class="button--text"><%= ::Storages::Storage.model_name.human %></span>
<% end %>
</li>
<% header.with_description do %>
<%= t("storages.page_titles.file_storages.subtitle") %>
<% end %>

<div class="op-toast -info -with-bottom-spacing">
<div class="op-toast--content">
<p>
<%= t('repositories.storage.setup_documentation_details') %>
<a
href="<%= ::OpenProject::Static::Links[:storage_docs][:setup][:href] %>"
target="_blank"
class="spot-link"
>
<%= t('repositories.storage.setup_documentation_details_link_text') %>
</a>
</p>
</div>
</div>

<%= render(::Storages::Admin::TableComponent.new(rows: @storages)) %>
<% header.with_actions do %>
<%= render(Storages::Admin::NewStorageButtonComponent.new) %>
<% end %>
<% end %>

<%= render(::Storages::Admin::StorageListComponent.new(@storages)) %>
Loading
Loading