From 4723743bf9047df45122e57fc4af31e32fe6d2fd Mon Sep 17 00:00:00 2001 From: Brandon Jordan Date: Fri, 26 Apr 2024 18:59:05 -0400 Subject: [PATCH] Add Get File From Folder action --- src/actions.ts | 2 ++ src/actions/get-file-from-folder.ts | 30 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/actions/get-file-from-folder.ts diff --git a/src/actions.ts b/src/actions.ts index 999b16e..bbbb74d 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -32,6 +32,7 @@ import GetDictionary from "~/actions/get-dictionary"; import GetDictionaryValue from "~/actions/get-dictionary-value"; import setDictionaryValue from "~/actions/set-dictionary-value"; import GetIpAddress from "~/actions/get-ip-address"; +import GetFileFromFolder from "~/actions/get-file-from-folder"; interface ActionDefinitions { [key: string]: ActionDefinition @@ -85,6 +86,7 @@ export let actions: ActionDefinitions = { 'getvalueforkey': GetDictionaryValue, 'setvalueforkey': setDictionaryValue, 'getipaddress': GetIpAddress, + 'documentpicker.open': GetFileFromFolder, }; export function actionText(value: string): HTMLElement { diff --git a/src/actions/get-file-from-folder.ts b/src/actions/get-file-from-folder.ts new file mode 100644 index 0000000..ecaf26a --- /dev/null +++ b/src/actions/get-file-from-folder.ts @@ -0,0 +1,30 @@ +import {renderActionHeader, renderParameters} from "~/render"; +import {actions, actionText} from "~/actions"; +import {renderValue} from "~/value"; + +interface GetIPAddress { + WFGetFilePath: string | object + WFFile: string | object + WFGetFolderContents: boolean + WFShowFilePicker: boolean + WFFileErrorIfNotFound: boolean +} + +export default { + title: "Get file from", + icon: 'house_fill', + render: (container: HTMLElement, params: GetIPAddress) => { + container.className += ' sp-blue-action'; + + const action = renderActionHeader(actions['documentpicker.open'], + renderValue(params.WFFile, 'Shortcuts'), + actionText('at path'), + renderValue(params.WFGetFilePath, 'example.txt'), + ); + action.appendChild(renderParameters(actions['documentpicker.open'], { + 'Error If Not Found': params.WFFileErrorIfNotFound, + })); + + return action; + } +}