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/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} 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 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(){