mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
- Reallow non-JSON serializable complex types - Remove unnecessary JSON serialization step to IPC - Remove unnecesary injectable-ization of MessageChannel and RequestChannel declarations - Add channel listener injectable getter function to remove general need for type casting and improve type safety Signed-off-by: Sebastian Malton <sebastian@malton.name>
43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import { getInjectable } from "@ogre-tools/injectable";
|
|
import { asyncComputed } from "@ogre-tools/injectable-react";
|
|
import { getActiveHelmRepositoriesChannel } from "../../../../../common/helm/get-active-helm-repositories-channel";
|
|
import { requestFromChannelInjectionToken } from "../../../../../common/utils/channel/request-from-channel-injection-token";
|
|
import showErrorNotificationInjectable from "../../../notifications/show-error-notification.injectable";
|
|
import helmRepositoriesErrorStateInjectable from "./helm-repositories-error-state.injectable";
|
|
import { runInAction } from "mobx";
|
|
|
|
const activeHelmRepositoriesInjectable = getInjectable({
|
|
id: "active-helm-repositories",
|
|
|
|
instantiate: (di) => {
|
|
const requestFromChannel = di.inject(requestFromChannelInjectionToken);
|
|
const showErrorNotification = di.inject(showErrorNotificationInjectable);
|
|
const helmRepositoriesErrorState = di.inject(helmRepositoriesErrorStateInjectable);
|
|
|
|
return asyncComputed(async () => {
|
|
const result = await requestFromChannel(getActiveHelmRepositoriesChannel);
|
|
|
|
if (result.callWasSuccessful) {
|
|
return result.response;
|
|
} else {
|
|
showErrorNotification(result.error);
|
|
|
|
runInAction(() =>
|
|
helmRepositoriesErrorState.set({
|
|
controlsAreShown: false,
|
|
errorMessage: result.error,
|
|
}),
|
|
);
|
|
|
|
return [];
|
|
}
|
|
}, []);
|
|
},
|
|
});
|
|
|
|
export default activeHelmRepositoriesInjectable;
|