Skip to content

Commit

Permalink
Fix ESLint warnings (1)
Browse files Browse the repository at this point in the history
  • Loading branch information
axelboc authored and marcus-oscarsson committed Sep 26, 2023
1 parent 4652da2 commit ff573df
Show file tree
Hide file tree
Showing 21 changed files with 107 additions and 78 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion ui/src/containers/GphlWorkflowParametersDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Form from '@rjsf/core';
import {
showGphlWorkflowParametersDialog,
gphlWorkflowSubmitParameters,
} from '../actions/gphl_workflow';
} from '../actions/gphlWorkflow';

class GphlWorkflowParametersDialog extends React.Component {
constructor(props) {
Expand Down
7 changes: 5 additions & 2 deletions ui/src/reducers/beamline.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import { STATE } from '../actions/beamline';
import { RUNNING, MOTOR_STATE } from '../constants';

Expand Down Expand Up @@ -141,7 +142,7 @@ export const INITIAL_STATE = {
energyScanElements: [],
};

export default (state = INITIAL_STATE, action) => {
function beamlineReducer(state = INITIAL_STATE, action = {}) {
let data = {};

switch (action.type) {
Expand Down Expand Up @@ -415,4 +416,6 @@ export default (state = INITIAL_STATE, action) => {
default:
return state;
}
};
}

export default beamlineReducer;
9 changes: 5 additions & 4 deletions ui/src/reducers/contextMenu.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable import/no-anonymous-default-export */
const initialState = {
const INITIAL_STATE = {
show: false,
shape: { type: 'NONE' },
x: 0,
Expand All @@ -12,7 +11,7 @@ const initialState = {
},
};

export default (state = initialState, action) => {
function contextMenuReducer(state = INITIAL_STATE, action = {}) {
switch (action.type) {
case 'SHOW_CONTEXT_MENU': {
return {
Expand All @@ -36,4 +35,6 @@ export default (state = initialState, action) => {
default:
return state;
}
};
}

export default contextMenuReducer;
8 changes: 5 additions & 3 deletions ui/src/reducers/general.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const initialState = {
const INITIAL_STATE = {
loading: false,
showErrorPanel: false,
errorMessage: '',
Expand All @@ -13,7 +13,7 @@ const initialState = {
applicationFetched: false,
};

export default (state = initialState, action) => {
function generalReducer(state = INITIAL_STATE, action = {}) {
switch (action.type) {
case 'SET_LOADING': {
return {
Expand Down Expand Up @@ -60,4 +60,6 @@ export default (state = initialState, action) => {
default:
return state;
}
};
}

export default generalReducer;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const initialState = {
const INITIAL_STATE = {
workflows: [],
current: null,
};

export default (state = initialState, action) => {
function gphlWorkflowReducer(state = INITIAL_STATE, action = {}) {
switch (action.type) {
case 'SET_WORKFLOWS': {
return { ...state, workflows: { ...action.workflows } };
Expand All @@ -25,4 +25,6 @@ export default (state = initialState, action) => {
default:
return state;
}
};
}

export default gphlWorkflowReducer;
2 changes: 1 addition & 1 deletion ui/src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import contextMenu from './contextMenu';
import remoteAccess from './remoteAccess';
import shapes from './shapes';
import workflow from './workflow';
import gphl_workflow from './gphl_workflow';
import gphl_workflow from './gphlWorkflow';
import taskResult from './taskResult';
import uiproperties from './uiproperties';

Expand Down
8 changes: 5 additions & 3 deletions ui/src/reducers/logger.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const initialState = {
const INITIAL_STATE = {
logRecords: [],
activePage: 0,
};

export default (state = initialState, action) => {
function loggerReducer(state = INITIAL_STATE, action = {}) {
switch (action.type) {
case 'ADD_LOG_RECORD': {
return { ...state, logRecords: [...state.logRecords, action.data] };
Expand All @@ -17,4 +17,6 @@ export default (state = initialState, action) => {
default:
return state;
}
};
}

export default loggerReducer;
8 changes: 5 additions & 3 deletions ui/src/reducers/login.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const initialState = {
const INITIAL_STATE = {
loggedIn: null, // null means loggedIn state is not known yet
showProposalsForm: false,
selectedProposal: '',
Expand All @@ -9,7 +9,7 @@ const initialState = {
},
};

export default (state = initialState, action) => {
function loginReducer(state = INITIAL_STATE, action = {}) {
switch (action.type) {
case 'SET_LOGIN_INFO': {
if (action.loginInfo.user.username !== '') {
Expand Down Expand Up @@ -56,4 +56,6 @@ export default (state = initialState, action) => {
default:
return state;
}
};
}

export default loginReducer;
16 changes: 9 additions & 7 deletions ui/src/reducers/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import update from 'immutability-helper';
import { QUEUE_STOPPED, CLICK_CENTRING } from '../constants';
import { clearAllLastUsedParameters } from '../components/Tasks/fields';

const initialState = {
const INITIAL_STATE = {
queue: [],
current: { sampleID: null, running: false },
queueStatus: QUEUE_STOPPED,
Expand All @@ -14,21 +14,21 @@ const initialState = {
groupFolder: '',
};

export default (state = initialState, action) => {
function queueReducer(state = INITIAL_STATE, action = {}) {
switch (action.type) {
case 'SET_QUEUE': {
return { ...state, queue: action.sampleOrder };
}
case 'CLEAR_QUEUE': {
return {
...state,
queue: initialState.queue,
current: initialState.current,
queue: INITIAL_STATE.queue,
current: INITIAL_STATE.current,
};
}
case 'ADD_SAMPLES_TO_QUEUE': {
const sampleIDList = action.samplesData.map((s) => s.sampleID);
return { ...state, queue: state.queue.concat(sampleIDList) };
return { ...state, queue: [...state.queue, ...sampleIDList] };
}
case 'SET_QUEUE_STATUS':
return {
Expand Down Expand Up @@ -103,7 +103,7 @@ export default (state = initialState, action) => {
return { ...state, [action.settingName]: action.value };
}
case 'CLEAR_ALL': {
return { ...state, ...initialState, autoMountNext: state.autoMountNext };
return { ...state, ...INITIAL_STATE, autoMountNext: state.autoMountNext };
}
case 'QUEUE_STATE': {
return Object.assign({}, state, ...action.queueState);
Expand All @@ -128,4 +128,6 @@ export default (state = initialState, action) => {
default:
return state;
}
};
}

export default queueReducer;
14 changes: 8 additions & 6 deletions ui/src/reducers/queueGUI.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { omit } from 'lodash/object';

const initialState = {
const INITIAL_STATE = {
showRestoreDialog: false,
searchString: '',
displayData: {},
Expand All @@ -10,7 +10,7 @@ const initialState = {
showConfirmCollectDialog: false,
};

export default (state = initialState, action) => {
function queueGUIReducer(state = INITIAL_STATE, action = {}) {
switch (action.type) {
case 'redux-form/CHANGE': {
if (action.form === 'search-sample') {
Expand All @@ -26,7 +26,7 @@ export default (state = initialState, action) => {
const newNodes = [];

action.sampleOrder.forEach((sampleID) => {
if (action.sampleList.hasOwnProperty(sampleID)) {
if (sampleID in action.sampleList) {
action.sampleList[sampleID].tasks.forEach((task) => {
if (!existingNodes.includes(task.queueID.toString())) {
newNodes.push(task.queueID.toString());
Expand Down Expand Up @@ -126,7 +126,7 @@ export default (state = initialState, action) => {
const newNodes = [];

sampleOrder.forEach((sampleID) => {
if (sampleList.hasOwnProperty(sampleID)) {
if (sampleID in sampleList) {
sampleList[sampleID].tasks.forEach((task) => {
if (!existingNodes.includes(task.queueID.toString())) {
newNodes.push(task.queueID.toString());
Expand All @@ -144,9 +144,11 @@ export default (state = initialState, action) => {
return { ...state, displayData };
}
case 'CLEAR_ALL': {
return initialState;
return INITIAL_STATE;
}
default:
return state;
}
};
}

export default queueGUIReducer;
8 changes: 5 additions & 3 deletions ui/src/reducers/remoteAccess.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const initialState = {
const INITIAL_STATE = {
// the null value is used to distinguish between signed out (null) or logged in (true/false)
sid: null,
observers: [],
Expand All @@ -8,7 +8,7 @@ const initialState = {
chatMessageCount: 0,
};

export default (state = initialState, action) => {
function remoteAccessReducer(state = INITIAL_STATE, action = {}) {
switch (action.type) {
case 'SET_RA_STATE': {
return {
Expand Down Expand Up @@ -51,4 +51,6 @@ export default (state = initialState, action) => {
default:
return state;
}
};
}

export default remoteAccessReducer;
7 changes: 5 additions & 2 deletions ui/src/reducers/sampleChanger.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
const INITIAL_STATE = {
contents: {},
state: 'READY',
Expand Down Expand Up @@ -87,7 +88,7 @@ const INITIAL_STATE = {
selectedDrop: null,
};

export default (state = INITIAL_STATE, action) => {
function sampleChangerReducer(state = INITIAL_STATE, action = {}) {
switch (action.type) {
case 'SET_SC_CONTENTS': {
return { ...state, contents: action.data.sampleChangerContents };
Expand Down Expand Up @@ -122,4 +123,6 @@ export default (state = INITIAL_STATE, action) => {
return state;
}
}
};
}

export default sampleChangerReducer;
14 changes: 9 additions & 5 deletions ui/src/reducers/sampleGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const INITIAL_STATE = {
},
};

export default (state = INITIAL_STATE, action) => {
function sampleGridReducer(state = INITIAL_STATE, action = {}) {
switch (action.type) {
case 'SET_QUEUE': {
const sampleList = { ...state.sampleList };
Expand Down Expand Up @@ -122,9 +122,11 @@ export default (state = INITIAL_STATE, action) => {
const sampleIDList = action.samplesData.map((s) => s.sampleID);
const sampleList = { ...state.sampleList };
sampleIDList.forEach((sampleID, i) => {
sampleList[sampleID].tasks.length > 0
? sampleList[sampleID].tasks.concat(action.samplesData[i].tasks)
: (sampleList[sampleID].tasks = action.samplesData[i].tasks);
if (sampleList[sampleID].tasks.length > 0) {
sampleList[sampleID].tasks.concat(action.samplesData[i].tasks);
} else {
sampleList[sampleID].tasks = action.samplesData[i].tasks;
}
});

return { ...state, sampleList };
Expand Down Expand Up @@ -370,4 +372,6 @@ export default (state = INITIAL_STATE, action) => {
return state;
}
}
};
}

export default sampleGridReducer;
19 changes: 6 additions & 13 deletions ui/src/reducers/sampleview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const initialState = {
const INITIAL_STATE = {
clickCentring: false,
clickCentringPoints: [],
clickCentringClicksLeft: -1,
Expand Down Expand Up @@ -43,7 +43,7 @@ const initialState = {
selectedShapes: [],
};

export default (state = initialState, action) => {
function sampleViewReducer(state = INITIAL_STATE, action = {}) {
switch (action.type) {
case 'TOOGLE_CINEMA': {
return { ...state, cinema: !state.cinema };
Expand Down Expand Up @@ -169,16 +169,7 @@ export default (state = initialState, action) => {
);
return { ...state, selectedShapes };
}
case 'CLEAR_ALL': {
return {
...state,
distancePoints: [],
clickCentringPoints: [],
gridList: [],
gridCount: 0,
selectedShapes: [],
};
}
case 'CLEAR_ALL':
case 'SET_CURRENT_SAMPLE': {
return {
...state,
Expand Down Expand Up @@ -225,4 +216,6 @@ export default (state = initialState, action) => {
default:
return state;
}
};
}

export default sampleViewReducer;
Loading

0 comments on commit ff573df

Please sign in to comment.