From e9f87210798b31b750686fe14a18578d2287b60e Mon Sep 17 00:00:00 2001 From: Kabiru Mwenja Date: Wed, 7 Aug 2024 19:33:46 +0300 Subject: [PATCH] feat[Op#56284]: specify last project folders in edit --- .../projects_storage_modal_component.html.erb | 2 +- .../storages/projects_storage_modal_component.rb | 6 ++++-- .../admin/storages/project_storages_controller.rb | 13 +++++++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/modules/storages/app/components/storages/admin/storages/projects_storage_modal_component.html.erb b/modules/storages/app/components/storages/admin/storages/projects_storage_modal_component.html.erb index c9e52ec9a58b..ea922f722acf 100644 --- a/modules/storages/app/components/storages/admin/storages/projects_storage_modal_component.html.erb +++ b/modules/storages/app/components/storages/admin/storages/projects_storage_modal_component.html.erb @@ -13,6 +13,6 @@ variant: :large ) - render(::Storages::Admin::Storages::ProjectsStorageFormModalComponent.new(project_storage:)) + render(::Storages::Admin::Storages::ProjectsStorageFormModalComponent.new(project_storage:, last_project_folders:)) end %> diff --git a/modules/storages/app/components/storages/admin/storages/projects_storage_modal_component.rb b/modules/storages/app/components/storages/admin/storages/projects_storage_modal_component.rb index c5093ae5c8af..a07edd7b0441 100644 --- a/modules/storages/app/components/storages/admin/storages/projects_storage_modal_component.rb +++ b/modules/storages/app/components/storages/admin/storages/projects_storage_modal_component.rb @@ -35,9 +35,11 @@ class ProjectsStorageModalComponent < ApplicationComponent DIALOG_ID = "storages--projects-storage-modal".freeze DIALOG_BODY_ID = "storages--projects-storage-modal-body".freeze - def initialize(project_storage:, **) + def initialize(project_storage:, last_project_folders:, **) @project_storage = project_storage @storage = project_storage.storage + @last_project_folders = last_project_folders + super(@project_storage, **) end @@ -46,7 +48,7 @@ def initialize(project_storage:, **) def dialog_id = DIALOG_ID def dialog_body_id = DIALOG_BODY_ID - attr_reader :project_storage, :storage + attr_reader :project_storage, :storage, :last_project_folders def title if new_record? diff --git a/modules/storages/app/controllers/storages/admin/storages/project_storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages/project_storages_controller.rb index f6dfcdc63ff4..1d763048323e 100644 --- a/modules/storages/app/controllers/storages/admin/storages/project_storages_controller.rb +++ b/modules/storages/app/controllers/storages/admin/storages/project_storages_controller.rb @@ -52,7 +52,9 @@ class Storages::Admin::Storages::ProjectStoragesController < ApplicationControll def index; end def new - respond_with_dialog Storages::Admin::Storages::ProjectsStorageModalComponent.new(project_storage: @project_storage) + respond_with_dialog Storages::Admin::Storages::ProjectsStorageModalComponent.new( + project_storage: @project_storage, last_project_folders: {} + ) end def create # rubocop:disable Metrics/AbcSize @@ -74,7 +76,14 @@ def create # rubocop:disable Metrics/AbcSize end def edit - respond_with_dialog Storages::Admin::Storages::ProjectsStorageModalComponent.new(project_storage: @project_storage) + last_project_folders = Storages::LastProjectFolder + .where(project_storage: @project_storage) + .pluck(:mode, :origin_folder_id) + .to_h + + respond_with_dialog Storages::Admin::Storages::ProjectsStorageModalComponent.new( + project_storage: @project_storage, last_project_folders: + ) end def update