pierrejeambrun commented on code in PR #55467: URL: https://github.com/apache/airflow/pull/55467#discussion_r2585709767
########## airflow-core/src/airflow/ui/src/pages/Dag/Code/VersionCompareSelect.tsx: ########## @@ -0,0 +1,114 @@ +/*! + * 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"; Review Comment: The dropdown menu should probably auto close when a version is selected. Nit: Also the `exit` button shouldn't show until we effectively have a compared version selected. (Currently it shows disabled, but there is no need for it). Also I would porbably replace `exit` by `exit diff` or something opposed to `diff`. ########## airflow-core/src/airflow/ui/src/pages/Dag/Code/Code.tsx: ########## @@ -73,24 +88,56 @@ export const Code = () => { versionNumber: selectedVersion, }); - const defaultWrap = Boolean(useConfig("default_wrap")); - - const [wrap, setWrap] = useState(defaultWrap); + const { + data: compareCode, + error: compareCodeError, + isLoading: isCompareCodeLoading, + } = useDagSourceServiceGetDagSource<DAGSourceResponse, ApiError | null>( + { + dagId: dagId ?? "", + versionNumber: compareVersionNumber, + }, + undefined, + { enabled: isDiffMode && compareVersionNumber !== undefined }, + ); const toggleWrap = () => setWrap(!wrap); + const toggleDiffMode = () => { + setIsDiffMode(!isDiffMode); + if (isDiffMode) { + setCompareVersionNumber(undefined); + } + }; + const { colorMode } = useColorMode(); useHotkeys("w", toggleWrap); + useHotkeys("d", toggleDiffMode); Review Comment: I don't think we need that shortcut, because it still requires us to mouse click the compared version. I would remove that. (Or remember the compared version when switching from diff to non diff, so the last comparedVersion is still selected and remembered) ########## airflow-core/src/airflow/ui/src/pages/Dag/Code/VersionCompareSelect.tsx: ########## @@ -0,0 +1,114 @@ +/*! + * 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 { useCallback, useMemo } from "react"; +import { useTranslation } from "react-i18next"; +import { useParams } from "react-router-dom"; + +import { useDagVersionServiceGetDagVersions } from "openapi/queries"; +import type { DagVersionResponse } from "openapi/requests/types.gen"; +import Time from "src/components/Time"; + +type VersionSelected = { + value: number; + version: DagVersionResponse; +}; + +type VersionCompareSelectProps = { + readonly excludeVersionNumber?: number; Review Comment: I wouldn't handle the `excludeVersionNumber`, worst case we compare the two same version, and diff viewer don't show any diff. Because you can still reach that unexpected situation if you select a diff version, and then change the `selectedVersion` to the selected diff version afterhand, so it does not really matter to handle that case specifically. -- 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]
