Skip to content

Commit

Permalink
Merge pull request #1043 from hubmapconsortium/error-window
Browse files Browse the repository at this point in the history
Adds HUbmap ID to Version navigation
  • Loading branch information
yuanzhou committed Jan 31, 2023
2 parents e799082 + b9c3bda commit 5d89908
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
6 changes: 4 additions & 2 deletions src/src/components/datasets.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const RenderDataset = (props) => {
var [globusLink, setGlobusLink] = useState(null);

var [entity_data, setEntity] = useState(null);
var [authToken, setAuthToken] = useState(null);
var [entityDT, setEntityDT] = useState([""]);
var [dtl_all, setDtl_all] = useState([""]);
var [dtl_primary, setDtl_primary] = useState([""]);
Expand Down Expand Up @@ -59,7 +60,7 @@ export const RenderDataset = (props) => {

// console.debug("useEffect", uuid, props);
var authSet = JSON.parse(localStorage.getItem("info"));

setAuthToken(authSet);

function checkAssayType(dtype){
// console.debug("checkAssayType", dt);
Expand Down Expand Up @@ -206,12 +207,13 @@ export const RenderDataset = (props) => {
<div>
{renderSuccessDialog()}
<DatasetFormLegacy
reportError={props.reportError}
authToken={authToken}
changeLink={onChangeGlobusLink}
onUpdated={onUpdated}
onCreated={onCreated}
handleCancel={handleCancel}
editingDataset={entity_data}
reportError={props.reportError}
dataTypeList={dataTypeList}
dtl_primary={dtl_primary}
dtl_all={dtl_all}
Expand Down
41 changes: 27 additions & 14 deletions src/src/components/ingest/dataset_edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { ingest_api_allowable_edit_states,
ingest_api_dataset_publish,
ingest_api_users_groups,
ingest_api_allowable_edit_states_statusless} from '../../service/ingest_api';
import { entity_api_update_entity, entity_api_get_globus_url } from '../../service/entity_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 { search_api_get_assay_type, search_api_get_primary_assays, search_api_get_assay_set } from '../../service/search_api';
import { getPublishStatusColor } from "../../utils/badgeClasses";
Expand Down Expand Up @@ -102,12 +102,13 @@ class DatasetEdit extends Component {
lookUpCancelled: false,
LookUpShow: false,
other_dt: "",
previous_revision_uuid: undefined,
buttonSpinnerTarget: "",
errorSnack:false,
disableSelectDatatype:false,
// Form Validation & processing
newVersion:false,
previousHID: undefined,
nextHID: undefined,
previous_revision_uuid: undefined,
has_other_datatype: false,
submitErrorResponse:"",
Expand Down Expand Up @@ -339,8 +340,27 @@ class DatasetEdit extends Component {
this.setState({
selected_dt: selected,
})



// Sets the Hubmap ID labels for Previous and Next version Buttons
if(this.props.editingDataset.next_revision_uuid){
entity_api_get_entity(this.props.editingDataset.next_revision_uuid, JSON.parse(localStorage.getItem("info")).groups_token)
.then((response) => {
this.setState({nextHID: response.results.hubmap_id})
})
.catch((error) => {
console.debug("fetchHubID Error", error);
})
}
if(this.props.editingDataset.previous_revision_uuid){
entity_api_get_entity(this.props.editingDataset.previous_revision_uuid, JSON.parse(localStorage.getItem("info")).groups_token)
.then((response) => {
this.setState({prevHID: response.results.hubmap_id})
})
.catch((error) => {
console.debug("fetchHubID Error", error);
})
}

// let primaryNames = primaryDTs.map((value, index) => { return value.name });
// // console.debug("primaryNames",primaryNames);
Expand All @@ -349,8 +369,8 @@ class DatasetEdit extends Component {
// var primInv = primaryDTs.find(({ name }) => name === thisDT);
// console.debug("looking for "+thisDT+" in primaryDTs",primInv);

// this.props.reportError("NOPE");


}
}

Expand Down Expand Up @@ -378,6 +398,7 @@ class DatasetEdit extends Component {
})
}


componentWillUnmount() {
document.removeEventListener("click", this.handleClickOutside, true);
}
Expand Down Expand Up @@ -1706,18 +1727,10 @@ class DatasetEdit extends Component {
return (
<Box sx={{width:"50%"}}>
{this.props.editingDataset.next_revision_uuid && (
<Button
variant="text"
onClick={() => this.handleVersionNavigate('next')}>
View Next Version
</Button>
<>Next Version: <Button variant="text" onClick={() => this.handleVersionNavigate('next')}> {this.state.nextHID}</Button></>
)}
{this.props.editingDataset.previous_revision_uuid && (
<Button
variant="text"
onClick={() => this.handleVersionNavigate('prev')}>
View previous Version
</Button>
<>Previous Version: <Button variant="text" onClick={() => this.handleVersionNavigate('prev')}>{this.state.prevHID}</Button></>
)}
</Box>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/src/components/search/SearchComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ renderInfoPanel() {
//ref={this.entityType}
value={this.state.search_filters.entityType}
>
<option value="---"></option>
<option value=""></option>



Expand Down

0 comments on commit 5d89908

Please sign in to comment.