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

Collection publish #1491

Merged
merged 14 commits into from
Oct 21, 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
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Running the following command will create an optimized static build of your app
npm run build
````

## Docker build for DEV development
## Docker build for DEV/TEST/PROD development

There are a few configurable environment variables to keep in mind:

Expand All @@ -28,11 +28,3 @@ There are a few configurable environment variables to keep in mind:
cd docker
./docker-development.sh [check|config|build|start|stop|down]
```

## Docker build for deployment on TEST/STAGE/PROD

```
cd docker
docker pull hubmap/ingest-ui:2.3.0 (replace with the actual released version number)
./docker-deployment.sh [start|stop|down]
```
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.12
2.6.13
3 changes: 2 additions & 1 deletion src/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ export function App (props){
};

function handleCancel(){
window.history.back();
// window.history.back();
navigate("/");
}
const onClose = (event, reason) => {
navigate("/");
Expand Down
118 changes: 88 additions & 30 deletions src/src/components/collections/collections.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "../../App.css";
import SearchComponent from "../search/SearchComponent";
import {COLUMN_DEF_MIXED,COLUMN_DEF_MIXED_SM} from "../search/table_constants";
import { entity_api_get_entity,entity_api_create_entity, entity_api_update_entity} from '../../service/entity_api';
import {ingest_api_publish_collection,ingest_api_user_admin} from '../../service/ingest_api';
import { getPublishStatusColor } from "../../utils/badgeClasses";
import { generateDisplaySubtypeSimple_UBKG } from "../../utils/display_subtypes";
import Papa from 'papaparse';
Expand All @@ -15,15 +16,15 @@ import Dialog from "@material-ui/core/Dialog";
import DialogActions from "@material-ui/core/DialogActions";
import DialogContent from "@material-ui/core/DialogContent";
import GroupModal from "../uuid/groupModal";

import LoadingButton from '@mui/lab/LoadingButton';
import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell';
import TableContainer from '@mui/material/TableContainer';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import {DataGrid,GridToolbar} from "@mui/x-data-grid";

import {ErrBox} from "../../utils/ui_elements";
import Alert from '@mui/material/Alert';
import Collapse from '@mui/material/Collapse';
import LinearProgress from '@material-ui/core/LinearProgress';
Expand All @@ -48,20 +49,29 @@ export function CollectionForm (props){
var [associatedEntities, setassociatedEntities] = useState([]);
var [associatedEntitiesInitial, setassociatedEntitiesInitial] = useState([]);
var [selectedSources, setSelectedSources] = useState([]);
var [publishing, setPublishing] = useState(false);
var [fileDetails, setFileDetails] = useState();
var [buttonState, setButtonState] = useState('');
var [warningOpen, setWarningOpen] = React.useState(false);
var [openGroupModal, setOpenGroupModal] = useState(false


);
var [openGroupModal, setOpenGroupModal] = useState(false);
var [lookupShow, setLookupShow] = useState(false);
var [loadingDatasets, setLoadingDatasets] = useState(true);
var [hideUUIDList, setHideUUIDList] = useState(true);
var [loadUUIDList, setLoadUUIDList] = useState(false);
var [validatingSubmitForm, setValidatingSubmitForm] = useState(false);
var [entityInfo, setEntityInfo] = useState();
var [userAdmin, setUserAdmin] = useState(false);
var [pageError, setPageError] = useState("");
// var [publishError, setPublishError] = useState({
// status:"",
// message:"",
// });
// @TODO: See what we can globalize/memoize/notize here
var [errorHandler, setErrorHandler] = useState({
status: "",
message: "",
isError: null
});
var [formWarnings, setFormWarnings] = useState({
bulk_dataset_uuids:""
});
Expand All @@ -87,6 +97,18 @@ export function CollectionForm (props){
var [datatypeList] = useState(props.dtl_all);
var [editingCollection] = useState(props.editingCollection);


useEffect(() => {
ingest_api_user_admin(JSON.parse(localStorage.getItem("info")).groups_token)
.then((results) => {
console.debug('%c◉ ADMINCHECK ', 'color:#3F007b', results);
setUserAdmin(results)
})
.catch((err) => {
console.debug('%c⭗', 'color:#1f005d', "ingest_api_user_admin ERR", err );
})
}, []);

useEffect(() => {
if (editingCollection) {
setassociatedEntities([])
Expand Down Expand Up @@ -379,18 +401,7 @@ export function CollectionForm (props){
// Only include if presnent, ignore if not
console.debug('%c⊙', 'color:#00ff7b', "contributors",contributors );
if (contributors && (contributors[0] && contributors[0].orcid!==undefined)) {
// formValuesSubmit.contributors = contributors
formValuesSubmit.contributors = contributors
setFormErrors((prevValues) => ({
...prevValues,
'contributors': "",
}))
} else{
setFormErrors((prevValues) => ({
...prevValues,
'contributors': "Contributors detected but colums are unsupported / improperly formatted. Please referto the examples linked below and try again.",
}))
isValid = false;
}
// Do not send blank contacts
if (contacts && (contacts[0])) {
Expand Down Expand Up @@ -467,6 +478,27 @@ export function CollectionForm (props){
});
}

const handlePublish = () => {
setPublishing(true)
ingest_api_publish_collection(props.authToken,editingCollection.uuid)
.then((response) => {
if(response.status === 200){
console.debug('%c◉ Good ingest_api_publish_collection ', 'color:#00ff7b', response);
props.onProcessed(response.results);
}else{
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);
}
})
.catch((error) => {
console.debug('%c⭗ handlePublishErr Broken Result', 'color:#ff005d', error);
setPageError(error.status + " | " + error.message);
setPublishing(false);
});
}

const handleUpdate = (formSubmit) => {
// Need to only pass what's changed now
console.debug('%c◉ formSubmit ', 'color:#00ff7b',formSubmit );
Expand Down Expand Up @@ -520,13 +552,12 @@ export function CollectionForm (props){
var contributors = []
var contacts = []
for (const row of data.data) {
contributors.push(row)
if(!row.is_contact){
row.is_contact = "NO"
}else if (row.is_contact && (row.is_contact === "TRUE"|| row.is_contact.toLowerCase()==="yes") ){
contacts.push(row)
}
contributors.push(row)

}
setFormValues ({
...formValues,
Expand All @@ -548,10 +579,14 @@ export function CollectionForm (props){
key={("rowName_" + index)}
className="row-selection"
>
<TableCell className="clicky-cell" scope="row">{row.display_name}</TableCell>
<TableCell className="clicky-cell" scope="row">{row.affiliation}</TableCell>
<TableCell className="clicky-cell" scope="row"> {row.orcid} </TableCell>
<TableCell className="clicky-cell" scope="row"> { (row.is_contact && (row.is_contact==="TRUE" || row.is_contact.toLowerCase()==="yes")) ? <FontAwesomeIcon icon={faCheck} /> : ""} </TableCell>
<TableCell className="clicky-cell" scope="row">{row.display_name}</TableCell>
<TableCell className="clicky-cell" scope="row">{row.affiliation}</TableCell>
<TableCell className="clicky-cell" scope="row">{row.orcid} </TableCell>
<TableCell className="clicky-cell" scope="row">{row.email }</TableCell>
<TableCell className="clicky-cell" scope="row"> { (row.is_contact && (row.is_contact==="TRUE" || row.is_contact.toLowerCase()==="yes")) ? <FontAwesomeIcon icon={faCheck} /> : ""} </TableCell>
<TableCell className="clicky-cell" scope="row">{row.is_principal_investigator }</TableCell>
<TableCell className="clicky-cell" scope="row">{row.is_operator }</TableCell>
<TableCell className="clicky-cell" scope="row">{row.metadata_schema_id}</TableCell>
</TableRow>
);
});
Expand All @@ -566,10 +601,14 @@ export function CollectionForm (props){
<Table stickyHeader aria-label="Associated Collaborators" size="small" className="table table-striped table-hover mb-0">
<TableHead className="thead-dark font-size-sm">
<TableRow className=" " >
<TableCell> Name</TableCell>
<TableCell component="th">Affiliation</TableCell>
<TableCell component="th">Orcid</TableCell>
<TableCell component="th">Is Contact</TableCell>
<TableCell> Name</TableCell>
<TableCell component="th">Affiliation</TableCell>
<TableCell component="th">Orcid</TableCell>
<TableCell component="th">Email</TableCell>
<TableCell component="th">Is Contact</TableCell>
<TableCell component="th">Is Principal Investigator</TableCell>
<TableCell component="th">Is Operator</TableCell>
<TableCell component="th">Metadata Schema ID</TableCell>
</TableRow>
</TableHead>
<TableBody>
Expand Down Expand Up @@ -880,6 +919,18 @@ export function CollectionForm (props){
value={formValues.title}
/>
</FormControl>
{editingCollection && editingCollection.doi_url && (
<FormControl>
<TextField
label="DOI url"
name="DOIurl"
id="DOIurl"
disabled={true}
variant="standard"
value={editingCollection.doi_url}
/>
</FormControl>
)}
<FormControl>
<TextField
label="Description"
Expand All @@ -895,17 +946,15 @@ export function CollectionForm (props){
value={formValues.description}
/>
</FormControl>

<FormControl>
<Typography sx={{ color: 'rgba(0, 0, 0.2, 0.6)' }}>
Contributors
</Typography>
{formValues.contributors && formValues.contributors.length > 0 && (
<>{renderContribTable()} </>
)}

<div className="text-right">
<Typography variant='caption'>Please referto the <a href="https://hubmapconsortium.github.io/ingest-validation-tools/contributors/current/" target='_blank'>contributor file schema information</a>, and this <a href='https://raw.githubusercontent.com/hubmapconsortium/dataset-metadata-spreadsheet/main/contributors/latest/contributors.tsv' target='_blank'>Example TSV File</a> </Typography>
<Typography variant='caption'>Please refer to the <a href="https://hubmapconsortium.github.io/ingest-validation-tools/contributors/current/" target='_blank'>contributor file schema information</a>, and this <a href='https://raw.githubusercontent.com/hubmapconsortium/dataset-metadata-spreadsheet/main/contributors/latest/contributors.tsv' target='_blank'>Example TSV File</a> </Typography>
</div>
<div className="text-left">
<label>
Expand All @@ -930,6 +979,15 @@ export function CollectionForm (props){

<div className="row">
<div className="buttonWrapRight">
{userAdmin === true && !editingCollection.doi_url && (
<LoadingButton
loading={publishing}
onClick={() => handlePublish()}
variant="contained">
Publish
</LoadingButton>
)}

<Button
variant="contained"
onClick={() => handleSubmit()}
Expand Down
Loading
Loading