mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 08:58:26 +00:00
Add action to set localStorage value (#1280)
* Add action to set localStorage value * Apply spacing between key and value of set localstorage action
This commit is contained in:
parent
e3087f737d
commit
afa5dfc00d
3 changed files with 41 additions and 0 deletions
|
|
@ -37,4 +37,12 @@ export const ActionTypes = [
|
|||
id: 'copy-to-clipboard',
|
||||
options: [{ name: 'copy-to-clipboard', type: 'text', default: '' }],
|
||||
},
|
||||
{
|
||||
name: 'Set local storage',
|
||||
id: 'set-localstorage-value',
|
||||
options: [
|
||||
{ name: 'key', type: 'code', default: '' },
|
||||
{ name: 'value', type: 'code', default: '' },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -266,6 +266,33 @@ export const EventManager = ({
|
|||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{event.actionId === 'set-localstorage-value' && (
|
||||
<>
|
||||
<div className="row">
|
||||
<div className="col-3 p-2">Key</div>
|
||||
<div className="col-9">
|
||||
<CodeHinter
|
||||
currentState={currentState}
|
||||
initialValue={event.key}
|
||||
onChange={(value) => handlerChanged(index, 'key', value)}
|
||||
enablePreview={true}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row mt-3">
|
||||
<div className="col-3 p-2">Value</div>
|
||||
<div className="col-9">
|
||||
<CodeHinter
|
||||
currentState={currentState}
|
||||
initialValue={event.value}
|
||||
onChange={(value) => handlerChanged(index, 'value', value)}
|
||||
enablePreview={true}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</Popover.Content>
|
||||
</Popover>
|
||||
|
|
|
|||
|
|
@ -188,6 +188,12 @@ function executeAction(_ref, event, mode) {
|
|||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
case 'set-localstorage-value': {
|
||||
const key = resolveReferences(event.key, _ref.state.currentState);
|
||||
const value = resolveReferences(event.value, _ref.state.currentState);
|
||||
localStorage.setItem(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue