Convert IntegrationForm to use Layout component

This commit is contained in:
Keviin Åberg Kultalahti 2021-04-28 14:33:40 +02:00
parent 4c776f68f2
commit 6beb6c4f44
3 changed files with 58 additions and 54 deletions

View File

@ -1,34 +1,33 @@
<script> <script>
import { Label, Input, Spacer } from "@budibase/bbui" import { Label, Input, Layout } from "@budibase/bbui"
import KeyValueBuilder from "components/integration/KeyValueBuilder.svelte" import KeyValueBuilder from "components/integration/KeyValueBuilder.svelte"
import { capitalise } from "../../../../helpers" import { capitalise } from "../../../../helpers"
export let integration export let integration
export let schema export let schema
let unsaved = false
</script> </script>
<form> <form>
{#each Object.keys(schema) as configKey} <Layout gap="S">
{#if schema[configKey].type === "object"} {#each Object.keys(schema) as configKey}
<Label>{capitalise(configKey)}</Label> {#if schema[configKey].type === "object"}
<Spacer small />
<KeyValueBuilder
defaults={schema[configKey].default}
bind:object={integration[configKey]}
/>
{:else}
<div class="form-row">
<Label>{capitalise(configKey)}</Label> <Label>{capitalise(configKey)}</Label>
<Input <KeyValueBuilder
type={schema[configKey].type} defaults={schema[configKey].default}
on:change bind:object={integration[configKey]}
bind:value={integration[configKey]}
/> />
</div> {:else}
{/if} <div class="form-row">
{/each} <Label>{capitalise(configKey)}</Label>
<Input
type={schema[configKey].type}
on:change
bind:value={integration[configKey]}
/>
</div>
{/if}
{/each}
</Layout>
</form> </form>
<style> <style>
@ -37,6 +36,5 @@
grid-template-columns: 20% 1fr; grid-template-columns: 20% 1fr;
grid-gap: var(--spacing-l); grid-gap: var(--spacing-l);
align-items: center; align-items: center;
margin-bottom: var(--spacing-m);
} }
</style> </style>

View File

@ -1,7 +1,13 @@
<script> <script>
import { flip } from "svelte/animate" import { flip } from "svelte/animate"
import { dndzone } from "svelte-dnd-action" import { dndzone } from "svelte-dnd-action"
import { Icon, Button, Popover, Spacer } from "@budibase/bbui" import {
Icon,
Button,
Popover,
Spacer,
DrawerContentWithSidebar,
} from "@budibase/bbui"
import actionTypes from "./actions" import actionTypes from "./actions"
import { generate } from "shortid" import { generate } from "shortid"
@ -68,8 +74,8 @@
} }
</script> </script>
<div class="actions-container"> <DrawerContentWithSidebar>
<div class="actions-list"> <div class="actions-list" slot="sidebar">
<div> <div>
<div bind:this={addActionButton}> <div bind:this={addActionButton}>
<Button wide secondary on:click={addActionDropdown.show}> <Button wide secondary on:click={addActionDropdown.show}>
@ -127,6 +133,8 @@
</div> </div>
{/if} {/if}
</div> </div>
</DrawerContentWithSidebar>
<div class="actions-container">
<div class="action-config"> <div class="action-config">
{#if selectedAction} {#if selectedAction}
<div class="selected-action-container"> <div class="selected-action-container">

View File

@ -1,6 +1,6 @@
<script> <script>
import { goto, beforeUrlChange } from "@roxi/routify" import { goto, beforeUrlChange } from "@roxi/routify"
import { Button, Heading, Body, Spacer, Divider } from "@budibase/bbui" import { Button, Heading, Body, Divider, Layout } from "@budibase/bbui"
import { datasources, integrations, queries } from "stores/backend" import { datasources, integrations, queries } from "stores/backend"
import { notifications } from "@budibase/bbui" import { notifications } from "@budibase/bbui"
import IntegrationConfigForm from "components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte" import IntegrationConfigForm from "components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte"
@ -43,39 +43,36 @@
{#if datasource} {#if datasource}
<section> <section>
<Spacer extraLarge /> <Layout>
<header> <header>
<svelte:component <svelte:component
this={ICONS[datasource.source]} this={ICONS[datasource.source]}
height="26" height="26"
width="26" width="26"
/> />
<Heading m>{datasource.name}</Heading> <Heading m>{datasource.name}</Heading>
</header> </header>
<Body small grey lh>{integration.description}</Body> <Body small grey lh>{integration.description}</Body>
<Spacer extraLarge /> <Divider />
<Divider /> <div class="container">
<Spacer extraLarge /> <div class="config-header">
<div class="container"> <Heading s>Configuration</Heading>
<div class="config-header"> <Button secondary on:click={saveDatasource}>Save</Button>
<Heading s>Configuration</Heading> </div>
<Button secondary on:click={saveDatasource}>Save</Button> <Body size="S"
</div> >Connect your database to Budibase using the config below.</Body
<Body s>Connect your database to Budibase using the config below.</Body> >
<Spacer extraLarge /> <IntegrationConfigForm
<IntegrationConfigForm schema={integration.datasource}
schema={integration.datasource} integration={datasource.config}
integration={datasource.config} on:change={setUnsaved}
on:change={setUnsaved} />
/> </div>
<Spacer extraLarge />
<Divider /> <Divider />
<Spacer extraLarge />
<div class="query-header"> <div class="query-header">
<Heading s>Queries</Heading> <Heading s>Queries</Heading>
<Button secondary on:click={() => $goto("./new")}>Add Query</Button> <Button secondary on:click={() => $goto("./new")}>Add Query</Button>
</div> </div>
<Spacer extraLarge />
<div class="query-list"> <div class="query-list">
{#each $queries.list.filter((query) => query.datasourceId === datasource._id) as query} {#each $queries.list.filter((query) => query.datasourceId === datasource._id) as query}
<div class="query-list-item" on:click={() => onClickQuery(query)}> <div class="query-list-item" on:click={() => onClickQuery(query)}>
@ -85,7 +82,7 @@
</div> </div>
{/each} {/each}
</div> </div>
</div> </Layout>
</section> </section>
{/if} {/if}
@ -109,6 +106,7 @@
} }
.container { .container {
width: 100%;
border-radius: var(--border-radius-m); border-radius: var(--border-radius-m);
margin: 0 auto; margin: 0 auto;
} }