Skip to content

Commit

Permalink
Merge pull request #368 from KPMP/develop
Browse files Browse the repository at this point in the history
Merge for release 3.0
  • Loading branch information
rlreamy authored Mar 27, 2023
2 parents e13cd66 + f1df94a commit cf3ecee
Show file tree
Hide file tree
Showing 8 changed files with 1,980 additions and 1,653 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
- run: npm install
- run: npm ci
- run: npm run build --if-present
- run: TZ=America/Detroit npm test
- run: TZ=America/Detroit npm test
3,529 changes: 1,965 additions & 1,564 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "orion-web",
"version": "2.8.4",
"version": "2.10.0",
"private": true,
"devDependencies": {
"acorn": "7.2.0",
"enzyme": "3.10.0",
"enzyme-adapter-react-16": "1.15.1",
"node-sass": "6.0.1",
"node-sass": "8.0.0",
"npm-run-all": "4.1.5",
"react-scripts": "3.4.1"
"react-scripts": "3.4.4"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "1.2.25",
Expand All @@ -17,7 +17,7 @@
"@fortawesome/free-solid-svg-icons": "5.11.2",
"@fortawesome/react-fontawesome": "0.1.7",
"antd": "3.26.0",
"axios": "0.21.1",
"axios": "0.21.2",
"bootstrap-css-only": "4.3.1",
"bowser": "2.7.0",
"braces": "3.0.2",
Expand All @@ -28,8 +28,8 @@
"fine-uploader": "5.16.2",
"js-polyfills": "0.1.42",
"kpmp-common-components": "1.1.10",
"moment": "2.24.0",
"node-sass": "6.0.1",
"moment": "2.29.4",
"node-sass": "8.0.0",
"popper.js": "1.16.0",
"prop-types": "15.7.2",
"react": "16.12.0",
Expand Down
1 change: 0 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import thunk from 'redux-thunk';
import rootReducer from './reducers';
import { Route, Switch, Router } from 'react-router-dom';
import createHistory from 'history/createBrowserHistory';
import ReactGA4 from 'react-ga4';
import ReactGA from 'react-ga';
import DynamicFormContainer from "./components/Upload/Forms/DynamicFormContainer";
import NavBarContainer from "./components/Nav/NavBarContainer";
Expand Down
16 changes: 0 additions & 16 deletions src/components/Packages/PackagePanel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { Component } from 'react';
import ReactGA from 'react-ga';
import { Col, Row } from 'reactstrap';
import { getLocalDateString, getLocalTimeString } from '../../helpers/timezoneUtil';
import { shouldColorRow } from './attachmentsModalRowHelper.js';
Expand All @@ -8,7 +7,6 @@ import AttachmentsModal from './AttachmentsModal';
import MetadataModal from './MetadataModal';
import LargeFileModal from './LargeFileModal';
import PropTypes from 'prop-types';
import Api from '../../helpers/Api';
import PackagePanelStateText from './PackagePanelStateText';

class PackagePanel extends Component {
Expand All @@ -20,7 +18,6 @@ class PackagePanel extends Component {
this.handleMetadataClick = this.handleMetadataClick.bind(this);
this.handleLargeFileClick = this.handleLargeFileClick.bind(this);
this.handleStateInfoClick = this.handleStateInfoClick.bind(this);
this.handleDownloadClick = this.handleDownloadClick.bind(this);
}

handleAttachmentClick() {
Expand All @@ -44,18 +41,6 @@ class PackagePanel extends Component {
this.setState({ showLargeFile: show });
}
}

handleDownloadClick(e) {
ReactGA.event({
category: 'Download',
action: 'File Package',
label: this.props.uploadPackage.packageInfo._id
});
let api = Api.getInstance();
let url = api.getBaseURL() + api.fixArguments(['api/v1/packages/']) + this.props.uploadPackage.packageInfo._id + '/files';

window.location.href=url;
}

render() {

Expand Down Expand Up @@ -98,7 +83,6 @@ class PackagePanel extends Component {
packageSubmitter={packageInfo.submitter}
largeFileUpload={packageInfo.largeFilesChecked}
stateDisplayMap={this.props.stateDisplayMap}
handleDownloadClick={this.handleDownloadClick}
/>
</Col>
}
Expand Down
17 changes: 3 additions & 14 deletions src/components/Packages/PackagePanelStateText.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import React, { Component } from 'react';
import { Popover, PopoverBody } from 'reactstrap';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import PropTypes from 'prop-types';
import { getIcon, getMessage, getClickEvent, getDisplayInfo, getDownloadButton } from './packagePanelStateHelper';
import { Col, Button } from 'reactstrap';
import { faDownload } from '@fortawesome/free-solid-svg-icons';
import { getIcon, getMessage, getClickEvent, getDisplayInfo } from './packagePanelStateHelper';

const POPOVER_CLASSES = {
classNames: '',
Expand Down Expand Up @@ -45,7 +43,7 @@ class PackagePanelStateText extends Component {
return null;
}

let clickEvent = getClickEvent(this.props.panelState.state, this.props.stateDisplayMap, this.props.handleStateInfoClick, this.props.handleDownloadClick);
let clickEvent = getClickEvent(this.props.panelState.state, this.props.stateDisplayMap, this.props.handleStateInfoClick);

let stateDisplayInfo = getDisplayInfo(this.props.panelState.state, this.props.stateDisplayMap);

Expand All @@ -55,8 +53,7 @@ class PackagePanelStateText extends Component {
}

let popoverTargetId = 'popover-' + this.props.panelState.packageId;
let downloadButton = getDownloadButton(this.props.panelState.state, this.props.stateDisplayMap, this.props.panelState.packageId, this.props.handleDownloadClick);


return <React.Fragment>
<div className='d-flex align-items-start'>
{ stateDisplayInfo &&
Expand Down Expand Up @@ -87,14 +84,6 @@ class PackagePanelStateText extends Component {
</span>
}
</div>
{ downloadButton === true &&
<Col xs={4} md={12} style={{'paddingLeft': '0'}}>
<Button size='sm' color='primary' value={this.props.panelState.packageId} onClick={(e) => this.props.handleDownloadClick(this.props.panelState.packageId, e)}>
<FontAwesomeIcon icon={faDownload} />
<span>&nbsp;Download</span>
</Button>
</Col>
}
</React.Fragment>;
}
}
Expand Down
29 changes: 5 additions & 24 deletions src/components/Packages/packagePanelStateHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,36 +49,17 @@ export const getIcon = (state, isLargeFile, currentEmail, packageEmail, stateDis

};

export const getDownloadButton = (state, stateDisplayMap, packageId, handleDownloadClick) => {
let stateDisplay = stateDisplayMap.filter(function(stateDisplayItem) {
if (stateDisplayItem.apps.dlu.showDownload === true && stateDisplayItem.state === state) {
export const getClickEvent = (state, stateDisplayMap, stateInfoClick) => {
stateDisplayMap.filter(function(stateDisplayItem) {
if (stateDisplayItem.state === state) {
return stateDisplayItem;
} else {
return null;
}

}, state);

if (stateDisplay.length === 1) {
return true;
}
};

export const getClickEvent = (state, stateDisplayMap, stateInfoClick, downloadClick) => {
let stateDisplay = stateDisplayMap.filter(function(stateDisplayItem) {
if (stateDisplayItem.apps.dlu.showDownload === true && stateDisplayItem.state === state) {
return stateDisplayItem;
} else {
return null;
}

}, state);

if (stateDisplay.length === 1) {
return downloadClick;
} else {
return stateInfoClick;
}
return stateInfoClick;
};

export const getMessage = (state, isLargeFile, currentEmail, packageEmail) => {
Expand All @@ -102,7 +83,7 @@ export const getMessage = (state, isLargeFile, currentEmail, packageEmail) => {

export const getDisplayInfo = (state, stateDisplayMap) => {
let stateDisplayText = stateDisplayMap.filter(function(stateDisplayItem) {
if(stateDisplayItem.state === state && stateDisplayItem.apps.dlu.showDownload !== true) {
if(stateDisplayItem.state === state) {
return stateDisplayItem;
} else {
// eslint-disable-next-line
Expand Down
27 changes: 0 additions & 27 deletions src/components/Packages/packagePanelStateHelper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,27 +126,6 @@ describe('getMessage', () => {

});

describe('getClickEvent', () => {
let stateDisplayMap;
let downloadClick;
let stateInfoClick;
beforeEach(() => {
stateDisplayMap = [{state: 'UPLOAD_SUCCEEDED', apps: { dlu: { 'showDownload': true }}}];
downloadClick = function() { return 'hi'; };
stateInfoClick = function() { return 'hola'; };
});

it('should return downloadClick when showDownload true for state', () => {
let method = getClickEvent('UPLOAD_SUCCEEDED', stateDisplayMap, stateInfoClick, downloadClick);
expect(method).toBe(downloadClick);
});

it ('should return stateInfoClick when showDownload not true', () => {
let method = getClickEvent('OTHER_EVENT', stateDisplayMap, stateInfoClick, downloadClick);
expect(method).toBe(stateInfoClick);
});
});

describe('getDisplayInfo', () => {

it('should return the correct info object for the given state', () => {
Expand All @@ -163,10 +142,4 @@ describe('getDisplayInfo', () => {
expect(stateInfo).toBeUndefined();
});

it('should return undefined if the given state is downloadable', () => {
let stateDisplayMap = [{state: 'UPLOAD_SUCCEEDED', apps: { dlu: { 'showDownload': true }}},
{state: 'UPLOAD_FAILED', apps: { dlu: { 'showDownload': false }}}];
let stateInfo = getDisplayInfo('UPLOAD_SUCCEEDED', stateDisplayMap);
expect(stateInfo).toBeUndefined();
});
});

0 comments on commit cf3ecee

Please sign in to comment.