guan404ming commented on code in PR #68657: URL: https://github.com/apache/airflow/pull/68657#discussion_r3500184588
########## airflow-core/src/airflow/ui/src/pages/DagsList/DagsFilters/RunStateSelect.tsx: ########## @@ -0,0 +1,86 @@ +/*! + * 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 { HStack, Text } from "@chakra-ui/react"; +import { createListCollection } from "@chakra-ui/react/collection"; +import { useTranslation } from "react-i18next"; +import { FiList } from "react-icons/fi"; + +import { StateBadge } from "src/components/StateBadge"; +import { Select } from "src/components/ui"; + +type RunState = "failed" | "queued" | "running" | "success"; + +type Props = { + readonly dataTestId?: string; + readonly label: string; + readonly onChange: (value: string | undefined) => void; + readonly states: ReadonlyArray<RunState>; + readonly value: string | undefined; +}; + +const ALL_VALUE = "all"; + +export const RunStateSelect = ({ dataTestId, label, onChange, states, value }: Props) => { + const { t: translate } = useTranslation(["dags", "common"]); + + const collection = createListCollection({ + items: [ + { label: translate("dags:filters.allStates"), state: undefined, value: ALL_VALUE }, + ...states.map((state) => ({ label: translate(`common:states.${state}`), state, value: state })), + ], + }); + + const current = collection.items.find((item) => item.value === (value ?? ALL_VALUE)); + + return ( + <Select.Root + collection={collection} + data-testid={dataTestId} + onValueChange={({ value: selected }) => onChange(selected[0] === ALL_VALUE ? undefined : selected[0])} + value={[value ?? ALL_VALUE]} + width="232px" Review Comment: Good point. I tested and switched the fixed width to width="fit-content" so the trigger sizes to its content and won't clip longer/shorter locales. Please have a another look, thanks! <img width="1456" height="370" alt="image" src="https://github.com/user-attachments/assets/f723ce91-8067-4c24-81be-f59ae4e94da0" /> -- 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]
