yuseok89 commented on code in PR #70470: URL: https://github.com/apache/airflow/pull/70470#discussion_r3744196134
########## airflow-core/src/airflow/ui/src/pages/DagsList/DagsFilters/runStateFilter.ts: ########## @@ -0,0 +1,51 @@ +/*! + * 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 { RunStateScope } from "./RunStateScopeSelect"; + +// The unified "Run state" control is backed by the existing independent URL params: +// - "latest" scope → last_dag_run_state (match the latest run only) +// - a time scope → dag_run_state (match any run) + a within-hours bound +// ("any" is any-run with no time bound, so it carries no window param) +// An unset key means "clear this param". +export type RunStateSelection = { + readonly dagRunState?: string; + readonly dagRunStateWithinHours?: string; + readonly lastDagRunState?: string; +}; + +export const runStateSelectionFor = (state: string | undefined, scope: RunStateScope): RunStateSelection => { + if (state === undefined) { + return {}; + } + if (scope === "latest") { + return { lastDagRunState: state }; + } + if (scope === "any") { + return { dagRunState: state }; + } + + return { dagRunState: state, dagRunStateWithinHours: scope }; +}; + +export const runScopeFor = ( + lastRunState: string | null, + anyRunState: string | null, + anyRunStateWindow: string | null, +): RunStateScope => + lastRunState !== null || anyRunState === null ? "latest" : ((anyRunStateWindow ?? "any") as RunStateScope); Review Comment: Thanks. `runLookbackFor` now only accepts a known lookback value; anything else falls back to "any". Added tests for the invalid cases. -- 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]
