summaryrefslogtreecommitdiff
path: root/frontend/src/plugin-loader.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/plugin-loader.tsx')
-rw-r--r--frontend/src/plugin-loader.tsx36
1 files changed, 35 insertions, 1 deletions
diff --git a/frontend/src/plugin-loader.tsx b/frontend/src/plugin-loader.tsx
index c4063557..8190fbc4 100644
--- a/frontend/src/plugin-loader.tsx
+++ b/frontend/src/plugin-loader.tsx
@@ -14,7 +14,7 @@ import { FaExclamationCircle, FaPlug } from 'react-icons/fa';
import { DeckyState, DeckyStateContextProvider, UserInfo, useDeckyState } from './components/DeckyState';
import LegacyPlugin from './components/LegacyPlugin';
-import { File } from './components/modals/filepicker';
+import { File, FileSelectionType } from './components/modals/filepicker';
import { deinitFilepickerPatches, initFilepickerPatches } from './components/modals/filepicker/patches';
import MultiplePluginsInstallModal from './components/modals/MultiplePluginsInstallModal';
import PluginInstallModal from './components/modals/PluginInstallModal';
@@ -361,6 +361,38 @@ class PluginLoader extends Logger {
openFilePicker(
startPath: string,
+ selectFiles?: boolean,
+ regex?: RegExp,
+ ): Promise<{ path: string; realpath: string }> {
+ if (selectFiles) {
+ return this.openFilePickerV2(
+ startPath,
+ true,
+ regex,
+ true,
+ undefined,
+ undefined,
+ undefined,
+ undefined,
+ FileSelectionType.FILE,
+ );
+ } else {
+ return this.openFilePickerV2(
+ startPath,
+ false,
+ regex,
+ true,
+ undefined,
+ undefined,
+ undefined,
+ undefined,
+ FileSelectionType.FOLDER,
+ );
+ }
+ }
+
+ openFilePickerV2(
+ startPath: string,
includeFiles?: boolean,
filter?: RegExp | ((file: File) => boolean),
includeFolders?: boolean,
@@ -368,6 +400,7 @@ class PluginLoader extends Logger {
showHiddenFiles?: boolean,
allowAllFiles?: boolean,
max?: number,
+ select?: FileSelectionType,
): Promise<{ path: string; realpath: string }> {
return new Promise((resolve, reject) => {
const Content = ({ closeModal }: { closeModal?: () => void }) => (
@@ -389,6 +422,7 @@ class PluginLoader extends Logger {
defaultHidden={showHiddenFiles}
onSubmit={resolve}
closeModal={closeModal}
+ fileSelType={select}
max={max}
/>
</WithSuspense>