mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Move initializing CatalogCategories to runnable in bootstrap
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
9e1d182459
commit
0cad3e7bae
16 files changed
+225
-171
No files matched your search
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { OpenDialogOptions } from "electron";
|
||||
import type { RequestChannel } from "../../../common/utils/channel/request-channel-listener-injection-token";
|
||||
|
||||
export type PathPickingResponse = {
|
||||
canceled: true;
|
||||
} | {
|
||||
canceled: false;
|
||||
paths: string[];
|
||||
};
|
||||
|
||||
export const openPathPickingDialogChannel: RequestChannel<OpenDialogOptions, PathPickingResponse> = {
|
||||
id: "open-path-picking-dialog",
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import askUserForFilePathsInjectable from "../../../main/ipc/ask-user-for-file-paths.injectable";
|
||||
import { getRequestChannelListenerInjectable } from "../../../main/utils/channel/channel-listeners/listener-tokens";
|
||||
import { openPathPickingDialogChannel } from "../common/channel";
|
||||
|
||||
const openPathPickingDialogListener = getRequestChannelListenerInjectable({
|
||||
channel: openPathPickingDialogChannel,
|
||||
handler: (di) => di.inject(askUserForFilePathsInjectable),
|
||||
});
|
||||
|
||||
export default openPathPickingDialogListener;
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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 type { PathPickOpts } from "../../../renderer/components/path-picker";
|
||||
import requestFromChannelInjectable from "../../../renderer/utils/channel/request-from-channel.injectable";
|
||||
import { openPathPickingDialogChannel } from "../common/channel";
|
||||
|
||||
export type OpenPathPickingDialog = (options: PathPickOpts) => Promise<void>;
|
||||
|
||||
const openPathPickingDialogInjectable = getInjectable({
|
||||
id: "open-path-picking-dialog",
|
||||
instantiate: (di): OpenPathPickingDialog => {
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectable);
|
||||
|
||||
return async (options) => {
|
||||
const { onPick, onCancel, label, ...dialogOptions } = options;
|
||||
const response = await requestFromChannel(openPathPickingDialogChannel, {
|
||||
message: label,
|
||||
...dialogOptions,
|
||||
});
|
||||
|
||||
if (response.canceled) {
|
||||
await onCancel?.();
|
||||
} else {
|
||||
await onPick?.(response.paths);
|
||||
}
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export default openPathPickingDialogInjectable;
|
||||
Reference in new issue
Block a user