Class: WorkItems::DataSync::Widgets::Designs

Inherits:
Base show all
Defined in:
app/services/work_items/data_sync/widgets/designs.rb

Constant Summary

Constants inherited from Base

Base::BATCH_SIZE

Constants inherited from Issuable::Callbacks::Base

Issuable::Callbacks::Base::Error

Instance Attribute Summary

Attributes inherited from Base

#current_user, #target_work_item, #work_item

Instance Method Summary collapse

Methods inherited from Base

cleanup_source_work_item_data?, #initialize, #raise_error!

Methods inherited from Callbacks::Base

#log_error, #raise_error

Methods inherited from Issuable::Callbacks::Base

#after_create, #after_initialize, #after_save, #after_update, #after_update_commit, #before_create, #before_update, execute_without_params?, #initialize

Methods included from Gitlab::Allowable

#can?, #can_all?, #can_any?

Constructor Details

This class inherits a constructor from WorkItems::DataSync::Widgets::Base

Instance Method Details

#after_save_commitObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/services/work_items/data_sync/widgets/designs.rb', line 7

def after_save_commit
  return unless target_work_item.get_widget(:designs)
  return unless work_item.designs.exists?

  unless user_can_copy?
    log_error("User cannot copy designs to work item")
    return
  end

  target_design_collection = target_work_item.design_collection

  unless target_design_collection.can_start_copy?
    log_error("Target design collection copy state must be `ready`")
    return
  end

  target_design_collection.start_copy!

  DesignManagement::CopyDesignCollectionWorker.perform_async(current_user.id, work_item.id, target_work_item.id)
end

#post_move_cleanupObject



28
29
30
31
# File 'app/services/work_items/data_sync/widgets/designs.rb', line 28

def post_move_cleanup
  cleanup_designs
  cleanup_design_versions
end