Skip to content

Commit

Permalink
Use Step class to get the correct action
Browse files Browse the repository at this point in the history
  • Loading branch information
pezholio committed Jan 24, 2025
1 parent 331fcfd commit 19e3d4b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
module Workflow::ShowMethods
extend ActiveSupport::Concern

SHOW_ACTIONS = {
edit_draft: :edit_draft,
review_links: :review_links,
schedule_publishing: :schedule_publishing,
internal_note: :internal_note,
change_note: :change_note,
review: :review,
confirmation: :confirmation,
}.freeze

def edit_draft
@content_block_edition = ContentBlockManager::ContentBlock::Edition.find(params[:id])
@form = ContentBlockManager::ContentBlock::EditionForm.for(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ module Workflow::UpdateMethods

REVIEW_ERROR = Data.define(:attribute, :full_message)

UPDATE_ACTIONS = {
review_links: :redirect_to_next_step,
schedule_publishing: :validate_schedule,
internal_note: :update_internal_note,
change_note: :update_change_note,
review: :validate_review_page,
}.freeze

def validate_schedule
@content_block_edition = ContentBlockManager::ContentBlock::Edition.find(params[:id])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ContentBlockManager::ContentBlock::Editions::WorkflowController < ContentB

def show
step = params[:step].to_sym
action = SHOW_ACTIONS[step]
action = Workflow::Step.by_name(step)&.show_action

if action
@content_block_edition = ContentBlockManager::ContentBlock::Edition.find(params[:id])
Expand All @@ -18,7 +18,7 @@ def show

def update
step = params[:step].to_sym
action = UPDATE_ACTIONS[step]
action = Workflow::Step.by_name(step)&.update_action

if action
@content_block_edition = ContentBlockManager::ContentBlock::Edition.find(params[:id])
Expand Down

0 comments on commit 19e3d4b

Please sign in to comment.