Fix shouldShowResource when not a cluster admin (#6900)

* Fix shouldShowResource when not a cluster admin

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix only tests that rely on bad formatting of resources

Signed-off-by: Sebastian Malton <sebastian@malton.name>

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2023-01-11 09:02:10 -05:00
1 parent 841c6b5720
commit 0ec8cbd7ed
23 files changed
+45 -41

No files matched your search

@@ -21,7 +21,7 @@ const podsWorkloadInjectable = getInjectable({
return {
resource: {
apiName: "pods",
group: "v1",
group: "",
},
open: navigate,
@@ -69,7 +69,7 @@ describe("<ClusterFrame />", () => {
describe("given cluster with list nodes and namespaces permissions", () => {
beforeEach(() => {
// TODO: replace with not using private info
(cluster as any).allowedResources.replace(["v1/nodes", "v1/namespaces"]);
(cluster as unknown as { readonly allowedResources: Cluster["allowedResources"] }).allowedResources.replace(["nodes", "namespaces"]);
});
it("renders", () => {
@@ -110,7 +110,7 @@ describe("<ClusterFrame />", () => {
describe("given cluster without list nodes, but with namespaces permissions", () => {
beforeEach(() => {
(cluster as any).allowedResources.replace(["v1/namespaces"]);
(cluster as unknown as { readonly allowedResources: Cluster["allowedResources"] }).allowedResources.replace(["namespaces"]);
});
it("renders", () => {
@@ -34,7 +34,7 @@ export const WorkloadEvents = withInjectables<Dependencies, WorkloadEventsProps>
getProps: (di, props) => ({
workloadEventsAreAllowed: di.inject(shouldShowResourceInjectionToken, {
apiName: "events",
group: "v1",
group: "",
}),
...props,
}),