-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat(package actions): Set up API to return actions; UI to read and render actions #182
Conversation
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.
just a couple comments. i think we can take the actions out of the itemresults type. but it looks really great.
found: boolean; | ||
actions: Action[]; |
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.
i dont think we are including these now right?
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.
Good catch; removed
{data.actions.map((action, idx) => ( | ||
<Link | ||
className="text-sky-500 underline" | ||
to={`/action/${id}/${action}`} | ||
key={`${idx}-${action}`} | ||
> | ||
<li>{mapActionLabel(action)}</li> | ||
</Link> | ||
))} |
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.
should we show some default text if no actions are available?
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.
Added in ternary to render default text when no length is present in the array 👍🏼
🎉 This PR is included in version 1.5.0-val.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Purpose
This PR handles preliminary work necessary for all package actions tickets forthcoming. It enables developers to create the conditions in which a package action is to be added to the API response for an item, and render out the option on the Details page of the UI.
Linked Issues to Close
Does not close any issues.
Approach
Package actions are not something that come through the sink in either data model (SEA Tool or OneMAC), so we have to infer package actions available based on the data within a package and a user's authorization to perform each action. There is precedent for this in OneMAC here.
We've implemented a similar approach in this PR with one exception: we have a designated endpoint
getPackageActions
for this. We don't pack them into theitem
response.Form Routing
The action strings given from the API will map to a dynamic URL (i.e.
/action/:type
). To make use of React Router's dynamic segments, we have a single ActionFormIndex. We use that:type
segment to return the proper UI from this component.Dynamic segments are enumerated in the
Action
enum inshared-types
Assorted Notes/Considerations/Learning
Set up a new action:
packageActionsForResult
functionmapActionLabel
functionActionFormIndex