From fa87ab5157cf47d9ff9abe73ad86f3c60c96b50f Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Fri, 3 Feb 2023 16:23:19 +0300 Subject: [PATCH] Move isSubnamespace method inside API Signed-off-by: Alex Andreev --- .../common/k8s-api/endpoints/namespace.api.ts | 4 + .../namespace-tree-view.test.tsx.snap | 80 ++++++++++--------- .../+namespaces/subnamespace-badge.tsx | 2 +- 3 files changed, 48 insertions(+), 38 deletions(-) diff --git a/packages/core/src/common/k8s-api/endpoints/namespace.api.ts b/packages/core/src/common/k8s-api/endpoints/namespace.api.ts index 3de24d3df9..456cd8bc6c 100644 --- a/packages/core/src/common/k8s-api/endpoints/namespace.api.ts +++ b/packages/core/src/common/k8s-api/endpoints/namespace.api.ts @@ -33,6 +33,10 @@ export class Namespace extends KubeObject< getStatus() { return this.status?.phase ?? "-"; } + + isSubnamespace(){ + return this.getAnnotations().find(annotation => annotation.includes("hnc.x-k8s.io/subnamespace-of")); + } } export class NamespaceApi extends KubeApi { diff --git a/packages/core/src/renderer/components/+namespaces/__snapshots__/namespace-tree-view.test.tsx.snap b/packages/core/src/renderer/components/+namespaces/__snapshots__/namespace-tree-view.test.tsx.snap index 3ad0e27cf7..abc6a75809 100644 --- a/packages/core/src/renderer/components/+namespaces/__snapshots__/namespace-tree-view.test.tsx.snap +++ b/packages/core/src/renderer/components/+namespaces/__snapshots__/namespace-tree-view.test.tsx.snap @@ -4,6 +4,7 @@ exports[` once the subscribe resolves collapses item by cli
once the subscribe resolves collapses item by cli
levels-deep
    @@ -89,14 +90,14 @@ exports[` once the subscribe resolves collapses item by cli
level-deep-child-a
    @@ -136,14 +137,14 @@ exports[` once the subscribe resolves collapses item by cli
    level-deep-child-b
      @@ -183,14 +184,14 @@ exports[` once the subscribe resolves collapses item by cli
      level-deep-subchild-a
        @@ -221,6 +222,7 @@ exports[` once the subscribe resolves expands item by click
        once the subscribe resolves expands item by click
        levels-deep
          @@ -306,14 +308,14 @@ exports[` once the subscribe resolves expands item by click
        level-deep-child-a
          @@ -353,14 +355,14 @@ exports[` once the subscribe resolves expands item by click
          level-deep-child-b
            @@ -400,14 +402,14 @@ exports[` once the subscribe resolves expands item by click
            level-deep-subchild-a
              @@ -438,6 +440,7 @@ exports[` once the subscribe resolves renders 2 levels deep
              once the subscribe resolves renders 2 levels deep
              levels-deep
                @@ -523,14 +526,14 @@ exports[` once the subscribe resolves renders 2 levels deep
              level-deep-child-a
                @@ -570,14 +573,14 @@ exports[` once the subscribe resolves renders 2 levels deep
                level-deep-child-b
                  @@ -617,14 +620,14 @@ exports[` once the subscribe resolves renders 2 levels deep
                  level-deep-subchild-a
                    @@ -655,6 +658,7 @@ exports[` once the subscribe resolves renders namespace wit
                    once the subscribe resolves renders namespace wit
                    acme-org
                      @@ -740,14 +744,14 @@ exports[` once the subscribe resolves renders namespace wit
                    team-a
                      @@ -790,14 +794,14 @@ exports[` once the subscribe resolves renders namespace wit
                      team-b
                        @@ -824,6 +828,7 @@ exports[` once the subscribe resolves renders namespace wit
                        once the subscribe resolves renders namespace wit
                        org-a
                          @@ -909,7 +914,7 @@ exports[` once the subscribe resolves renders namespace wit
                        service-1 @@ -923,7 +928,7 @@ exports[` once the subscribe resolves renders namespace wit
                          @@ -966,14 +971,14 @@ exports[` once the subscribe resolves renders namespace wit
                          team-c
                            @@ -1006,6 +1011,7 @@ exports[` once the subscribe resolves renders one namespace
                            once the subscribe resolves renders one namespace
                            single-root
                            diff --git a/packages/core/src/renderer/components/+namespaces/subnamespace-badge.tsx b/packages/core/src/renderer/components/+namespaces/subnamespace-badge.tsx index d7865468b4..a56f737b93 100644 --- a/packages/core/src/renderer/components/+namespaces/subnamespace-badge.tsx +++ b/packages/core/src/renderer/components/+namespaces/subnamespace-badge.tsx @@ -14,7 +14,7 @@ interface SubnamespaceBadgeProps extends React.HTMLAttributes { } export function SubnamespaceBadge({ namespace, id, ...other }: SubnamespaceBadgeProps) { - if (!namespace.getAnnotations().find(annotation => annotation.includes("hnc.x-k8s.io/subnamespace-of"))) { + if (!namespace.isSubnamespace()) { return null; }