Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reset URL upload box after submit/close #1584

Merged
merged 3 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions app/assets/javascripts/stash_engine/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down
10 changes: 8 additions & 2 deletions app/javascript/react/containers/UploadFiles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -518,6 +523,7 @@ export default function UploadFiles({
)}
<ModalUrl
ref={modalRef}
key={manFileType}
submitted={submitUrlsHandler}
changedUrls={(e) => setUrls(e.target.value)}
clickedClose={hideModal}
Expand Down
16 changes: 12 additions & 4 deletions script/py-frictionless/lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 1 addition & 20 deletions ui-library/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down
Loading