From 37a18bbe0daeef322a328274523c27ae79b54028 Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Mon, 25 Sep 2023 11:43:45 -0500 Subject: [PATCH] Add some urlencoding of primary keys in query, view, and run process; updated qqq-frontend-core to also do more urlencoding --- package.json | 8 ++------ src/qqq/pages/processes/ProcessRun.tsx | 21 ++++++++++++--------- src/qqq/pages/records/query/RecordQuery.tsx | 16 ++++++++-------- src/qqq/pages/records/view/RecordView.tsx | 2 +- src/qqq/utils/DataGridUtils.tsx | 2 +- 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index 82e295e..cedcb40 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "@auth0/auth0-react": "1.10.2", "@emotion/react": "11.7.1", "@emotion/styled": "11.6.0", - "@kingsrook/qqq-frontend-core": "1.0.80", + "@kingsrook/qqq-frontend-core": "1.0.82", "@mui/icons-material": "5.4.1", "@mui/material": "5.11.1", "@mui/styles": "5.11.1", @@ -56,9 +56,7 @@ "npm-install": "npm install --legacy-peer-deps", "prepublishOnly": "tsc -p ./ --outDir lib/", "start": "BROWSER=none react-scripts --max-http-header-size=65535 start", - "test": "react-scripts test", - "cypress:open": "cypress open", - "cypress:run": "cypress run" + "test": "react-scripts test" }, "eslintConfig": { "extends": [ @@ -86,8 +84,6 @@ "@types/react-table": "7.7.9", "@typescript-eslint/eslint-plugin": "5.10.2", "@typescript-eslint/parser": "5.10.2", - "cypress": "11.0.1", - "cypress-wait-for-stable-dom": "0.1.0", "eslint": "8.8.0", "eslint-import-resolver-typescript": "2.5.0", "eslint-plugin-import": "2.25.4", diff --git a/src/qqq/pages/processes/ProcessRun.tsx b/src/qqq/pages/processes/ProcessRun.tsx index 24de3a3..ae629c3 100644 --- a/src/qqq/pages/processes/ProcessRun.tsx +++ b/src/qqq/pages/processes/ProcessRun.tsx @@ -76,7 +76,7 @@ interface Props isModal?: boolean; isWidget?: boolean; isReport?: boolean; - recordIds?: string | QQueryFilter; + recordIds?: string[] | QQueryFilter; closeModalHandler?: (event: object, reason: string) => void; forceReInit?: number; overrideLabel?: string; @@ -1082,8 +1082,10 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is let queryStringPairsForInit = []; if (urlSearchParams.get("recordIds")) { + const recordIdsFromQueryString = urlSearchParams.get("recordIds").split(","); + const encodedRecordIds = recordIdsFromQueryString.map(r => encodeURIComponent(r)).join(","); queryStringPairsForInit.push("recordsParam=recordIds"); - queryStringPairsForInit.push(`recordIds=${urlSearchParams.get("recordIds")}`); + queryStringPairsForInit.push(`recordIds=${encodedRecordIds}`); } else if (urlSearchParams.get("filterJSON")) { @@ -1097,16 +1099,17 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is // } else if (recordIds) { - if (typeof recordIds === "string") - { - queryStringPairsForInit.push("recordsParam=recordIds"); - queryStringPairsForInit.push(`recordIds=${recordIds}`); - } - else if (recordIds instanceof QQueryFilter) + if (recordIds instanceof QQueryFilter) { queryStringPairsForInit.push("recordsParam=filterJSON"); queryStringPairsForInit.push(`filterJSON=${JSON.stringify(recordIds)}`); } + else if (typeof recordIds === "object" && recordIds.length) + { + const encodedRecordIds = recordIds.map(r => encodeURIComponent(r)).join(","); + queryStringPairsForInit.push("recordsParam=recordIds"); + queryStringPairsForInit.push(`recordIds=${encodedRecordIds}`); + } } if (tableVariantLocalStorageKey && localStorage.getItem(tableVariantLocalStorageKey)) @@ -1162,7 +1165,7 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is if (tableMetaData) { - queryStringPairsForInit.push(`tableName=${tableMetaData.name}`); + queryStringPairsForInit.push(`tableName=${encodeURIComponent(tableMetaData.name)}`); } try diff --git a/src/qqq/pages/records/query/RecordQuery.tsx b/src/qqq/pages/records/query/RecordQuery.tsx index ce76c8e..acd75b1 100644 --- a/src/qqq/pages/records/query/RecordQuery.tsx +++ b/src/qqq/pages/records/query/RecordQuery.tsx @@ -234,7 +234,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element const [activeModalProcess, setActiveModalProcess] = useState(null as QProcessMetaData); const [launchingProcess, setLaunchingProcess] = useState(launchProcess); - const [recordIdsForProcess, setRecordIdsForProcess] = useState(null as string | QQueryFilter); + const [recordIdsForProcess, setRecordIdsForProcess] = useState([] as string[] | QQueryFilter); const [columnStatsFieldName, setColumnStatsFieldName] = useState(null as string); const [columnStatsField, setColumnStatsField] = useState(null as QFieldMetaData); const [columnStatsFieldTableName, setColumnStatsFieldTableName] = useState(null as string) @@ -926,11 +926,11 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element { if (table.primaryKeyField !== "id") { - navigate(`${metaData.getTablePathByName(tableName)}/${params.row[tableMetaData.primaryKeyField]}`); + navigate(`${metaData.getTablePathByName(tableName)}/${encodeURIComponent(params.row[tableMetaData.primaryKeyField])}`); } else { - navigate(`${metaData.getTablePathByName(tableName)}/${params.id}`); + navigate(`${metaData.getTablePathByName(tableName)}/${encodeURIComponent(params.id)}`); } }, 100); } @@ -1189,17 +1189,17 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element { if (selectFullFilterState === "filter") { - return `?recordsParam=filterJSON&filterJSON=${JSON.stringify(buildQFilter(tableMetaData, filterModel))}`; + return `?recordsParam=filterJSON&filterJSON=${encodeURIComponent(JSON.stringify(buildQFilter(tableMetaData, filterModel)))}`; } if (selectFullFilterState === "filterSubset") { - return `?recordsParam=filterJSON&filterJSON=${JSON.stringify(buildQFilter(tableMetaData, filterModel, selectionSubsetSize))}`; + return `?recordsParam=filterJSON&filterJSON=${encodeURIComponent(JSON.stringify(buildQFilter(tableMetaData, filterModel, selectionSubsetSize)))}`; } if (selectedIds.length > 0) { - return `?recordsParam=recordIds&recordIds=${selectedIds.join(",")}`; + return `?recordsParam=recordIds&recordIds=${selectedIds.map(r => encodeURIComponent(r)).join(",")}`; } return ""; @@ -1217,11 +1217,11 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element } else if (selectedIds.length > 0) { - setRecordIdsForProcess(selectedIds.join(",")); + setRecordIdsForProcess(selectedIds); } else { - setRecordIdsForProcess(""); + setRecordIdsForProcess([]); } navigate(`${metaData?.getTablePathByName(tableName)}/${process.name}${getRecordsQueryString()}`); diff --git a/src/qqq/pages/records/view/RecordView.tsx b/src/qqq/pages/records/view/RecordView.tsx index b7e4727..733f712 100644 --- a/src/qqq/pages/records/view/RecordView.tsx +++ b/src/qqq/pages/records/view/RecordView.tsx @@ -931,7 +931,7 @@ function RecordView({table, launchProcess}: Props): JSX.Element activeModalProcess && closeModalProcess(event, reason)}>
- +
} diff --git a/src/qqq/utils/DataGridUtils.tsx b/src/qqq/utils/DataGridUtils.tsx index 7a1c0c2..7ca67da 100644 --- a/src/qqq/utils/DataGridUtils.tsx +++ b/src/qqq/utils/DataGridUtils.tsx @@ -246,7 +246,7 @@ export default class DataGridUtils if (key === tableMetaData.primaryKeyField && linkBase) { column.renderCell = (cellValues: any) => ( - e.stopPropagation()}>{cellValues.value} + e.stopPropagation()}>{cellValues.value} ); } });