langcode: en
status: true
dependencies:
  config:
    - views.view.user_admin_people
  module:
    - eca_access
    - eca_base
    - eca_endpoint
    - eca_queue
    - eca_user
    - eca_views
id: eca_lib_0016
modeller: bpmn_io
label: 'Asynchronous views export'
version: v1
weight: 0
events:
  Event_0upnk7p:
    plugin: 'eca_endpoint:response'
    label: 'Endpoint response event'
    configuration:
      first_path_argument: export
      second_path_argument: users
    successors:
      -
        id: Activity_077y9bb
        condition: ''
  Event_079c3t3:
    plugin: 'eca_endpoint:access'
    label: 'Verify access to the endpoint'
    configuration:
      first_path_argument: export
      second_path_argument: users
    successors:
      -
        id: Activity_03czabg
        condition: Flow_1qwm7o2
  Event_0k7tmxh:
    plugin: 'eca_queue:processing_task'
    label: 'Process task export-users'
    configuration:
      distribute: false
      task_name: export-users
      task_value: ''
      cron: ''
    successors:
      -
        id: Activity_13dr0m3
        condition: ''
conditions:
  Flow_1qwm7o2:
    plugin: eca_current_user_role
    configuration:
      negate: false
      role: administrator
gateways: {  }
actions:
  Activity_077y9bb:
    plugin: eca_token_set_value
    label: "Get user's email address"
    configuration:
      token_name: email
      token_value: '[current_user:mail:value]'
      use_yaml: false
    successors:
      -
        id: Activity_0udkfuk
        condition: ''
  Activity_0udkfuk:
    plugin: eca_enqueue_task
    label: 'Enqueue the export task'
    configuration:
      task_name: export-users
      task_value: ''
      tokens: email
    successors:
      -
        id: Activity_00rb6ol
        condition: ''
  Activity_00rb6ol:
    plugin: action_message_action
    label: 'Print message'
    configuration:
      message: "Your request for the user export has been received. We will notify you by email ([email]) once it's ready for download."
      replace_tokens: true
    successors:
      -
        id: Activity_0ebf5c5
        condition: ''
  Activity_0ebf5c5:
    plugin: eca_endpoint_get_request_header
    label: 'Get the referrer URL'
    configuration:
      name: referer
      token_name: referer
    successors:
      -
        id: Activity_1mwsdsv
        condition: ''
  Activity_1mwsdsv:
    plugin: action_goto_action
    label: 'Redirect the user'
    configuration:
      url: '[referer]'
      replace_tokens: true
    successors: {  }
  Activity_03czabg:
    plugin: eca_access_set_result
    label: 'Allow access'
    configuration:
      access_result: allowed
    successors: {  }
  Activity_0lbjb7k:
    plugin: eca_views_export
    label: 'Run export'
    configuration:
      filename: 'private://user-export.csv'
      token_for_filename: ''
      load_results_into_token: false
      token_name: ''
      view_id: user_admin_people
      display_id: data_export_1
      arguments: ''
    successors:
      -
        id: Activity_0kl7hjm
        condition: ''
  Activity_0kl7hjm:
    plugin: action_send_email_action
    label: 'Send email'
    configuration:
      recipient: '[email]'
      subject: 'Your export is available for download'
      message: 'You can find it here: [site:url]sites/default/private/user-export.csv'
      replace_tokens: true
    successors: {  }
  Activity_13dr0m3:
    plugin: eca_switch_account
    label: 'Switch user'
    configuration:
      user_id: '1'
    successors:
      -
        id: Activity_0lbjb7k
        condition: ''
