From 0d84746831462216a50d5ef9522eae04f4fe416a Mon Sep 17 00:00:00 2001 From: Kolea PLESCO Date: Fri, 20 Dec 2024 00:47:42 +0200 Subject: [PATCH] Minor improvements and fixes --- .../backend/fields_registry/entrypoints/api/routes.py | 2 +- .../backend/package_importer/entrypoints/api/routes.py | 2 +- .../package_importer/services/import_mapping_suite.py | 10 ++++++---- .../frontend/src/api/mapping-packages/index.js | 3 ++- .../sections/app/mapping-package/package-importer.js | 3 +-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/mapping_workbench/backend/fields_registry/entrypoints/api/routes.py b/mapping_workbench/backend/fields_registry/entrypoints/api/routes.py index ec420e58..2978b4b2 100644 --- a/mapping_workbench/backend/fields_registry/entrypoints/api/routes.py +++ b/mapping_workbench/backend/fields_registry/entrypoints/api/routes.py @@ -194,7 +194,7 @@ async def route_search_structural_elements_versioned_view_by_eforms_version( status_code=status.HTTP_201_CREATED ) async def route_task_import_eforms_xsd( - github_repository_url: str = Form(...), + github_repository_url: str = Form(default=None), branch_or_tag_name: str = Form(...), project_id: PydanticObjectId = Form(...), user: User = Depends(current_active_user) diff --git a/mapping_workbench/backend/package_importer/entrypoints/api/routes.py b/mapping_workbench/backend/package_importer/entrypoints/api/routes.py index c57a5608..653b92ea 100644 --- a/mapping_workbench/backend/package_importer/entrypoints/api/routes.py +++ b/mapping_workbench/backend/package_importer/entrypoints/api/routes.py @@ -48,7 +48,7 @@ async def route_import_package_archive( user: User = Depends(current_active_user) ): imported_mapping_package: ImportedMappingSuiteResponse = await import_mapping_package_from_archive( - file.file.read(), await get_project(project), package_type, user + file.file.read(), await get_project(project), package_type, False, user ) return imported_mapping_package diff --git a/mapping_workbench/backend/package_importer/services/import_mapping_suite.py b/mapping_workbench/backend/package_importer/services/import_mapping_suite.py index 23c7c9be..e5d0871e 100644 --- a/mapping_workbench/backend/package_importer/services/import_mapping_suite.py +++ b/mapping_workbench/backend/package_importer/services/import_mapping_suite.py @@ -31,7 +31,6 @@ async def import_mapping_package( package_type: PackageType, user: User = None, task_response: TaskResponse = None ) -> ImportedMappingSuiteResponse: - MappingPackageStructureValidator(mapping_package_dir_path).validate() if package_type == PackageType.STANDARD: @@ -62,7 +61,9 @@ async def import_and_process_mapping_package_from_archive( ) -> ImportedMappingSuiteResponse: if not task_response: task_response = TaskResponse() - result = await import_mapping_package_from_archive(file_content, project, package_type, cleanup_project, user, task_response) + result = await import_mapping_package_from_archive( + file_content, project, package_type, cleanup_project, user, task_response + ) await process_mapping_package( package_id=result.mapping_package.id, @@ -75,7 +76,8 @@ async def import_and_process_mapping_package_from_archive( async def import_mapping_package_from_archive( file_content: bytes, project: Project, package_type: PackageType, - cleanup_project: bool = False, user: User = None, + cleanup_project: bool = False, + user: User = None, task_response: TaskResponse = None ) -> ImportedMappingSuiteResponse: if not task_response: @@ -84,7 +86,7 @@ async def import_mapping_package_from_archive( tempdir = tempfile.TemporaryDirectory() tempdir_name = tempdir.name tempdir_path = pathlib.Path(tempdir_name) - zf.extractall(tempdir_name) # NOSONAR + zf.extractall(tempdir_name) # NOSONAR dir_contents = list(tempdir_path.iterdir()) try: assert len(dir_contents) == 1, "Archive must contain only the package folder!" diff --git a/mapping_workbench/frontend/src/api/mapping-packages/index.js b/mapping_workbench/frontend/src/api/mapping-packages/index.js index 4bee6cdc..c54ea14e 100644 --- a/mapping_workbench/frontend/src/api/mapping-packages/index.js +++ b/mapping_workbench/frontend/src/api/mapping-packages/index.js @@ -9,7 +9,8 @@ export const PACKAGE_TYPE = { EFORMS: 'eForms', STANDARD: 'Standard' }; -export const DEFAULT_PACKAGE_TYPE = "EFORMS"; +export const EFORMS_PACKAGE_TYPE = "EFORMS"; +export const DEFAULT_PACKAGE_TYPE = EFORMS_PACKAGE_TYPE; class MappingPackagesApi extends SectionApi { get SECTION_TITLE() { diff --git a/mapping_workbench/frontend/src/sections/app/mapping-package/package-importer.js b/mapping_workbench/frontend/src/sections/app/mapping-package/package-importer.js index b85ae04f..ed8dc2f3 100644 --- a/mapping_workbench/frontend/src/sections/app/mapping-package/package-importer.js +++ b/mapping_workbench/frontend/src/sections/app/mapping-package/package-importer.js @@ -23,7 +23,6 @@ import {toastError, toastLoad, toastSuccess} from "src/components/app-toast"; import Divider from "@mui/material/Divider"; - export const PackageImporter = (props) => { const {onClose, open = false, sectionApi} = props; @@ -119,7 +118,7 @@ export const PackageImporter = (props) => { {PACKAGE_TYPE[key]} ))} - + After Import