1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { sanitizeHTML } from 'common/html-sanitize';
6 import { ResourcesState, setResource, deleteResource } from './resources';
7 import { ResourcesAction, resourcesActions } from './resources-actions';
9 export const resourcesReducer = (state: ResourcesState = {}, action: ResourcesAction) => {
10 if (Array.isArray(action.payload)) {
11 for (const item of action.payload) {
12 if (typeof item === 'object' && item.description) {
13 item.description = sanitizeHTML(item.description);
18 return resourcesActions.match(action, {
19 SET_RESOURCES: resources => resources.reduce((state, resource) => setResource(resource.uuid, resource)(state), state),
20 DELETE_RESOURCES: ids => ids.reduce((state, id) => deleteResource(id)(state), state),