Skip to content

Commit

Permalink
Remove the need for a secure context for the app (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinebhs authored Dec 12, 2023
1 parent 7c2d607 commit ffbd8ba
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 20 deletions.
25 changes: 22 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@types/node": "^20.2.5",
"@types/react": "^18.2.9",
"@types/react-dom": "^18.2.4",
"@types/uuid": "^9.0.6",
"ace-builds": "^1.4.12",
"ag-grid-community": "^29.0.0",
"ag-grid-react": "^29.0.0",
Expand All @@ -41,6 +42,7 @@
"redux": "^4.0.5",
"typeface-roboto": "^1.0.0",
"typescript": "^5.1.3",
"uuid": "^9.0.1",
"yup": "^1.0.0"
},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import {
} from '../../utils/field-constants';
import { ContingencyListType } from '../../../utils/elementType';
import { prepareContingencyListForBackend } from '../contingency-list-helper';

import { v4 as uuid4 } from 'uuid';
import { getCriteriaBasedFormData } from '../commons/criteria-based/criteria-based-utils';

export const makeDefaultRowData = () => ({
[AG_GRID_ROW_UUID]: crypto.randomUUID(),
[AG_GRID_ROW_UUID]: uuid4(),
[CONTINGENCY_NAME]: '',
[EQUIPMENT_IDS]: [],
});
Expand Down Expand Up @@ -63,7 +63,7 @@ export const getExplicitNamingFormDataFromFetchedElement = (response) => {
result = response.identifierContingencyList?.identifiers?.map(
(identifiers) => {
return {
[AG_GRID_ROW_UUID]: crypto.randomUUID(),
[AG_GRID_ROW_UUID]: uuid4(),
[CONTINGENCY_LIST_TYPE]:
ContingencyListType.EXPLICIT_NAMING.id,
[CONTINGENCY_NAME]: identifiers.contingencyId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import yup from '../../../utils/yup-config';
import { makeDefaultRowData } from '../contingency-list-utils';
import ChipsArrayEditor from '../../../utils/rhf-inputs/ag-grid-table-rhf/cell-editors/chips-array-editor';
import { ContingencyListType } from 'utils/elementType';
import { v4 as uuid4 } from 'uuid';

export const getExplicitNamingSchema = (id) => {
return {
Expand Down Expand Up @@ -119,7 +120,7 @@ const ExplicitNamingForm = () => {
if (csvData) {
return csvData.map((value) => {
return {
[AG_GRID_ROW_UUID]: crypto.randomUUID(),
[AG_GRID_ROW_UUID]: uuid4(),
[CONTINGENCY_NAME]: value[0]?.trim() || '',
[EQUIPMENT_IDS]:
value[1]
Expand Down
3 changes: 2 additions & 1 deletion src/components/dialogs/filter/expert/expert-filter-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import yup from '../../../utils/yup-config';
import { FilterType } from '../../../../utils/elementType';
import CustomReactQueryBuilder from '../../../utils/rqb-inputs/custom-react-query-builder';
import { FieldType } from './expert-filter.type';
import { v4 as uuid4 } from 'uuid';

export const EXPERT_FILTER_QUERY = 'rules';

Expand Down Expand Up @@ -74,7 +75,7 @@ const defaultQuery = {
combinator: COMBINATOR_OPTIONS.AND.name,
rules: [
{
id: crypto.randomUUID(),
id: uuid4(),
field: FieldType.ID,
operator: OPERATOR_OPTIONS.CONTAINS.name,
value: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
} from '../../../utils/field-constants';
import { FetchStatus } from '../../../../utils/custom-hooks';
import { FilterForm } from '../filter-form';
import { v4 as uuid4 } from 'uuid';

const formSchema = yup
.object()
Expand Down Expand Up @@ -75,7 +76,7 @@ const ExplicitNamingFilterEditionDialog = ({
[FILTER_EQUIPMENTS_ATTRIBUTES]: response[
FILTER_EQUIPMENTS_ATTRIBUTES
].map((row) => ({
[AG_GRID_ROW_UUID]: crypto.randomUUID(),
[AG_GRID_ROW_UUID]: uuid4(),
...row,
})),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { FilterType } from '../../../../utils/elementType';
import { NumericEditor } from '../../../utils/rhf-inputs/ag-grid-table-rhf/cell-editors/numericEditor';
import { toFloatOrNullValue } from '../../../utils/dialog-utils';
import InputWithPopupConfirmation from '../../../utils/rhf-inputs/select-inputs/input-with-popup-confirmation';
import { v4 as uuid4 } from 'uuid';

export const FILTER_EQUIPMENTS_ATTRIBUTES = 'filterEquipmentsAttributes';
export const DISTRIBUTION_KEY = 'distributionKey';
Expand Down Expand Up @@ -82,7 +83,7 @@ interface FilterTableRow {

function makeDefaultRowData(): FilterTableRow {
return {
[AG_GRID_ROW_UUID]: crypto.randomUUID(),
[AG_GRID_ROW_UUID]: uuid4(),
[EQUIPMENT_ID]: '',
[DISTRIBUTION_KEY]: null,
};
Expand Down Expand Up @@ -153,7 +154,7 @@ function ExplicitNamingFilterForm() {
if (csvData) {
return csvData.map((value: any) => {
return {
[AG_GRID_ROW_UUID]: crypto.randomUUID(),
[AG_GRID_ROW_UUID]: uuid4(),
[EQUIPMENT_ID]: value[0]?.trim(),
[DISTRIBUTION_KEY]: toFloatOrNullValue(value[1]?.trim()),
};
Expand Down
9 changes: 0 additions & 9 deletions src/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,4 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import crypto from 'crypto';

// make crypto.randomUUID() available in tests
window.crypto = {
randomUUID: function () {
return crypto.randomUUID();
},
};

global.IS_REACT_ACT_ENVIRONMENT = true;

0 comments on commit ffbd8ba

Please sign in to comment.