-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Add Required Actions tab in group task page
#54322
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
Closed
Closed
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 hidden or 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 |
|---|---|---|
|
|
@@ -18,28 +18,49 @@ | |
| */ | ||
| import { ReactFlowProvider } from "@xyflow/react"; | ||
| import { useTranslation } from "react-i18next"; | ||
| import { FiUser } from "react-icons/fi"; | ||
| import { MdOutlineTask } from "react-icons/md"; | ||
| import { useParams } from "react-router-dom"; | ||
|
|
||
| import { useHumanInTheLoopServiceGetHitlDetails } from "openapi/queries"; | ||
| import { DetailsLayout } from "src/layouts/Details/DetailsLayout"; | ||
| import { useGridTiSummaries } from "src/queries/useGridTISummaries.ts"; | ||
| import { isStatePending, useAutoRefresh } from "src/utils"; | ||
|
|
||
| import { Header } from "./Header"; | ||
|
|
||
| export const GroupTaskInstance = () => { | ||
| const { dagId = "", runId = "", taskId = "" } = useParams(); | ||
| const { dagId = "", groupId = "", runId = "" } = useParams(); | ||
| const { t: translate } = useTranslation("dag"); | ||
| const { data: gridTISummaries } = useGridTiSummaries({ dagId, runId }); | ||
| const taskInstance = gridTISummaries?.task_instances.find((ti) => ti.task_id === taskId); | ||
| const taskInstance = gridTISummaries?.task_instances.find((ti) => ti.task_id === groupId); | ||
|
|
||
| const refetchInterval = useAutoRefresh({ dagId }); | ||
|
|
||
| const tabs = [{ icon: <MdOutlineTask />, label: translate("tabs.taskInstances"), value: "" }]; | ||
| const { data: hitlData } = useHumanInTheLoopServiceGetHitlDetails( | ||
| { | ||
| dagId, | ||
| dagRunId: runId, | ||
| taskIdPattern: groupId, | ||
| }, | ||
| undefined, | ||
| { | ||
| enabled: Boolean(dagId && groupId), | ||
| }, | ||
| ); | ||
|
|
||
| const hasHitlForTask = (hitlData?.total_entries ?? 0) > 0; | ||
|
|
||
| const tabs = [ | ||
| { icon: <MdOutlineTask />, label: translate("tabs.taskInstances"), value: "" }, | ||
| { icon: <FiUser />, label: translate("tabs.requiredActions"), value: "required_actions" }, | ||
| ]; | ||
|
Comment on lines
+54
to
+57
Member
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. You don't need to create the full list to then filter it again. Example:
Member
Author
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. Yes, it does make the code more clear and more efficient. I would update it. |
||
|
|
||
| const displayTabs = tabs.filter((tab) => tab.value !== "required_actions" || hasHitlForTask); | ||
|
|
||
| return ( | ||
| <ReactFlowProvider> | ||
| <DetailsLayout tabs={tabs}> | ||
| <DetailsLayout tabs={displayTabs}> | ||
| {taskInstance === undefined ? undefined : ( | ||
| <Header | ||
| isRefreshing={Boolean(isStatePending(taskInstance.state) && Boolean(refetchInterval))} | ||
|
|
||
This file contains hidden or 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.
Using
taskIdPatternto retrieve 'group related' HILT will not work in every case. While this is true that task from a same group tend to share the same prefix, it also mean that any task outside the group that also maches thepatternwill get returned wrongly in here and displayed in the group actions.For instance, based on your example, I added a TI, outside all groups, and since the name matches the 'validation' prefix, this will end up like this in the UI
We need to add a backend filter on
group_idI think. To be sure to only retrieve 'group' related TIs.Uh oh!
There was an error while loading. Please reload this page.
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.
Thanks for clear example that makes sense to me. Let me mark this as draft to wait the backend update.