diff --git a/airflow/ui/src/components/ClearRun/ClearRunButton.tsx b/airflow/ui/src/components/ClearRun/ClearRunButton.tsx index ae0386612c3d5..f31b9f1a46aca 100644 --- a/airflow/ui/src/components/ClearRun/ClearRunButton.tsx +++ b/airflow/ui/src/components/ClearRun/ClearRunButton.tsx @@ -16,19 +16,14 @@ * specific language governing permissions and limitations * under the License. */ -import { - Box, - type ButtonProps, - IconButton, - useDisclosure, -} from "@chakra-ui/react"; -import { type FC, useState } from "react"; +import { Box, useDisclosure } from "@chakra-ui/react"; +import { useState } from "react"; import { FiRefreshCw } from "react-icons/fi"; import type { TaskInstanceCollectionResponse } from "openapi/requests/types.gen"; -import { Button, Tooltip } from "src/components/ui"; import { useClearDagRun } from "src/queries/useClearRun"; +import ActionButton from "../ui/ActionButton"; import ClearRunDialog from "./ClearRunDialog"; type Props = { @@ -48,8 +43,6 @@ const ClearRunButton = ({ dagId, dagRunId, withText = true }: Props) => { total_entries: 0, }); - const ButtonComponent: FC = withText ? Button : IconButton; - const { isPending, mutate } = useClearDagRun({ dagId, dagRunId, @@ -59,25 +52,20 @@ const ClearRunButton = ({ dagId, dagRunId, withText = true }: Props) => { return ( - - { - onOpen(); - mutate({ - dagId, - dagRunId, - requestBody: { dry_run: true, only_failed: onlyFailed }, - }); - }} - size={withText ? "md" : "sm"} - variant={withText ? "outline" : "ghost"} - > - - {withText ? "Clear Run" : ""} - - + } + onClick={() => { + onOpen(); + mutate({ + dagId, + dagRunId, + requestBody: { dry_run: true, only_failed: onlyFailed }, + }); + }} + text="Clear Run" + withText={withText} + /> = ({ dag }) => { +const TriggerDAGButton: React.FC = ({ dag, withText = true }) => { const { onClose, onOpen, open } = useDisclosure(); return ( - } onClick={onOpen} - size="xs" - variant="ghost" - > - - + text="Trigger" + variant="solid" + withText={withText} + /> = ({ dag }) => { ); }; -export default TriggerDAGIconButton; +export default TriggerDAGButton; diff --git a/airflow/ui/src/components/TriggerDag/TriggerDAGTextButton.tsx b/airflow/ui/src/components/TriggerDag/TriggerDAGTextButton.tsx deleted file mode 100644 index 663155bf0926f..0000000000000 --- a/airflow/ui/src/components/TriggerDag/TriggerDAGTextButton.tsx +++ /dev/null @@ -1,52 +0,0 @@ -/*! - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -import { Box, Button } from "@chakra-ui/react"; -import { useDisclosure } from "@chakra-ui/react"; -import { FiPlay } from "react-icons/fi"; - -import type { DAGResponse } from "openapi/requests/types.gen"; - -import TriggerDAGModal from "./TriggerDAGModal"; - -type Props = { - readonly dag: DAGResponse; -}; - -const TriggerDAGIconButton: React.FC = ({ dag }) => { - const { onClose, onOpen, open } = useDisclosure(); - - return ( - - - - - - ); -}; - -export default TriggerDAGIconButton; diff --git a/airflow/ui/src/components/ui/ActionButton.tsx b/airflow/ui/src/components/ui/ActionButton.tsx new file mode 100644 index 0000000000000..9820775223d74 --- /dev/null +++ b/airflow/ui/src/components/ui/ActionButton.tsx @@ -0,0 +1,61 @@ +/*! + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { type ButtonProps, IconButton } from "@chakra-ui/react"; +import type { FC, ReactElement } from "react"; + +import { Button, Tooltip } from "src/components/ui"; + +type Props = { + readonly actionName: string; + readonly colorPalette?: string; + readonly icon: ReactElement; + readonly onClick: () => void; + readonly text: string; + readonly variant?: string; + readonly withText?: boolean; +} & ButtonProps; + +const ActionButton = ({ + actionName, + colorPalette, + icon, + onClick, + text, + variant = "outline", + withText = true, +}: Props) => { + const ButtonComponent: FC = withText ? Button : IconButton; + + return ( + + + {icon} + {withText ? text : ""} + + + ); +}; + +export default ActionButton; diff --git a/airflow/ui/src/pages/Dag/Header.tsx b/airflow/ui/src/pages/Dag/Header.tsx index 0772c960ea7c7..8371f68e3b905 100644 --- a/airflow/ui/src/pages/Dag/Header.tsx +++ b/airflow/ui/src/pages/Dag/Header.tsx @@ -29,7 +29,7 @@ import DocumentationModal from "src/components/DocumentationModal"; import ParseDag from "src/components/ParseDag"; import { Stat } from "src/components/Stat"; import { TogglePause } from "src/components/TogglePause"; -import TriggerDAGTextButton from "src/components/TriggerDag/TriggerDAGTextButton"; +import TriggerDAGButton from "src/components/TriggerDag/TriggerDAGButton"; import { Tooltip } from "src/components/ui"; import { DagTags } from "../DagsList/DagTags"; @@ -64,7 +64,7 @@ export const Header = ({ )} - + ) : undefined} diff --git a/airflow/ui/src/pages/DagsList/DagCard.tsx b/airflow/ui/src/pages/DagsList/DagCard.tsx index 8b45a15cddaa2..854d6787bb043 100644 --- a/airflow/ui/src/pages/DagsList/DagCard.tsx +++ b/airflow/ui/src/pages/DagsList/DagCard.tsx @@ -23,7 +23,7 @@ import type { DAGWithLatestDagRunsResponse } from "openapi/requests/types.gen"; import DagRunInfo from "src/components/DagRunInfo"; import { Stat } from "src/components/Stat"; import { TogglePause } from "src/components/TogglePause"; -import TriggerDAGIconButton from "src/components/TriggerDag/TriggerDAGIconButton"; +import TriggerDAGButton from "src/components/TriggerDag/TriggerDAGButton"; import { Tooltip } from "src/components/ui"; import { DagTags } from "./DagTags"; @@ -71,7 +71,7 @@ export const DagCard = ({ dag }: Props) => { dagId={dag.dag_id} isPaused={dag.is_paused} /> - + diff --git a/airflow/ui/src/pages/DagsList/DagsList.tsx b/airflow/ui/src/pages/DagsList/DagsList.tsx index c35132c1564e9..fbe706bbd8215 100644 --- a/airflow/ui/src/pages/DagsList/DagsList.tsx +++ b/airflow/ui/src/pages/DagsList/DagsList.tsx @@ -42,7 +42,7 @@ import { useTableURLState } from "src/components/DataTable/useTableUrlState"; import { ErrorAlert } from "src/components/ErrorAlert"; import { SearchBar } from "src/components/SearchBar"; import { TogglePause } from "src/components/TogglePause"; -import TriggerDAGIconButton from "src/components/TriggerDag/TriggerDAGIconButton"; +import TriggerDAGButton from "src/components/TriggerDag/TriggerDAGButton"; import { SearchParamsKeys, type SearchParamsKeysType, @@ -128,7 +128,7 @@ const columns: Array> = [ }, { accessorKey: "trigger", - cell: ({ row }) => , + cell: ({ row }) => , enableSorting: false, header: "", },