Skip to content

Commit

Permalink
minor refactoring and missing update for subcellular component
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelpiano committed Jul 10, 2024
1 parent 834a4c1 commit 0d6e11c
Show file tree
Hide file tree
Showing 5 changed files with 336 additions and 300 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export default class NetPyNEConnectivityRule extends React.Component {
};
}

UNSAFE_componentWillReceiveProps (nextProps) {
this.setState({ currentName: nextProps.name });
}

handleRenameChange = (event) => {
const storedValue = this.props.name;
const newValue = Utils.nameValidation(event.target.value);
Expand Down Expand Up @@ -60,19 +64,7 @@ export default class NetPyNEConnectivityRule extends React.Component {
}
};

triggerUpdate (updateMethod) {
// common strategy when triggering processing of a value change, delay it, every time there is a change we reset
// eslint-disable-next-line eqeqeq
if (this.updateTimer !== undefined) {
clearTimeout(this.updateTimer);
}
this.updateTimer = setTimeout(updateMethod, 1000);
}

select = (index, sectionId) => this.setState({
selectedIndex: index,
sectionId,
});
handleChange = (event, index, values) => this.setState({ values });

getBottomNavigationAction (index, sectionId, label, icon, id) {
return (
Expand All @@ -86,6 +78,20 @@ export default class NetPyNEConnectivityRule extends React.Component {
);
}

select = (index, sectionId) => this.setState({
selectedIndex: index,
sectionId,
});

triggerUpdate (updateMethod) {
// common strategy when triggering processing of a value change, delay it, every time there is a change we reset
// eslint-disable-next-line eqeqeq
if (this.updateTimer !== undefined) {
clearTimeout(this.updateTimer);
}
this.updateTimer = setTimeout(updateMethod, 1000);
}

postProcessMenuItems (pythonData, selected) {
return pythonData.map((name) => (
<MenuItem
Expand All @@ -99,10 +105,6 @@ export default class NetPyNEConnectivityRule extends React.Component {
));
}

UNSAFE_componentWillReceiveProps (nextProps) {
this.setState({ currentName: nextProps.name });
}

render () {
const dialogPop = this.state.errorMessage !== undefined ? (
<Dialog open style={{ whiteSpace: 'pre-wrap' }}>
Expand Down Expand Up @@ -445,6 +447,4 @@ export default class NetPyNEConnectivityRule extends React.Component {
</div>
);
}

handleChange = (event, index, values) => this.setState({ values });
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ export default class NetPyNEConnectivityRules extends Component {
}

componentDidUpdate (prevProps, prevState) {
if (this.props.commands !== prevProps.commands)
if (this.props.commands !== prevProps.commands) {
this.forceUpdate();
}
// we need to check if any of the three entities have been renamed and if that's the case change the state for the selection variable
const newConnectivityRuleName = this.hasSelectedConnectivityRuleBeenRenamed(
prevState,
Expand Down
Loading

0 comments on commit 0d6e11c

Please sign in to comment.