-
Notifications
You must be signed in to change notification settings - Fork 41
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
Changes from all commits
24d2e0c
4953e38
cc4de37
ae5f888
28d0289
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,27 +54,18 @@ export function hideProposalsForm() { | |
}; | ||
} | ||
|
||
export function selectProposalAction(prop) { | ||
return { | ||
type: 'SELECT_PROPOSAL', | ||
proposal: prop, | ||
}; | ||
} | ||
|
||
export function setInitialState(data) { | ||
return { type: 'SET_INITIAL_STATE', data }; | ||
} | ||
|
||
export function selectProposal(number, navigate) { | ||
export function selectProposal(number) { | ||
return async (dispatch) => { | ||
try { | ||
await sendSelectProposal(number); | ||
navigate('/'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
dispatch(hideProposalsForm()); | ||
dispatch(getLoginInfo()); | ||
} catch { | ||
dispatch(showErrorPanel(true, 'Server refused to select proposal')); | ||
navigate('/login'); | ||
} | ||
}; | ||
} | ||
|
@@ -108,16 +99,14 @@ export function ssoLogIn() { | |
|
||
export function signOut() { | ||
return async (dispatch) => { | ||
dispatch(resetLoginInfo()); // disconnect sockets before actually logging out (cf. `App.jsx`) | ||
dispatch(applicationFetched(false)); | ||
// We make sure that user data is reseted so that websockets | ||
// are keept dicconnected while logging out. | ||
dispatch(resetLoginInfo()); | ||
await sendSignOut().finally(() => | ||
dispatch( | ||
// Retreiving the user data from the backend | ||
getLoginInfo(), | ||
), | ||
); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, ok :) |
||
try { | ||
await sendSignOut(); | ||
} finally { | ||
dispatch(getLoginInfo()); | ||
} | ||
}; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
import { Button } from 'react-bootstrap'; | ||
|
||
function ActionButton(props) { | ||
const { selectedSession, onClick } = props; | ||
|
||
if (!selectedSession) { | ||
return ( | ||
<Button variant="primary" disabled data-default-styles> | ||
Select Proposal | ||
</Button> | ||
); | ||
} | ||
|
||
if (!selectedSession.is_scheduled_beamline) { | ||
return ( | ||
<Button variant="danger" data-default-styles onClick={onClick}> | ||
Move here | ||
</Button> | ||
); | ||
} | ||
|
||
if (!selectedSession.is_scheduled_time) { | ||
return ( | ||
<Button variant="warning" data-default-styles onClick={onClick}> | ||
Reschedule | ||
</Button> | ||
); | ||
} | ||
|
||
return ( | ||
<Button variant="primary" data-default-styles onClick={onClick}> | ||
Select {selectedSession.code}-{selectedSession.number} | ||
</Button> | ||
); | ||
} | ||
|
||
export default ActionButton; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no longer used