pierrejeambrun commented on code in PR #55927:
URL: https://github.com/apache/airflow/pull/55927#discussion_r2391771700
##########
airflow-core/src/airflow/ui/src/layouts/Details/Grid/GridTI.tsx:
##########
@@ -62,15 +60,49 @@ type Props = {
readonly taskId: string;
};
-const Instance = ({ dagId, instance, isGroup, isMapped, onClick, runId,
search, taskId }: Props) => {
+const Instance = ({
+ dagId,
+ fullInstance,
+ instance,
+ isGroup,
+ isMapped,
+ onClick,
+ runId,
+ search,
+ taskId,
+}: Props) => {
const { setHoveredTaskId } = useHover();
const { groupId: selectedGroupId, taskId: selectedTaskId } = useParams();
- const { t: translate } = useTranslation();
const location = useLocation();
+ const [open, setOpen] = useState(false);
+
const onMouseEnter = handleMouseEnter(setHoveredTaskId);
const onMouseLeave = handleMouseLeave(taskId, setHoveredTaskId);
+ // include the map index for mapped tasks so API returns the specific TI
+ const mapIndexArray =
+ "map_index" in instance && typeof instance.map_index === "number" ?
[instance.map_index] : undefined;
+
+ // Hydrate the tooltip with a full TaskInstance when opened (skip if parent
already provided one)
+ const { data: tiPage } = useTaskInstanceServiceGetTaskInstances(
+ {
+ dagId,
+ dagRunId: runId,
+ taskId,
+ ...(mapIndexArray === undefined ? {} : { mapIndex: mapIndexArray }),
+ limit: 1, // don't use orderBy here — it 400's this endpoint
+ },
+ undefined,
+ {
+ enabled: open && !fullInstance,
+ staleTime: 15_000,
Review Comment:
Why?
```suggestion
staleTime: 15_000,
```
##########
airflow-core/src/airflow/ui/src/layouts/Details/Grid/GridTI.tsx:
##########
@@ -62,15 +60,49 @@ type Props = {
readonly taskId: string;
};
-const Instance = ({ dagId, instance, isGroup, isMapped, onClick, runId,
search, taskId }: Props) => {
+const Instance = ({
+ dagId,
+ fullInstance,
+ instance,
+ isGroup,
+ isMapped,
+ onClick,
+ runId,
+ search,
+ taskId,
+}: Props) => {
const { setHoveredTaskId } = useHover();
const { groupId: selectedGroupId, taskId: selectedTaskId } = useParams();
- const { t: translate } = useTranslation();
const location = useLocation();
+ const [open, setOpen] = useState(false);
+
const onMouseEnter = handleMouseEnter(setHoveredTaskId);
const onMouseLeave = handleMouseLeave(taskId, setHoveredTaskId);
+ // include the map index for mapped tasks so API returns the specific TI
+ const mapIndexArray =
+ "map_index" in instance && typeof instance.map_index === "number" ?
[instance.map_index] : undefined;
Review Comment:
This might be simpler, but I don't know if the linter will be happy with
that.
```
Boolean(instance?.map_index) ?
```
##########
airflow-core/src/airflow/ui/src/layouts/Details/Grid/GridTI.tsx:
##########
@@ -62,15 +60,49 @@ type Props = {
readonly taskId: string;
};
-const Instance = ({ dagId, instance, isGroup, isMapped, onClick, runId,
search, taskId }: Props) => {
+const Instance = ({
+ dagId,
+ fullInstance,
+ instance,
+ isGroup,
+ isMapped,
+ onClick,
+ runId,
+ search,
+ taskId,
+}: Props) => {
const { setHoveredTaskId } = useHover();
const { groupId: selectedGroupId, taskId: selectedTaskId } = useParams();
- const { t: translate } = useTranslation();
const location = useLocation();
+ const [open, setOpen] = useState(false);
+
const onMouseEnter = handleMouseEnter(setHoveredTaskId);
const onMouseLeave = handleMouseLeave(taskId, setHoveredTaskId);
+ // include the map index for mapped tasks so API returns the specific TI
+ const mapIndexArray =
+ "map_index" in instance && typeof instance.map_index === "number" ?
[instance.map_index] : undefined;
+
+ // Hydrate the tooltip with a full TaskInstance when opened (skip if parent
already provided one)
+ const { data: tiPage } = useTaskInstanceServiceGetTaskInstances(
+ {
+ dagId,
Review Comment:
That is not possible. Rendering all GridTI will trigger a lot of calls to
the `GetTaskInstances` endpoint. We should probably avoid that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]