-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[UI v2] feat: Begins logic for creating UX based on an action type #16752
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
ui-v2/src/components/automations/action-details/action-details.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { Automation } from "@/api/automations"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { ActionDetails } from "./action-details"; | ||
|
||
const ACTIONS: Array<Automation["actions"][number]> = [ | ||
{ type: "do-nothing" }, | ||
{ type: "cancel-flow-run" }, | ||
{ type: "suspend-flow-run" }, | ||
{ type: "cancel-flow-run" }, | ||
{ type: "resume-flow-run" }, | ||
{ type: "run-deployment", deployment_id: null, source: "inferred" }, | ||
{ type: "run-deployment", deployment_id: "abc", source: "selected" }, | ||
{ type: "pause-deployment", deployment_id: null, source: "inferred" }, | ||
{ type: "resume-deployment", deployment_id: "abc", source: "selected" }, | ||
{ type: "pause-work-queue", work_queue_id: null, source: "inferred" }, | ||
{ type: "resume-work-queue", work_queue_id: "abc", source: "selected" }, | ||
{ type: "pause-work-pool", work_pool_id: null, source: "inferred" }, | ||
{ type: "resume-work-pool", work_pool_id: "abc", source: "selected" }, | ||
{ type: "pause-automation", automation_id: null, source: "inferred" }, | ||
{ type: "resume-automation", automation_id: "abc", source: "selected" }, | ||
{ | ||
type: "send-notification", | ||
block_document_id: "abc", | ||
body: "my_body", | ||
subject: "my_subject", | ||
}, | ||
{ | ||
type: "change-flow-run-state", | ||
state: "CANCELLED", | ||
}, | ||
{ | ||
type: "change-flow-run-state", | ||
state: "CANCELLING", | ||
}, | ||
{ | ||
type: "change-flow-run-state", | ||
state: "COMPLETED", | ||
}, | ||
{ | ||
type: "change-flow-run-state", | ||
state: "CRASHED", | ||
}, | ||
{ | ||
type: "change-flow-run-state", | ||
state: "FAILED", | ||
}, | ||
{ | ||
type: "change-flow-run-state", | ||
state: "PAUSED", | ||
}, | ||
{ | ||
type: "change-flow-run-state", | ||
state: "PENDING", | ||
}, | ||
{ | ||
type: "change-flow-run-state", | ||
state: "RUNNING", | ||
message: "My message", | ||
name: "My name", | ||
}, | ||
{ | ||
type: "change-flow-run-state", | ||
state: "SCHEDULED", | ||
}, | ||
{ | ||
type: "call-webhook", | ||
block_document_id: "abc", | ||
payload: "my_payload", | ||
}, | ||
]; | ||
|
||
const meta = { | ||
title: "Components/Automations/ActionDetails", | ||
component: ActionDetailsStory, | ||
} satisfies Meta<typeof ActionDetails>; | ||
|
||
export default meta; | ||
|
||
export const Story: StoryObj = { | ||
name: "ActionDetails", | ||
}; | ||
|
||
function ActionDetailsStory() { | ||
return ( | ||
<ul className="flex flex-col gap-4"> | ||
{ACTIONS.map((action, i) => ( | ||
<li key={i}> | ||
<ActionDetails key={i} action={action} /> | ||
</li> | ||
))} | ||
</ul> | ||
); | ||
} |
96 changes: 96 additions & 0 deletions
96
ui-v2/src/components/automations/action-details/action-details.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { Automation } from "@/api/automations"; | ||
import { Card } from "@/components/ui/card"; | ||
import { Typography } from "@/components/ui/typography"; | ||
type AutomationAction = Automation["actions"][number]; | ||
|
||
type ActionDetailsProps = { | ||
action: AutomationAction; | ||
}; | ||
export const ActionDetails = ({ action }: ActionDetailsProps) => ( | ||
<Card className="p-4 border-r-8"> | ||
<ActionDetailsType action={action} /> | ||
</Card> | ||
); | ||
|
||
export const ActionDetailsType = ({ action }: ActionDetailsProps) => { | ||
switch (action.type) { | ||
// Non-inferrable Actions | ||
case "do-nothing": | ||
case "cancel-flow-run": | ||
case "suspend-flow-run": | ||
case "resume-flow-run": | ||
return <NoninferredAction action={action} />; | ||
// Inferable actions | ||
case "run-deployment": | ||
return action.deployment_id && action.source == "selected" ? ( | ||
"TODO" | ||
) : ( | ||
<InferredAction action={action} /> | ||
); | ||
case "pause-deployment": | ||
case "resume-deployment": | ||
return action.deployment_id && action.source == "selected" ? ( | ||
"TODO" | ||
) : ( | ||
<InferredAction action={action} /> | ||
); | ||
case "pause-work-queue": | ||
case "resume-work-queue": | ||
return action.work_queue_id && action.source == "selected" ? ( | ||
"TODO" | ||
) : ( | ||
<InferredAction action={action} /> | ||
); | ||
case "pause-automation": | ||
case "resume-automation": | ||
return action.automation_id && action.source == "selected" ? ( | ||
"TODO" | ||
) : ( | ||
<InferredAction action={action} /> | ||
); | ||
case "pause-work-pool": | ||
case "resume-work-pool": | ||
return action.work_pool_id && action.source == "selected" ? ( | ||
"TODO" | ||
) : ( | ||
<InferredAction action={action} /> | ||
); | ||
// Other actions | ||
case "send-notification": | ||
return "TODO"; | ||
case "change-flow-run-state": | ||
return "TODO"; | ||
case "call-webhook": | ||
return "TODO"; | ||
} | ||
}; | ||
|
||
const ACTION_TYPE_TO_STRING: Record<AutomationAction["type"], string> = { | ||
"cancel-flow-run": "Cancel flow run", | ||
"suspend-flow-run": "Suspend flow run", | ||
"resume-flow-run": "Resume a flow run", | ||
"change-flow-run-state": "Change state of a flow run", | ||
"run-deployment": "Run deployment", | ||
"pause-deployment": "Pause deployment", | ||
"resume-deployment": "Resume deployment", | ||
"pause-work-queue": "Pause work queue", | ||
"resume-work-queue": "Resume work queue", | ||
"pause-work-pool": "Pause work queue", | ||
"resume-work-pool": "Resume work queue", | ||
"pause-automation": "Pause automation", | ||
"resume-automation": "Resume automation", | ||
"call-webhook": "Call a custom webhook notification", | ||
"send-notification": "Send a notification", | ||
"do-nothing": "Do nothing", | ||
} as const; | ||
|
||
const NoninferredAction = ({ action }: ActionDetailsProps) => ( | ||
<Typography variant="bodySmall"> | ||
{`${ACTION_TYPE_TO_STRING[action.type]} from the triggering event`} | ||
</Typography> | ||
); | ||
const InferredAction = ({ action }: ActionDetailsProps) => ( | ||
<Typography variant="bodySmall"> | ||
{`${ACTION_TYPE_TO_STRING[action.type]} inferred from the triggering event`} | ||
</Typography> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { ActionDetails } from "./action-details"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
adding this optimization so that the joins for deployment flows removes repeated ids