Source

overview-actions/satellite-overview-actions.js

const prefix = 'overview/satellites';

const CLEAR_FILTER = `${prefix}/CLEAR_FILTER`;
const OPEN_SATELLITE = `${prefix}/OPEN_SATELLITE`;
const PAGINATE = `${prefix}/PAGINATE`;
const SORT = `${prefix}/SORT`;
const UPDATE_FILTERS = `${prefix}/UPDATE_DEPLOYMENT_TASKS_FILTERS`;

/**
 * Provides actions to manipulate with satellite screen.
 *
 * @module overview/satellites
 */
export default {
    CLEAR_FILTER,
    /**
     * Resets the filter to an initial state.
     *
     * @param {string} flowId - The unique Id of opened tab
     * @property {string} type - CLEAR_FILTER
     */
    clearFilter: (flowId) => ({
        flowId,
        type: CLEAR_FILTER
    }),
    OPEN_SATELLITE,
    /**
     * Fetches the information about the satellite.
     *
     * @param {string} satelliteId - Satellite CI Id.
     * @property {string} type - OPEN_SATELLITE
     */
    openSatellite: (satelliteId) => ({
        satelliteId,
        type: OPEN_SATELLITE
    }),
    PAGINATE,
    /**
     * Changes the pagination configuration for fetching data
     *
     * @param {string} flowId - The unique id of the opened tab
     * @param {number} page -
     * @param {number} resultsPerPage - the size of the fetched page
     * @property {string} type - PAGINATE
     */
    paginate: (flowId, page, resultsPerPage) => ({
        flowId,
        page,
        resultsPerPage,
        type: PAGINATE
    }),
    SORT,
    /**
     * Changes the filter sorting.
     *
     * @param {string} flowId - The unique Id of opened tab
     * @param {string} name - the field name
     * @param {string} order - ASC or DESC, the sorting direction
     * @property {string} type - SORT
     */
    sort: (flowId, name, order) => ({
        flowId,
        name,
        order,
        type: SORT
    }),
    UPDATE_FILTERS,
    /**
     * Updates query for filtering results.
     *
     * @param {string} flowId - The unique Id of opened tab
     * @param {object} updatedFilter - The shape of the object is {[nameOfField]: valueContains}.
     * So it means that, if field is specified, it will be searched for it. And it will search
     * based on "contains" logic. I.e. "ap", will find from ["apple", "planet"] - ["apple"] as it contains
     * "ap" in the word.
     * @property {string} type - UPDATE_FILTERS
     */
    updateFilters: (flowId, updatedFilter) => ({
        flowId,
        type: UPDATE_FILTERS,
        updatedFilter
    })
};