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

feat(package actions): Set up API to return actions; UI to read and render actions #182

Merged
merged 18 commits into from
Nov 2, 2023

Conversation

hannasage
Copy link

@hannasage hannasage commented Oct 31, 2023

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 the item 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 in shared-types

Assorted Notes/Considerations/Learning

Set up a new action:

  1. Add the action conditions to the packageActionsForResult function
  2. Add the UI-friendly name to the mapActionLabel function
  3. Return your action form component via ActionFormIndex

@hannasage hannasage self-assigned this Oct 31, 2023
@hannasage hannasage marked this pull request as ready for review October 31, 2023 17:31
Copy link
Collaborator

@benjaminpaige benjaminpaige left a 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.

Comment on lines 39 to 40
found: boolean;
actions: Action[];
Copy link
Collaborator

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?

Copy link
Author

Choose a reason for hiding this comment

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

Good catch; removed

Comment on lines 52 to 60
{data.actions.map((action, idx) => (
<Link
className="text-sky-500 underline"
to={`/action/${id}/${action}`}
key={`${idx}-${action}`}
>
<li>{mapActionLabel(action)}</li>
</Link>
))}
Copy link
Collaborator

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?

Copy link
Author

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 👍🏼

@hannasage hannasage merged commit 103c04e into master Nov 2, 2023
9 checks passed
@hannasage hannasage deleted the oy2-25560 branch November 7, 2023 17:54
Copy link
Contributor

🎉 This PR is included in version 1.5.0-val.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants