From e26aae005921c4ea0e9a2d8a51925a651c2ff8d0 Mon Sep 17 00:00:00 2001 From: Audrey Hamelers Date: Mon, 1 Apr 2024 17:43:54 +0200 Subject: [PATCH 1/3] delete unneeded, erroring js --- app/assets/javascripts/stash_engine/ui.js | 21 +-------------------- ui-library/js/main.js | 21 +-------------------- 2 files changed, 2 insertions(+), 40 deletions(-) diff --git a/app/assets/javascripts/stash_engine/ui.js b/app/assets/javascripts/stash_engine/ui.js index db765e7c87..84fa4e84b8 100644 --- a/app/assets/javascripts/stash_engine/ui.js +++ b/app/assets/javascripts/stash_engine/ui.js @@ -1487,26 +1487,7 @@ function debounce(callback, delay = 300) { function joelsReady(){ - - // ***** Upload Modal Component ***** // - - if (document.querySelector('.js-uploadmodal__button-show-modal')) { - var buttonShowModal = document.querySelectorAll('.js-uploadmodal__button-show-modal'); - var buttonCloseModal = document.querySelectorAll('.js-uploadmodal__button-close-modal'); - - [...buttonShowModal].forEach(function(button) { - button.addEventListener('click', function() { - uploadModal.showModal(); - }); - }); - - [...buttonCloseModal].forEach(function(button) { - button.addEventListener('click', function() { - uploadModal.close(); - }); - }); - } - + // ***** Select Content Object ***** // $('.o-select__select').change(function(){ diff --git a/ui-library/js/main.js b/ui-library/js/main.js index 8e0285c9c3..ffb6e40178 100644 --- a/ui-library/js/main.js +++ b/ui-library/js/main.js @@ -30,26 +30,7 @@ function debounce(callback, delay = 300) { function joelsReady(){ - - // ***** Upload Modal Component ***** // - - if (document.querySelector('.js-uploadmodal__button-show-modal')) { - var buttonShowModal = document.querySelectorAll('.js-uploadmodal__button-show-modal'); - var buttonCloseModal = document.querySelectorAll('.js-uploadmodal__button-close-modal'); - - [...buttonShowModal].forEach(function(button) { - button.addEventListener('click', function() { - uploadModal.showModal(); - }); - }); - - [...buttonCloseModal].forEach(function(button) { - button.addEventListener('click', function() { - uploadModal.close(); - }); - }); - } - + // ***** Select Content Object ***** // $('.o-select__select').change(function(){ From eb2be69c96a549e7c3b44fcbb224a662b64dc992 Mon Sep 17 00:00:00 2001 From: Audrey Hamelers Date: Mon, 1 Apr 2024 17:49:33 +0200 Subject: [PATCH 2/3] reset URL upload dialog each time --- app/javascript/react/containers/UploadFiles.jsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/javascript/react/containers/UploadFiles.jsx b/app/javascript/react/containers/UploadFiles.jsx index 3dc036f629..62de7ad283 100644 --- a/app/javascript/react/containers/UploadFiles.jsx +++ b/app/javascript/react/containers/UploadFiles.jsx @@ -423,10 +423,15 @@ export default function UploadFiles({ } }; + useEffect(() => { + if (manFileType) { + modalRef.current.showModal(); + document.addEventListener('keydown', hideModal); + } + }, [manFileType]); + const showModalHandler = (uploadType) => { setManFileType(uploadType); - modalRef.current.showModal(); - document.addEventListener('keydown', hideModal); }; useEffect(() => { @@ -518,6 +523,7 @@ export default function UploadFiles({ )} setUrls(e.target.value)} clickedClose={hideModal} From f496003adcc532866ec3992da26c822b872bcafc Mon Sep 17 00:00:00 2001 From: Audrey Hamelers Date: Mon, 8 Apr 2024 15:28:19 +0200 Subject: [PATCH 3/3] Closes https://github.com/CDL-Dryad/dryad-product-roadmap/issues/3289 --- script/py-frictionless/lambda.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/script/py-frictionless/lambda.py b/script/py-frictionless/lambda.py index 2f4e18a22b..bed7fd0533 100644 --- a/script/py-frictionless/lambda.py +++ b/script/py-frictionless/lambda.py @@ -9,23 +9,31 @@ # event json has these params passed in: download_url, callback_url, file_mime_type, token def lambda_handler(event, context): + print(event) ftype = event.get("file_mime_type", '') - if ftype.endswith('/xml'): + xml_doublecheck = ftype == 'text/plain' and event["download_url"].endswith('.xml') + json_doublecheck = ftype == 'text/plain' and event["download_url"].endswith('.json') + if ftype.endswith('/xml') or xml_doublecheck: try: xmlfile = urlopen(event["download_url"]) report = ET.parse(xmlfile) except ET.ParseError as err: # invalid XML - update(token=event["token"], status='issues', report=json.dumps({'report': f'XML file is invalid: {err}'}), callback=event['callback_url']) + report=json.dumps({'report': f'XML file is invalid: {err}'}) + update(token=event["token"], status='issues', report=report, callback=event['callback_url']) + return report # valid XML update(token=event["token"], status='noissues', report=json.dumps({'report': ''}), callback=event['callback_url']) - if ftype.endswith('/json'): + return report + if ftype.endswith('/json') or json_doublecheck: try: jsonfile = urlopen(event["download_url"]) report = json.load(jsonfile) except ValueError as err: # invalid JSON - update(token=event["token"], status='issues', report=json.dumps({'report': f'JSON file is invalid: {err}'}), callback=event['callback_url']) + report=json.dumps({'report': f'JSON file is invalid: {err}'}) + update(token=event["token"], status='issues', report=report, callback=event['callback_url']) + return report # valid JSON update(token=event["token"], status='noissues', report=json.dumps({'report': ''}), callback=event['callback_url']) return report