Queue Frontend Development - TISTATechnologies/caseflow GitHub Wiki
Definitions
Relevant files
task_action_repository.rb- referenced by
funcof actions in TASK_ACTIONS.json - defines a configuration used by QueueFlowModal.jsx
modal_title,modal_bodytype: Task nameoptions: provided in dropdown menu in the modalselected: initial selection in dropdown menumodal_selector_placeholder: placeholder text for dropdown menuredirect_after: redirect path after submit is pressed and there's no errorvalue: used by QueueApp.jsx to route a URL to a modal component- custom configurations:
back_to_hearing_schedule
- referenced by
- QueueFlowModal.jsx
- modal window that pops up when a user selects a task action from the dropdown (in the Case Details page of an appeal)
- Many modals simply feed
propsto QueueFlowModal in order to configuresubmit,success,pathAfterSubmit,validateForm,button,reloadPageAfterSubmitetc. - Some
propsalso come from the Redux state, e.g., thesuccessanderrormessages.
- QueueLoadingScreen.jsx
- used to (potentially) load queues:
queueConfig,fetchAllAttorneys,fetchAmaTasksOfUser,loadAttorneys - sets common Redux
state.uiproperties, e.g.userId,userRole
- used to (potentially) load queues:
- app/controllers/tasks_controller.rb
- Update
TASK_CLASSES_LOOKUPif a new task type is to be created via theTaskController. These task types are sent to the frontend via TaskActionRepository'stypeoroptionsparameters. - The controller calls
task.update_from_paramsso the new task model should implementupdate_from_paramsorupdate_with_instructions.
- Update
Available actions
- An appeal's case detail pages shows available actions for the logged-in user.
- A task defines
available_actionswhich references constants in TASK_ACTIONS.json. TaskActionHelperbuild a hash of available actions by returning the TASK_ACTIONS constants or callingfunc.- A task calls
TaskActionHelper.build_hashto create the list of available actions. - The logic to determine available actions is sometimes defined in
task_action_repository.rband other times in the task itself.
Redux state
Ever see this in React components: export default (connect(mapStateToProps, mapDispatchToProps)(QueueLoadingScreen)). Here's what it's used for:
mapStateToPropsmaps Reduxstateto the component'sprops- it calls functions like
getTasksandtaskById(defined inselectors.js)
- it calls functions like
mapDispatchToPropsmaps results of functions (defined inuiActions.js) topropsand Reduxstate- functions like
setUserIdandfetchAllAttorneys - The functions can be called within the file to update the
stateand hence the page. - These functions return an object with
typebeing the Redux action (defined inuiConstants.js) andpayloadbeing the thing to be added toprops.
- functions like
Reducers are defined in uiReducer.js and are keyed off Redux action type and do the actual update to the Redux state.
- When are these reducers called?
Selectors are defined in selectors.js and are what we use to read and filter through the Redux state. Here's a quick article with more on what selectors are and why we use them.
React Component Trees for reference
(Rough) React component tree for Case Details page
- Queue
- ReduxBase
- QueueApp.jsx
- CaseDetailsLoadingScreen.jsx
- SomeCustomModal.jsx (e.g., AssignToView.jsx)
- QueueFlowModal.jsx
- SomeCustomModal.jsx (e.g., AssignToView.jsx)
- CaseDetailsLoadingScreen.jsx
- QueueApp.jsx
- ReduxBase
(Rough) React component tree for Judge Case Assignment page
- Queue
- ReduxBase
- QueueApp.jsx
- QueueLoadingScreen.jsx
- JudgeAssignTaskListView.jsx
- QueueLoadingScreen.jsx
- QueueApp.jsx
- ReduxBase
Routes
Let's track how :user_id is propagated to components:
Route /queue/:user_id(*rest)(.:format) is handled by
app/controllers/legacy_tasks_controller.rb- which is an ApplicationController (which sets
current_userbased on the authenticated logged-in user)
- which is an ApplicationController (which sets
If the request is for html, then controller will render "queue/index", which is provided by
- app/views/queue/index.html.erb which
- sets
props.userIdbased on thecurrent_user; - forwards the
propsto children React components, includingQueueApp.jsx; - and loads React component generator called
Queue, which:- is defined in
client/app/queue/index.jsx - and wraps
client/app/queue/QueueApp.jsxin aReduxBasethat sets up the Redux store withinitialState
- is defined in
- sets
QueueApp.jsx feeds the props (including userId) to other React components.
QueueLoadingScreen.jsx sets ui.loadedUserId in the Redux store based on props.userId.
How are alerts displayed in Queue pages?
(Or how to trigger the display of an alert there?)
Success messages are typically shown with the showSuccessMessage ui action. Same for errors. Most components will check the redux store to show any error messages that are present. A lot of components will use the requestSave ui action which handles sending a request to the backend and dispatching the success message if it was provided, or an error if the request fails.
Error and success messages are stored in state.ui.messages.error and state.ui.messages.success respectively.
You may also want to subsequently clear the alert from the redux state by using something like resetSuccessMessages
Useful Links
Below are pages within the greater Caseflow wiki related to Frontend development