Add button action for manually refreshing a data provider

This commit is contained in:
Andrew Kingston 2021-09-23 19:34:01 +01:00
parent 9cbf830a92
commit 78e4f00e11
4 changed files with 43 additions and 2 deletions

View File

@ -0,0 +1,35 @@
<script>
import { Select, Label, Checkbox } from "@budibase/bbui"
import { currentAsset, store } from "builderStore"
import { getActionProviderComponents } from "builderStore/dataBinding"
export let parameters
$: actionProviders = getActionProviderComponents(
$currentAsset,
$store.selectedComponentId,
"RefreshDataProvider"
)
</script>
<div class="root">
<Label small>Data Provider</Label>
<Select
bind:value={parameters.componentId}
options={actionProviders}
getOptionLabel={x => x._instanceName}
getOptionValue={x => x._id}
/>
</div>
<style>
.root {
display: grid;
column-gap: var(--spacing-l);
row-gap: var(--spacing-s);
grid-template-columns: 70px 1fr;
align-items: center;
max-width: 400px;
margin: 0 auto;
}
</style>

View File

@ -12,6 +12,7 @@ import ClearForm from "./ClearForm.svelte"
import CloseScreenModal from "./CloseScreenModal.svelte" import CloseScreenModal from "./CloseScreenModal.svelte"
import ChangeFormStep from "./ChangeFormStep.svelte" import ChangeFormStep from "./ChangeFormStep.svelte"
import UpdateStateStep from "./UpdateState.svelte" import UpdateStateStep from "./UpdateState.svelte"
import RefreshDataProvider from "./RefreshDataProvider.svelte"
// Defines which actions are available to configure in the front end. // Defines which actions are available to configure in the front end.
// Unfortunately the "name" property is used as the identifier so please don't // Unfortunately the "name" property is used as the identifier so please don't
@ -62,6 +63,10 @@ export const getAvailableActions = () => {
name: "Change Form Step", name: "Change Form Step",
component: ChangeFormStep, component: ChangeFormStep,
}, },
{
name: "Refresh Data Provider",
component: RefreshDataProvider,
},
] ]
if (get(store).clientFeatures?.state) { if (get(store).clientFeatures?.state) {

View File

@ -2389,6 +2389,7 @@
"icon": "Data", "icon": "Data",
"illegalChildren": ["section"], "illegalChildren": ["section"],
"hasChildren": true, "hasChildren": true,
"actions": ["RefreshDatasource"],
"settings": [ "settings": [
{ {
"type": "dataSource", "type": "dataSource",

View File

@ -88,7 +88,7 @@ const validateFormHandler = async (action, context) => {
) )
} }
const refreshDatasourceHandler = async (action, context) => { const refreshDataProviderHandler = async (action, context) => {
return await executeActionHandler( return await executeActionHandler(
context, context,
action.parameters.componentId, action.parameters.componentId,
@ -139,7 +139,7 @@ const handlerMap = {
["Execute Query"]: queryExecutionHandler, ["Execute Query"]: queryExecutionHandler,
["Trigger Automation"]: triggerAutomationHandler, ["Trigger Automation"]: triggerAutomationHandler,
["Validate Form"]: validateFormHandler, ["Validate Form"]: validateFormHandler,
["Refresh Datasource"]: refreshDatasourceHandler, ["Refresh Data Provider"]: refreshDataProviderHandler,
["Log Out"]: logoutHandler, ["Log Out"]: logoutHandler,
["Clear Form"]: clearFormHandler, ["Clear Form"]: clearFormHandler,
["Close Screen Modal"]: closeScreenModalHandler, ["Close Screen Modal"]: closeScreenModalHandler,