Class: SourceMonitor::ImportSessionsController

Inherits:
ApplicationController show all
Includes:
SourceMonitor::ImportSessions::BulkConfiguration
Defined in:
app/controllers/source_monitor/import_sessions_controller.rb

Constant Summary collapse

STEP_HANDLERS =
{
  "upload" => :handle_upload_step,
  "preview" => :handle_preview_step,
  "health_check" => :handle_health_check_step,
  "configure" => :handle_configure_step,
  "confirm" => :handle_confirm_step
}.freeze
STEP_CONTEXTS =
{
  "preview" => :prepare_preview_context,
  "health_check" => :prepare_health_check_context,
  "configure" => :prepare_configure_context,
  "confirm" => :prepare_confirm_context
}.freeze

Instance Method Summary collapse

Instance Method Details

#createObject



38
39
40
41
42
43
44
45
# File 'app/controllers/source_monitor/import_sessions_controller.rb', line 38

def create
  import_session = ImportSession.create!(
    user_id: current_user_id,
    current_step: ImportSession.default_step
  )

  redirect_to source_monitor.step_import_session_path(import_session, step: import_session.current_step)
end

#destroyObject



65
66
67
68
# File 'app/controllers/source_monitor/import_sessions_controller.rb', line 65

def destroy
  @import_session.destroy
  redirect_to source_monitor.sources_path, notice: "Import canceled"
end

#newObject

The OPML import wizard requires a persisted ImportSession record to track state across steps (file upload, preview, health check, configure, confirm). Visiting “new” immediately creates a session and redirects to the first step, so there is no separate form – the wizard IS the form.



34
35
36
# File 'app/controllers/source_monitor/import_sessions_controller.rb', line 34

def new
  create
end

#showObject



47
48
49
50
51
52
# File 'app/controllers/source_monitor/import_sessions_controller.rb', line 47

def show
  context_method = STEP_CONTEXTS[@current_step]
  send(context_method) if context_method
  persist_step!
  render :show
end

#updateObject



54
55
56
57
58
59
60
61
62
63
# File 'app/controllers/source_monitor/import_sessions_controller.rb', line 54

def update
  handler = STEP_HANDLERS[@current_step]
  return send(handler) if handler

  @import_session.update!(session_attributes)
  @current_step = target_step
  @import_session.update_column(:current_step, @current_step) if @import_session.current_step != @current_step

  redirect_to source_monitor.step_import_session_path(@import_session, step: @current_step), allow_other_host: false
end