Skip to content

Commit

Permalink
Add Get File From Folder action
Browse files Browse the repository at this point in the history
  • Loading branch information
electrikmilk committed Apr 26, 2024
1 parent fa57e67 commit 4723743
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -85,6 +86,7 @@ export let actions: ActionDefinitions = {
'getvalueforkey': GetDictionaryValue,
'setvalueforkey': setDictionaryValue,
'getipaddress': GetIpAddress,
'documentpicker.open': GetFileFromFolder,
};

export function actionText(value: string): HTMLElement {
Expand Down
30 changes: 30 additions & 0 deletions src/actions/get-file-from-folder.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 4723743

Please sign in to comment.