mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix cron jobs not being viewable on newer kube (#6542)
* Replace use of legacy globals with injectables Signed-off-by: Sebastian Malton <sebastian@malton.name> * Remove dead code Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix error shown to users when load fails Signed-off-by: Sebastian Malton <sebastian@malton.name> * Switch CronJob default apiBase Signed-off-by: Sebastian Malton <sebastian@malton.name> Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
95ec86a2db
commit
5c34d65de8
@ -13,7 +13,12 @@ const cronJobApiInjectable = getInjectable({
|
|||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
assert(di.inject(storesAndApisCanBeCreatedInjectionToken), "cronJobApi is only available in certain environments");
|
assert(di.inject(storesAndApisCanBeCreatedInjectionToken), "cronJobApi is only available in certain environments");
|
||||||
|
|
||||||
return new CronJobApi();
|
return new CronJobApi({
|
||||||
|
fallbackApiBases: [
|
||||||
|
"/apis/batch/v1beta1/cronjobs",
|
||||||
|
],
|
||||||
|
checkPreferredVersion: true,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
injectionToken: kubeApiInjectionToken,
|
injectionToken: kubeApiInjectionToken,
|
||||||
|
|||||||
@ -73,7 +73,7 @@ export class CronJob extends KubeObject<
|
|||||||
> {
|
> {
|
||||||
static readonly kind = "CronJob";
|
static readonly kind = "CronJob";
|
||||||
static readonly namespaced = true;
|
static readonly namespaced = true;
|
||||||
static readonly apiBase = "/apis/batch/v1beta1/cronjobs";
|
static readonly apiBase = "/apis/batch/v1/cronjobs";
|
||||||
|
|
||||||
getSuspendFlag() {
|
getSuspendFlag() {
|
||||||
return (this.spec.suspend ?? false).toString();
|
return (this.spec.suspend ?? false).toString();
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import type { ClusterContext } from "./cluster-context";
|
|||||||
|
|
||||||
import { action, computed, makeObservable, observable, reaction, when } from "mobx";
|
import { action, computed, makeObservable, observable, reaction, when } from "mobx";
|
||||||
import type { Disposer } from "../utils";
|
import type { Disposer } from "../utils";
|
||||||
import { waitUntilDefined, autoBind, includes, isRequestError, noop, rejectPromiseBy } from "../utils";
|
import { waitUntilDefined, autoBind, includes, noop, rejectPromiseBy } from "../utils";
|
||||||
import type { KubeJsonApiDataFor, KubeObject } from "./kube-object";
|
import type { KubeJsonApiDataFor, KubeObject } from "./kube-object";
|
||||||
import { KubeStatus } from "./kube-object";
|
import { KubeStatus } from "./kube-object";
|
||||||
import type { IKubeWatchEvent } from "./kube-watch-event";
|
import type { IKubeWatchEvent } from "./kube-watch-event";
|
||||||
@ -221,11 +221,7 @@ export abstract class KubeObjectStore<
|
|||||||
try {
|
try {
|
||||||
return await res ?? [];
|
return await res ?? [];
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
onLoadFailure((
|
onLoadFailure(String(error));
|
||||||
isRequestError(error)
|
|
||||||
? error.message || error.toString()
|
|
||||||
: "Unknown error"
|
|
||||||
));
|
|
||||||
|
|
||||||
// reset the store because we are loading all, so that nothing is displayed
|
// reset the store because we are loading all, so that nothing is displayed
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
|
|||||||
@ -7,14 +7,18 @@ import "./cronjobs.scss";
|
|||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { cronJobStore } from "./legacy-store";
|
|
||||||
import { jobStore } from "../+workloads-jobs/legacy-store";
|
|
||||||
import { eventStore } from "../+events/legacy-store";
|
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
|
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
|
||||||
import { KubeObjectAge } from "../kube-object/age";
|
import { KubeObjectAge } from "../kube-object/age";
|
||||||
|
import type { CronJobStore } from "./store";
|
||||||
|
import type { JobStore } from "../+workloads-jobs/store";
|
||||||
|
import type { EventStore } from "../+events/store";
|
||||||
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
|
import cronJobStoreInjectable from "./store.injectable";
|
||||||
|
import jobStoreInjectable from "../+workloads-jobs/store.injectable";
|
||||||
|
import eventStoreInjectable from "../+events/store.injectable";
|
||||||
|
|
||||||
enum columnId {
|
enum columnId {
|
||||||
name = "name",
|
name = "name",
|
||||||
@ -26,9 +30,21 @@ enum columnId {
|
|||||||
age = "age",
|
age = "age",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Dependencies {
|
||||||
|
cronJobStore: CronJobStore;
|
||||||
|
jobStore: JobStore;
|
||||||
|
eventStore: EventStore;
|
||||||
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class CronJobs extends React.Component {
|
class NonInjectedCronJobs extends React.Component<Dependencies>{
|
||||||
render() {
|
render() {
|
||||||
|
const {
|
||||||
|
cronJobStore,
|
||||||
|
eventStore,
|
||||||
|
jobStore,
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SiblingsInTabLayout>
|
<SiblingsInTabLayout>
|
||||||
<KubeObjectListLayout
|
<KubeObjectListLayout
|
||||||
@ -80,3 +96,11 @@ export class CronJobs extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const CronJobs = withInjectables<Dependencies>(NonInjectedCronJobs, {
|
||||||
|
getProps: (di, props) => ({
|
||||||
|
cronJobStore: di.inject(cronJobStoreInjectable),
|
||||||
|
eventStore: di.inject(eventStoreInjectable),
|
||||||
|
jobStore: di.inject(jobStoreInjectable),
|
||||||
|
...props,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|||||||
@ -1,12 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
|
||||||
import cronJobStoreInjectable from "./store.injectable";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use `di.inject(cronJobStoreInjectable)` instead
|
|
||||||
*/
|
|
||||||
export const cronJobStore = asLegacyGlobalForExtensionApi(cronJobStoreInjectable);
|
|
||||||
Loading…
Reference in New Issue
Block a user