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

Improve rendered_template ux in react dag page #39122

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 36 additions & 23 deletions airflow/www/static/js/dag/details/taskInstance/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,29 +231,6 @@ const Details = ({ gridInstance, taskInstance, group }: Props) => {
</Td>
</Tr>
)}
{taskInstance?.renderedFields && (
<>
{Object.keys(taskInstance.renderedFields).map((key) => {
const renderedFields = taskInstance.renderedFields as Record<
string,
unknown
>;
if (renderedFields[key]) {
return (
<Tr key={key}>
<Td>{key}</Td>
<Td>
<Code fontSize="md">
{JSON.stringify(renderedFields[key])}
</Code>
</Td>
</Tr>
);
}
return null;
})}
</>
)}
{!!taskInstance?.pool && (
<Tr>
<Td>Pool</Td>
Expand Down Expand Up @@ -300,6 +277,42 @@ const Details = ({ gridInstance, taskInstance, group }: Props) => {
)}
</Tbody>
</Table>
{taskInstance?.renderedFields && (
<Box mt={3}>
<Text as="strong" mb={3}>
Rendered Templates
</Text>
<Table>
<Tbody>
{Object.keys(taskInstance.renderedFields).map((key) => {
const renderedFields = taskInstance.renderedFields as Record<
string,
unknown
>;
let field = renderedFields[key];
if (field) {
if (typeof field !== "string") {
try {
field = JSON.stringify(field);
} catch (e) {
// skip
}
}
return (
<Tr key={key}>
<Td>{key}</Td>
<Td>
<Code fontSize="md">{field as string}</Code>
</Td>
</Tr>
);
}
return null;
})}
</Tbody>
</Table>
</Box>
)}
</Box>
);
};
Expand Down
10 changes: 2 additions & 8 deletions airflow/www/static/js/dag/details/taskInstance/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const dagId = getMetaValue("dag_id");
const isK8sExecutor = getMetaValue("k8s_or_k8scelery_executor") === "True";
const taskInstancesUrl = getMetaValue("task_instances_list_url");
const renderedK8sUrl = getMetaValue("rendered_k8s_url");
const renderedTemplatesUrl = getMetaValue("rendered_templates_url");
const taskUrl = getMetaValue("task_url");
const gridUrl = getMetaValue("grid_url");

Expand All @@ -50,7 +49,6 @@ const Nav = forwardRef<HTMLDivElement, Props>(
map_index: mapIndex ?? -1,
});
const detailsLink = `${taskUrl}&${params}`;
const renderedLink = `${renderedTemplatesUrl}&${params}`;
const k8sLink = `${renderedK8sUrl}&${params}`;
const listParams = new URLSearchParamsWrapper({
_flt_3_dag_id: dagId,
Expand Down Expand Up @@ -79,7 +77,6 @@ const Nav = forwardRef<HTMLDivElement, Props>(
{(!isMapped || mapIndex !== undefined) && (
<>
<LinkButton href={detailsLink}>More Details</LinkButton>
<LinkButton href={renderedLink}>Rendered Template</LinkButton>
{isK8sExecutor && (
<LinkButton href={k8sLink}>K8s Pod Spec</LinkButton>
)}
Expand All @@ -88,11 +85,8 @@ const Nav = forwardRef<HTMLDivElement, Props>(
)}
</>
)}
<LinkButton
href={allInstancesLink}
title="View all instances across all DAG runs"
>
List Instances, all runs
<LinkButton href={allInstancesLink} title="View all">
List All Instances
</LinkButton>
</Flex>
);
Expand Down
1 change: 0 additions & 1 deletion airflow/www/templates/airflow/dag.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
<meta name="graph_url" content="{{ url_for('Airflow.graph', dag_id=dag.dag_id, root=root) }}">
<meta name="task_url" content="{{ url_for('Airflow.task', dag_id=dag.dag_id) }}">
<meta name="log_url" content="{{ url_for('Airflow.log', dag_id=dag.dag_id) }}">
<meta name="rendered_templates_url" content="{{ url_for('Airflow.rendered_templates', dag_id=dag.dag_id) }}">
<meta name="rendered_k8s_url" content="{{ url_for('Airflow.rendered_k8s', dag_id=dag.dag_id) }}">
<meta name="task_instances_list_url" content="{{ url_for('TaskInstanceModelView.list') }}">
<meta name="tag_index_url" content="{{ url_for('Airflow.index', tags='_TAG_NAME_') }}">
Expand Down