diff --git a/src/example.env b/src/example.env index 142f8069..c4ee8caf 100644 --- a/src/example.env +++ b/src/example.env @@ -5,12 +5,14 @@ REACT_APP_SPECIMEN_API_URL = 'https://ingest-api.dev.hubmapconsortium.org' REACT_APP_METADATA_API_URL = 'https://ingest-api.dev.hubmapconsortium.org' REACT_APP_ENTITY_API_URL = 'https://entity-api.dev.hubmapconsortium.org' REACT_APP_SEARCH_API_URL = 'https://search-api.dev.hubmapconsortium.org/v3' -REACT_APP_PORTAL_URL = 'https://portal.dev.hubmapconsortium.org/browse/dataset +REACT_APP_PORTAL_URL = 'https://portal.dev.hubmapconsortium.org/' REACT_APP_UBKG_API_URL = 'https://ontology-api.dev.hubmapconsortium.org' # UI URL (default value used for local development) # Point to remote URL for testing and production deployment REACT_APP_URL = 'http://localhost:8585' +# REACT_APP_URL = 'https://ingest.test.hubmapconsortium.org' +# REACT_APP_URL = 'https://ingest.dev.hubmapconsortium.org' # Link to the registration/profile system REACT_APP_PROFILE_URL = 'https://profile.hubmapconsortium.org' diff --git a/src/src/components/ingest/dataset_edit.jsx b/src/src/components/ingest/dataset_edit.jsx index 6c99495b..5a4b2956 100644 --- a/src/src/components/ingest/dataset_edit.jsx +++ b/src/src/components/ingest/dataset_edit.jsx @@ -32,7 +32,8 @@ import { ingest_api_allowable_edit_states, ingest_api_dataset_submit, ingest_api_dataset_publish, ingest_api_users_groups, - ingest_api_allowable_edit_states_statusless} from '../../service/ingest_api'; + ingest_api_allowable_edit_states_statusless, + ingest_api_notify_slack} from '../../service/ingest_api'; import { entity_api_update_entity, entity_api_get_globus_url, entity_api_get_entity } from '../../service/entity_api'; //import { withRouter } from 'react-router-dom'; import { ubkg_api_get_assay_type_set } from "../../service/ubkg_api"; @@ -358,6 +359,27 @@ class DatasetEdit extends Component { } } + uncapError(response){ + + var submitErrorResponse="Uncaptured Error"; + if(response.err && response.err.response.data ){ + submitErrorResponse = response.err.response.data + } + if(response.error && response.error.response.data ){ + submitErrorResponse = response.error.response.data + } + if(typeof response === "string"){ + submitErrorResponse = response; + } + this.setState({ + showSubmitModal:false, + submit_error: true, + submitting: false, + submitErrorResponse:submitErrorResponse, + buttonSpinnerTarget:"" }, () => { + this.props.reportError(); + }); + } setAssayLists(){ ubkg_api_get_assay_type_set() .then((res) => { @@ -975,32 +997,43 @@ class DatasetEdit extends Component { } entity_api_update_entity(this.props.editingDataset.uuid, JSON.stringify(dataSubmit), JSON.parse(localStorage.getItem("info")).groups_token) .then((response) => { + // We shouldn't need to check agaisnt Trojan errors hiding in 200s anymore, + // if they appear, file as bugs on returning API + console.debug("entity_api_update_entity response", response); + // var portalURL= process.env.REACT_APP_PORTAL_URL+"/browse/dataset/"+this.props.editingDataset.uuid + var ingestURL= process.env.REACT_APP_URL+"/dataset/"+this.props.editingDataset.uuid + var slackMessage = { + "channel": "#data-testing-notifications", + "message": "Dataset has been submitted ("+ingestURL+")" + } + ingest_api_notify_slack(JSON.parse(localStorage.getItem("info")).groups_token, slackMessage) + .then((slackRes) => { + console.debug("slackRes", slackRes); if (response.status < 300) { this.setState({ submit_error: false, submitting: false, }); - this.props.onUpdated(response.results); + console.debug("submitting"); + this.props.onUpdated(response.results); } else { - var submitErrorResponse="Uncaptured Error"; - if(response.err && response.err.response.data ){ - submitErrorResponse = response.err.response.data - } - if(response.error && response.error.response.data ){ - submitErrorResponse = response.error.response.data - } - if(typeof response === "string"){ - submitErrorResponse = response; - } this.setState({ - showSubmitModal:false, submit_error: true, submitting: false, - submitErrorResponse:submitErrorResponse, - buttonSpinnerTarget:"" }, () => { - this.props.reportError(); - }); + submitErrorResponse:response, + buttonSpinnerTarget:"" }); + this.props.reportError(response); } + // this.props.onUpdated(res.data); + }) + .catch((error) => { + this.setState({ + submit_error: true, + submitting: false, + submitErrorResponse:error.result.data, + buttonSpinnerTarget:"", }); + }); + }) .catch((error) => { this.props.reportError(error); @@ -1795,11 +1828,9 @@ class DatasetEdit extends Component { } assay_contains_pii(assay) { - console.debug("AssauCOntainsPii", assay); let assay_val = [...assay.values()][0] // only one assay can now be selected, the Set() is older code for (let i in this.props.dataTypeList) { let e = this.props.dataTypeList[i] - console.debug(e, e['contains_pii'], assay_val); if (e['name'] === assay_val) { // console.debug("e:",e,e['contains_pii']); return e['contains_pii'] diff --git a/src/src/components/ingest/publications_edit.jsx b/src/src/components/ingest/publications_edit.jsx index 95a0adfa..5fa4062d 100644 --- a/src/src/components/ingest/publications_edit.jsx +++ b/src/src/components/ingest/publications_edit.jsx @@ -44,6 +44,7 @@ import { ingest_api_dataset_publish, ingest_api_users_groups, ingest_api_allowable_edit_states_statusless, + ingest_api_notify_slack } from "../../service/ingest_api"; import { entity_api_update_entity, @@ -1071,11 +1072,25 @@ class PublicationEdit extends Component { .then((response) => { console.debug("entity_api_update_entity SUBMIT response", response); if (response.status < 300 ) { - this.setState({ - submit_error: false, - submitting: false, - }); - this.props.onUpdated(response.results); + var ingestURL= process.env.REACT_APP_URL+"/publication/"+this.props.editingPublication.uuid + var slackMessage = { + "channel": "#data-testing-notifications", + "message": "Publication has been submitted ("+ingestURL+")" + } + ingest_api_notify_slack(JSON.parse(localStorage.getItem("info")).groups_token, slackMessage) + .then((slackRes) => { + console.debug("slackRes", slackRes); + if (response.status < 300) { + this.setState({ + submit_error: false, + submitting: false, + }); + + this.props.onUpdated(response.results); + } else { + this.props.reportError(response); + } + }) } else { console.debug("entity_api_update_entity SUBMITNONERR error", response); this.setState({ @@ -1555,7 +1570,7 @@ class PublicationEdit extends Component { {pubCheck && versCheck && latestCheck && ( <>{this.renderNewVersionButtons()} )} - {(subCheck || newStateCheck)&& adminCheck && latestCheck && ( + {(subCheck || newStateCheck) && adminCheck && latestCheck && ( <>{this.processButton()} )} {writeCheck && !newFormCheck && newStateCheck &&( diff --git a/src/src/components/uploads/editUploads.jsx b/src/src/components/uploads/editUploads.jsx index 798dac4e..cf504fc6 100644 --- a/src/src/components/uploads/editUploads.jsx +++ b/src/src/components/uploads/editUploads.jsx @@ -29,7 +29,8 @@ import { ingest_api_get_globus_url, ingest_api_validate_upload, ingest_api_submit_upload, ingest_api_reorganize_upload, - ingest_api_all_user_groups } from '../../service/ingest_api'; + ingest_api_all_user_groups, + ingest_api_notify_slack } from '../../service/ingest_api'; import { entity_api_update_entity, entity_api_get_globus_url @@ -422,14 +423,12 @@ class EditUploads extends Component{ GroupSelectShow: false, submitting_submission: true, }); - // package the data up let data = { title: this.state.title, description: this.state.description }; - if (this.props.editingUpload) { // if user selected Publish @@ -437,21 +436,44 @@ class EditUploads extends Component{ .then((response) => { this.handleSpinnerClear(); if (response.status === 200) { - this.props.onUpdated(response.results); + var ingestURL= process.env.REACT_APP_URL+"/upload/"+this.props.editingUpload.uuid + var slackMessage = { + "channel": "#data-testing-notifications", + "message": "Upload has been submitted ("+ingestURL+")" + } + ingest_api_notify_slack(JSON.parse(localStorage.getItem("info")).groups_token, slackMessage) + .then((slackRes) => { + console.debug("slackRes", slackRes); + if (response.status < 300) { + this.setState({ + submit_error: false, + submitting: false, + }); + this.props.onUpdated(response.results); + } else { + this.uncapError(response); + } + }) + .catch((error) => { + this.setState({ + submit_error: true, + submitting: false, + submitErrorResponse:error.result.data, + buttonSpinnerTarget:"", }); + }); this.handleSpinnerClear(); } else { this.setState({ submit_error: true, submitting: false, submitting_submission:false }); this.handleSpinnerClear(); } - }) - .catch((error) => { - + }) + .catch((error) => { this.handleSpinnerClear(); }); } } }else{ - this.handleSpinnerClear(); + this.handleSpinnerClear(); } }); }; @@ -510,51 +532,47 @@ class EditUploads extends Component{ renderButtonBar(){ - return ( -
-
- -
- - {this.renderHelperText()} - *': { - m: 1, - }, - button:{ - m:1, - align:'right', - float:'right', - }, - - }} - > - - - {this.renderSaveButton()} - {this.renderReorganizeButton()} - {this.renderSubmitButton()} - {this.renderValidateButton()} - - - -
- ); + return ( +
+
+ +
+ {this.renderHelperText()} + *': { + m: 1, + }, + button:{ + m:1, + align:'right', + float:'right', + }, + }} + > + + + {this.renderSaveButton()} + {this.renderReorganizeButton()} + {this.renderSubmitButton()} + {this.renderValidateButton()} + + + +
+ ); } renderValidateButton() { @@ -709,11 +727,9 @@ renderReorganizeButton() { }, () => { }); - this.handleValidateUpload(i); }else if(action==="submit"){ - - this.handleValidateUploadSubmission(i); + this.handleValidateUploadSubmission(i); } else if (action === "reorganize") { this.handleReorganize(); } diff --git a/src/src/service/ingest_api.js b/src/src/service/ingest_api.js index dcee0d9a..030202ae 100644 --- a/src/src/service/ingest_api.js +++ b/src/src/service/ingest_api.js @@ -531,3 +531,30 @@ export function ingest_api_reorganize_upload(uuid, auth) { return {error} }); }; + +/* + * Slack Notify + * + */ +export function ingest_api_notify_slack(auth, data) { + const options = { + headers: { + Authorization: + "Bearer " + auth, + "Content-Type": "application/json" + } + }; + // const data = ["data-testing-notificatons","Beep (O v O)!"] + let url = `${process.env.REACT_APP_DATAINGEST_API_URL}/notify-slack`; + return axios + .post(url,data,options) + .then(res => { + console.debug("ingest_api_notify_slack",res); + let results = res.data; + return {status: res.status, results: results} + }) + .catch(error => { + console.debug("ingest_api_notify_slack",error); + return {error} + }); +};