Sha256: 7ddc985590d2733a85e250cfabe0893d42c6b6322287f717242b471bc606e6c0

Contents?: true

Size: 1.23 KB

Versions: 53

Compression:

Stored size: 1.23 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 {
  IMPORT_ANSIBLE_V_R,
  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

53 entries across 53 versions & 1 rubygems

Version Path
foreman_ansible-15.0.2 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-15.0.1 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-15.0.0 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-14.2.2 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-14.2.1 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-13.0.7 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-14.2.0 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-14.1.1 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-14.1.0 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-13.0.5 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-14.0.0 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-13.0.4 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-13.0.3 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-13.0.2 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-13.0.1 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-13.0.0 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-12.0.7 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-10.4.4 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-7.1.8 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js
foreman_ansible-12.0.6 webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js