Skip to content

Commit

Permalink
connects up the successful publish behavior & better handles resettin…
Browse files Browse the repository at this point in the history
…g ui elements on failure
  • Loading branch information
BirdMachine committed Oct 21, 2024
1 parent 972d3f1 commit 0fc666a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 33 deletions.
22 changes: 5 additions & 17 deletions src/src/components/collections/collections.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -482,32 +482,20 @@ export function CollectionForm (props){
setPublishing(true)
ingest_api_publish_collection(props.authToken,editingCollection.uuid)
.then((response) => {
console.debug('%c◉ PUBLISHED ', 'color:#00ff7b', );
// props.onProcessed(response);
if(response.status === 200){
// GOOD
console.debug('%c◉ Good ', 'color:#00ff7b', response);
console.debug('%c◉ Good ingest_api_publish_collection ', 'color:#00ff7b', response);
props.onProcessed(response.results);
}else{
// BAD
console.debug('%c◉ handlePublishErr Bad result', 'color:#00ff7b', response);
console.debug('%c◉ ingest_api_publish_collection Bad result', 'color:#ff337b', response);
setPublishing(false)
let authMessage = response.status === 401 ? "User must be Authorized" : response.results.error.toString();
setPageError(response.status + " | " + authMessage);
// setPublishError({
// status:response.status,
// message: response.results.error ? response.results.error : response.results.toString()
// })
}
})
.catch((error) => {
console.debug('%c⭗ handlePublishErr Broken Result', 'color:#ff005d', error);
// status: "",
// message: "",
// isError: null
setPageError(error.status + " | " + error.message);
// setPageError(error.toString());
// setButtonState("");

setPublishing(false);
});
}

Expand Down Expand Up @@ -931,7 +919,7 @@ export function CollectionForm (props){
value={formValues.title}
/>
</FormControl>
{editingCollection.doi_url && (
{editingCollection && editingCollection.doi_url && (
<FormControl>
<TextField
label="DOI url"
Expand Down
23 changes: 7 additions & 16 deletions src/src/components/collections/epicollections.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -495,28 +495,19 @@ export function EPICollectionForm (props){
console.debug('%c◉ PUBLISHED ', 'color:#00ff7b', );
// props.onProcessed(response);
if(response.status === 200){
// GOOD
console.debug('%c◉ Good ', 'color:#00ff7b', response);
console.debug('%c◉ Good ingest_api_publish_collection ', 'color:#00ff7b', response);
props.onProcessed(response.results);
}else{
// BAD
console.debug('%c◉ handlePublishErr Bad result', 'color:#00ff7b', response);
setPageError(response.status + " | " + response.results.error);
console.debug('%c◉ ingest_api_publish_collection Bad result', 'color:#ff337b', response);
setPublishing(false)
// setPublishError({
// status:response.status,
// message: response.results.error ? response.results.error : response.results.toString()
// })
let authMessage = response.status === 401 ? "User must be Authorized" : response.results.error.toString();
setPageError(response.status + " | " + authMessage);
}
})
.catch((error) => {
console.debug('%c⭗ handlePublishErr Broken Result', 'color:#ff005d', error);
// status: "",
// message: "",
// isError: null
setPageError(error.status + " | " + error.message);
// setPageError(error.toString());
// setButtonState("");

setPublishing(false);
});
}

Expand Down Expand Up @@ -947,7 +938,7 @@ export function EPICollectionForm (props){
value={formValues.title}
/>
</FormControl>
{editingCollection.doi_url && (
{editingCollection && editingCollection.doi_url && (
<FormControl>
<TextField
label="DOI url"
Expand Down

0 comments on commit 0fc666a

Please sign in to comment.