1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/initializers/workload-events.tsx
Sebastian Malton 0ec8cbd7ed
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>
2023-01-11 09:02:10 -05:00

42 lines
1.2 KiB
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { withInjectables } from "@ogre-tools/injectable-react";
import type { IComputedValue } from "mobx";
import { observer } from "mobx-react";
import React from "react";
import { shouldShowResourceInjectionToken } from "../../common/cluster-store/allowed-resources-injection-token";
import { Events } from "../components/+events/events";
export interface WorkloadEventsProps {}
interface Dependencies {
workloadEventsAreAllowed: IComputedValue<boolean>;
}
const NonInjectedWorkloadEvents = observer(({ workloadEventsAreAllowed }: Dependencies & WorkloadEventsProps) => {
if (!workloadEventsAreAllowed.get()) {
return null;
}
return (
<Events
className="box grow"
compact
hideFilters
/>
);
});
export const WorkloadEvents = withInjectables<Dependencies, WorkloadEventsProps>(NonInjectedWorkloadEvents, {
getProps: (di, props) => ({
workloadEventsAreAllowed: di.inject(shouldShowResourceInjectionToken, {
apiName: "events",
group: "",
}),
...props,
}),
});