bbovenzi commented on code in PR #47411: URL: https://github.com/apache/airflow/pull/47411#discussion_r1991711593
########## airflow/ui/src/components/Banner/BackfillBanner.tsx: ########## @@ -0,0 +1,109 @@ +/*! + * 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, HStack, Spacer, Text } from "@chakra-ui/react"; +import { useState } from "react"; +import { MdPause, MdPlayArrow, MdStop } from "react-icons/md"; + +import { + useBackfillServiceCancelBackfill, + useBackfillServiceListBackfills, + useBackfillServicePauseBackfill, + useBackfillServiceUnpauseBackfill, +} from "openapi/queries"; + +import Time from "../Time"; +import { ProgressBar } from "../ui"; +import ActionButton from "../ui/ActionButton"; + +type Props = { + readonly dagId: string; +}; + +const BackfillBanner = ({ dagId }: Props) => { + const { data, isLoading } = useBackfillServiceListBackfills({ + dagId, + }); + const [backfill] = data?.backfills.filter((bf) => bf.completed_at === null) ?? []; + + const { isPending: isPausePending, mutate: pauseMutate } = useBackfillServicePauseBackfill(); + const { isPending: isUnPausePending, mutate: unpauseMutate } = useBackfillServiceUnpauseBackfill(); + + const { isPending: isStopPending, mutate: stopPending } = useBackfillServiceCancelBackfill(); + + const [isPaused, setIsPaused] = useState(backfill?.is_paused ?? false); + const [isDisabled, setIsDisabled] = useState<boolean>(isPausePending || isUnPausePending || isStopPending); Review Comment: We don't need either of these states. Paused: We should just always use the backfill's value. And on an action make sure we refetch the backill. Ctrl+f the codebase for `await queryClient.invalidateQueries({`. We can make it a single `onSuccess` function we pass to all three of our mutation queries Disabled: Actually, you can delete it entirely. When `loading` is true on the button, it will already be disabled. -- 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]
