mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix pick paths import type error and simplify signature
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
bae2aa0884
commit
a81873fe52
@ -4,18 +4,21 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { FileFilter } from "electron";
|
||||
import { requestOpenFilePickingDialog } from "../../../../../../../renderer/ipc";
|
||||
import openPathPickingDialogInjectable from "../../../../../../path-picking-dialog/renderer/pick-paths.injectable";
|
||||
|
||||
const getFilePathsInjectable = getInjectable({
|
||||
id: "get-file-paths",
|
||||
|
||||
instantiate: () => async (fileFilter: FileFilter) =>
|
||||
await requestOpenFilePickingDialog({
|
||||
instantiate: (di) => {
|
||||
const openPathPickingDialog = di.inject(openPathPickingDialogInjectable);
|
||||
|
||||
return async (fileFilter: FileFilter) => await openPathPickingDialog({
|
||||
properties: ["openFile", "showHiddenFiles"],
|
||||
message: `Select file`,
|
||||
buttonLabel: `Use file`,
|
||||
message: "Select file",
|
||||
buttonLabel: "Use file",
|
||||
filters: [fileFilter, { name: "Any", extensions: ["*"] }],
|
||||
}),
|
||||
});
|
||||
},
|
||||
|
||||
causesSideEffects: true,
|
||||
});
|
||||
|
||||
@ -15,11 +15,8 @@ const openPathPickingDialogInjectable = getInjectable({
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectable);
|
||||
|
||||
return async (options) => {
|
||||
const { onPick, onCancel, label, ...dialogOptions } = options;
|
||||
const response = await requestFromChannel(openPathPickingDialogChannel, {
|
||||
message: label,
|
||||
...dialogOptions,
|
||||
});
|
||||
const { onPick, onCancel, ...dialogOptions } = options;
|
||||
const response = await requestFromChannel(openPathPickingDialogChannel, dialogOptions);
|
||||
|
||||
if (response.canceled) {
|
||||
await onCancel?.();
|
||||
|
||||
@ -13,7 +13,7 @@ import { cssNames } from "../../utils";
|
||||
import { Button } from "../button";
|
||||
|
||||
export interface PathPickOpts {
|
||||
label: string;
|
||||
message: string;
|
||||
onPick?: (paths: string[]) => any;
|
||||
onCancel?: () => any;
|
||||
defaultPath?: string;
|
||||
@ -35,7 +35,6 @@ interface Dependencies {
|
||||
const NonInjectedPathPicker = observer((props: PathPickerProps & Dependencies) => {
|
||||
const {
|
||||
className,
|
||||
label,
|
||||
disabled,
|
||||
openPathPickingDialog,
|
||||
...pickOpts
|
||||
@ -44,13 +43,10 @@ const NonInjectedPathPicker = observer((props: PathPickerProps & Dependencies) =
|
||||
return (
|
||||
<Button
|
||||
primary
|
||||
label={label}
|
||||
label={pickOpts.message}
|
||||
disabled={disabled}
|
||||
className={cssNames("PathPicker", className)}
|
||||
onClick={() => void openPathPickingDialog({
|
||||
label,
|
||||
...pickOpts,
|
||||
})}
|
||||
onClick={() => void openPathPickingDialog(pickOpts)}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user