1
0
Fork 0
mirror of synced 2024-06-16 09:25:12 +12:00
This commit is contained in:
mike12345567 2021-01-14 17:02:05 +00:00
parent 0c66d9fca4
commit 29424e59c0
11 changed files with 84 additions and 60 deletions

View file

@ -1,5 +1,5 @@
import { writable } from "svelte/store"
import api, {get} from "../api"
import api, { get } from "../api"
const INITIAL_HOSTING_UI_STATE = {
hostingInfo: {},
@ -45,7 +45,7 @@ export const getHostingStore = () => {
return state
})
return deployments
}
},
}
return store
}

View file

@ -50,7 +50,10 @@
function addBlockToAutomation(stepId, blockDefinition) {
const newBlock = $automationStore.selectedAutomation.constructBlock(
selectedTab, stepId, blockDefinition)
selectedTab,
stepId,
blockDefinition
)
automationStore.actions.addBlockToAutomation(newBlock)
closePopover()
if (stepId === "WEBHOOK") {

View file

@ -36,9 +36,7 @@
</script>
<div class="root">
<div class="add-field">
<i class="ri-add-line" on:click={addField} />
</div>
<div class="add-field"><i class="ri-add-line" on:click={addField} /></div>
<div class="spacer" />
{#each fieldsArray as field}
<div class="field">
@ -57,13 +55,11 @@
<option>datetime</option>
</Select>
<i class="remove-field ri-delete-bin-line"
<i
class="remove-field ri-delete-bin-line"
on:click={() => removeField(field.name)} />
</div>
{/each}
</div>
<style>
@ -105,7 +101,8 @@
}
.field :global(input) {
padding: var(--spacing-m) var(--spacing-xl) var(--spacing-xs) var(--spacing-m);
padding: var(--spacing-m) var(--spacing-xl) var(--spacing-xs)
var(--spacing-m);
font-size: var(--font-size-s);
font-weight: bold;
}
@ -129,5 +126,4 @@
.add-field > i {
cursor: pointer;
}
</style>

View file

@ -36,7 +36,8 @@
let errorReason
let poll
let deployments = []
let urlComponent = $hostingStore.hostingInfo.type === "self" ? $store.url : `/${appId}`
let urlComponent =
$hostingStore.hostingInfo.type === "self" ? $store.url : `/${appId}`
let deploymentUrl = `${$hostingStore.appUrl}${urlComponent}`
const formatDate = (date, format) =>

View file

@ -2,7 +2,7 @@
import { Input, TextArea } from "@budibase/bbui"
import { store, hostingStore } from "builderStore"
import api from "builderStore/api"
import {object, string} from "yup"
import { object, string } from "yup"
import { onMount } from "svelte"
import { get } from "svelte/store"
@ -47,7 +47,8 @@
}
onMount(async () => {
const nameError = "Your application must have a name.", urlError = "Your application must have a URL."
const nameError = "Your application must have a name.",
urlError = "Your application must have a URL."
let hostingInfo = await hostingStore.actions.fetch()
if (hostingInfo.type === "self") {
await hostingStore.actions.fetchDeployedApps()
@ -55,8 +56,16 @@
const existingAppUrls = get(hostingStore).deployedAppUrls
existingAppNames.splice(existingAppNames.indexOf(get(store).name), 1)
existingAppUrls.splice(existingAppUrls.indexOf(get(store).url), 1)
nameValidation = { name: string().required(nameError).notOneOf(existingAppNames) }
urlValidation = { url: string().required(urlError).notOneOf(existingAppUrls) }
nameValidation = {
name: string()
.required(nameError)
.notOneOf(existingAppNames),
}
urlValidation = {
url: string()
.required(urlError)
.notOneOf(existingAppUrls),
}
} else {
nameValidation = { name: string.required(nameError) }
}
@ -71,7 +80,7 @@
bind:value={$store.name}
bind:error={nameError}
label="App Name" />
{#if $hostingStore.hostingInfo.type === "self"}
{#if $hostingStore.hostingInfo.type === 'self'}
<Input
on:save={e => updateApplication({ url: e.detail })}
thin

View file

@ -84,7 +84,9 @@
if (hostingInfo.type === "self") {
await hostingStore.actions.fetchDeployedApps()
const existingAppNames = svelteGet(hostingStore).deployedAppNames
infoValidation.applicationName = string().required("Your application must have a name.").notOneOf(existingAppNames)
infoValidation.applicationName = string()
.required("Your application must have a name.")
.notOneOf(existingAppNames)
isApiKeyValid = true
steps = [buildStep(Info), buildStep(User)]
validationSchemas = [infoValidation, userValidation]

View file

@ -47,32 +47,36 @@
await createAutomation(action.parameters)
}
}
dispatch("change", actions)
dispatch("change", actions)
}
// called by the parent modal when actions are saved
// called by the parent modal when actions are saved
const createAutomation = async parameters => {
if (parameters.automationId || !parameters.newAutomationName) return
await automationStore.actions.create({name: parameters.newAutomationName})
await automationStore.actions.create({ name: parameters.newAutomationName })
const appActionDefinition = $automationStore.blockDefinitions.TRIGGER.APP
const newBlock = $automationStore.selectedAutomation.constructBlock(
"TRIGGER", "APP", appActionDefinition)
"TRIGGER",
"APP",
appActionDefinition
)
newBlock.inputs = {
fields: Object.entries(parameters.fields).reduce((fields, [key, value]) => {
fields[key] = value.type
return fields
}, {})
fields: Object.entries(parameters.fields).reduce(
(fields, [key, value]) => {
fields[key] = value.type
return fields
},
{}
),
}
automationStore.actions.addBlockToAutomation(newBlock)
await automationStore.actions.save(
$automationStore.selectedAutomation)
await automationStore.actions.save($automationStore.selectedAutomation)
parameters.automationId = $automationStore.selectedAutomation.automation._id
delete parameters.newAutomationName

View file

@ -1,6 +1,13 @@
<script>
// accepts an array of field names, and outputs an object of { FieldName: value }
import { DataList, Label, TextButton, Spacer, Select, Input } from "@budibase/bbui"
import {
DataList,
Label,
TextButton,
Spacer,
Select,
Input,
} from "@budibase/bbui"
import { store, backendUiStore, currentAsset } from "builderStore"
import fetchBindableProperties from "builderStore/fetchBindableProperties"
import { CloseCircleIcon, AddIcon } from "components/common/Icons"
@ -14,7 +21,7 @@
export let parameterFields
export let schemaFields
export let fieldLabel="Column"
export let fieldLabel = "Column"
const emptyField = () => ({ name: "", value: "" })
@ -60,7 +67,9 @@
// value and type is needed by the client, so it can parse
// a string into a correct type
newParameterFields[field.name] = {
type: schemaFields ? schemaFields.find(f => f.name === field.name).type : "string",
type: schemaFields
? schemaFields.find(f => f.name === field.name).type
: "string",
value: readableToRuntimeBinding(bindableProperties, field.value),
}
}
@ -83,7 +92,7 @@
{/each}
</Select>
{:else}
<Input secondary bind:value={field.name} on:blur={rebuildParameters}/>
<Input secondary bind:value={field.name} on:blur={rebuildParameters} />
{/if}
<Label size="m" color="dark">Value</Label>
<DataList secondary bind:value={field.value} on:blur={rebuildParameters}>
@ -105,7 +114,8 @@
<Spacer small />
<TextButton text small blue on:click={addField}>
Add {fieldLabel}
Add
{fieldLabel}
<div style="height: 20px; width: 20px;">
<AddIcon />
</div>

View file

@ -41,53 +41,53 @@
newOrExisting = "existing"
parameters.newAutomationName = ""
}
</script>
<div class="root">
<div class="radio-container" on:click={setNew}>
<input
type="radio"
value="new"
<input
type="radio"
value="new"
bind:group={newOrExisting}
disabled={!hasAutomations}>
<Label disabled={!hasAutomations}>Create a new automation </Label>
disabled={!hasAutomations} />
<Label disabled={!hasAutomations}>Create a new automation</Label>
</div>
<div class="radio-container" on:click={setExisting}>
<input
type="radio"
value="existing"
<input
type="radio"
value="existing"
bind:group={newOrExisting}
disabled={!hasAutomations}>
<Label disabled={!hasAutomations}>Use an existing automation </Label>
disabled={!hasAutomations} />
<Label disabled={!hasAutomations}>Use an existing automation</Label>
</div>
<Label size="m" color="dark">Automation</Label>
{#if newOrExisting=== "existing"}
<Select secondary bind:value={parameters.automationId} placeholder="Choose automation">
{#if newOrExisting === 'existing'}
<Select
secondary
bind:value={parameters.automationId}
placeholder="Choose automation">
<option value="" />
{#each automations as automation}
<option value={automation._id}>{automation.name}</option>
{/each}
</Select>
{:else}
<Input secondary bind:value={parameters.newAutomationName} placeholder="Enter automation name" />
<Input
secondary
bind:value={parameters.newAutomationName}
placeholder="Enter automation name" />
{/if}
<SaveFields
parameterFields={parameters.fields}
schemaFields={newOrExisting === "existing" && selectedAutomation && selectedAutomation.schema}
schemaFields={newOrExisting === 'existing' && selectedAutomation && selectedAutomation.schema}
fieldLabel="Field"
on:fieldschanged={onFieldsChanged} />
</div>
<style>
@ -127,5 +127,4 @@
.radio-container > input:focus {
outline: none;
}
</style>

View file

@ -5,7 +5,8 @@ const { join } = require("path")
const { homedir } = require("os")
// level option is purely for testing (development)
const COUCH_DB_URL = env.COUCH_DB_URL || `leveldb://${join(homedir(), ".budibase")}/.data/`
const COUCH_DB_URL =
env.COUCH_DB_URL || `leveldb://${join(homedir(), ".budibase")}/.data/`
const Pouch = PouchDB.defaults({
prefix: COUCH_DB_URL,
@ -13,4 +14,4 @@ const Pouch = PouchDB.defaults({
allDbs(Pouch)
module.exports = Pouch
module.exports = Pouch

View file

@ -2,8 +2,7 @@ const env = require("../environment")
module.exports = async (ctx, next) => {
const selfHostKey =
ctx.request.headers["x-budibase-auth"] ||
ctx.request.body.selfHostKey
ctx.request.headers["x-budibase-auth"] || ctx.request.body.selfHostKey
if (!selfHostKey || env.SELF_HOST_KEY !== selfHostKey) {
ctx.throw(401, "Request unauthorised")
} else {