Skip to content

Convert SelectProposal to function component and other fixes #1496

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

Merged
merged 5 commits into from
Nov 25, 2024

Conversation

axelboc
Copy link
Collaborator

@axelboc axelboc commented Nov 21, 2024

This is based on mo-lims and meant to be merged into it.

Comment on lines -57 to -62
export function selectProposalAction(prop) {
return {
type: 'SELECT_PROPOSAL',
proposal: prop,
};
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no longer used

return async (dispatch) => {
try {
await sendSelectProposal(number);
navigate('/');
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think we need to navigate after selecting a proposal. The redirect to /login actually had no effect since the user was redirected right away to /datacollection.

return (
<Modal
show={show}
backdrop={showProposalsForm || 'static'}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The dialog doesn't have to be a modal when re-opened manually (i.e. when a proposal is already selected). This line allows the dialog to be dismissed by clicking on the backdrop in this situation.

Comment on lines +60 to +62
if (showProposalsForm) {
handleHide();
}
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 condition does the opposite: it makes the dialog truly modal when shown because no proposal is selected. It does so by preventing the dialog from being dismissed with Escape in this situation.

data-default-styles
onClick={() => handleHide()}
>
{showProposalsForm ? 'Cancel' : 'Sign out'}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Being more explicit about what canceling does when the dialog is shown because no proposal is selected.

}}
>
<Modal.Header closeButton>
<Modal.Title>Select a session</Modal.Title>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There seems to be a bit of confusion in the UI with the terms "proposal" and "session". Are those the same thing?

Copy link
Member

Choose a reason for hiding this comment

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

:), almost but not really. When using proposal to login they are considered the same but when using user based login they are not.

Copy link
Member

Choose a reason for hiding this comment

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

You are right that it is confusing, the form should really be called SelectSession or similar. This can be changed in a future PR.

<th>Portal</th>
<th>User</th>
<th>Logbook</th>
<th scope="col">ID</th>
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 heading cell was missing.

</del>
);
if (sessions.length === 0) {
return <span className={styles.fallback}>No sessions</span>;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Showing a fallback instead of an empty table.

Comment on lines +42 to +47
onKeyDown={(evt) => {
// For keyboard accessibility; ideally add "Select" button to each row instead of making rows clickable
if (evt.key === 'Enter' || evt.key === ' ') {
onSessionSelected(session);
}
}}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm including a bunch of accessibility fixes like this one and various aria-label attributes.

Copy link
Member

Choose a reason for hiding this comment

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

Very nice !

@@ -105,7 +107,7 @@ class ServerIO {
this.hwrSocket.on('disconnect', (reason) => {
console.log('hwrSocket disconnected!'); // eslint-disable-line no-console

setTimeout(() => {
this.connectionLostTimeout = setTimeout(() => {
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 timeout was triggered sometimes when logging out and back in quickly, which made the connection-lost dialog flash on the screen.

Copy link
Member

Choose a reason for hiding this comment

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

Well spotted, nice fix !

@axelboc axelboc marked this pull request as ready for review November 21, 2024 15:10
@marcus-oscarsson
Copy link
Member

Thanks, 👍

getLoginInfo(),
),
);

Copy link
Member

Choose a reason for hiding this comment

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

I see, ok :)

@marcus-oscarsson marcus-oscarsson merged commit a0d81fc into mo-lims Nov 25, 2024
14 checks passed
@marcus-oscarsson marcus-oscarsson deleted the ab-mo-lims branch November 25, 2024 09:18
@marcus-oscarsson marcus-oscarsson restored the ab-mo-lims branch December 11, 2024 13:52
@axelboc axelboc deleted the ab-mo-lims branch December 20, 2024 10:08
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