Skip to content

Commit

Permalink
feat(dataset_event): add showSource and showTriggeredDagRuns to Datas…
Browse files Browse the repository at this point in the history
…etEventCard (#41300)
  • Loading branch information
Lee-W authored Aug 8, 2024
1 parent 49669c9 commit 472e683
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
44 changes: 27 additions & 17 deletions airflow/www/static/js/components/DatasetEventCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ import TriggeredDagRuns from "./TriggeredDagRuns";

type CardProps = {
datasetEvent: DatasetEvent;
showSource?: boolean;
showTriggeredDagRuns?: boolean;
};

const datasetsUrl = getMetaValue("datasets_url");

const DatasetEventCard = ({ datasetEvent }: CardProps) => {
const DatasetEventCard = ({
datasetEvent,
showSource = true,
showTriggeredDagRuns = true,
}: CardProps) => {
const [searchParams] = useSearchParams();

const selectedUri = decodeURIComponent(searchParams.get("uri") || "");
Expand Down Expand Up @@ -92,25 +98,29 @@ const DatasetEventCard = ({ datasetEvent }: CardProps) => {
</Flex>
</GridItem>
<GridItem>
Source:
{fromRestApi && (
<Tooltip
portalProps={{ containerRef }}
hasArrow
placement="top"
label="Manually created from REST API"
>
<Box width="20px">
<TbApi size="20px" />
</Box>
</Tooltip>
)}
{!!datasetEvent.sourceTaskId && (
<SourceTaskInstance datasetEvent={datasetEvent} />
{showSource && (
<>
Source:
{fromRestApi && (
<Tooltip
portalProps={{ containerRef }}
hasArrow
placement="top"
label="Manually created from REST API"
>
<Box width="20px">
<TbApi size="20px" />
</Box>
</Tooltip>
)}
{!!datasetEvent.sourceTaskId && (
<SourceTaskInstance datasetEvent={datasetEvent} />
)}
</>
)}
</GridItem>
<GridItem>
{!!datasetEvent?.createdDagruns?.length && (
{showTriggeredDagRuns && !!datasetEvent?.createdDagruns?.length && (
<>
Triggered Dag Runs:
<TriggeredDagRuns createdDagRuns={datasetEvent?.createdDagruns} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ interface Props {
const dagId = getMetaValue("dag_id");

const cardDef: CardDef<DatasetEvent> = {
card: ({ row }) => <DatasetEventCard datasetEvent={row} />,
card: ({ row }) => (
<DatasetEventCard datasetEvent={row} showTriggeredDagRuns={false} />
),
};

const DatasetTriggerEvents = ({ runId }: Props) => {
Expand All @@ -56,10 +58,6 @@ const DatasetTriggerEvents = ({ runId }: Props) => {
Header: "Source Task Instance",
accessor: "sourceTaskId",
},
{
Header: "Triggered Runs",
accessor: "createdDagruns",
},
{
Header: "Extra",
accessor: "extra",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface Props {
}

const cardDef: CardDef<DatasetEvent> = {
card: ({ row }) => <DatasetEventCard datasetEvent={row} />,
card: ({ row }) => <DatasetEventCard datasetEvent={row} showSource={false} />,
};

const dagId = getMetaValue("dag_id") || undefined;
Expand All @@ -57,10 +57,6 @@ const DatasetUpdateEvents = ({ runId, taskId }: Props) => {
Header: "Dataset",
accessor: "datasetUri",
},
{
Header: "Source Task Instance",
accessor: "sourceTaskId",
},
{
Header: "Triggered Runs",
accessor: "createdDagruns",
Expand Down

0 comments on commit 472e683

Please sign in to comment.