Skip to content

Commit 67cff15

Browse files
authored
Refactor documentation modal component to use it for dag and task. (apache#44863)
* Refactor documentation modal component to use it for dag and task. * Refactor to pass doc type directly instead of using a boolean.
1 parent 39d79fc commit 67cff15

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

airflow/ui/src/components/DagDocumentation.tsx airflow/ui/src/components/DocumentationModal.tsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,20 @@ import Markdown from "react-markdown";
2323

2424
import { Button, Dialog } from "src/components/ui";
2525

26-
const DagDocumentation = ({ docMd }: { readonly docMd: string }) => {
26+
const DocumentationModal = ({
27+
docMd,
28+
docType,
29+
}: {
30+
readonly docMd: string;
31+
readonly docType: string;
32+
}) => {
2733
const [isDocsOpen, setIsDocsOpen] = useState(false);
2834

2935
return (
3036
<Box>
3137
<Button onClick={() => setIsDocsOpen(true)} variant="outline">
3238
<FiBookOpen height={5} width={5} />
33-
Dag Docs
39+
{docType} Docs
3440
</Button>
3541
<Dialog.Root
3642
onOpenChange={() => setIsDocsOpen(false)}
@@ -39,7 +45,7 @@ const DagDocumentation = ({ docMd }: { readonly docMd: string }) => {
3945
>
4046
<Dialog.Content backdrop>
4147
<Dialog.Header bg="blue.muted">
42-
<Heading size="xl">Dag Documentation</Heading>
48+
<Heading size="xl">{docType} Documentation</Heading>
4349
<Dialog.CloseTrigger closeButtonProps={{ size: "xl" }} />
4450
</Dialog.Header>
4551
<Dialog.Body display="flex">
@@ -51,4 +57,4 @@ const DagDocumentation = ({ docMd }: { readonly docMd: string }) => {
5157
);
5258
};
5359

54-
export default DagDocumentation;
60+
export default DocumentationModal;

airflow/ui/src/pages/Dag/Header.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import type {
2424
DAGRunResponse,
2525
} from "openapi/requests/types.gen";
2626
import { DagIcon } from "src/assets/DagIcon";
27-
import DagDocumentation from "src/components/DagDocumentation";
2827
import DagRunInfo from "src/components/DagRunInfo";
28+
import DocumentationModal from "src/components/DocumentationModal";
2929
import ParseDag from "src/components/ParseDag";
3030
import { Stat } from "src/components/Stat";
3131
import { TogglePause } from "src/components/TogglePause";
@@ -61,7 +61,7 @@ export const Header = ({
6161
{dag ? (
6262
<HStack>
6363
{dag.doc_md === null ? undefined : (
64-
<DagDocumentation docMd={dag.doc_md} />
64+
<DocumentationModal docMd={dag.doc_md} docType="Dag" />
6565
)}
6666
<ParseDag dagId={dag.dag_id} fileToken={dag.file_token} />
6767
<TriggerDAGTextButton dag={dag} />

airflow/ui/src/pages/Task/Header.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { Box, Flex, Heading, HStack, SimpleGrid, Text } from "@chakra-ui/react";
2020

2121
import type { TaskResponse } from "openapi/requests/types.gen";
2222
import { TaskIcon } from "src/assets/TaskIcon";
23-
import DagDocumentation from "src/components/DagDocumentation";
23+
import DocumentationModal from "src/components/DocumentationModal";
2424
import { Stat } from "src/components/Stat";
2525

2626
export const Header = ({ task }: { readonly task: TaskResponse }) => (
@@ -38,7 +38,7 @@ export const Header = ({ task }: { readonly task: TaskResponse }) => (
3838
</Flex>
3939
</HStack>
4040
{task.doc_md === null ? undefined : (
41-
<DagDocumentation docMd={task.doc_md} />
41+
<DocumentationModal docMd={task.doc_md} docType="Task" />
4242
)}
4343
</Flex>
4444
<SimpleGrid columns={4} gap={4}>

0 commit comments

Comments
 (0)