-
Notifications
You must be signed in to change notification settings - Fork 17k
Dag Run and Overview Tab Display Deadlines #62195
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
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
e593169
Add FailedIcon component and DurationChart failed icon plugin
imrichardwu 6c32415
Add initial plugin files for AI provider with license information
imrichardwu e6bec47
Merge branch 'main' into error-ui-frontend
imrichardwu 5c7fd91
Add deadline management features to DAG UI
imrichardwu 9b2fd64
Add name and description fields to DeadlineAlert and related serializ…
imrichardwu d42cd59
Refactor deadline management in DAG UI: update DeadlineAlert fields, …
imrichardwu af27e2f
Enhance AllDeadlinesModal: add pagination support and update deadline…
imrichardwu 1e8cc1d
Merge branch 'main' into error-ui-frontend
imrichardwu 83b4e02
Enhance AllDeadlinesModal: increase dialog size and add backdrop padding
imrichardwu 3c14138
Merge branch 'main' into error-ui-frontend
imrichardwu c040737
Enhance DeadlineStatus: update icon colors for better visibility
imrichardwu 001bc71
Merge branch 'main' into error-ui-frontend
imrichardwu 1cb841c
Enhance Deadline Management: add completion rules, improve deadline a…
imrichardwu 60b3edb
Merge branch 'main' into error-ui-frontend
imrichardwu 445ce90
Enhance DeadlineAlertsBadge: include alert name in display and remove…
imrichardwu 20ee187
Enhance DeadlineAlertsBadge: display alert name conditionally and sim…
imrichardwu 2b6c629
Merge branch 'main' into error-ui-frontend
imrichardwu fd76b5b
remove python
imrichardwu ea9fd13
UI: Enhance deadline components with additional data handling and props
imrichardwu a425539
UI: Refactor alert handling to use alert IDs instead of names in dead…
imrichardwu b1ab8b6
Merge branch 'main' into error-ui-frontend
imrichardwu d369033
Merge branch 'main' into error-ui-frontend
imrichardwu 85abba7
Merge branch 'main' into error-ui-frontend
imrichardwu 53322d5
undo
imrichardwu 2f88c83
Enhance deadline status UI with improved translations and layout adju…
imrichardwu 27d457b
Remove unused deadline-related translations from UI localization
imrichardwu 760a7f5
Refactor deadline completion rule translations in UI components
imrichardwu d93a757
Merge branch 'main' into error-ui-frontend
imrichardwu d80fb34
Refactor deadline handling by consolidating deadline queries and remo…
imrichardwu 52f562a
Update airflow-core/src/airflow/ui/public/i18n/locales/en/dag.json
imrichardwu 7974ec0
Refactor deadline handling and improve UI translations for deadline a…
imrichardwu 45c6ef8
Update dialog sizes in AllDeadlinesModal and DeadlineStatusModal for …
imrichardwu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
airflow-core/src/airflow/ui/src/pages/Dag/DeadlineAlertsBadge.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /*! | ||
| * 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, Separator, Text, VStack } from "@chakra-ui/react"; | ||
| import dayjs from "dayjs"; | ||
| import duration from "dayjs/plugin/duration"; | ||
| import relativeTime from "dayjs/plugin/relativeTime"; | ||
| import { useTranslation } from "react-i18next"; | ||
| import { FiClock } from "react-icons/fi"; | ||
|
|
||
| import { useDeadlinesServiceGetDagDeadlineAlerts } from "openapi/queries"; | ||
| import type { DeadlineAlertResponse } from "openapi/requests/types.gen"; | ||
| import { Popover } from "src/components/ui"; | ||
|
|
||
| dayjs.extend(duration); | ||
| dayjs.extend(relativeTime); | ||
|
|
||
| const AlertRow = ({ alert }: { readonly alert: DeadlineAlertResponse }) => { | ||
| const { t: translate } = useTranslation("dag"); | ||
| const reference = translate(`deadlineAlerts.referenceType.${alert.reference_type}`, { | ||
| defaultValue: alert.reference_type, | ||
| }); | ||
| const interval = dayjs.duration(alert.interval, "seconds").humanize(); | ||
|
|
||
| return ( | ||
| <Box py={2} width="100%"> | ||
| <Text color="fg.muted" fontSize="xs"> | ||
| {translate("deadlineAlerts.completionRule", { interval, reference })} | ||
| {Boolean(alert.name) && ( | ||
| <Text as="span" color="fg.subtle" fontSize="xs"> | ||
| {" "} | ||
| ({alert.name}) | ||
| </Text> | ||
| )} | ||
| </Text> | ||
| </Box> | ||
| ); | ||
| }; | ||
|
|
||
| export const DeadlineAlertsBadge = ({ dagId }: { readonly dagId: string }) => { | ||
| const { t: translate } = useTranslation("dag"); | ||
|
|
||
| const { data } = useDeadlinesServiceGetDagDeadlineAlerts({ dagId }); | ||
|
|
||
| const alerts = data?.deadline_alerts ?? []; | ||
|
|
||
| if (alerts.length === 0) { | ||
| return undefined; | ||
| } | ||
|
|
||
| return ( | ||
| // eslint-disable-next-line jsx-a11y/no-autofocus | ||
| <Popover.Root autoFocus={false} lazyMount unmountOnExit> | ||
| <Popover.Trigger asChild> | ||
| <Button color="fg.info" size="xs" variant="outline"> | ||
| <FiClock /> | ||
| {translate("deadlineAlerts.count", { count: data?.total_entries ?? alerts.length })} | ||
| </Button> | ||
|
imrichardwu marked this conversation as resolved.
|
||
| </Popover.Trigger> | ||
|
imrichardwu marked this conversation as resolved.
|
||
| <Popover.Content css={{ "--popover-bg": "colors.bg.emphasized" }} maxWidth="360px" width="fit-content"> | ||
| <Popover.Arrow /> | ||
| <Popover.Body> | ||
| <VStack gap={0} separator={<Separator />}> | ||
| {alerts.map((alert) => ( | ||
| <AlertRow alert={alert} key={alert.id} /> | ||
| ))} | ||
| </VStack> | ||
| </Popover.Body> | ||
| </Popover.Content> | ||
| </Popover.Root> | ||
| ); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
airflow-core/src/airflow/ui/src/pages/Dag/Overview/AllDeadlinesModal.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| /*! | ||
| * 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 { Heading, HStack, Separator, Skeleton, VStack } from "@chakra-ui/react"; | ||
| import { useState } from "react"; | ||
| import { useTranslation } from "react-i18next"; | ||
|
|
||
| import type { DeadlineAlertResponse } from "openapi/requests/types.gen"; | ||
| import { ErrorAlert } from "src/components/ErrorAlert"; | ||
| import { Dialog } from "src/components/ui"; | ||
| import { Pagination } from "src/components/ui/Pagination"; | ||
| import { useDeadlines } from "src/queries/useDeadlines"; | ||
|
|
||
| import { DeadlineRow } from "./DeadlineRow"; | ||
|
|
||
| const PAGE_LIMIT = 10; | ||
|
|
||
| type AllDeadlinesModalProps = { | ||
| readonly alertMap: Map<string, DeadlineAlertResponse>; | ||
| readonly dagId: string; | ||
| readonly onClose: () => void; | ||
| readonly open: boolean; | ||
| }; | ||
|
|
||
| export const AllDeadlinesModal = ({ alertMap, dagId, onClose, open }: AllDeadlinesModalProps) => { | ||
| const { t: translate } = useTranslation("dag"); | ||
| const [page, setPage] = useState(1); | ||
| const offset = (page - 1) * PAGE_LIMIT; | ||
|
|
||
| const { data, error, isLoading } = useDeadlines({ | ||
| dagId, | ||
| enabled: open, | ||
| limit: PAGE_LIMIT, | ||
| offset, | ||
| }); | ||
|
|
||
| const deadlines = data?.deadlines ?? []; | ||
| const totalEntries = data?.total_entries ?? 0; | ||
|
|
||
| const getAlert = (alertId?: string | null) => | ||
| alertId !== undefined && alertId !== null ? alertMap.get(alertId) : undefined; | ||
|
|
||
| const onOpenChange = () => { | ||
| setPage(1); | ||
| onClose(); | ||
| }; | ||
|
|
||
| return ( | ||
| <Dialog.Root onOpenChange={onOpenChange} open={open} scrollBehavior="inside" size="xl"> | ||
| <Dialog.Content backdrop p={4}> | ||
| <Dialog.Header> | ||
| <Heading size="sm">{translate("overview.deadlines.title")}</Heading> | ||
| </Dialog.Header> | ||
| <Dialog.CloseTrigger /> | ||
| <Dialog.Body pb={2}> | ||
| <ErrorAlert error={error} /> | ||
| {isLoading ? ( | ||
| <VStack> | ||
| {Array.from({ length: PAGE_LIMIT }).map((_, idx) => ( | ||
| // eslint-disable-next-line react/no-array-index-key | ||
| <Skeleton height="36px" key={idx} width="100%" /> | ||
| ))} | ||
| </VStack> | ||
| ) : ( | ||
| <VStack gap={0} separator={<Separator />}> | ||
| {deadlines.map((deadline) => ( | ||
| <DeadlineRow alert={getAlert(deadline.alert_id)} deadline={deadline} key={deadline.id} /> | ||
| ))} | ||
| </VStack> | ||
| )} | ||
| </Dialog.Body> | ||
| {totalEntries > PAGE_LIMIT ? ( | ||
| <Pagination.Root | ||
| count={totalEntries} | ||
| onPageChange={(event) => setPage(event.page)} | ||
| p={3} | ||
| page={page} | ||
| pageSize={PAGE_LIMIT} | ||
| > | ||
| <HStack justify="center"> | ||
| <Pagination.PrevTrigger /> | ||
| <Pagination.Items /> | ||
| <Pagination.NextTrigger /> | ||
| </HStack> | ||
| </Pagination.Root> | ||
| ) : undefined} | ||
| </Dialog.Content> | ||
| </Dialog.Root> | ||
| ); | ||
| }; |
102 changes: 102 additions & 0 deletions
102
airflow-core/src/airflow/ui/src/pages/Dag/Overview/DagDeadlines.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| /*! | ||
| * 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, Flex, Heading, Separator, Skeleton, VStack } from "@chakra-ui/react"; | ||
| import { useState } from "react"; | ||
| import { useTranslation } from "react-i18next"; | ||
| import { FiClock } from "react-icons/fi"; | ||
|
|
||
| import { useDeadlinesServiceGetDagDeadlineAlerts } from "openapi/queries"; | ||
| import type { DeadlineAlertResponse } from "openapi/requests/types.gen"; | ||
| import { ErrorAlert } from "src/components/ErrorAlert"; | ||
| import { useDeadlines } from "src/queries/useDeadlines"; | ||
|
|
||
| import { AllDeadlinesModal } from "./AllDeadlinesModal"; | ||
| import { DeadlineRow } from "./DeadlineRow"; | ||
|
|
||
| const LIMIT = 10; | ||
|
|
||
| type DagDeadlinesProps = { | ||
| readonly dagId: string; | ||
| }; | ||
|
|
||
| export const DagDeadlines = ({ dagId }: DagDeadlinesProps) => { | ||
| const { t: translate } = useTranslation("dag"); | ||
| const [modalOpen, setModalOpen] = useState(false); | ||
|
|
||
| const { data, error, isLoading } = useDeadlines({ dagId, limit: LIMIT }); | ||
|
|
||
| const { data: alertData } = useDeadlinesServiceGetDagDeadlineAlerts({ dagId, limit: 100 }); | ||
|
|
||
| const alertMap = new Map<string, DeadlineAlertResponse>(); | ||
|
|
||
| for (const alert of alertData?.deadline_alerts ?? []) { | ||
| alertMap.set(alert.id, alert); | ||
| } | ||
|
imrichardwu marked this conversation as resolved.
|
||
|
|
||
| const deadlines = data?.deadlines ?? []; | ||
| const totalEntries = data?.total_entries ?? 0; | ||
| const hasMore = totalEntries > LIMIT; | ||
|
|
||
| if (!isLoading && error === null && deadlines.length === 0) { | ||
| return undefined; | ||
| } | ||
|
|
||
| const getAlert = (alertId?: string | null) => | ||
| alertId !== undefined && alertId !== null ? alertMap.get(alertId) : undefined; | ||
|
|
||
| return ( | ||
| <Box> | ||
| <Flex alignItems="center" color="fg.muted" gap={1} mb={2}> | ||
| <FiClock /> | ||
| <Heading ml={1} size="xs"> | ||
| {translate("overview.deadlines.title")} | ||
| </Heading> | ||
| </Flex> | ||
| <ErrorAlert error={error} /> | ||
| <Box borderRadius="lg" borderWidth={1} overflow="hidden" p={3}> | ||
| {isLoading ? ( | ||
| <VStack> | ||
| {Array.from({ length: 3 }).map((_, idx) => ( | ||
| // eslint-disable-next-line react/no-array-index-key | ||
| <Skeleton height="36px" key={idx} width="100%" /> | ||
| ))} | ||
| </VStack> | ||
| ) : ( | ||
| <VStack gap={0} separator={<Separator />}> | ||
| {deadlines.map((deadline) => ( | ||
| <DeadlineRow alert={getAlert(deadline.alert_id)} deadline={deadline} key={deadline.id} /> | ||
| ))} | ||
| </VStack> | ||
| )} | ||
| {hasMore ? ( | ||
| <Button mt={2} onClick={() => setModalOpen(true)} size="xs" variant="ghost" width="100%"> | ||
| {translate("overview.deadlines.showAll")} | ||
| </Button> | ||
| ) : undefined} | ||
| </Box> | ||
|
|
||
| <AllDeadlinesModal | ||
| alertMap={alertMap} | ||
| dagId={dagId} | ||
| onClose={() => setModalOpen(false)} | ||
| open={modalOpen} | ||
| /> | ||
| </Box> | ||
| ); | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.