Sha256: 56a6b7404304ac136dc296d8842242aa518da30e1fa1b948a79b9e604c225e0c

Contents?: true

Size: 1.79 KB

Versions: 150

Compression:

Stored size: 1.79 KB

Contents

import { foremanApi, userId } from '../../../services/api';

import {
  TABLES_REQUEST,
  TABLES_SUCCESS,
  TABLES_FAILURE,
  CREATE_TABLE,
  CREATE_TABLE_SUCCESS,
  CREATE_TABLE_FAILURE,
  UPDATE_TABLE,
  UPDATE_TABLE_SUCCESS,
  UPDATE_TABLE_FAILURE,
} from './TableConstants';

const getResponseError = ({ data }) => data && (data.displayMessage || data.error);

export const loadTables = () => async (dispatch) => {
  dispatch({ type: TABLES_REQUEST, params: {} });

  try {
    const { data } = await foremanApi.get(`/users/${userId()}/table_preferences`, {});
    return dispatch({
      type: TABLES_SUCCESS,
      payload: data,
    });
  } catch (error) {
    const { response } = error;
    return dispatch({
      type: TABLES_FAILURE,
      error: getResponseError(response),
    });
  }
};

export const createColumns = (params = {}) => async (dispatch) => {
  dispatch({ type: CREATE_TABLE, params });

  try {
    const { data } = await foremanApi.post(`/users/${userId()}/table_preferences`, params);
    return dispatch({
      type: CREATE_TABLE_SUCCESS,
      payload: [data],
    });
  } catch (error) {
    const { response } = error;
    return dispatch({
      type: CREATE_TABLE_FAILURE,
      error: getResponseError(response),
    });
  }
};

export const updateColumns = (params = {}) => async (dispatch) => {
  dispatch({ type: UPDATE_TABLE, params });
  const updateParams = { columns: params.columns };

  try {
    const { data } = await foremanApi
      .put(`/users/${userId()}/table_preferences/${params.name}`, updateParams);
    return dispatch({
      type: UPDATE_TABLE_SUCCESS,
      payload: [data],
    });
  } catch (error) {
    const { response } = error;
    return dispatch({
      type: UPDATE_TABLE_FAILURE,
      error: getResponseError(response),
    });
  }
};
export default loadTables;

Version data entries

150 entries across 150 versions & 1 rubygems

Version Path
katello-4.7.1 webpack/scenes/Settings/Tables/TableActions.js
katello-4.6.2.1 webpack/scenes/Settings/Tables/TableActions.js
katello-4.6.2 webpack/scenes/Settings/Tables/TableActions.js
katello-4.7.0 webpack/scenes/Settings/Tables/TableActions.js
katello-4.6.1 webpack/scenes/Settings/Tables/TableActions.js
katello-4.7.0.rc2 webpack/scenes/Settings/Tables/TableActions.js
katello-4.7.0.rc1 webpack/scenes/Settings/Tables/TableActions.js
katello-4.4.2.2 webpack/scenes/Settings/Tables/TableActions.js
katello-4.4.2.1 webpack/scenes/Settings/Tables/TableActions.js
katello-4.4.2 webpack/scenes/Settings/Tables/TableActions.js
katello-4.5.1 webpack/scenes/Settings/Tables/TableActions.js
katello-4.6.0 webpack/scenes/Settings/Tables/TableActions.js
katello-4.6.0.rc2 webpack/scenes/Settings/Tables/TableActions.js
katello-4.6.0.rc1 webpack/scenes/Settings/Tables/TableActions.js
katello-4.5.0 webpack/scenes/Settings/Tables/TableActions.js
katello-4.5.0.rc2 webpack/scenes/Settings/Tables/TableActions.js
katello-4.4.1 webpack/scenes/Settings/Tables/TableActions.js
katello-4.5.0.rc1 webpack/scenes/Settings/Tables/TableActions.js
katello-4.4.0.2 webpack/scenes/Settings/Tables/TableActions.js
katello-4.4.0.1 webpack/scenes/Settings/Tables/TableActions.js