diff --git a/src/actions/Packages/packageActions.js b/src/actions/Packages/packageActions.js index 950f16d..2be846e 100644 --- a/src/actions/Packages/packageActions.js +++ b/src/actions/Packages/packageActions.js @@ -16,6 +16,18 @@ export const getPackages = () => { }; } +export const movePackageFiles = (packageId) => { + return (dispatch) => { + api.post('/api/v1/packages/' + packageId + '/files/move') + .then(res => { + alert(res.data); + }) + .catch(err => { + alert("There was a problem moving the files."); + }); + } +} + export const setPackages = (packages) => { return { type: actionNames.SET_PACKAGES, diff --git a/src/components/PackageDashboard/PackageDashboardPage.js b/src/components/PackageDashboard/PackageDashboardPage.js index e916615..337ffa0 100644 --- a/src/components/PackageDashboard/PackageDashboardPage.js +++ b/src/components/PackageDashboard/PackageDashboardPage.js @@ -22,7 +22,7 @@ class PackageDashboardPage extends Component { diff --git a/src/components/PackageDashboard/PackageDashboardPageContainer.js b/src/components/PackageDashboard/PackageDashboardPageContainer.js index e209262..18e03d4 100644 --- a/src/components/PackageDashboard/PackageDashboardPageContainer.js +++ b/src/components/PackageDashboard/PackageDashboardPageContainer.js @@ -1,5 +1,5 @@ import { connect } from 'react-redux'; -import { getPackages } from "../../actions/Packages/packageActions"; +import { getPackages, movePackageFiles } from "../../actions/Packages/packageActions"; import PackageDashboardPage from './PackageDashboardPage'; const mapStateToProps = (state, props) => ({ @@ -9,6 +9,9 @@ const mapStateToProps = (state, props) => ({ const mapDispatchToProps = (dispatch, props) => ({ getPackages() { dispatch(getPackages()); + }, + movePackageFiles(packageId) { + dispatch(movePackageFiles(packageId)); } }); diff --git a/src/components/PackageDashboard/PackageTable.js b/src/components/PackageDashboard/PackageTable.js index bfaf23e..c0ce53d 100644 --- a/src/components/PackageDashboard/PackageTable.js +++ b/src/components/PackageDashboard/PackageTable.js @@ -4,6 +4,7 @@ import ReactGA from 'react-ga'; import PropTypes from 'prop-types'; import Moment from 'moment'; import stateMap from './stateMap'; +import { Button } from 'reactstrap'; const PACKAGE_ID_LABEL = 'Package ID'; const PACKAGE_TYPE_LABEL = 'Package Type'; @@ -13,6 +14,7 @@ const DATE_SUBMITTED_LABEL = 'Date Submitted'; const PACKAGE_STATE_LABEL = 'Package State'; const SUBJECT_ID_LABEL = 'Subject Id'; const GLOBUS_LINK_LABEL = 'Globus Link'; +const MOVE_PACKAGE_FILES_LABEL = 'Move Files to DLU'; const PACKAGE_ID = '_id'; const SUBMITTER_ID = 'displayName'; @@ -112,6 +114,23 @@ class PackageTable extends Component { return ''; } } + }, { + Header: MOVE_PACKAGE_FILES_LABEL, + accessor: 'button', + filterable: false, + Cell: (info) => { + let row = info.original; + // eslint-disable-next-line + if(row[PACKAGE_INFO_PROPERTY][LARGE_FILE_UPLOAD] && row.state[PACKAGE_STATE_ID] === 'METADATA_RECEIVED') { + return ( + // eslint-disable-next-line + + ); + } else { + // eslint-disable-next-line + return ''; + } + } } ]; @@ -137,6 +156,10 @@ class PackageTable extends Component { }); } + handleMoveFileClick = (packageId) => { + this.props.movePackageFiles(packageId); + }; + defaultFilterMethod(filter, row, column) { return row[filter.id] && row[filter.id].toUpperCase().indexOf(filter.value.toUpperCase()) > -1; }