};
export const sanitizeHTML = (dirtyInput: string): string => {
- console.log('dirty ->',dirtyInput);
+ console.log('dirty------', dirtyInput);
+
const clean = DOMPurify.sanitize(dirtyInput, domPurifyConfig);
- console.log('clean =>',clean);
+
+ console.log('clean------', clean);
+
return clean;
};
import { change, formValueSelector } from 'redux-form';
import { ResourcePropertiesFormData } from 'views-components/resource-properties-form/resource-properties-form';
+export type ResourceWithDescription = Resource & { description?: string }
+
export const resourcesActions = unionize({
- SET_RESOURCES: ofType<Resource[]>(),
+ SET_RESOURCES: ofType<ResourceWithDescription[] >(),
DELETE_RESOURCES: ofType<string[]>()
});
//
// SPDX-License-Identifier: AGPL-3.0
+import { sanitizeHTML } from 'common/html-sanitize';
import { ResourcesState, setResource, deleteResource } from './resources';
import { ResourcesAction, resourcesActions } from './resources-actions';
-export const resourcesReducer = (state: ResourcesState = {}, action: ResourcesAction) =>
- resourcesActions.match(action, {
- SET_RESOURCES: resources => resources.reduce(
- (state, resource) => setResource(resource.uuid, resource)(state),
- state),
- DELETE_RESOURCES: ids => ids.reduce(
- (state, id) => deleteResource(id)(state),
- state),
+export const resourcesReducer = (state: ResourcesState = {}, action: ResourcesAction) => {
+ if (Array.isArray(action.payload)) {
+ for (const item of action.payload) {
+ if (typeof item === 'object' && item.description) {
+ item.description = sanitizeHTML(item.description);
+ }
+ }
+ }
+
+ return resourcesActions.match(action, {
+ SET_RESOURCES: resources => resources.reduce((state, resource) => setResource(resource.uuid, resource)(state), state),
+ DELETE_RESOURCES: ids => ids.reduce((state, id) => deleteResource(id)(state), state),
default: () => state,
- });
\ No newline at end of file
+ });
+};
\ No newline at end of file
}
const mapStateToProps = (state: RootState, { id }: Props) => {
+ // console.log(state.form.projectUpdateFormName? state.form.projectUpdateFormName:'')
const progress = state.progressIndicator.find(p => p.id === id);
const dataExplorerState = getDataExplorer(state.dataExplorer, id);
const currentRoute = state.router.location ? state.router.location.pathname : '';
import { RootState } from 'store/store';
import { ResourcesState } from 'store/resources/resources';
import { resourceIsFrozen } from 'common/frozen-resources';
-import { sanitizeHTML } from 'common/html-sanitize';
export class ProjectDetails extends DetailsData<ProjectResource> {
getIcon(className?: string) {
{project.description ?
<RichTextEditorLink
title={`Description of ${project.name}`}
- content={sanitizeHTML(project.description)}
+ content={project.description}
label='Show full description' />
: '---'
}