From 8e200c9cbdd7d41ff796c1a787c6fa604fe891f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Castillo?= Date: Tue, 5 May 2026 14:49:22 -0300 Subject: [PATCH 1/4] fix: add allowed extensions props on formik input component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Castillo --- src/components/mui/formik-inputs/mui-formik-upload.js | 8 +++++--- .../modules/page-template-document-download-module.js | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/mui/formik-inputs/mui-formik-upload.js b/src/components/mui/formik-inputs/mui-formik-upload.js index db7a4dfd0..86d7f07f6 100644 --- a/src/components/mui/formik-inputs/mui-formik-upload.js +++ b/src/components/mui/formik-inputs/mui-formik-upload.js @@ -14,7 +14,8 @@ const MuiFormikUpload = ({ id, name, onDelete, - maxFiles = MAX_INVENTORY_IMAGES_UPLOAD_QTY + maxFiles = MAX_INVENTORY_IMAGES_UPLOAD_QTY, + allowedExtensions }) => { const [field, meta, helpers] = useField(name); @@ -22,7 +23,7 @@ const MuiFormikUpload = ({ max_size: MAX_INVENTORY_IMAGE_UPLOAD_SIZE, max_uploads_qty: maxFiles, type: { - allowed_extensions: ALLOWED_INVENTORY_IMAGE_FORMATS + allowed_extensions: allowedExtensions || ALLOWED_INVENTORY_IMAGE_FORMATS } }; @@ -95,7 +96,8 @@ MuiFormikUpload.propTypes = { id: PropTypes.string, name: PropTypes.string.isRequired, onDelete: PropTypes.func, - maxFiles: PropTypes.number + maxFiles: PropTypes.number, + allowedExtensions: PropTypes.arrayOf(PropTypes.string) }; export default MuiFormikUpload; diff --git a/src/pages/sponsors-global/page-templates/page-template-popup/modules/page-template-document-download-module.js b/src/pages/sponsors-global/page-templates/page-template-popup/modules/page-template-document-download-module.js index 5241b752b..88ec9c371 100644 --- a/src/pages/sponsors-global/page-templates/page-template-popup/modules/page-template-document-download-module.js +++ b/src/pages/sponsors-global/page-templates/page-template-popup/modules/page-template-document-download-module.js @@ -5,7 +5,10 @@ import { useField } from "formik"; import { Divider, Grid2, InputLabel } from "@mui/material"; import MuiFormikUpload from "../../../../../components/mui/formik-inputs/mui-formik-upload"; import MuiFormikTextField from "../../../../../components/mui/formik-inputs/mui-formik-textfield"; -import { PAGE_MODULES_DOWNLOAD } from "../../../../../utils/constants"; +import { + ALLOWED_INVENTORY_IMAGE_FORMATS, + PAGE_MODULES_DOWNLOAD +} from "../../../../../utils/constants"; import MuiFormikRadioGroup from "../../../../../components/mui/formik-inputs/mui-formik-radio-group"; const DocumentDownloadModule = ({ baseName, index }) => { @@ -79,6 +82,7 @@ const DocumentDownloadModule = ({ baseName, index }) => { id={`document-module-upload-${index}`} name={buildFieldName("file")} maxFiles={1} + allowedExtensions={["pdf", ...ALLOWED_INVENTORY_IMAGE_FORMATS]} /> )} From 7af1940b45e31940853d0b08af271e7ad1c23f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Castillo?= Date: Wed, 6 May 2026 10:06:17 -0300 Subject: [PATCH 2/4] fix: replace mui formik upload with uicore component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Castillo --- .../mui/formik-inputs/mui-formik-upload.js | 103 ------------------ .../page-template-document-download-module.js | 2 +- 2 files changed, 1 insertion(+), 104 deletions(-) delete mode 100644 src/components/mui/formik-inputs/mui-formik-upload.js diff --git a/src/components/mui/formik-inputs/mui-formik-upload.js b/src/components/mui/formik-inputs/mui-formik-upload.js deleted file mode 100644 index 86d7f07f6..000000000 --- a/src/components/mui/formik-inputs/mui-formik-upload.js +++ /dev/null @@ -1,103 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import T from "i18n-react/dist/i18n-react"; -import { FormHelperText } from "@mui/material"; -import UploadInputV3 from "openstack-uicore-foundation/lib/components/inputs/upload-input-v3"; -import { useField } from "formik"; -import { - ALLOWED_INVENTORY_IMAGE_FORMATS, - MAX_INVENTORY_IMAGE_UPLOAD_SIZE, - MAX_INVENTORY_IMAGES_UPLOAD_QTY -} from "../../../utils/constants"; - -const MuiFormikUpload = ({ - id, - name, - onDelete, - maxFiles = MAX_INVENTORY_IMAGES_UPLOAD_QTY, - allowedExtensions -}) => { - const [field, meta, helpers] = useField(name); - - const mediaType = { - max_size: MAX_INVENTORY_IMAGE_UPLOAD_SIZE, - max_uploads_qty: maxFiles, - type: { - allowed_extensions: allowedExtensions || ALLOWED_INVENTORY_IMAGE_FORMATS - } - }; - - const getInputValue = () => - field.value?.length > 0 - ? field.value.map((img) => ({ - ...img, - filename: - img.file_name ?? img.filename ?? img.file_path ?? img.file_url - })) - : []; - - const buildFileObject = (response) => { - const file = {}; - if (response.id !== undefined) file.id = response.id; - if (response.name) file.file_name = response.name; - if (response.md5) file.md5 = response.md5; - if (response.mime_type) file.mime_type = response.mime_type; - if (response.source_bucket) file.bucket = response.source_bucket; - if (response.size) file.size = response.size; - if (response.path && response.name) - file.file_path = `${response.path}${response.name}`; - return file; - }; - - const handleUploadComplete = (response) => { - if (response) { - const image = buildFileObject(response); - helpers.setValue([...(field.value || []), image]); - helpers.setTouched(true); - } - }; - - const handleRemove = (imageFile) => { - const updated = (field.value || []).filter( - (i) => i.filename !== imageFile.name - ); - helpers.setValue(updated); - if (onDelete) { - onDelete(imageFile.id); - } - }; - - const canAddMore = () => (field.value?.length || 0) < maxFiles; - - return ( - <> - {meta.touched && meta.error && ( - {meta.error} - )} - - - ); -}; - -MuiFormikUpload.propTypes = { - id: PropTypes.string, - name: PropTypes.string.isRequired, - onDelete: PropTypes.func, - maxFiles: PropTypes.number, - allowedExtensions: PropTypes.arrayOf(PropTypes.string) -}; - -export default MuiFormikUpload; diff --git a/src/pages/sponsors-global/page-templates/page-template-popup/modules/page-template-document-download-module.js b/src/pages/sponsors-global/page-templates/page-template-popup/modules/page-template-document-download-module.js index 88ec9c371..916d5d75f 100644 --- a/src/pages/sponsors-global/page-templates/page-template-popup/modules/page-template-document-download-module.js +++ b/src/pages/sponsors-global/page-templates/page-template-popup/modules/page-template-document-download-module.js @@ -3,7 +3,7 @@ import PropTypes from "prop-types"; import T from "i18n-react/dist/i18n-react"; import { useField } from "formik"; import { Divider, Grid2, InputLabel } from "@mui/material"; -import MuiFormikUpload from "../../../../../components/mui/formik-inputs/mui-formik-upload"; +import MuiFormikUpload from "openstack-uicore-foundation/lib/components/mui/formik-inputs/upload"; import MuiFormikTextField from "../../../../../components/mui/formik-inputs/mui-formik-textfield"; import { ALLOWED_INVENTORY_IMAGE_FORMATS, From 595e3c651c2e017292ada2c73f337b7c41b50d41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Castillo?= Date: Thu, 7 May 2026 18:19:09 -0300 Subject: [PATCH 3/4] fix: adjust mock import on test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Castillo --- .../page-template-popup/page-template-module-form.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/sponsors-global/page-templates/page-template-popup/page-template-module-form.test.js b/src/pages/sponsors-global/page-templates/page-template-popup/page-template-module-form.test.js index a5b7042e7..8d4a77efa 100644 --- a/src/pages/sponsors-global/page-templates/page-template-popup/page-template-module-form.test.js +++ b/src/pages/sponsors-global/page-templates/page-template-popup/page-template-module-form.test.js @@ -30,7 +30,7 @@ jest.mock( ); jest.mock( - "../../../../components/mui/formik-inputs/mui-formik-upload", + "openstack-uicore-foundation/lib/components/mui/formik-inputs/upload", () => function MockMuiFormikUpload({ name }) { return
Upload
; From 654ddf1837e80b92e5a2affbdbc74e090cd9a26b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Castillo?= Date: Fri, 8 May 2026 12:47:16 -0300 Subject: [PATCH 4/4] fix: adjust uicore version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Castillo --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 351b69f74..8f9fab70e 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,7 @@ "moment": "^2.29.1", "moment-duration-format": "^2.3.2", "moment-timezone": "^0.5.33", - "openstack-uicore-foundation": "5.0.18-beta.1", + "openstack-uicore-foundation": "5.0.17", "p-limit": "^6.1.0", "path-browserify": "^1.0.1", "postcss-loader": "^6.2.1", diff --git a/yarn.lock b/yarn.lock index 210f5d00f..33c1761b0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9056,10 +9056,10 @@ open@^10.0.3: is-inside-container "^1.0.0" wsl-utils "^0.1.0" -openstack-uicore-foundation@5.0.18-beta.1: - version "5.0.18-beta.1" - resolved "https://registry.yarnpkg.com/openstack-uicore-foundation/-/openstack-uicore-foundation-5.0.18-beta.1.tgz#f79763d84cbe555c5401e254dbd756675bb52043" - integrity sha512-szrIkY99ljJwowsd3jsbmnOTd7hq3SeOTKCB2FFWu06hQ1FdRwX+vew6uqMTiXrIZt+DJlLaUXnd/bQaXCLqeg== +openstack-uicore-foundation@5.0.17: + version "5.0.17" + resolved "https://registry.yarnpkg.com/openstack-uicore-foundation/-/openstack-uicore-foundation-5.0.17.tgz#1438766e41761789afe6487840cc78139c249fad" + integrity sha512-P8z1Vm8X0as6vMsuwUaNhROkVym1DoBUB6bbIE30i8r24wmNKbkvokb+dtYxFvQ/PN4TuCwXAORw/g2zOsrdJA== optionator@^0.9.1: version "0.9.4"