You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "josix (via GitHub)" <gi...@apache.org> on 2026/07/24 18:44:20 UTC
[PR] UI: Add Select Recent Configurations dropdown to Trigger Dag form [airflow]
josix opened a new pull request, #70413:
URL: https://github.com/apache/airflow/pull/70413
Reusing a past run's config currently requires leaving the trigger flow to hunt for the right run in the run list and use "Trigger again with this config". Restoring the Airflow 2 in-form dropdown lets users pick any distinct config from the recent runs in a scrollable list while composing a run. The dropdown reuses the existing dagRuns list endpoint and the same conf-only prefill path as the menu item, so no new API surface is added.
closes: #69820
### Verification
<img width="1470" height="837" alt="image" src="https://github.com/user-attachments/assets/8a8f61da-cec8-42cf-be12-43ae927cd245" />
<img width="1470" height="828" alt="image" src="https://github.com/user-attachments/assets/32fdea90-6978-45c0-9054-38526fb6dcd2" />
<!-- SPDX-License-Identifier: Apache-2.0
https://www.apache.org/licenses/LICENSE-2.0 -->
<!--
Thank you for contributing!
Please provide above a brief description of the changes made in this pull request.
Write a good git commit message following this guide: https://chris.beams.io/posts/git-commit/
Please make sure that your code changes are covered with tests.
And in case of new features or big changes remember to adjust the documentation.
For user-facing UI changes, please attach before/after screenshots (or a short
screen recording) so reviewers can assess the visual impact.
Feel free to ping (in general) for the review if you do not see reaction for a few days
(72 Hours is the minimum reaction time you can expect from volunteers) - we sometimes miss notifications.
In case of an existing issue, reference it using one of the following:
* closes: #ISSUE
* related: #ISSUE
-->
---
##### Was generative AI tooling used to co-author this PR?
<!--
If generative AI tooling has been used in the process of authoring this PR, please
change below checkbox to `[X]` followed by the name of the tool, uncomment the "Generated-by".
-->
- [x] Yes
Generated-by: Claude COde following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
---
* Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
* For fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
* When adding dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
* For significant user-facing changes create newsfragment: `{pr_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments). You can add this file in a follow-up commit after the PR is created so you know the PR number.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI: Add Select Recent Configurations dropdown to Trigger Dag form [airflow]
Posted by "josix (via GitHub)" <gi...@apache.org>.
josix commented on PR #70413:
URL: https://github.com/apache/airflow/pull/70413#issuecomment-6096625369
Thanks for the review @bbovenzi! Addressed all three comments in the latest push: `RecentConfigSelect` now uses Select from `src/system-components`, so the dropdown is portalled and no longer cut off by the modal. The trigger is just `Select.Trigger` with `Select.ValueText`, and the extra `Select.Positioner` is gone now.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI: Add Select Recent Configurations dropdown to Trigger Dag form [airflow]
Posted by "josix (via GitHub)" <gi...@apache.org>.
josix commented on code in PR #70413:
URL: https://github.com/apache/airflow/pull/70413#discussion_r4072649703
##########
airflow-core/src/airflow/ui/src/components/TriggerDag/RecentConfigSelect.tsx:
##########
@@ -0,0 +1,117 @@
+/*!
+ * 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 { createListCollection, Flex, Select, type SelectValueChangeDetails, Text } from "@chakra-ui/react";
+import { useMemo, useState } from "react";
+import { useTranslation } from "react-i18next";
+
+import { useDagRunServiceGetDagRuns } from "openapi/queries";
+import type { DAGRunResponse } from "openapi/requests/types.gen";
+
+import Time from "../Time";
+
+type RecentConfigOption = {
+ run: DAGRunResponse;
+ value: string;
+};
+
+type RecentConfigSelectProps = {
+ readonly dagId: string;
+ readonly onSelectConf: (conf: Record<string, unknown>) => void;
+ readonly open: boolean;
+};
+
+const RecentConfigSelect = ({ dagId, onSelectConf, open }: RecentConfigSelectProps) => {
+ const { t: translate } = useTranslation("components");
+ const [selectedValue, setSelectedValue] = useState<Array<string>>([]);
+ const { data, isLoading } = useDagRunServiceGetDagRuns(
+ { dagId, limit: 25, orderBy: ["-run_after"] },
+ undefined,
+ { enabled: open },
+ );
+
+ const options = useMemo(() => {
+ const seenConfs = new Set<string>();
+
+ return (data?.dag_runs ?? []).reduce<Array<RecentConfigOption>>((items, run) => {
+ const hasConf = run.conf !== null && Object.keys(run.conf).length > 0;
+ const confKey = hasConf ? JSON.stringify(run.conf) : undefined;
+ const isNewConf = confKey !== undefined && !seenConfs.has(confKey);
+
+ if (isNewConf) {
+ seenConfs.add(confKey);
+ items.push({ run, value: run.dag_run_id });
+ }
+
+ return items;
+ }, []);
+ }, [data?.dag_runs]);
+
+ const recentConfigOptions = createListCollection({
+ items: options,
+ itemToString: (item: RecentConfigOption) => item.run.dag_run_id,
+ });
+
+ const handleValueChange = ({ items, value }: SelectValueChangeDetails<RecentConfigOption>) => {
+ const [selected] = items;
+
+ setSelectedValue(value);
+ if (selected?.run.conf) {
+ onSelectConf(selected.run.conf);
Review Comment:
Thanks for catching this, I've fixed the issue. Selecting a recent configuration now only swaps `conf` via `reset((prev) => ({ ...prev, conf }))` and leaves the logical date, run ID, note, and data interval as the user set them. The prefill path still performs a full reset.
Here is the recording for this fix: https://jam.dev/c/02f5eba8-bc69-440d-975e-ca233b620f9b
##########
airflow-core/src/airflow/ui/src/components/TriggerDag/RecentConfigSelect.tsx:
##########
@@ -0,0 +1,117 @@
+/*!
+ * 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 { createListCollection, Flex, Select, type SelectValueChangeDetails, Text } from "@chakra-ui/react";
+import { useMemo, useState } from "react";
+import { useTranslation } from "react-i18next";
+
+import { useDagRunServiceGetDagRuns } from "openapi/queries";
+import type { DAGRunResponse } from "openapi/requests/types.gen";
+
+import Time from "../Time";
+
+type RecentConfigOption = {
+ run: DAGRunResponse;
+ value: string;
+};
+
+type RecentConfigSelectProps = {
+ readonly dagId: string;
+ readonly onSelectConf: (conf: Record<string, unknown>) => void;
+ readonly open: boolean;
+};
+
+const RecentConfigSelect = ({ dagId, onSelectConf, open }: RecentConfigSelectProps) => {
+ const { t: translate } = useTranslation("components");
+ const [selectedValue, setSelectedValue] = useState<Array<string>>([]);
+ const { data, isLoading } = useDagRunServiceGetDagRuns(
+ { dagId, limit: 25, orderBy: ["-run_after"] },
+ undefined,
+ { enabled: open },
+ );
+
+ const options = useMemo(() => {
+ const seenConfs = new Set<string>();
+
+ return (data?.dag_runs ?? []).reduce<Array<RecentConfigOption>>((items, run) => {
+ const hasConf = run.conf !== null && Object.keys(run.conf).length > 0;
+ const confKey = hasConf ? JSON.stringify(run.conf) : undefined;
+ const isNewConf = confKey !== undefined && !seenConfs.has(confKey);
+
+ if (isNewConf) {
+ seenConfs.add(confKey);
+ items.push({ run, value: run.dag_run_id });
+ }
+
+ return items;
+ }, []);
+ }, [data?.dag_runs]);
+
+ const recentConfigOptions = createListCollection({
+ items: options,
+ itemToString: (item: RecentConfigOption) => item.run.dag_run_id,
+ });
+
+ const handleValueChange = ({ items, value }: SelectValueChangeDetails<RecentConfigOption>) => {
+ const [selected] = items;
+
+ setSelectedValue(value);
+ if (selected?.run.conf) {
+ onSelectConf(selected.run.conf);
+ }
+ };
+
+ if (!isLoading && options.length === 0) {
+ return undefined;
+ }
+
+ return (
+ <Select.Root
+ collection={recentConfigOptions}
+ data-testid="recent-config-select"
+ disabled={isLoading || options.length === 0}
+ onValueChange={handleValueChange}
+ size="sm"
+ value={selectedValue}
+ >
+ <Select.Label fontSize="xs">{translate("triggerDag.recentConfig")}</Select.Label>
+ <Select.Control>
+ <Select.Trigger>
+ <Select.ValueText placeholder={translate("triggerDag.recentConfigPlaceholder")} />
+ </Select.Trigger>
Review Comment:
Yeah, thanks for pointing it out. The form already retains a DAG run's `conf` when using the “Trigger Again with This Config” button, so I think we don't need the dropdown in this case. I've removed the selector from the form for this flow.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI: Add Select Recent Configurations dropdown to Trigger Dag form [airflow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #70413:
URL: https://github.com/apache/airflow/pull/70413#issuecomment-6247961965
### Backport successfully created: v3-4-test
Note: As of [Merging PRs targeted for Airflow 3.X](https://github.com/apache/airflow/blob/main/dev/README_AIRFLOW3_DEV.md#merging-prs-targeted-for-airflow-3x)
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.
In matter of doubt please ask in [#release-management](https://apache-airflow.slack.com/archives/C03G9H97MM2) Slack channel.
<table>
<tr>
<th>Status</th>
<th>Branch</th>
<th>Result</th>
</tr>
<tr>
<td>✅</td>
<td>v3-4-test</td>
<td><a href="https://github.com/apache/airflow/pull/74977"><img src="https://img.shields.io/badge/PR-74977-blue" alt="PR Link"></a></td>
</tr>
</table>
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI: Add Select Recent Configurations dropdown to Trigger Dag form [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on PR #70413:
URL: https://github.com/apache/airflow/pull/70413#issuecomment-6154302308
E2e test failure is unrelated
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI: Add Select Recent Configurations dropdown to Trigger Dag form [airflow]
Posted by "josix (via GitHub)" <gi...@apache.org>.
josix commented on PR #70413:
URL: https://github.com/apache/airflow/pull/70413#issuecomment-5778198517
Hello @pierrejeambrun, thank you for the kind review. I've addressed the issues you pointed out. Please take a look when you have chance Thank you so much!
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI: Add Select Recent Configurations dropdown to Trigger Dag form [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #70413:
URL: https://github.com/apache/airflow/pull/70413#discussion_r4137927607
##########
airflow-core/src/airflow/ui/src/components/TriggerDag/RecentConfigSelect.tsx:
##########
@@ -0,0 +1,118 @@
+/*!
+ * 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 { useMemo, useState } from "react";
+
+import { createListCollection, Flex, Select, type SelectValueChangeDetails, Text } from "@chakra-ui/react";
+import { useTranslation } from "react-i18next";
+
+import { useDagRunServiceGetDagRuns } from "openapi/queries";
+import type { DAGRunResponse } from "openapi/requests/types.gen";
+
+import Time from "../Time";
+
+type RecentConfigOption = {
+ run: DAGRunResponse;
+ value: string;
+};
+
+type RecentConfigSelectProps = {
+ readonly dagId: string;
+ readonly onSelectConf: (conf: Record<string, unknown>) => void;
+ readonly open: boolean;
+};
+
+const RecentConfigSelect = ({ dagId, onSelectConf, open }: RecentConfigSelectProps) => {
+ const { t: translate } = useTranslation("components");
+ const [selectedValue, setSelectedValue] = useState<Array<string>>([]);
+ const { data, isLoading } = useDagRunServiceGetDagRuns(
+ { dagId, limit: 25, orderBy: ["-run_after"] },
+ undefined,
+ { enabled: open },
+ );
+
+ const options = useMemo(() => {
+ const seenConfs = new Set<string>();
+
+ return (data?.dag_runs ?? []).reduce<Array<RecentConfigOption>>((items, run) => {
+ const hasConf = run.conf !== null && Object.keys(run.conf).length > 0;
+ const confKey = hasConf ? JSON.stringify(run.conf) : undefined;
+ const isNewConf = confKey !== undefined && !seenConfs.has(confKey);
+
+ if (isNewConf) {
+ seenConfs.add(confKey);
+ items.push({ run, value: run.dag_run_id });
+ }
+
+ return items;
+ }, []);
+ }, [data?.dag_runs]);
+
+ const recentConfigOptions = createListCollection({
+ items: options,
+ itemToString: (item: RecentConfigOption) => item.run.dag_run_id,
+ });
+
+ const handleValueChange = ({ items, value }: SelectValueChangeDetails<RecentConfigOption>) => {
+ const [selected] = items;
+
+ setSelectedValue(value);
+ if (selected?.run.conf) {
+ onSelectConf(selected.run.conf);
+ }
+ };
+
+ if (!isLoading && options.length === 0) {
+ return undefined;
+ }
+
+ return (
+ <Select.Root
+ collection={recentConfigOptions}
+ data-testid="recent-config-select"
+ disabled={isLoading || options.length === 0}
+ onValueChange={handleValueChange}
+ size="sm"
+ value={selectedValue}
+ >
+ <Select.Label fontSize="xs">{translate("triggerDag.recentConfig")}</Select.Label>
+ <Select.Control>
+ <Select.Trigger>
+ <Select.ValueText placeholder={translate("triggerDag.recentConfigPlaceholder")} />
+ </Select.Trigger>
+ <Select.IndicatorGroup>
+ <Select.Indicator />
+ </Select.IndicatorGroup>
+ </Select.Control>
Review Comment:
When we change to import our local select then we only need <Select.Trigger> and <Select.ValueText>. The rest we can remove.
##########
airflow-core/src/airflow/ui/src/components/TriggerDag/RecentConfigSelect.tsx:
##########
@@ -0,0 +1,118 @@
+/*!
+ * 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 { useMemo, useState } from "react";
+
+import { createListCollection, Flex, Select, type SelectValueChangeDetails, Text } from "@chakra-ui/react";
+import { useTranslation } from "react-i18next";
+
+import { useDagRunServiceGetDagRuns } from "openapi/queries";
+import type { DAGRunResponse } from "openapi/requests/types.gen";
+
+import Time from "../Time";
+
+type RecentConfigOption = {
+ run: DAGRunResponse;
+ value: string;
+};
+
+type RecentConfigSelectProps = {
+ readonly dagId: string;
+ readonly onSelectConf: (conf: Record<string, unknown>) => void;
+ readonly open: boolean;
+};
+
+const RecentConfigSelect = ({ dagId, onSelectConf, open }: RecentConfigSelectProps) => {
+ const { t: translate } = useTranslation("components");
+ const [selectedValue, setSelectedValue] = useState<Array<string>>([]);
+ const { data, isLoading } = useDagRunServiceGetDagRuns(
+ { dagId, limit: 25, orderBy: ["-run_after"] },
+ undefined,
+ { enabled: open },
+ );
+
+ const options = useMemo(() => {
+ const seenConfs = new Set<string>();
+
+ return (data?.dag_runs ?? []).reduce<Array<RecentConfigOption>>((items, run) => {
+ const hasConf = run.conf !== null && Object.keys(run.conf).length > 0;
+ const confKey = hasConf ? JSON.stringify(run.conf) : undefined;
+ const isNewConf = confKey !== undefined && !seenConfs.has(confKey);
+
+ if (isNewConf) {
+ seenConfs.add(confKey);
+ items.push({ run, value: run.dag_run_id });
+ }
+
+ return items;
+ }, []);
+ }, [data?.dag_runs]);
+
+ const recentConfigOptions = createListCollection({
+ items: options,
+ itemToString: (item: RecentConfigOption) => item.run.dag_run_id,
+ });
+
+ const handleValueChange = ({ items, value }: SelectValueChangeDetails<RecentConfigOption>) => {
+ const [selected] = items;
+
+ setSelectedValue(value);
+ if (selected?.run.conf) {
+ onSelectConf(selected.run.conf);
+ }
+ };
+
+ if (!isLoading && options.length === 0) {
+ return undefined;
+ }
+
+ return (
+ <Select.Root
+ collection={recentConfigOptions}
+ data-testid="recent-config-select"
+ disabled={isLoading || options.length === 0}
+ onValueChange={handleValueChange}
+ size="sm"
+ value={selectedValue}
+ >
+ <Select.Label fontSize="xs">{translate("triggerDag.recentConfig")}</Select.Label>
+ <Select.Control>
+ <Select.Trigger>
+ <Select.ValueText placeholder={translate("triggerDag.recentConfigPlaceholder")} />
+ </Select.Trigger>
+ <Select.IndicatorGroup>
+ <Select.Indicator />
+ </Select.IndicatorGroup>
+ </Select.Control>
+ <Select.Positioner>
Review Comment:
We can also remove the Select.Positioner
##########
airflow-core/src/airflow/ui/src/components/TriggerDag/RecentConfigSelect.tsx:
##########
@@ -0,0 +1,118 @@
+/*!
+ * 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 { useMemo, useState } from "react";
+
+import { createListCollection, Flex, Select, type SelectValueChangeDetails, Text } from "@chakra-ui/react";
Review Comment:
Let's import select from our system-components
`import { Select } from "src/system-components";`
That should properly portal the select's dropdown so that the edge of the modal doesn't cut it off.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI: Add Select Recent Configurations dropdown to Trigger Dag form [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #70413:
URL: https://github.com/apache/airflow/pull/70413#discussion_r3829947101
##########
airflow-core/src/airflow/ui/src/components/TriggerDag/RecentConfigSelect.tsx:
##########
@@ -0,0 +1,117 @@
+/*!
+ * 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 { createListCollection, Flex, Select, type SelectValueChangeDetails, Text } from "@chakra-ui/react";
+import { useMemo, useState } from "react";
+import { useTranslation } from "react-i18next";
+
+import { useDagRunServiceGetDagRuns } from "openapi/queries";
+import type { DAGRunResponse } from "openapi/requests/types.gen";
+
+import Time from "../Time";
+
+type RecentConfigOption = {
+ run: DAGRunResponse;
+ value: string;
+};
+
+type RecentConfigSelectProps = {
+ readonly dagId: string;
+ readonly onSelectConf: (conf: Record<string, unknown>) => void;
+ readonly open: boolean;
+};
+
+const RecentConfigSelect = ({ dagId, onSelectConf, open }: RecentConfigSelectProps) => {
+ const { t: translate } = useTranslation("components");
+ const [selectedValue, setSelectedValue] = useState<Array<string>>([]);
+ const { data, isLoading } = useDagRunServiceGetDagRuns(
+ { dagId, limit: 25, orderBy: ["-run_after"] },
+ undefined,
+ { enabled: open },
+ );
+
+ const options = useMemo(() => {
+ const seenConfs = new Set<string>();
+
+ return (data?.dag_runs ?? []).reduce<Array<RecentConfigOption>>((items, run) => {
+ const hasConf = run.conf !== null && Object.keys(run.conf).length > 0;
+ const confKey = hasConf ? JSON.stringify(run.conf) : undefined;
+ const isNewConf = confKey !== undefined && !seenConfs.has(confKey);
+
+ if (isNewConf) {
+ seenConfs.add(confKey);
+ items.push({ run, value: run.dag_run_id });
+ }
+
+ return items;
+ }, []);
+ }, [data?.dag_runs]);
+
+ const recentConfigOptions = createListCollection({
+ items: options,
+ itemToString: (item: RecentConfigOption) => item.run.dag_run_id,
+ });
+
+ const handleValueChange = ({ items, value }: SelectValueChangeDetails<RecentConfigOption>) => {
+ const [selected] = items;
+
+ setSelectedValue(value);
+ if (selected?.run.conf) {
+ onSelectConf(selected.run.conf);
Review Comment:
This will reset user defined logicalDate, runId, and note to defaults.
But here it fires interactively: a user who sets a logical date / custom run ID / manual data interval / note and then picks a recent config to reuse its params loses all of those to defaults. The dropdown is meant to apply a past run's conf, not reset the run's scheduling fields.
Either fix that or move this config selector at the top of the form, so we know that all fields are affected and will be reset to
##########
airflow-core/src/airflow/ui/src/components/TriggerDag/RecentConfigSelect.tsx:
##########
@@ -0,0 +1,117 @@
+/*!
+ * 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 { createListCollection, Flex, Select, type SelectValueChangeDetails, Text } from "@chakra-ui/react";
+import { useMemo, useState } from "react";
+import { useTranslation } from "react-i18next";
+
+import { useDagRunServiceGetDagRuns } from "openapi/queries";
+import type { DAGRunResponse } from "openapi/requests/types.gen";
+
+import Time from "../Time";
+
+type RecentConfigOption = {
+ run: DAGRunResponse;
+ value: string;
+};
+
+type RecentConfigSelectProps = {
+ readonly dagId: string;
+ readonly onSelectConf: (conf: Record<string, unknown>) => void;
+ readonly open: boolean;
+};
+
+const RecentConfigSelect = ({ dagId, onSelectConf, open }: RecentConfigSelectProps) => {
+ const { t: translate } = useTranslation("components");
+ const [selectedValue, setSelectedValue] = useState<Array<string>>([]);
+ const { data, isLoading } = useDagRunServiceGetDagRuns(
+ { dagId, limit: 25, orderBy: ["-run_after"] },
+ undefined,
+ { enabled: open },
+ );
+
+ const options = useMemo(() => {
+ const seenConfs = new Set<string>();
+
+ return (data?.dag_runs ?? []).reduce<Array<RecentConfigOption>>((items, run) => {
+ const hasConf = run.conf !== null && Object.keys(run.conf).length > 0;
+ const confKey = hasConf ? JSON.stringify(run.conf) : undefined;
+ const isNewConf = confKey !== undefined && !seenConfs.has(confKey);
+
+ if (isNewConf) {
+ seenConfs.add(confKey);
+ items.push({ run, value: run.dag_run_id });
+ }
+
+ return items;
+ }, []);
+ }, [data?.dag_runs]);
+
+ const recentConfigOptions = createListCollection({
+ items: options,
+ itemToString: (item: RecentConfigOption) => item.run.dag_run_id,
+ });
+
+ const handleValueChange = ({ items, value }: SelectValueChangeDetails<RecentConfigOption>) => {
+ const [selected] = items;
+
+ setSelectedValue(value);
+ if (selected?.run.conf) {
+ onSelectConf(selected.run.conf);
+ }
+ };
+
+ if (!isLoading && options.length === 0) {
+ return undefined;
+ }
+
+ return (
+ <Select.Root
+ collection={recentConfigOptions}
+ data-testid="recent-config-select"
+ disabled={isLoading || options.length === 0}
+ onValueChange={handleValueChange}
+ size="sm"
+ value={selectedValue}
+ >
+ <Select.Label fontSize="xs">{translate("triggerDag.recentConfig")}</Select.Label>
+ <Select.Control>
+ <Select.Trigger>
+ <Select.ValueText placeholder={translate("triggerDag.recentConfigPlaceholder")} />
+ </Select.Trigger>
Review Comment:
When we run through 'trigger again with this conf button', this drop down probably shouldn't be there at all.
It's confusing to have it (with nothing selected), but actually a conf is passed down. And if it's to change the run conf to another run, there's no point running through that 'trigger again with this conf' button.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] UI: Add Select Recent Configurations dropdown to Trigger Dag form [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi merged PR #70413:
URL: https://github.com/apache/airflow/pull/70413
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org