All files / js/actions gnresource.js

100% Statements 16/16
100% Branches 0/0
100% Functions 8/8
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117              1x 1x 1x 1x 1x 1x 1x 1x                         3x                     2x                       1x                       2x                       3x                     1x                     1x                           1x            
/*
 * Copyright 2020, GeoSolutions Sas.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree.
*/
 
export const RESOURCE_LOADING = 'GEONODE:RESOURCE_LOADING';
export const SET_RESOURCE = 'GEONODE:SET_RESOURCE';
export const RESOURCE_ERROR = 'GEONODE:RESOURCE_ERROR';
export const UPDATE_RESOURCE_PROPERTIES = 'GEONODE:UPDATE_RESOURCE_PROPERTIES';
export const SET_RESOURCE_TYPE = 'GEONODE:SET_RESOURCE_TYPE';
export const SET_NEW_RESOURCE = 'GEONODE:SET_NEW_RESOURCE';
export const SET_RESOURCE_ID = 'GEONODE:SET_RESOURCE_ID';
export const SET_RESOURCE_PERMISSIONS = 'GEONODE:SET_RESOURCE_PERMISSIONS';
 
/**
* Actions for GeoNode resource
* store information of the resource in use
* @name actions.gnresource
*/
 
/**
* Initialize loading state
* @memberof actions.gnresource
*/
export function resourceLoading() {
    return {
        type: RESOURCE_LOADING
    };
}
 
/**
* Set the resource in the state
* @memberof actions.gnresource
* @param {object} data resource data object
*/
export function setResource(data) {
    return {
        type: SET_RESOURCE,
        data
    };
}
 
/**
* Set the resource type in the state
* @memberof actions.gnresource
* @param {object} resourceType resource type
*/
export function setResourceType(resourceType) {
    return {
        type: SET_RESOURCE_TYPE,
        resourceType
    };
}
 
/**
* Set error of resource request
* @memberof actions.gnresource
* @param {object} error error data object
*/
export function resourceError(error) {
    return {
        type: RESOURCE_ERROR,
        error
    };
}
 
/**
* Update resource properties
* @memberof actions.gnresource
* @param {object} properties resource properties to override
*/
export function updateResourceProperties(properties) {
    return {
        type: UPDATE_RESOURCE_PROPERTIES,
        properties
    };
}
 
/**
* Set the current resource as new
* @memberof actions.gnresource
*/
export function setNewResource() {
    return {
        type: SET_NEW_RESOURCE
    };
}
 
/**
* Set resource id or primary key
* @memberof actions.gnresource
* @param {number|string} id resource id or primary key
*/
export function setResourceId(id) {
    return {
        type: SET_RESOURCE_ID,
        id
    };
}
 
/**
* Set resource permissions
* @memberof actions.gnresource
* @param {object} permissions permissions info
* @param {bool} permissions.canEdit can edit permission
* @param {bool} permissions.canView can view permission
*/
export function setResourcePermissions(permissions) {
    return {
        type: SET_RESOURCE_PERMISSIONS,
        permissions
    };
}