From 0bd547923d2484965db9e353d80ae62fdb37f896 Mon Sep 17 00:00:00 2001 From: Craig O'Donnell Date: Mon, 13 May 2024 21:55:15 -0400 Subject: [PATCH] fix config and view files tab underlines (#4616) * fix config and view files tab underlines * use cgr.dev/chainguard/apko * override apko-image for deps action too * add descriptions for actionlint * use last working apko image --- .../build-custom-image-with-apko/action.yml | 1 + .../build-dep-image-with-apko/action.yml | 1 + .../kurl-addon-kots-generate/action.yml | 1 + .../kurl-addon-kots-publish/action.yml | 1 + .../actions/kurl-addon-kots-test/action.yml | 1 + web/src/components/apps/AppDetailPage.tsx | 7 ++-- web/src/utilities/utilities.js | 13 +++++++ web/src/utilities/utilities.test.js | 39 +++++++++++++++++++ 8 files changed, 61 insertions(+), 3 deletions(-) diff --git a/.github/actions/build-custom-image-with-apko/action.yml b/.github/actions/build-custom-image-with-apko/action.yml index d31e09cd5f..f01b27572e 100644 --- a/.github/actions/build-custom-image-with-apko/action.yml +++ b/.github/actions/build-custom-image-with-apko/action.yml @@ -49,6 +49,7 @@ runs: - uses: chainguard-images/actions/apko-publish@main with: + apko-image: ghcr.io/wolfi-dev/apko@sha256:87b47283433066d19b71e1cb4401be8d04b7d51f4f4263fde1977c3043b9754f config: ${{ inputs.context }}/apko.yaml archs: amd64,arm64 tag: ${{ inputs.image-name }} diff --git a/.github/actions/build-dep-image-with-apko/action.yml b/.github/actions/build-dep-image-with-apko/action.yml index 7f234ca742..658f350bc8 100644 --- a/.github/actions/build-dep-image-with-apko/action.yml +++ b/.github/actions/build-dep-image-with-apko/action.yml @@ -43,6 +43,7 @@ runs: - uses: chainguard-images/actions/apko-publish@main if: ${{ inputs.overwrite == 'true' || steps.check-image-exists.outputs.image-exists == 'false' }} with: + apko-image: ghcr.io/wolfi-dev/apko@sha256:87b47283433066d19b71e1cb4401be8d04b7d51f4f4263fde1977c3043b9754f config: ${{ inputs.apko-config }} archs: amd64,arm64 tag: ${{ inputs.image-name }} diff --git a/.github/actions/kurl-addon-kots-generate/action.yml b/.github/actions/kurl-addon-kots-generate/action.yml index b1c914cef3..ace922704e 100644 --- a/.github/actions/kurl-addon-kots-generate/action.yml +++ b/.github/actions/kurl-addon-kots-generate/action.yml @@ -1,4 +1,5 @@ name: Generate kURL Add-On +description: Generate kURL Add-On inputs: addon_version: diff --git a/.github/actions/kurl-addon-kots-publish/action.yml b/.github/actions/kurl-addon-kots-publish/action.yml index 8838089ae3..93bd23945d 100644 --- a/.github/actions/kurl-addon-kots-publish/action.yml +++ b/.github/actions/kurl-addon-kots-publish/action.yml @@ -1,4 +1,5 @@ name: Publish kURL Add-On +description: Publish kURL Add-On inputs: addon_version: diff --git a/.github/actions/kurl-addon-kots-test/action.yml b/.github/actions/kurl-addon-kots-test/action.yml index aa429be372..91fb5eb0c3 100644 --- a/.github/actions/kurl-addon-kots-test/action.yml +++ b/.github/actions/kurl-addon-kots-test/action.yml @@ -1,4 +1,5 @@ name: Test kURL Add-On +description: Test kURL Add-On inputs: addon_version: diff --git a/web/src/components/apps/AppDetailPage.tsx b/web/src/components/apps/AppDetailPage.tsx index 1fe2c41284..bc3443c1e4 100644 --- a/web/src/components/apps/AppDetailPage.tsx +++ b/web/src/components/apps/AppDetailPage.tsx @@ -425,8 +425,9 @@ function AppDetailPage(props: Props) { updateCallback: refetchData, }; - const lastItem = location.pathname.substring( - location.pathname.lastIndexOf("/") + 1 + const lastItem = Utilities.getSubnavItemForRoute( + location.pathname, + params.slug ); return ( @@ -480,7 +481,7 @@ function AppDetailPage(props: Props) { { expect(Utilities.snapshotLocationStr(undefined, undefined)).toBe(""); }); }); + + describe("getSubnavItemForRoute", () => { + it("should return an empty string if there is no route", () => { + expect(Utilities.getSubnavItemForRoute(undefined, "my-app")).toBe(""); + }); + + it("should return an empty string if there is no app slug", () => { + expect( + Utilities.getSubnavItemForRoute("/app/my-app/config", undefined) + ).toBe(""); + }); + + it("should return an empty string if there is no subnav item", () => { + expect(Utilities.getSubnavItemForRoute("/app/my-app/", "my-app")).toBe( + "" + ); + }); + + it("should return the subnav item for the route", () => { + expect( + Utilities.getSubnavItemForRoute("/app/my-app/config", "my-app") + ).toBe("config"); + }); + + it("should return the subnav item for the route with a subpath", () => { + expect( + Utilities.getSubnavItemForRoute("/app/my-app/config/1", "my-app") + ).toBe("config"); + }); + + it("should return the subnav item for the route with multiple subpaths", () => { + expect( + Utilities.getSubnavItemForRoute( + "/app/my-app/troubleshoot/analyze/abcdefg", + "my-app" + ) + ).toBe("troubleshoot"); + }); + }); });