Skip to content

Commit

Permalink
Merge pull request #979 from InseeFr/sanitize
Browse files Browse the repository at this point in the history
fix: solve issue with concepts
  • Loading branch information
FBibonne authored Sep 27, 2024
2 parents efdfb85 + 418dd8c commit 0491f32
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 47 deletions.
1 change: 0 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export default [
"@typescript-eslint/no-explicit-any": "off",
"no-extra-boolean-cast": "off",
'@typescript-eslint/ban-ts-comment': 'off',
"no-case-declarations": "off",
"@typescript-eslint/no-unnecessary-type-constraint": "off",
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
"no-prototype-builtins": "off"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import { Row } from '../../../components';
import { Note } from '../../../components/note';

const Members = ({ members, secondLang }) => {
const membersLg1 = members.map((m, i) => (
<li key={i}>
const membersLg1 = members.map((m) => (
<li key={m.id}>
<Link to={`/classifications/series/${m.id}`}>{m.labelLg1}</Link>
</li>
));
let membersLg2 = [];
if (secondLang)
membersLg2 = members.map((m, i) =>
membersLg2 = members.map((m) =>
m.labelLg2 ? (
<li key={i}>
<li key={m.id}>
<Link to={`/classifications/series/${m.id}`}>{m.labelLg2}</Link>
</li>
) : null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,15 @@ class CollectionEditionCreation extends Component {
//set mutliple properties at the same time)
this.handleChangeGeneral = (update) => {
setSubmitting(true);
const data = this.state.data;
const general = data.general;
const newData = {
...data,
general: {
...general,
update,
this.setState((state) => ({
data: {
...state.data,
general: {
...state.data.general,
...update,
},
},
};
this.setState({
data: newData,
});
}));
};

//`newLinks` looks like
Expand Down
40 changes: 18 additions & 22 deletions src/packages/modules-concepts/edition-creation/home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,31 @@ class ConceptEditionCreation extends Component {
//set mutliple properties at the same time)
this.handleChangeGeneral = (update) => {
setSubmitting(true);
const data = this.state.data;
const general = data.general;
const newData = {
...data,
general: {
...general,
update,
this.setState((state) => ({
...state,
data: {
...state.data,
general: {
...state.general,
...update,
},
},
};
this.setState({
data: newData,
});
}));
};

//update should look like `{ editorialNoteLg1: '...' }`
this.handleChangeNotes = (update) => {
setSubmitting(true);
const data = this.state.data;
const notes = data.notes;
const newData = {
...data,
general: {
...notes,
update,
this.setState((state) => ({
...state,
data: {
...state.data,
notes: {
...state.data.notes,
...update,
},
},
};
this.setState({
data: newData,
});
}));
};

this.handleChangeLinks = (newLinks) => {
Expand Down
15 changes: 10 additions & 5 deletions src/packages/modules-operations/msd/sims-field-title/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,20 @@ export const SimsFieldTitleIndicatorBridge = ({
case Date:
isEmpty = !currentSection.value;
break;
case RICH_TEXT:
case RICH_TEXT: {
const richTextValue =
currentSection[secondLang ? 'labelLg2' : 'labelLg1'];
isEmpty = checkRichText(richTextValue);
break;
}
case GEOGRAPHY:
isEmpty = !currentSection.uri;
break;
case CODE_LIST:
case CODE_LIST: {
const value = currentSection.value;
isEmpty = !value || value.length === 0;
break;
}
default:
isEmpty = !currentSection.value;
}
Expand All @@ -71,9 +73,10 @@ export const isEssentialRubricKo = (msd, currentSection, secondLang) => {
switch (msd.rangeType) {
case TEXT:
return !currentSection?.labelLg2 || currentSection?.labelLg2 === '';
case RICH_TEXT:
case RICH_TEXT: {
const richTextValueLg2 = currentSection.labelLg2;
return checkRichText(richTextValueLg2);
}
default:
return false;
}
Expand All @@ -86,14 +89,16 @@ export const isEssentialRubricKo = (msd, currentSection, secondLang) => {
return !currentSection.value;
case Date:
return !currentSection.value;
case RICH_TEXT:
case RICH_TEXT: {
const richTextValueLg1 = currentSection.labelLg1;
return checkRichText(richTextValueLg1);
}
case GEOGRAPHY:
return !currentSection.uri;
case CODE_LIST:
case CODE_LIST: {
const value = currentSection.value;
return !value || value.length === 0;
}
default:
return !currentSection.value;
}
Expand Down
3 changes: 2 additions & 1 deletion src/packages/redux/classifications/level/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
const reducers = (state: any = {}, action: any) => {
const { type, payload } = action;
switch (type) {
case LOAD_CLASSIFICATION_LEVEL_GENERAL:
case LOAD_CLASSIFICATION_LEVEL_GENERAL: {
const { classificationId, levelId } = payload;
const otherLevels = state[classificationId];
return {
Expand All @@ -21,6 +21,7 @@ const reducers = (state: any = {}, action: any) => {
},
},
};
}
case LOAD_CLASSIFICATION_LEVEL_GENERAL_SUCCESS: {
const { classificationId, levelId, results } = payload;
const otherLevels = state[classificationId];
Expand Down
3 changes: 2 additions & 1 deletion src/packages/redux/classifications/level/members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
const membersReducer = (state: any = {}, action: any) => {
const { type, payload } = action;
switch (type) {
case LOAD_CLASSIFICATION_LEVEL_MEMBERS:
case LOAD_CLASSIFICATION_LEVEL_MEMBERS: {
const { classificationId, levelId } = payload;
const otherLevels = state[classificationId];
return {
Expand All @@ -19,6 +19,7 @@ const membersReducer = (state: any = {}, action: any) => {
},
},
};
}
case LOAD_CLASSIFICATION_LEVEL_MEMBERS_SUCCESS: {
const { classificationId, levelId, results } = payload;
const otherLevels = state[classificationId];
Expand Down
3 changes: 2 additions & 1 deletion src/packages/redux/operations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function makeReducers([
status: ERROR,
err: action.payload.err,
};
case SAVE_ITEM_SUCCESS:
case SAVE_ITEM_SUCCESS: {
if (!state.results) return state;

/**
Expand All @@ -56,6 +56,7 @@ function makeReducers([
},
]),
};
}
default:
return state;
}
Expand Down
2 changes: 1 addition & 1 deletion src/packages/utils/hooks/useUrlQueryParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const computeFromUrl = (defaultValue: any) => {

//@ts-ignore
for (const [key, value] of searchQuery.entries()) {
values[key] = DOMPurify.sanitize(value);
values[DOMPurify.sanitize(key)] = DOMPurify.sanitize(value);
}
}

Expand Down

0 comments on commit 0491f32

Please sign in to comment.