From 74c16e3ae281b45190982f69f878cd3acd86c5cc Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 8 Mar 2021 16:05:33 +0100 Subject: [PATCH] cosmetic code changes --- src/common/table.js | 45 +++++++++++++++++++------------------- src/user/edit-own-user.js | 14 ++++-------- src/user/edit-user.js | 1 - src/user/login-complete.js | 7 ++---- src/user/login.js | 2 +- src/user/new-user.js | 1 - src/user/user.js | 16 ++++++++------ src/user/users-store.js | 1 - src/user/users.js | 45 +++++++++++++++++++++++++++++++------- 9 files changed, 76 insertions(+), 56 deletions(-) diff --git a/src/common/table.js b/src/common/table.js index 78d3b55..ebcbea2 100644 --- a/src/common/table.js +++ b/src/common/table.js @@ -169,14 +169,16 @@ class CustomTable extends Component { Export } > + overlay={ Export } + > - ); + + ); } if (child.props.duplicateButton) { @@ -191,7 +193,8 @@ class CustomTable extends Component { disabled={child.props.onDuplicate == null}> - ); + + ); } if (child.props.addRemoveFilesButton) { @@ -206,7 +209,8 @@ class CustomTable extends Component { disabled={child.props.onAddRemove == null}> - ); + + ); } if (child.props.downloadAllButton) { @@ -246,8 +250,6 @@ class CustomTable extends Component { } } - - return cell; } // addCell @@ -312,26 +314,24 @@ class CustomTable extends Component { { - this.state.rows.map((row, rowIndex) => ( + this.state.rows.map((row, rowIndex) => { row.map((cell, cellIndex) => { let isCellInlineEditable = children[cellIndex].props.inlineEditable === true; - let tabIndex = isCellInlineEditable ? 0 : -1; - let evtHdls = isCellInlineEditable ? { onCellClick: (event) => this.onClick(event, rowIndex, cellIndex), onCellFocus: () => this.onCellFocus({ cell: cellIndex, row: rowIndex }), onCellBlur: () => this.cellLostFocus() } : { - onCellClick: () => { }, - onCellFocus: () => { }, - onCellBlur: () => { } - }; + onCellClick: () => { }, + onCellFocus: () => { }, + onCellBlur: () => { } + }; - return ( children[cellIndex].props.onInlineChange(event, rowIndex, cellIndex)} ref={ref => { this.activeInput = ref; }} /> - ) : ( - - {cell.map((element, elementIndex) => ( + : + { + cell.map((element, elementIndex) => {element} - ))} - - )} - ) + ) + } + + } + }) } - )) + ) } diff --git a/src/user/edit-own-user.js b/src/user/edit-own-user.js index 4b7a639..d093ec7 100644 --- a/src/user/edit-own-user.js +++ b/src/user/edit-own-user.js @@ -37,8 +37,6 @@ class EditOwnUserDialog extends React.Component { } } - - onClose(canceled) { if (canceled === false) { if (this.valid) { @@ -49,8 +47,6 @@ class EditOwnUserDialog extends React.Component { } } - - handleChange(e) { this.setState({ [e.target.id]: e.target.value }); @@ -65,26 +61,24 @@ class EditOwnUserDialog extends React.Component { username = false; } - if(this.state.mail === ''){ + if (this.state.mail === '') { mail = false; } - if(this.state.password === ''){ + if (this.state.password === '') { pw = false; } - if(this.state.oldPassword === ''){ + if (this.state.oldPassword === '') { oldPassword = false; } - if(this.state.confirmpassword === ''){ + if (this.state.confirmpassword === '') { confirmpassword = false; } - // form is valid if the following condition is met this.valid = username || mail || (oldPassword && pw && confirmpassword); - } resetState() { diff --git a/src/user/edit-user.js b/src/user/edit-user.js index 12ee58a..a137562 100644 --- a/src/user/edit-user.js +++ b/src/user/edit-user.js @@ -60,7 +60,6 @@ class EditUserDialog extends React.Component { var confirmpassword = true; var oldPW = true; - if (this.state.username === '') { username = false; } diff --git a/src/user/login-complete.js b/src/user/login-complete.js index 4fd4922..698dc81 100644 --- a/src/user/login-complete.js +++ b/src/user/login-complete.js @@ -26,7 +26,7 @@ class LoginComplete extends React.Component { constructor(props) { console.log("LoginComplete constructor"); super(props); - + AppDispatcher.dispatch({ type: 'users/extlogin', }); @@ -42,8 +42,6 @@ class LoginComplete extends React.Component { this.startTimer = this.startTimer.bind(this); this.countDown = this.countDown.bind(this); this.stopTimer = this.stopTimer.bind(this); - - } componentDidMount() { @@ -51,7 +49,6 @@ class LoginComplete extends React.Component { this.setState({secondsToWait: 5}); } - static getStores(){ return [LoginStore] } @@ -104,4 +101,4 @@ class LoginComplete extends React.Component { } let fluxContainerConverter = require('../common/FluxContainerConverter'); -export default Container.create(fluxContainerConverter.convert(LoginComplete)); \ No newline at end of file +export default Container.create(fluxContainerConverter.convert(LoginComplete)); diff --git a/src/user/login.js b/src/user/login.js index ea38f89..f265342 100644 --- a/src/user/login.js +++ b/src/user/login.js @@ -32,7 +32,7 @@ class Login extends Component { constructor(props) { super(props); - // load config in case the user goes directly to /login + // Load config in case the user goes directly to /login // otherwise it will be loaded in app constructor AppDispatcher.dispatch({ type: 'config/load', diff --git a/src/user/new-user.js b/src/user/new-user.js index 2d0c434..a8cd5a8 100644 --- a/src/user/new-user.js +++ b/src/user/new-user.js @@ -54,7 +54,6 @@ class NewUserDialog extends React.Component { let mail = this.state.mail !== ''; this.valid = username && password && role && mail; - } resetState() { diff --git a/src/user/user.js b/src/user/user.js index e85f5ac..cc0271e 100644 --- a/src/user/user.js +++ b/src/user/user.js @@ -46,7 +46,6 @@ class User extends Component { } componentDidMount() { - let currentUserID = JSON.parse(localStorage.getItem("currentUser")).id; AppDispatcher.dispatch({ @@ -54,12 +53,13 @@ class User extends Component { data: parseInt(currentUserID, 10), token: this.state.token }); - } closeEditModal(data) { + this.setState({ + editModal: false + }); - this.setState({ editModal: false }); let updatedData = {} updatedData.id = this.state.currentUser.id; let updatedUser = this.state.currentUser; @@ -87,8 +87,7 @@ class User extends Component { } if (hasChanged || pwChanged) { - - if(hasChanged){ + if (hasChanged){ this.setState({currentUser: updatedUser}) } @@ -103,9 +102,12 @@ class User extends Component { } } - getHumanRoleName(role_key) { - const HUMAN_ROLE_NAMES = {Admin: 'Administrator', User: 'User', Guest: 'Guest'}; + const HUMAN_ROLE_NAMES = { + Admin: 'Administrator', + User: 'User', + Guest: 'Guest' + }; return HUMAN_ROLE_NAMES.hasOwnProperty(role_key)? HUMAN_ROLE_NAMES[role_key] : ''; } diff --git a/src/user/users-store.js b/src/user/users-store.js index 8bda26a..fccb4a9 100644 --- a/src/user/users-store.js +++ b/src/user/users-store.js @@ -50,7 +50,6 @@ class UsersStore extends ArrayStore { return super.reduce(state, action); } } - } export default new UsersStore(); diff --git a/src/user/users.js b/src/user/users.js index 96b1e4c..e83bccf 100644 --- a/src/user/users.js +++ b/src/user/users.js @@ -129,7 +129,6 @@ class Users extends Component { } render() { - const buttonStyle = { marginLeft: '10px', }; @@ -153,17 +152,47 @@ class Users extends Component { - - - - this.getHumanRoleName(role)} /> - this.modifyActiveColumn(active)} /> - this.setState({ editModal: true, modalData: this.state.users[index] })} onDelete={index => this.setState({ deleteModal: true, modalData: this.state.users[index] })} /> + + + + this.getHumanRoleName(role)} + /> + this.modifyActiveColumn(active)} + /> + this.setState({ + editModal: true, + modalData: this.state.users[index] + })} + onDelete={index => this.setState({ + deleteModal: true, + modalData: this.state.users[index] + })} + />
this.closeNewModal(data)} /> this.closeEditModal(data)} user={this.state.modalData} /> - this.closeDeleteModal(e)} /> );