Skip to content

Commit 763dee5

Browse files
authored
Fix version check for RC versions (#61318)
* fix version check * chnaged typescript * Update NavTabs.tsx * generated * suggestions followed * fix static * fix static * fix static * Update NavTabs.tsx * addressed suggestions * assets restored * correctly handled tests * fix: rebuild assets and update www-hash.txt
1 parent 206a0f3 commit 763dee5

File tree

6 files changed

+84
-16
lines changed

6 files changed

+84
-16
lines changed

providers/edge3/src/airflow/providers/edge3/plugins/www/dist/main.umd.cjs

Lines changed: 7 additions & 7 deletions
Large diffs are not rendered by default.

providers/edge3/src/airflow/providers/edge3/plugins/www/src/layouts/NavTabs.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import { useQuery } from "@tanstack/react-query";
2222
import { useRef, type ReactNode } from "react";
2323
import { NavLink } from "react-router-dom";
2424

25-
import { useContainerWidth } from "src/utils";
26-
import { lte } from "semver";
25+
import { getLegacyRouterNavigation, useContainerWidth } from "src/utils";
2726

2827
type Props = {
2928
readonly tabs: Array<{ icon?: ReactNode; label: string; value: string }>;
@@ -44,12 +43,7 @@ export const NavTabs = ({ tabs }: Props) => {
4443
let legacyRouterNavigation: boolean | undefined = undefined;
4544

4645
if (data) {
47-
const airflowCoreVersion = data.version;
48-
if (lte(airflowCoreVersion, "3.1.6")) {
49-
legacyRouterNavigation = true;
50-
} else {
51-
legacyRouterNavigation = false;
52-
}
46+
legacyRouterNavigation = getLegacyRouterNavigation(data.version);
5347
}
5448

5549
return (

providers/edge3/src/airflow/providers/edge3/plugins/www/src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@
1919

2020
export { autoRefreshInterval } from "./config";
2121
export { useContainerWidth } from "./useContainerWidth";
22+
export { getLegacyRouterNavigation } from "./versionUtils";
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
/*!
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
*/
20+
21+
import { getLegacyRouterNavigation } from "src/utils/versionUtils";
22+
import { describe, expect, it } from "vitest";
23+
24+
describe("getLegacyRouterNavigation", () => {
25+
it("returns true for versions <= 3.1.6", () => {
26+
expect(getLegacyRouterNavigation("3.1.6")).toBe(true);
27+
expect(getLegacyRouterNavigation("3.1.5")).toBe(true);
28+
expect(getLegacyRouterNavigation("3.0.0")).toBe(true);
29+
});
30+
31+
it("returns false for versions > 3.1.6", () => {
32+
expect(getLegacyRouterNavigation("3.1.7")).toBe(false);
33+
expect(getLegacyRouterNavigation("3.1.7rc1")).toBe(false);
34+
expect(getLegacyRouterNavigation("3.2.0")).toBe(false);
35+
expect(getLegacyRouterNavigation("4.0.0")).toBe(false);
36+
});
37+
38+
it("returns undefined for invalid versions", () => {
39+
expect(getLegacyRouterNavigation("invalid")).toBe(undefined);
40+
expect(getLegacyRouterNavigation("")).toBe(undefined);
41+
});
42+
});
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
/*!
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
*/
20+
21+
import { coerce, lte } from "semver";
22+
23+
export const getLegacyRouterNavigation = (version: string): boolean | undefined => {
24+
const coercedVersion = coerce(version);
25+
const airflowCoreVersion = coercedVersion?.version ?? null;
26+
27+
if (airflowCoreVersion) {
28+
return lte(airflowCoreVersion, "3.1.6");
29+
}
30+
return undefined;
31+
};

providers/edge3/www-hash.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
94785f1784e07613622a92efb89c8462c814f73c1c8add12af2404ecd88e4820
1+
19f521c1d0e6f65e70c05c45650ec710e5301922f9e18079529284c007cda3b9

0 commit comments

Comments
 (0)