Sha256: 55c50d05b4c363254d8fb791489793e108df7074f222a62642dda49bab0cc023

Contents?: true

Size: 1.21 KB

Versions: 12

Compression:

Stored size: 1.21 KB

Contents

import React from 'react';
import { translate as __ } from 'foremanReact/common/I18n';
import { post } from 'foremanReact/redux/API';
import { push } from 'connected-react-router';
import { prepareResult } from './AnsibleRolesAndVariablesHelpers';
import {
  ANSIBLE_ROLE_CONFIRM_IMPORT_PATH,
  ANSIBLE_ROLES_INDEX,
} from './AnsibleRolesAndVariablesConstants';

export const foremanUrl = path => `${window.URL_PREFIX}${path}`;

export const onSubmit = (rows, proxy) => dispatch => {
  const params = prepareResult(rows);
  dispatch(
    post({
      key: 'import_ansible_v_r',
      url: ANSIBLE_ROLE_CONFIRM_IMPORT_PATH,
      params: { changed: params, proxy },
      handleSuccess: () => {
        setTimeout(() => dispatch(push(ANSIBLE_ROLES_INDEX)), 500);
      },
      successToast: response => (
        <span>
          {__('Import roles and variables started: ')}
          <a
            target="_blank"
            rel="noopener noreferrer"
            href={foremanUrl(`/foreman_tasks/tasks/${response.data?.task?.id}`)}
          >
            {__('view the task in progress')}
          </a>
        </span>
      ),
      errorToast: error =>
        `${__('Failed to import roles and variables ')} ${error}`,
    })
  );
};

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
foreman_ansible-7.0.4 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-7.0.3 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-7.0.2 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-7.0.1 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-7.0.0 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-6.3.4 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-6.3.3 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-6.3.2 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-6.3.1 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-6.4.1 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-6.4.0 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-6.3.0 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js