mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Remove another use of legacy requestOpenPathPicker
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
177d364d3f
commit
a33b3cde73
@ -3,37 +3,30 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { requestOpenFilePickingDialog } from "../../ipc";
|
|
||||||
import { supportedExtensionFormats } from "./supported-extension-formats";
|
import { supportedExtensionFormats } from "./supported-extension-formats";
|
||||||
import attemptInstallsInjectable from "./attempt-installs.injectable";
|
import attemptInstallsInjectable from "./attempt-installs.injectable";
|
||||||
import directoryForDownloadsInjectable from "../../../common/app-paths/directory-for-downloads/directory-for-downloads.injectable";
|
import directoryForDownloadsInjectable from "../../../common/app-paths/directory-for-downloads/directory-for-downloads.injectable";
|
||||||
|
import openPathPickingDialogInjectable from "../../../features/path-picking-dialog/renderer/pick-paths.injectable";
|
||||||
|
|
||||||
interface Dependencies {
|
export type InstallFromSelectFileDialog = () => Promise<void>;
|
||||||
attemptInstalls: (filePaths: string[]) => Promise<void>;
|
|
||||||
directoryForDownloads: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const installFromSelectFileDialog = ({ attemptInstalls, directoryForDownloads }: Dependencies) => async () => {
|
|
||||||
const { canceled, filePaths } = await requestOpenFilePickingDialog({
|
|
||||||
defaultPath: directoryForDownloads,
|
|
||||||
properties: ["openFile", "multiSelections"],
|
|
||||||
message: `Select extensions to install (formats: ${supportedExtensionFormats.join(", ")}), `,
|
|
||||||
buttonLabel: "Use configuration",
|
|
||||||
filters: [{ name: "tarball", extensions: supportedExtensionFormats }],
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!canceled) {
|
|
||||||
await attemptInstalls(filePaths);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const installFromSelectFileDialogInjectable = getInjectable({
|
const installFromSelectFileDialogInjectable = getInjectable({
|
||||||
id: "install-from-select-file-dialog",
|
id: "install-from-select-file-dialog",
|
||||||
|
|
||||||
instantiate: (di) => installFromSelectFileDialog({
|
instantiate: (di): InstallFromSelectFileDialog => {
|
||||||
attemptInstalls: di.inject(attemptInstallsInjectable),
|
const attemptInstalls = di.inject(attemptInstallsInjectable);
|
||||||
directoryForDownloads: di.inject(directoryForDownloadsInjectable),
|
const directoryForDownloads = di.inject(directoryForDownloadsInjectable);
|
||||||
}),
|
const openPathPickingDialog = di.inject(openPathPickingDialogInjectable);
|
||||||
|
|
||||||
|
return () => openPathPickingDialog({
|
||||||
|
defaultPath: directoryForDownloads,
|
||||||
|
properties: ["openFile", "multiSelections"],
|
||||||
|
message: `Select extensions to install (formats: ${supportedExtensionFormats.join(", ")}), `,
|
||||||
|
buttonLabel: "Use configuration",
|
||||||
|
filters: [{ name: "tarball", extensions: supportedExtensionFormats }],
|
||||||
|
onPick: attemptInstalls,
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default installFromSelectFileDialogInjectable;
|
export default installFromSelectFileDialogInjectable;
|
||||||
|
|||||||
@ -14,8 +14,8 @@ import { Button } from "../button";
|
|||||||
|
|
||||||
export interface PathPickOpts {
|
export interface PathPickOpts {
|
||||||
message: string;
|
message: string;
|
||||||
onPick?: (paths: string[]) => any;
|
onPick?: (paths: string[]) => void | Promise<void>;
|
||||||
onCancel?: () => any;
|
onCancel?: () => void | Promise<void>;
|
||||||
defaultPath?: string;
|
defaultPath?: string;
|
||||||
buttonLabel?: string;
|
buttonLabel?: string;
|
||||||
filters?: FileFilter[];
|
filters?: FileFilter[];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user