-
Notifications
You must be signed in to change notification settings - Fork 17.3k
Add Browse > Deadlines page #67586
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
Add Browse > Deadlines page #67586
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
9af36d3
feat/browser: Add DataTable and browse UI components
imrichardwu 7796ac6
Merge branch 'main' into feat/browser
imrichardwu 1a7ba44
Merge branch 'main' into feat/browser
imrichardwu d8b319e
Add FAB permissions for Deadlines page
imrichardwu b17a752
Merge branch 'main' into feat/browser
imrichardwu 9a92951
Added AIRFLOW_V_3_2_PLUS to the version_compat impor
imrichardwu 0553697
Merge branch 'main' into feat/browser
imrichardwu 5d35d9c
Merge branch 'main' into feat/browser
imrichardwu fec261f
Remove AIRFLOW_V_3_2_PLUS import and update conditional check for Men…
imrichardwu 94b97fc
Merge branch 'main' into feat/browser
imrichardwu 2a1e62a
Merge branch 'main' into feat/browser
imrichardwu ffaad9b
Merge branch 'main' into feat/browser
imrichardwu 56310ca
Add RESOURCE_DEADLINE permission for MenuItem.DEADLINES in test_fab_a…
imrichardwu f19bc60
Merge branch 'main' into feat/browser
imrichardwu ff6865f
Refactor Deadlines permissions and update related tests
imrichardwu 1a52fe5
Merge branch 'main' into feat/browser
imrichardwu 4e09d9e
Add conditional check for MenuItem.DEADLINES in TestFabAuthManager
imrichardwu fee47dc
Update airflow-core/src/airflow/ui/src/pages/Deadlines/index.tsx
imrichardwu a450638
fix indent
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Add a new **Deadlines** page under the Browse menu. | ||
|
|
||
| The page is accessible to any role that already has ``can_read`` and | ||
| ``menu_access`` on ``DAG Runs``. |
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
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 |
|---|---|---|
|
|
@@ -3144,6 +3144,7 @@ components: | |
| - Config | ||
| - Connections | ||
| - Dags | ||
| - Deadlines | ||
| - Docs | ||
| - Jobs | ||
| - Plugins | ||
|
|
||
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
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
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
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
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
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
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
156 changes: 156 additions & 0 deletions
156
airflow-core/src/airflow/ui/src/pages/Deadlines/index.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,156 @@ | ||
| /*! | ||
| * 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 { Badge, Box, Heading, Link, VStack } from "@chakra-ui/react"; | ||
| import type { ColumnDef } from "@tanstack/react-table"; | ||
| import type { TFunction } from "i18next"; | ||
| import { useTranslation } from "react-i18next"; | ||
| import { Link as RouterLink, useSearchParams } from "react-router-dom"; | ||
|
|
||
| import { useDeadlinesServiceGetDeadlines } from "openapi/queries"; | ||
| import type { DeadlineResponse } from "openapi/requests/types.gen"; | ||
| import { DataTable } from "src/components/DataTable"; | ||
| import { useTableURLState } from "src/components/DataTable/useTableUrlState"; | ||
| import { ErrorAlert } from "src/components/ErrorAlert"; | ||
| import { FilterBar } from "src/components/FilterBar"; | ||
| import Time from "src/components/Time"; | ||
| import { TruncatedText } from "src/components/TruncatedText"; | ||
| import { SearchParamsKeys } from "src/constants/searchParams"; | ||
| import { useFiltersHandler, type FilterableSearchParamsKeys } from "src/utils"; | ||
|
|
||
| type DeadlineRow = { row: { original: DeadlineResponse } }; | ||
|
|
||
| const createColumns = (translate: TFunction): Array<ColumnDef<DeadlineResponse>> => [ | ||
| { | ||
| accessorKey: "dag_id", | ||
| cell: ({ row: { original } }: DeadlineRow) => ( | ||
| <Link asChild color="fg.info"> | ||
| <RouterLink to={`/dags/${original.dag_id}`}> | ||
| <TruncatedText text={original.dag_id} /> | ||
| </RouterLink> | ||
| </Link> | ||
| ), | ||
| header: translate("common:dagId"), | ||
| }, | ||
| { | ||
| accessorKey: "dag_run_id", | ||
| cell: ({ row: { original } }: DeadlineRow) => ( | ||
| <Link asChild color="fg.info"> | ||
| <RouterLink to={`/dags/${original.dag_id}/runs/${original.dag_run_id}`}> | ||
| <TruncatedText text={original.dag_run_id} /> | ||
| </RouterLink> | ||
| </Link> | ||
| ), | ||
| enableSorting: false, | ||
| header: translate("common:dagRunId"), | ||
| }, | ||
| { | ||
| accessorKey: "deadline_time", | ||
| cell: ({ row: { original } }: DeadlineRow) => <Time datetime={original.deadline_time} />, | ||
| header: translate("browse:deadlines.columns.deadlineTime"), | ||
| }, | ||
| { | ||
| accessorKey: "missed", | ||
| cell: ({ | ||
| row: { | ||
| original: { missed }, | ||
| }, | ||
| }) => ( | ||
| <Badge colorPalette={missed ? "red" : "blue"} size="sm" variant="solid"> | ||
| {missed | ||
| ? translate("browse:deadlines.filters.statusOptions.missed") | ||
| : translate("browse:deadlines.filters.statusOptions.pending")} | ||
| </Badge> | ||
| ), | ||
| header: translate("browse:deadlines.columns.status"), | ||
| }, | ||
| { | ||
| accessorKey: "alert_name", | ||
| cell: ({ row: { original } }) => original.alert_name ?? "", | ||
| enableSorting: false, | ||
| header: translate("browse:deadlines.columns.alertName"), | ||
| }, | ||
| { | ||
| accessorKey: "created_at", | ||
| cell: ({ row: { original } }: DeadlineRow) => <Time datetime={original.created_at} />, | ||
| header: translate("common:table.createdAt"), | ||
| }, | ||
| ]; | ||
|
|
||
| const deadlinesFilterKeys: Array<FilterableSearchParamsKeys> = [ | ||
| SearchParamsKeys.DAG_ID, | ||
| SearchParamsKeys.DEADLINE_TIME_RANGE, | ||
| SearchParamsKeys.MISSED, | ||
| ]; | ||
|
|
||
| export const Deadlines = () => { | ||
| const { t: translate } = useTranslation(["browse", "common"]); | ||
| const { setTableURLState, tableURLState } = useTableURLState(); | ||
| const [searchParams] = useSearchParams(); | ||
|
|
||
| const { filterConfigs, handleFiltersChange, initialValues } = useFiltersHandler(deadlinesFilterKeys); | ||
|
|
||
| const columns = createColumns(translate); | ||
|
|
||
| const { pagination, sorting } = tableURLState; | ||
| const [sort] = sorting; | ||
| const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] : ["-deadline_time"]; | ||
|
|
||
| const filteredDagId = searchParams.get(SearchParamsKeys.DAG_ID); | ||
| const filteredMissed = searchParams.get(SearchParamsKeys.MISSED); | ||
| const deadlineTimeGte = searchParams.get(SearchParamsKeys.DEADLINE_TIME_GTE); | ||
| const deadlineTimeLte = searchParams.get(SearchParamsKeys.DEADLINE_TIME_LTE); | ||
|
|
||
| const missedFilter = filteredMissed === "true" ? true : filteredMissed === "false" ? false : undefined; | ||
|
|
||
| const { data, error, isFetching, isLoading } = useDeadlinesServiceGetDeadlines({ | ||
| dagId: filteredDagId !== null && filteredDagId !== "" ? filteredDagId : "~", | ||
| dagRunId: "~", | ||
| deadlineTimeGte: deadlineTimeGte ?? undefined, | ||
| deadlineTimeLte: deadlineTimeLte ?? undefined, | ||
| limit: pagination.pageSize, | ||
| missed: missedFilter, | ||
| offset: pagination.pageIndex * pagination.pageSize, | ||
| orderBy, | ||
| }); | ||
|
|
||
| return ( | ||
| <Box p={2}> | ||
| <Heading>{translate("browse:deadlines.title")}</Heading> | ||
| <VStack align="start" gap={4} paddingY="4px"> | ||
| <FilterBar | ||
| configs={filterConfigs} | ||
| initialValues={initialValues} | ||
| onFiltersChange={handleFiltersChange} | ||
| /> | ||
| </VStack> | ||
| <DataTable | ||
| columns={columns} | ||
| data={data?.deadlines ?? []} | ||
| errorMessage={<ErrorAlert error={error} />} | ||
| initialState={tableURLState} | ||
| isFetching={isFetching} | ||
| isLoading={isLoading} | ||
| modelName="browse:deadlines.deadline" | ||
| onStateChange={setTableURLState} | ||
| showRowCountHeading={false} | ||
| total={data?.total_entries} | ||
| /> | ||
| </Box> | ||
| ); | ||
| }; | ||
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
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
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
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
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.