Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor OneAxisTranslationControl #1445

Merged
merged 1 commit into from
Oct 14, 2024
Merged

Refactor OneAxisTranslationControl #1445

merged 1 commit into from
Oct 14, 2024

Conversation

axelboc
Copy link
Collaborator

@axelboc axelboc commented Oct 14, 2024

OneAxisTranslationControl has an input field that behaves the same way as the input field in MotorInput: you can type a number and press enter, or use up/down arrow to increment decrement, and it updates the value and shows the state of the underlying motor.

So in this PR, I extract this shared input from MotorInput into a BaseMotorInput component, and use it in OneAxisTranslationControl. This resolves a few minor inconsistencies between the two components and removes a bunch of duplicated code.

Peek 2024-10-14 09-30

Still more refactoring to go — notably, I'd like to reduce the number of props that are passed down to some of the components.

Comment on lines -59 to -94
renderMotorSettings() {
return (
<Popover title={<b>Sample alignment motors</b>}>
<div>
<MotorInput
save={this.props.save}
value={this.props.motors.sample_vertical.position}
saveStep={this.props.saveStep}
step={this.props.steps.sample_verticalStep}
motorName="sample_vertical"
label="Vertical"
suffix="mm"
decimalPoints="3"
state={this.props.motors.sample_vertical.state}
stop={this.props.stop}
disabled={this.props.motorsDisabled}
inplace
/>
<MotorInput
save={this.props.save}
value={this.props.motors.sample_horizontal.position}
saveStep={this.props.saveStep}
step={this.props.steps.sample_horizontalStep}
motorName="sample_horizontal"
label="Horizontal"
suffix="mm"
decimalPoints="3"
state={this.props.motors.sample_horizontal.state}
stop={this.props.stop}
disabled={this.props.motorsDisabled}
inplace
/>
</div>
</Popover>
);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was dead code — maybe from copy-pasting TwoAxisTranslationControl.

@axelboc axelboc marked this pull request as ready for review October 14, 2024 07:51
@marcus-oscarsson
Copy link
Member

Thanks !

@marcus-oscarsson marcus-oscarsson merged commit 56dbd43 into develop Oct 14, 2024
19 checks passed
@marcus-oscarsson marcus-oscarsson deleted the ab-refact branch October 14, 2024 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants