diff --git a/ui/.eslintignore b/ui/.eslintignore index 641d98dbd..fda4db5bb 100644 --- a/ui/.eslintignore +++ b/ui/.eslintignore @@ -1,2 +1,3 @@ /build/ /release/ +/src/components/SampleView/jsmpeg.min.js diff --git a/ui/.prettierignore b/ui/.prettierignore index df9bc0bdd..0b8cd5062 100644 --- a/ui/.prettierignore +++ b/ui/.prettierignore @@ -1,3 +1,3 @@ /build/ /public/ - +/src/components/SampleView/jsmpeg.min.js diff --git a/ui/cypress/e2e/app.cy.js b/ui/cypress/e2e/app.cy.js index 01729f999..b8858bec9 100644 --- a/ui/cypress/e2e/app.cy.js +++ b/ui/cypress/e2e/app.cy.js @@ -1,3 +1,5 @@ +/* global Cypress, cy, it, describe, beforeEach */ + describe('login', () => { it("can't login with invalid credentials", () => { cy.login('idte0', '0000'); diff --git a/ui/cypress/support.js b/ui/cypress/support.js index 50f1b0f48..bada81ef8 100644 --- a/ui/cypress/support.js +++ b/ui/cypress/support.js @@ -1,3 +1,4 @@ +/* global Cypress, cy */ import '@testing-library/cypress/add-commands'; Cypress.Commands.add('login', (username = 'idtest0', password = '0000') => { diff --git a/ui/src/actions/beamline.js b/ui/src/actions/beamline.js index 51d461572..700d8b9ee 100644 --- a/ui/src/actions/beamline.js +++ b/ui/src/actions/beamline.js @@ -52,7 +52,7 @@ export function sendGetAllhardwareObjects() { fetch(url, { method: 'GET', headers: { - Accept: 'application/json', + Accept: 'application/json', // eslint-disable-line sonarjs/no-duplicate-string 'Content-type': 'application/json', }, credentials: 'include', diff --git a/ui/src/actions/beamlineActions.js b/ui/src/actions/beamlineActions.js index 6a1b20e96..bee42dc36 100644 --- a/ui/src/actions/beamlineActions.js +++ b/ui/src/actions/beamlineActions.js @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import fetch from 'isomorphic-fetch'; import { RUNNING } from '../constants'; import { checkStatus, parseJSON } from '../requests'; diff --git a/ui/src/actions/general.js b/ui/src/actions/general.js index 07e3f8351..0e8da6c61 100644 --- a/ui/src/actions/general.js +++ b/ui/src/actions/general.js @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import fetch from 'isomorphic-fetch'; import { assign } from 'lodash'; import { unselectShapes } from './sampleview'; diff --git a/ui/src/actions/login.js b/ui/src/actions/login.js index 95105bc18..a36bfc805 100644 --- a/ui/src/actions/login.js +++ b/ui/src/actions/login.js @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import fetch from 'isomorphic-fetch'; import { showErrorPanel, setLoading, getInitialState } from './general'; import { serverIO } from '../serverIO'; @@ -183,7 +184,9 @@ export function doSignOut(navigate) { }).then(() => { dispatch(signOut()); dispatch(getLoginInfo()); - navigate && navigate('/login'); + if (navigate) { + navigate('/login'); + } }); }; } diff --git a/ui/src/actions/queue.js b/ui/src/actions/queue.js index 68b719acd..034166b9e 100644 --- a/ui/src/actions/queue.js +++ b/ui/src/actions/queue.js @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import fetch from 'isomorphic-fetch'; import { showErrorPanel } from './general'; import { loadSample } from './sampleChanger'; diff --git a/ui/src/actions/remoteAccess.js b/ui/src/actions/remoteAccess.js index ea17305ad..20c3ca93f 100644 --- a/ui/src/actions/remoteAccess.js +++ b/ui/src/actions/remoteAccess.js @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import { getLoginInfo } from './login'; export function showObserverDialog(show = true) { diff --git a/ui/src/actions/sampleChanger.js b/ui/src/actions/sampleChanger.js index 74a55f82a..23e620ea7 100644 --- a/ui/src/actions/sampleChanger.js +++ b/ui/src/actions/sampleChanger.js @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import fetch from 'isomorphic-fetch'; import { showErrorPanel } from './general'; import { clearCurrentSample } from './queue'; diff --git a/ui/src/actions/sampleGrid.js b/ui/src/actions/sampleGrid.js index 944dc85d0..a7668486c 100644 --- a/ui/src/actions/sampleGrid.js +++ b/ui/src/actions/sampleGrid.js @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import fetch from 'isomorphic-fetch'; import { setLoading, showErrorPanel } from './general'; import { setQueue } from './queue'; diff --git a/ui/src/actions/sampleview.js b/ui/src/actions/sampleview.js index f57450d4a..f70719ba8 100644 --- a/ui/src/actions/sampleview.js +++ b/ui/src/actions/sampleview.js @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import fetch from 'isomorphic-fetch'; import { showErrorPanel } from './general'; diff --git a/ui/src/components/Equipment/PlateManipulator.jsx b/ui/src/components/Equipment/PlateManipulator.jsx index e3d9e2005..c63f63dbc 100644 --- a/ui/src/components/Equipment/PlateManipulator.jsx +++ b/ui/src/components/Equipment/PlateManipulator.jsx @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import React from 'react'; import { Row, diff --git a/ui/src/components/Login/Login.jsx b/ui/src/components/Login/Login.jsx index ace4b16c6..687c48f8c 100644 --- a/ui/src/components/Login/Login.jsx +++ b/ui/src/components/Login/Login.jsx @@ -132,5 +132,4 @@ function LoginComponent(props) { ); } -LoginComponent = withRouter(LoginComponent); -export default LoginComponent; +export default withRouter(LoginComponent); diff --git a/ui/src/components/Login/SelectProposal.js b/ui/src/components/Login/SelectProposal.js index 2bacfa795..9072f5f08 100644 --- a/ui/src/components/Login/SelectProposal.js +++ b/ui/src/components/Login/SelectProposal.js @@ -91,12 +91,10 @@ class SelectProposal extends React.Component { } } -SelectProposal = reduxForm({ +const SelectProposalForm = reduxForm({ form: 'proposals', })(SelectProposal); -SelectProposal = connect((state) => ({ +export default connect((state) => ({ initialValues: { ...state.login.data }, -}))(SelectProposal); - -export default SelectProposal; +}))(SelectProposalForm); diff --git a/ui/src/components/MXNavbar/MXNavbar.jsx b/ui/src/components/MXNavbar/MXNavbar.jsx index 9dd338702..e10c17a89 100644 --- a/ui/src/components/MXNavbar/MXNavbar.jsx +++ b/ui/src/components/MXNavbar/MXNavbar.jsx @@ -93,5 +93,5 @@ class MXNavbar extends React.Component { ); } } -MXNavbar = withRouter(MXNavbar); -export default MXNavbar; + +export default withRouter(MXNavbar); diff --git a/ui/src/components/MachInfo/MachInfo.jsx b/ui/src/components/MachInfo/MachInfo.jsx index 874c59b3d..d1bf3bba3 100644 --- a/ui/src/components/MachInfo/MachInfo.jsx +++ b/ui/src/components/MachInfo/MachInfo.jsx @@ -31,7 +31,7 @@ export default class MachInfo extends React.Component { }; for (propname in this.props.info) { - if (this.props.info.hasOwnProperty(propname)) { + if (propname in this.props.info) { if (propname === 'attention') { continue; } diff --git a/ui/src/components/Main.jsx b/ui/src/components/Main.jsx index 6e79657a0..064324841 100644 --- a/ui/src/components/Main.jsx +++ b/ui/src/components/Main.jsx @@ -149,6 +149,4 @@ function mapDispatchToProps(dispatch) { }; } -Main = withRouter(Main); - -export default connect(mapStateToProps, mapDispatchToProps)(Main); +export default connect(mapStateToProps, mapDispatchToProps)(withRouter(Main)); diff --git a/ui/src/components/RemoteAccess/ObserverDialog.jsx b/ui/src/components/RemoteAccess/ObserverDialog.jsx index c24109ae8..f141fde11 100644 --- a/ui/src/components/RemoteAccess/ObserverDialog.jsx +++ b/ui/src/components/RemoteAccess/ObserverDialog.jsx @@ -25,8 +25,6 @@ export class ObserverDialog extends React.Component { } } - onHide() {} - show() { return ( !this.props.login.user.inControl && this.props.login.user.nickname === '' @@ -55,12 +53,7 @@ export class ObserverDialog extends React.Component { render() { return ( - + {this.title()} @@ -112,7 +105,7 @@ function mapStateToProps(state) { function mapDispatchToProps(dispatch) { return { - hide: bindActionCreators(showObserverDialog.bind(this, false), dispatch), + hide: bindActionCreators(showObserverDialog.bind(null, false), dispatch), sendUpdateNickname: bindActionCreators(sendUpdateNickname, dispatch), }; } diff --git a/ui/src/components/RemoteAccess/PassControlDialog.jsx b/ui/src/components/RemoteAccess/PassControlDialog.jsx index d3fc08dfd..73f257549 100644 --- a/ui/src/components/RemoteAccess/PassControlDialog.jsx +++ b/ui/src/components/RemoteAccess/PassControlDialog.jsx @@ -13,8 +13,6 @@ export class PassControlDialog extends React.Component { this.getObserver = this.getObserver.bind(this); } - onHide() {} - getObserver() { let observer = { name: '', message: '', requestsControl: false }; @@ -52,12 +50,7 @@ export class PassControlDialog extends React.Component { const observer = this.getObserver(); return ( - + {observer.nickname} is asking for control diff --git a/ui/src/components/SampleQueue/CharacterisationTaskItem.jsx b/ui/src/components/SampleQueue/CharacterisationTaskItem.jsx index 477ec88e2..d6488c2b2 100644 --- a/ui/src/components/SampleQueue/CharacterisationTaskItem.jsx +++ b/ui/src/components/SampleQueue/CharacterisationTaskItem.jsx @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { @@ -81,7 +82,7 @@ export default class TaskItem extends Component { getDiffPlan(data) { let diffPlan = []; if ( - data.hasOwnProperty('diffractionPlan') && + 'diffractionPlan' in data && Object.keys(data.diffractionPlan).length > 0 ) { // it can be empty diff --git a/ui/src/components/SampleQueue/EnergyScanTaskItem.jsx b/ui/src/components/SampleQueue/EnergyScanTaskItem.jsx index 2b4a30736..e727ea6a3 100644 --- a/ui/src/components/SampleQueue/EnergyScanTaskItem.jsx +++ b/ui/src/components/SampleQueue/EnergyScanTaskItem.jsx @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { diff --git a/ui/src/components/SampleQueue/QueueControl.js b/ui/src/components/SampleQueue/QueueControl.js index 1624a1d37..450bde274 100644 --- a/ui/src/components/SampleQueue/QueueControl.js +++ b/ui/src/components/SampleQueue/QueueControl.js @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import React from 'react'; import './app.css'; import { Button, Navbar, Nav } from 'react-bootstrap'; diff --git a/ui/src/components/SampleQueue/TaskItem.jsx b/ui/src/components/SampleQueue/TaskItem.jsx index cc1d45d9f..dc68f8a6b 100644 --- a/ui/src/components/SampleQueue/TaskItem.jsx +++ b/ui/src/components/SampleQueue/TaskItem.jsx @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { diff --git a/ui/src/components/SampleQueue/WorkflowTaskItem.jsx b/ui/src/components/SampleQueue/WorkflowTaskItem.jsx index aff1a07d9..de5fc8400 100644 --- a/ui/src/components/SampleQueue/WorkflowTaskItem.jsx +++ b/ui/src/components/SampleQueue/WorkflowTaskItem.jsx @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { diff --git a/ui/src/components/SampleQueue/XRFTaskItem.jsx b/ui/src/components/SampleQueue/XRFTaskItem.jsx index 73cf55a32..d26b2a75d 100644 --- a/ui/src/components/SampleQueue/XRFTaskItem.jsx +++ b/ui/src/components/SampleQueue/XRFTaskItem.jsx @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { diff --git a/ui/src/components/SampleView/ContextMenu.js b/ui/src/components/SampleView/ContextMenu.js index 0cddff168..a0d034007 100644 --- a/ui/src/components/SampleView/ContextMenu.js +++ b/ui/src/components/SampleView/ContextMenu.js @@ -304,9 +304,9 @@ export default class ContextMenu extends React.Component { // that already have a line [P1, P2, L1] // we do not want to add a DC/Char to a line - const points = sid.filter((x) => x.match(/P*/)[0]); + const points = sid.filter((x) => x.match(/P*/u)[0]); const containsPoints = points.length > 0; - const lines = sid.filter((x) => x.match(/L*/)[0]); + const lines = sid.filter((x) => x.match(/L*/u)[0]); const containsLine = lines.length > 0; if (containsPoints && containsLine) { @@ -419,9 +419,11 @@ export default class ContextMenu extends React.Component { this.props.sampleActions.sendAbortCentring(); } - this.props.sampleActions.sendDeleteShape(this.props.shape.id).then(() => { - this.props.sampleActions.showContextMenu(false); - }); + voithis.props.sampleActions + .sendDeleteShape(this.props.shape.id) + .then(() => { + this.props.sampleActions.showContextMenu(false); + }); } measureDistance() { @@ -454,7 +456,7 @@ export default class ContextMenu extends React.Component { const { shape } = this.props; const sid = shape.id; - const lines = sid.filter((x) => x.match(/L*/)[0]); + const lines = sid.filter((x) => x.match(/L*/u)[0]); const containsLine = lines.length > 0; if (containsLine) { diff --git a/ui/src/components/SampleView/DrawGridPlugin.js b/ui/src/components/SampleView/DrawGridPlugin.js index c9edd2671..4018cd7a3 100644 --- a/ui/src/components/SampleView/DrawGridPlugin.js +++ b/ui/src/components/SampleView/DrawGridPlugin.js @@ -324,7 +324,7 @@ export default class DrawGridPlugin { let { result } = gd; // Use selected result type if it exists - if (gd.result !== null && gd.result.hasOwnProperty(this.resultType)) { + if (gd.result !== null && this.resultType in gd.result) { result = gd.result[this.resultType]; } diff --git a/ui/src/components/SampleView/SampleControls.js b/ui/src/components/SampleView/SampleControls.js index 0a0f5f82d..75881372d 100644 --- a/ui/src/components/SampleView/SampleControls.js +++ b/ui/src/components/SampleView/SampleControls.js @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import './SampleView.css'; import React from 'react'; import { OverlayTrigger, Button, Dropdown } from 'react-bootstrap'; diff --git a/ui/src/components/SampleView/jsmpeg.min.js b/ui/src/components/SampleView/jsmpeg.min.js index 3e8a5ca81..1ec838235 100644 --- a/ui/src/components/SampleView/jsmpeg.min.js +++ b/ui/src/components/SampleView/jsmpeg.min.js @@ -1,4 +1,3 @@ -/*eslint-disable */ export const JSMpeg = { Player: null, VideoElement: null, diff --git a/ui/src/components/SampleView/shapes.js b/ui/src/components/SampleView/shapes.js index 3332993ea..98c5fe0ee 100644 --- a/ui/src/components/SampleView/shapes.js +++ b/ui/src/components/SampleView/shapes.js @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import 'fabric'; const { fabric } = window; diff --git a/ui/src/components/Tasks/Characterisation.js b/ui/src/components/Tasks/Characterisation.js index 7f17b3bb7..04cf6da7b 100644 --- a/ui/src/components/Tasks/Characterisation.js +++ b/ui/src/components/Tasks/Characterisation.js @@ -463,7 +463,7 @@ class Characterisation extends React.Component { } } -Characterisation = reduxForm({ +const CharacterisationForm = reduxForm({ form: 'characterisation', validate, warn, @@ -471,7 +471,7 @@ Characterisation = reduxForm({ const selector = formValueSelector('characterisation'); -Characterisation = connect((state) => { +export default connect((state) => { const subdir = selector(state, 'subdir'); let position = state.taskForm.pointID === '' ? 'PX' : state.taskForm.pointID; if (typeof position === 'object') { @@ -524,6 +524,4 @@ Characterisation = connect((state) => { : toFixed(state, 'diffractometer.phi'), }, }; -})(Characterisation); - -export default Characterisation; +})(CharacterisationForm); diff --git a/ui/src/components/Tasks/DataCollection.js b/ui/src/components/Tasks/DataCollection.js index 9ea5c0ea5..befce872a 100644 --- a/ui/src/components/Tasks/DataCollection.js +++ b/ui/src/components/Tasks/DataCollection.js @@ -337,7 +337,7 @@ class DataCollection extends React.Component { } } -DataCollection = reduxForm({ +const DataCollectionForm = reduxForm({ form: 'datacollection', validate, warn, @@ -345,7 +345,7 @@ DataCollection = reduxForm({ const selector = formValueSelector('datacollection'); -DataCollection = connect((state) => { +export default connect((state) => { const subdir = selector(state, 'subdir'); let position = state.taskForm.pointID === '' ? 'PX' : state.taskForm.pointID; @@ -392,6 +392,4 @@ DataCollection = connect((state) => { : toFixed(state, 'diffractometer.phi'), }, }; -})(DataCollection); - -export default DataCollection; +})(DataCollectionForm); diff --git a/ui/src/components/Tasks/EnergyScan.jsx b/ui/src/components/Tasks/EnergyScan.jsx index 483d1d689..a5537f586 100644 --- a/ui/src/components/Tasks/EnergyScan.jsx +++ b/ui/src/components/Tasks/EnergyScan.jsx @@ -152,14 +152,14 @@ class EnergyScan extends React.Component { } } -EnergyScan = reduxForm({ +const EnergyScanForm = reduxForm({ form: 'workflow', validate, })(EnergyScan); const selector = formValueSelector('workflow'); -EnergyScan = connect((state) => { +export default connect((state) => { const subdir = selector(state, 'subdir'); const element = selector(state, 'element'); const edge = selector(state, 'edge'); @@ -196,6 +196,4 @@ EnergyScan = connect((state) => { : state.beamline.hardwareObjects.transmission.value, }, }; -})(EnergyScan); - -export default EnergyScan; +})(EnergyScanForm); diff --git a/ui/src/components/Tasks/GenericTaskForm.js b/ui/src/components/Tasks/GenericTaskForm.js index a97d1e925..58f206fff 100644 --- a/ui/src/components/Tasks/GenericTaskForm.js +++ b/ui/src/components/Tasks/GenericTaskForm.js @@ -322,7 +322,7 @@ class GenericTaskForm extends React.Component { } } -GenericTaskForm = reduxForm({ +const GenericTaskFormForm = reduxForm({ form: 'GenericTaskForm', validate, warn, @@ -330,7 +330,7 @@ GenericTaskForm = reduxForm({ const selector = formValueSelector('GenericTaskForm'); -GenericTaskForm = connect((state) => { +export default connect((state) => { const subdir = selector(state, 'subdir'); const experimentNameSelector = selector(state, 'experimentName'); let position = state.taskForm.pointID === '' ? 'PX' : state.taskForm.pointID; @@ -392,6 +392,4 @@ GenericTaskForm = connect((state) => { osc_start: state.taskForm.taskData.parameters.osc_start, }, }; -})(GenericTaskForm); - -export default GenericTaskForm; +})(GenericTaskFormForm); diff --git a/ui/src/components/Tasks/GphlWorkflow.jsx b/ui/src/components/Tasks/GphlWorkflow.jsx index 02b19f21f..8b531f231 100644 --- a/ui/src/components/Tasks/GphlWorkflow.jsx +++ b/ui/src/components/Tasks/GphlWorkflow.jsx @@ -133,14 +133,14 @@ class GphlWorkflow extends React.Component { } } -GphlWorkflow = reduxForm({ +const GphlWorkflowForm = reduxForm({ form: 'gphl_workflow', validate, })(GphlWorkflow); const selector = formValueSelector('gphl_workflow'); -GphlWorkflow = connect((state) => { +export default connect((state) => { const subdir = selector(state, 'subdir'); const strategy_name = selector(state, 'strategy_name'); const fileSuffix = state.taskForm.fileSuffix === 'h5' ? '_master.h5' : 'cbf'; @@ -179,6 +179,4 @@ GphlWorkflow = connect((state) => { : state.beamline.hardwareObjects.transmission.value, }, }; -})(GphlWorkflow); - -export default GphlWorkflow; +})(GphlWorkflowForm); diff --git a/ui/src/components/Tasks/Helical.js b/ui/src/components/Tasks/Helical.js index f6ac0ded3..818c7f701 100644 --- a/ui/src/components/Tasks/Helical.js +++ b/ui/src/components/Tasks/Helical.js @@ -218,7 +218,7 @@ class Helical extends React.Component { } } -Helical = reduxForm({ +const HelicalForm = reduxForm({ form: 'helical', validate, warn, @@ -226,7 +226,7 @@ Helical = reduxForm({ const selector = formValueSelector('helical'); -Helical = connect((state) => { +export default connect((state) => { const subdir = selector(state, 'subdir'); let fname = ''; @@ -266,6 +266,4 @@ Helical = connect((state) => { : toFixed(state, 'diffractometer.phi'), }, }; -})(Helical); - -export default Helical; +})(HelicalForm); diff --git a/ui/src/components/Tasks/Interleaved.jsx b/ui/src/components/Tasks/Interleaved.jsx index 3f87d2cba..1aaa18180 100644 --- a/ui/src/components/Tasks/Interleaved.jsx +++ b/ui/src/components/Tasks/Interleaved.jsx @@ -283,14 +283,14 @@ class Interleaved extends React.Component { } } -Interleaved = reduxForm({ +const InterleavedForm = reduxForm({ form: 'workflow', validate, })(Interleaved); const selector = formValueSelector('workflow'); -Interleaved = connect((state) => { +export default connect((state) => { const fileSuffix = state.taskForm.fileSuffix === 'h5' ? '_master.h5' : 'cbf'; const shapeId = state.taskForm.pointID; const subWedgeSize = selector(state, 'sub_wedge_size'); @@ -312,6 +312,4 @@ Interleaved = connect((state) => { state.taskForm.defaultParameters.datacollection.sub_wedge_size, }, }; -})(Interleaved); - -export default Interleaved; +})(InterleavedForm); diff --git a/ui/src/components/Tasks/Mesh.js b/ui/src/components/Tasks/Mesh.js index 54bbebe37..73b97bc7b 100644 --- a/ui/src/components/Tasks/Mesh.js +++ b/ui/src/components/Tasks/Mesh.js @@ -238,7 +238,7 @@ class Mesh extends React.Component { } } -Mesh = reduxForm({ +const MeshForm = reduxForm({ form: 'mesh', validate, warn, @@ -246,7 +246,7 @@ Mesh = reduxForm({ const selector = formValueSelector('helical'); -Mesh = connect((state) => { +export default connect((state) => { const subdir = selector(state, 'subdir'); let fname = ''; @@ -281,6 +281,4 @@ Mesh = connect((state) => { osc_start: state.beamline.hardwareObjects['diffractometer.phi'].value, }, }; -})(Mesh); - -export default Mesh; +})(MeshForm); diff --git a/ui/src/components/Tasks/Workflow.jsx b/ui/src/components/Tasks/Workflow.jsx index 9b66efb2b..4a56a151b 100644 --- a/ui/src/components/Tasks/Workflow.jsx +++ b/ui/src/components/Tasks/Workflow.jsx @@ -112,14 +112,14 @@ class Workflow extends React.Component { } } -Workflow = reduxForm({ +const WorkflowForm = reduxForm({ form: 'workflow', validate, })(Workflow); const selector = formValueSelector('workflow'); -Workflow = connect((state) => { +export default connect((state) => { const subdir = selector(state, 'subdir'); const fileSuffix = state.taskForm.fileSuffix === 'h5' ? '_master.h5' : 'cbf'; let position = state.taskForm.pointID === '' ? 'PX' : state.taskForm.pointID; @@ -160,6 +160,4 @@ Workflow = connect((state) => { : state.beamline.hardwareObjects.transmission.value, }, }; -})(Workflow); - -export default Workflow; +})(WorkflowForm); diff --git a/ui/src/components/Tasks/XRFScan.jsx b/ui/src/components/Tasks/XRFScan.jsx index 443f2eb15..f7236393d 100644 --- a/ui/src/components/Tasks/XRFScan.jsx +++ b/ui/src/components/Tasks/XRFScan.jsx @@ -124,14 +124,14 @@ class XRFScan extends React.Component { } } -XRFScan = reduxForm({ +const XRFScanForm = reduxForm({ form: 'workflow', validate, })(XRFScan); const selector = formValueSelector('workflow'); -XRFScan = connect((state) => { +export default connect((state) => { const subdir = selector(state, 'subdir'); const exp_time = selector(state, 'exp_time'); const fileSuffix = state.taskForm.fileSuffix === 'h5' ? '_master.h5' : 'cbf'; @@ -166,6 +166,4 @@ XRFScan = connect((state) => { : state.beamline.hardwareObjects.transmission.value, }, }; -})(XRFScan); - -export default XRFScan; +})(XRFScanForm); diff --git a/ui/src/components/Tasks/fields.js b/ui/src/components/Tasks/fields.js index 6e617a2b7..69a22b327 100644 --- a/ui/src/components/Tasks/fields.js +++ b/ui/src/components/Tasks/fields.js @@ -5,12 +5,11 @@ import { TiWarning, TiTimes } from 'react-icons/ti'; import './style.css'; -export function getLastUsedParameters(type, parameters) { +export function getLastUsedParameters(type, newParams) { const lastParameters = localStorage.getItem(`last${type}Parameters`); - if (lastParameters !== null) { - parameters = JSON.parse(lastParameters); - } + const parameters = + lastParameters === null ? newParams : JSON.parse(lastParameters); if (parseFloat(parameters.osc_range) === 0) { parameters.osc_range = @@ -324,7 +323,7 @@ export class CollapsableRows extends React.Component { this.setState({ collapsed: false }); }} > - Show more + Show more ) : ( )} diff --git a/ui/src/components/Tasks/validate.js b/ui/src/components/Tasks/validate.js index 07ca92350..2522bdc03 100644 --- a/ui/src/components/Tasks/validate.js +++ b/ui/src/components/Tasks/validate.js @@ -1,5 +1,8 @@ const everpolate = require('everpolate'); +const INVALID_CHAR_MSG = + 'Invalid character in path, only alphanumerical characters and -, _, : allowed'; + const validate = (values, props) => { const errors = {}; if (!props.beamline.hardwareObjects) { @@ -21,20 +24,16 @@ const validate = (values, props) => { // here we update the resolution limits based on the energy the typed in the form, // the limits come from a table sent by the client - /* eslint-disable no-useless-escape */ - const validFname = /^[-\w\-\#\_\{\}\[\]]+$/.test(props.filename); - /* eslint-enable no-useless-escape */ + const validFname = /^[\w#[\]{}-\-]+$/u.test(props.filename); const emptyField = 'field is empty'; if (!validFname) { - errors.prefix = - 'Invalid character in path, only alphanumerical characters and -, _, : allowed'; + errors.prefix = INVALID_CHAR_MSG; } - if (props.subdir && !/^[-\w\-\/\_\{\}]+$/.test(props.subdir)) { - errors.subdir = - 'Invalid character in path, only alphanumerical characters and -, _, : allowed'; + if (props.subdir && !/^[\w/{}-\-]+$/u.test(props.subdir)) { + errors.subdir = INVALID_CHAR_MSG; } if (props.experimentName === undefined) { @@ -43,10 +42,9 @@ const validate = (values, props) => { if ( props.experimentName !== undefined && - !/^[-\w\-\/\_\{\}]+$/.test(props.experimentName) + !/^[\w/{}-\-]+$/u.test(props.experimentName) ) { - errors.experimentName = - 'Invalid character in path, only alphanumerical characters and -, _, : allowed'; + errors.experimentName = INVALID_CHAR_MSG; } let resMin = 0; diff --git a/ui/src/containers/BeamlineSetupContainer.jsx b/ui/src/containers/BeamlineSetupContainer.jsx index 1120a0aad..f83c2630e 100644 --- a/ui/src/containers/BeamlineSetupContainer.jsx +++ b/ui/src/containers/BeamlineSetupContainer.jsx @@ -11,7 +11,7 @@ import DeviceState from '../components/DeviceState/DeviceState'; import LabeledValue from '../components/LabeledValue/LabeledValue'; import MachInfo from '../components/MachInfo/MachInfo'; import OneAxisTranslationControl from '../components/MotorInput/OneAxisTranslationControl'; -import * as SampleViewActions from '../actions/sampleview'; +import * as sampleViewActions from '../actions/sampleview'; // eslint-disable-line import/no-namespace import { find, filter } from 'lodash'; @@ -84,7 +84,7 @@ class BeamlineSetupContainer extends React.Component { const acts = []; const { uiproperties } = this.props; - if (uiproperties.hasOwnProperty('beamline_setup')) { + if ('beamline_setup' in uiproperties) { const blsetup_properties = uiproperties.beamline_setup.components; for (const key in this.props.beamline.hardwareObjects) { @@ -140,7 +140,7 @@ class BeamlineSetupContainer extends React.Component { const { uiproperties } = this.props; - if (uiproperties.hasOwnProperty('camera_setup')) { + if ('camera_setup' in uiproperties) { for (const [ key, camera, @@ -222,7 +222,7 @@ class BeamlineSetupContainer extends React.Component { render() { const { uiproperties } = this.props; - if (!uiproperties.hasOwnProperty('beamline_setup')) { + if (!('beamline_setup' in uiproperties)) { return null; } @@ -327,7 +327,7 @@ function mapDispatchToProps(dispatch) { sendGetAllhardwareObjects, dispatch, ), - sampleViewActions: bindActionCreators(SampleViewActions, dispatch), + sampleViewActions: bindActionCreators(sampleViewActions, dispatch), setAttribute: bindActionCreators(sendSetAttribute, dispatch), sendCommand: bindActionCreators(sendCommand, dispatch), abortCurrentAction: bindActionCreators(sendAbortCurrentAction, dispatch), diff --git a/ui/src/containers/ConfirmCollectDialog.jsx b/ui/src/containers/ConfirmCollectDialog.jsx index e37950556..72427a1e1 100644 --- a/ui/src/containers/ConfirmCollectDialog.jsx +++ b/ui/src/containers/ConfirmCollectDialog.jsx @@ -40,7 +40,6 @@ export class ConfirmCollectDialog extends React.Component { this.resizeTable = this.resizeTable.bind(this); this.autoLoopCentringOnClick = this.autoLoopCentringOnClick.bind(this); this.autoMountNextOnClick = this.autoMountNextOnClick.bind(this); - this.onHide = this.onHide.bind(this); this.collectText = this.collectText.bind(this); this.tasksToCollect = this.tasksToCollect.bind(this); this.setNumSnapshots = this.setNumSnapshots.bind(this); @@ -74,8 +73,6 @@ export class ConfirmCollectDialog extends React.Component { this.resizeTable(); } - onHide() {} - setNumSnapshots(n) { this.props.sendSetNumSnapshots(n); } @@ -352,11 +349,7 @@ export class ConfirmCollectDialog extends React.Component { render() { const autoMountNext = this.props.queue.queue.length > 1; return ( - + Collect Queue ? @@ -423,7 +416,7 @@ function mapStateToProps(state) { function mapDispatchToProps(dispatch) { return { hide: bindActionCreators( - showConfirmCollectDialog.bind(this, false), + showConfirmCollectDialog.bind(null, false), dispatch, ), sendRunQueue: bindActionCreators(sendRunQueue, dispatch), diff --git a/ui/src/containers/ConnectionLostDialog.jsx b/ui/src/containers/ConnectionLostDialog.jsx index 14c8699aa..6a26d796b 100644 --- a/ui/src/containers/ConnectionLostDialog.jsx +++ b/ui/src/containers/ConnectionLostDialog.jsx @@ -74,7 +74,7 @@ function mapStateToProps(state) { function mapDispatchToProps(dispatch) { return { hide: bindActionCreators( - showConnectionLostDialog.bind(this, false), + showConnectionLostDialog.bind(null, false), dispatch, ), }; diff --git a/ui/src/containers/EquipmentContainer.jsx b/ui/src/containers/EquipmentContainer.jsx index ae39d6f41..3fedb8533 100644 --- a/ui/src/containers/EquipmentContainer.jsx +++ b/ui/src/containers/EquipmentContainer.jsx @@ -17,7 +17,7 @@ import { selectDrop, } from '../actions/sampleChanger'; -import * as GeneralActions from '../actions/general'; +import * as generalActions from '../actions/general'; // eslint-disable-line import/no-namespace import { syncWithCrims } from '../actions/sampleGrid'; @@ -167,7 +167,7 @@ function mapDispatchToProps(dispatch) { abort: () => dispatch(abort()), sendCommand: (cmd, args) => dispatch(sendCommand(cmd, args)), executeCommand: bindActionCreators(executeCommand, dispatch), - generalActions: bindActionCreators(GeneralActions, dispatch), + generalActions: bindActionCreators(generalActions, dispatch), selectWell: (row, col) => dispatch(selectWell(row, col)), setPlate: (address) => dispatch(setPlate(address)), selectDrop: (address) => dispatch(selectDrop(address)), diff --git a/ui/src/containers/ErrorNotificationPanel.js b/ui/src/containers/ErrorNotificationPanel.js index 72034031a..5e90d4eac 100644 --- a/ui/src/containers/ErrorNotificationPanel.js +++ b/ui/src/containers/ErrorNotificationPanel.js @@ -33,7 +33,7 @@ function mapStateToProps(state) { function mapDispatchToProps(dispatch) { return { hideErrorPanel: bindActionCreators( - showErrorPanel.bind(this, false), + showErrorPanel.bind(null, false), dispatch, ), }; diff --git a/ui/src/containers/GphlWorkflowParametersDialog.jsx b/ui/src/containers/GphlWorkflowParametersDialog.jsx index 4a42518f3..8521c37be 100644 --- a/ui/src/containers/GphlWorkflowParametersDialog.jsx +++ b/ui/src/containers/GphlWorkflowParametersDialog.jsx @@ -74,7 +74,7 @@ function mapStateToProps(state) { function mapDispatchToProps(dispatch) { return { hide: bindActionCreators( - showGphlWorkflowParametersDialog.bind(this, null, false), + showGphlWorkflowParametersDialog.bind(null, null, false), dispatch, ), gphlWorkflowSubmitParameters: bindActionCreators( diff --git a/ui/src/containers/GroupFolderInput.jsx b/ui/src/containers/GroupFolderInput.jsx index 8f4451b05..eeea10a36 100644 --- a/ui/src/containers/GroupFolderInput.jsx +++ b/ui/src/containers/GroupFolderInput.jsx @@ -2,7 +2,7 @@ import React from 'react'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import { Form, Button } from 'react-bootstrap'; -import * as QueueActions from '../actions/queue'; +import * as queueActions from '../actions/queue'; // eslint-disable-line import/no-namespace class GroupFolderInput extends React.Component { constructor(props) { @@ -75,7 +75,7 @@ function mapStateToProps(state) { function mapDispatchToProps(dispatch) { return { - queueActions: bindActionCreators(QueueActions, dispatch), + queueActions: bindActionCreators(queueActions, dispatch), }; } diff --git a/ui/src/containers/MotorInputContainer.js b/ui/src/containers/MotorInputContainer.js index 0c52e9099..4c6891261 100644 --- a/ui/src/containers/MotorInputContainer.js +++ b/ui/src/containers/MotorInputContainer.js @@ -1,10 +1,9 @@ import React, { Component } from 'react'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; -import { Col } from 'react-bootstrap'; -import * as SampleViewActions from '../actions/sampleview'; -import * as GeneralActions from '../actions/general'; -import * as BeamlineActions from '../actions/beamline'; +import * as sampleViewActions from '../actions/sampleview'; // eslint-disable-line import/no-namespace +import * as generalActions from '../actions/general'; // eslint-disable-line import/no-namespace +import * as beamlineActions from '../actions/beamline'; // eslint-disable-line import/no-namespace import { QUEUE_RUNNING } from '../constants'; import MotorInput from '../components/MotorInput/MotorInput'; @@ -60,9 +59,9 @@ function mapStateToProps(state, ownProps) { function mapDispatchToProps(dispatch) { return { - sampleViewActions: bindActionCreators(SampleViewActions, dispatch), - beamlineActions: bindActionCreators(BeamlineActions, dispatch), - generalActions: bindActionCreators(GeneralActions, dispatch), + sampleViewActions: bindActionCreators(sampleViewActions, dispatch), + beamlineActions: bindActionCreators(beamlineActions, dispatch), + generalActions: bindActionCreators(generalActions, dispatch), }; } diff --git a/ui/src/containers/PleaseWaitDialog.js b/ui/src/containers/PleaseWaitDialog.js index ed0fd5c94..93a52f225 100644 --- a/ui/src/containers/PleaseWaitDialog.js +++ b/ui/src/containers/PleaseWaitDialog.js @@ -7,26 +7,12 @@ import { setLoading } from '../actions/general'; export class PleaseWaitDialog extends React.Component { constructor(props) { super(props); - this.getHideFun = this.getHideFun.bind(this); + this.hide = this.hide.bind(this); this.abort = this.abort.bind(this); } - getTitle() { - return this.props.title || 'Please wait'; - } - - getMessage() { - return this.props.message || ''; - } - - getHideFun() { - let fun = this.props.setLoadingFalse; - - if (this.props.blocking) { - fun = this.props.setLoadingTrue; - } - - return fun; + hide() { + this.props.setLoading(this.props.blocking); } abort() { @@ -34,66 +20,7 @@ export class PleaseWaitDialog extends React.Component { this.props.abortFun(); } - this.props.setLoadingFalse(); - } - - renderHeader() { - let header = ( - - {this.getTitle()} - - ); - - if (this.props.blocking) { - header = ( - - {this.getTitle()} - - ); - } - - return header; - } - - renderFooter() { - let footer = ( - - - - ); - - if (this.props.blocking) { - footer = ( - - - - ); - } - - return footer; - } - - renderContent() { - let content = ( -
-

{this.getMessage()}

-
- ); - - if (this.props.blocking) { - content = ( -
-

{this.getMessage()}

- -
- ); - } - - return content; + this.props.setLoading(false); } render() { @@ -101,11 +28,31 @@ export class PleaseWaitDialog extends React.Component { - {this.renderHeader()} - {this.renderContent()} - {this.renderFooter()} + + {this.props.title || 'Please wait'} + + +
+

{this.props.message || ''}

+ {this.props.blocking && ( + + )} +
+
+ + {this.props.blocking ? ( + + ) : ( + + )} +
); } @@ -123,8 +70,7 @@ function mapStateToProps(state) { function mapDispatchToProps(dispatch) { return { - setLoadingFalse: bindActionCreators(setLoading.bind(this, false), dispatch), - setLoadingTrue: bindActionCreators(setLoading.bind(this, true), dispatch), + setLoading: bindActionCreators(setLoading, dispatch), }; } diff --git a/ui/src/containers/QueueSettings.jsx b/ui/src/containers/QueueSettings.jsx index 9183abc4f..5468f1251 100644 --- a/ui/src/containers/QueueSettings.jsx +++ b/ui/src/containers/QueueSettings.jsx @@ -1,14 +1,14 @@ import React from 'react'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; -import { Form, DropdownButton, Dropdown } from 'react-bootstrap'; +import { Form, Dropdown } from 'react-bootstrap'; import { AUTO_LOOP_CENTRING, CLICK_CENTRING } from '../constants'; import GroupFolderInput from './GroupFolderInput.jsx'; import NumSnapshotsDropDown from './NumSnapshotsDropDown.jsx'; -import * as QueueActions from '../actions/queue'; +import * as queueActions from '../actions/queue'; // eslint-disable-line import/no-namespace class QueueSettings extends React.Component { constructor(props) { @@ -130,7 +130,7 @@ function mapStateToProps(state) { function mapDispatchToProps(dispatch) { return { - queueActions: bindActionCreators(QueueActions, dispatch), + queueActions: bindActionCreators(queueActions, dispatch), }; } diff --git a/ui/src/containers/ResumeQueueDialog.jsx b/ui/src/containers/ResumeQueueDialog.jsx index 0c04537b5..1de2fc15d 100644 --- a/ui/src/containers/ResumeQueueDialog.jsx +++ b/ui/src/containers/ResumeQueueDialog.jsx @@ -46,7 +46,7 @@ function mapStateToProps(state) { function mapDispatchToProps(dispatch) { return { - hide: bindActionCreators(showResumeQueueDialog.bind(this, false), dispatch), + hide: bindActionCreators(showResumeQueueDialog.bind(null, false), dispatch), }; } diff --git a/ui/src/containers/SampleFlexView.jsx b/ui/src/containers/SampleFlexView.jsx index a2fd6de12..98c15b9cc 100644 --- a/ui/src/containers/SampleFlexView.jsx +++ b/ui/src/containers/SampleFlexView.jsx @@ -160,6 +160,7 @@ function mapDispatchToProps(dispatch) { }; } -NewSampleFlexView = withRouter(NewSampleFlexView); - -export default connect(mapStateToProps, mapDispatchToProps)(NewSampleFlexView); +export default connect( + mapStateToProps, + mapDispatchToProps, +)(withRouter(NewSampleFlexView)); diff --git a/ui/src/containers/SampleGridTableContainer.jsx b/ui/src/containers/SampleGridTableContainer.jsx index d6f2dbcf4..ab93dbd28 100644 --- a/ui/src/containers/SampleGridTableContainer.jsx +++ b/ui/src/containers/SampleGridTableContainer.jsx @@ -766,7 +766,7 @@ class SampleGridTableContainer extends React.Component { const scList = this.props.sampleList; const manualSamples = []; const ks = Object.keys(scList); - ks.map((sample) => { + ks.forEach((sample) => { if (scList[sample].location === 'Manual') { scList[sample].cell_no = 0; manualSamples.push(scList[sample]); @@ -1263,9 +1263,7 @@ function mapDispatchToProps(dispatch) { }; } -SampleGridTableContainer = withRouter(SampleGridTableContainer); - export default connect( mapStateToProps, mapDispatchToProps, -)(SampleGridTableContainer); +)(withRouter(SampleGridTableContainer)); diff --git a/ui/src/containers/SampleIsaraView.jsx b/ui/src/containers/SampleIsaraView.jsx index d504987c6..b29024c2f 100644 --- a/ui/src/containers/SampleIsaraView.jsx +++ b/ui/src/containers/SampleIsaraView.jsx @@ -276,6 +276,7 @@ function mapDispatchToProps(dispatch) { }; } -NewSampleIsaraView = withRouter(NewSampleIsaraView); - -export default connect(mapStateToProps, mapDispatchToProps)(NewSampleIsaraView); +export default connect( + mapStateToProps, + mapDispatchToProps, +)(withRouter(NewSampleIsaraView)); diff --git a/ui/src/containers/SampleListViewContainer.jsx b/ui/src/containers/SampleListViewContainer.jsx index 6eff1e247..4bca9e8cb 100644 --- a/ui/src/containers/SampleListViewContainer.jsx +++ b/ui/src/containers/SampleListViewContainer.jsx @@ -896,7 +896,7 @@ function mapDispatchToProps(dispatch) { dispatch, ), confirmClearQueueHide: bindActionCreators( - showConfirmClearQueueDialog.bind(this, false), + showConfirmClearQueueDialog.bind(null, false), dispatch, ), showConfirmCollectDialog: bindActionCreators( @@ -908,9 +908,7 @@ function mapDispatchToProps(dispatch) { }; } -SampleListViewContainer = withRouter(SampleListViewContainer); - export default connect( mapStateToProps, mapDispatchToProps, -)(SampleListViewContainer); +)(withRouter(SampleListViewContainer)); diff --git a/ui/src/containers/SampleQueueContainer.js b/ui/src/containers/SampleQueueContainer.js index 3abd10956..e5b5445df 100644 --- a/ui/src/containers/SampleQueueContainer.js +++ b/ui/src/containers/SampleQueueContainer.js @@ -4,17 +4,17 @@ import { connect } from 'react-redux'; import CurrentTree from '../components/SampleQueue/CurrentTree'; import TodoTree from '../components/SampleQueue/TodoTree'; import QueueControl from '../components/SampleQueue/QueueControl'; -import * as QueueActions from '../actions/queue'; -import * as QueueGUIActions from '../actions/queueGUI'; -import * as SampleViewActions from '../actions/sampleview'; -import * as SampleChangerActions from '../actions/sampleChanger'; +import * as beamlineActions from '../actions/beamline'; // eslint-disable-line import/no-namespace +import * as queueActions from '../actions/queue'; // eslint-disable-line import/no-namespace +import * as queueGUIActions from '../actions/queueGUI'; // eslint-disable-line import/no-namespace +import * as sampleViewActions from '../actions/sampleview'; // eslint-disable-line import/no-namespace +import * as sampleChangerActions from '../actions/sampleChanger'; // eslint-disable-line import/no-namespace import { showTaskForm } from '../actions/taskForm'; import { Nav } from 'react-bootstrap'; import { showDialog } from '../actions/general'; import UserMessage from '../components/Notify/UserMessage'; import loader from '../img/loader.gif'; -import * as BeamlineActions from '../actions/beamline'; function mapStateToProps(state) { return { @@ -42,13 +42,13 @@ function mapStateToProps(state) { function mapDispatchToProps(dispatch) { return { - queueActions: bindActionCreators(QueueActions, dispatch), - queueGUIActions: bindActionCreators(QueueGUIActions, dispatch), - sampleViewActions: bindActionCreators(SampleViewActions, dispatch), - sampleChangerActions: bindActionCreators(SampleChangerActions, dispatch), + queueActions: bindActionCreators(queueActions, dispatch), + queueGUIActions: bindActionCreators(queueGUIActions, dispatch), + sampleViewActions: bindActionCreators(sampleViewActions, dispatch), + sampleChangerActions: bindActionCreators(sampleChangerActions, dispatch), showForm: bindActionCreators(showTaskForm, dispatch), showDialog: bindActionCreators(showDialog, dispatch), - beamlineActions: bindActionCreators(BeamlineActions, dispatch), + beamlineActions: bindActionCreators(beamlineActions, dispatch), }; } @@ -128,7 +128,6 @@ class SampleQueueContainer extends React.Component { return (
{ +function sampleChangerMaintenanceReducer(state = INITIAL_STATE, action = {}) { switch (action.type) { case 'SET_INITIAL_STATE': { return { @@ -28,4 +28,6 @@ export default (state = INITIAL_STATE, action) => { return state; } } -}; +} + +export default sampleChangerMaintenanceReducer;