Open continue

This commit is contained in:
Adria Navarro 2023-05-31 11:24:06 +02:00
parent 3a6a3eb8a5
commit d4ba73f331
3 changed files with 51 additions and 23 deletions

View File

@ -88,7 +88,7 @@ export async function postAuth(
} }
) )
ctx.redirect(`${baseUrl}/new?type=google&action=continue&id=${id}`) ctx.redirect(`${baseUrl}/new?action=google_continue&id=${id}`)
} }
)(ctx, next) )(ctx, next)
} }

View File

@ -1,35 +1,41 @@
<script> <script>
import { ModalContent, Body, Layout, Link } from "@budibase/bbui" import { ModalContent, Body, Layout, Link } from "@budibase/bbui"
import { IntegrationNames } from "constants/backend" import { IntegrationNames, IntegrationTypes } from "constants/backend"
import cloneDeep from "lodash/cloneDeepWith"
import GoogleButton from "../_components/GoogleButton.svelte" import GoogleButton from "../_components/GoogleButton.svelte"
import { organisation } from "stores/portal" import { organisation } from "stores/portal"
import { onMount } from "svelte" import { onMount } from "svelte"
export let integration export let continueSetup = false
// kill the reference so the input isn't saved
let datasource = cloneDeep(integration)
$: isGoogleConfigured = !!$organisation.googleDatasourceConfigured $: isGoogleConfigured = !!$organisation.googleDatasourceConfigured
onMount(async () => { onMount(async () => {
await organisation.init() await organisation.init()
}) })
const integrationName = IntegrationNames[IntegrationTypes.GOOGLE_SHEETS]
export const GoogleDatasouceConfigStep = {
AUTH: "Auth",
SET_URL: "Set_url",
}
let step = continueSetup
? GoogleDatasouceConfigStep.SET_URL
: GoogleDatasouceConfigStep.AUTH
</script> </script>
<ModalContent <ModalContent
title={`Connect to ${IntegrationNames[datasource.type]}`} title={`Connect to ${integrationName}`}
cancelText="Back" cancelText="Back"
size="L" size="L"
showConfirmButton={false} showConfirmButton={false}
> >
{#if step === GoogleDatasouceConfigStep.AUTH}
<!-- check true and false directly, don't render until flag is set --> <!-- check true and false directly, don't render until flag is set -->
{#if isGoogleConfigured === true} {#if isGoogleConfigured === true}
<Layout noPadding> <Layout noPadding>
<Body size="S" <Body size="S"
>Authenticate with your google account to use the {IntegrationNames[ >Authenticate with your google account to use the {integrationName} integration.</Body
datasource.type
]} integration.</Body
> >
</Layout> </Layout>
<GoogleButton samePage /> <GoogleButton samePage />
@ -40,4 +46,10 @@
> >
<Link href="/builder/portal/settings/auth">Configure Google SSO</Link> <Link href="/builder/portal/settings/auth">Configure Google SSO</Link>
{/if} {/if}
{/if}
{#if step === GoogleDatasouceConfigStep.SET_URL}
<Layout noPadding>
<Body size="S">Add the URL of the sheet you want to connect</Body>
</Layout>
{/if}
</ModalContent> </ModalContent>

View File

@ -17,6 +17,7 @@
import IntegrationIcon from "components/backend/DatasourceNavigator/IntegrationIcon.svelte" import IntegrationIcon from "components/backend/DatasourceNavigator/IntegrationIcon.svelte"
import ICONS from "components/backend/DatasourceNavigator/icons/index.js" import ICONS from "components/backend/DatasourceNavigator/icons/index.js"
import FontAwesomeIcon from "components/common/FontAwesomeIcon.svelte" import FontAwesomeIcon from "components/common/FontAwesomeIcon.svelte"
import { onMount } from "svelte"
let internalTableModal let internalTableModal
let externalDatasourceModal let externalDatasourceModal
@ -24,6 +25,7 @@
let integration = null let integration = null
let disabled = false let disabled = false
let promptUpload = false let promptUpload = false
let continueGoogleSetup
$: hasData = $datasources.list.length > 1 || $tables.list.length > 1 $: hasData = $datasources.list.length > 1 || $tables.list.length > 1
$: hasDefaultData = $: hasDefaultData =
@ -135,15 +137,29 @@
} }
$: fetchIntegrations() $: fetchIntegrations()
onMount(() => {
const urlParams = new URLSearchParams(window.location.search)
const action = urlParams.get("action")
if (action === "google_continue") {
continueGoogleSetup = true
externalDatasourceModal.show()
}
})
</script> </script>
<Modal bind:this={internalTableModal}> <Modal bind:this={internalTableModal}>
<CreateTableModal {promptUpload} afterSave={handleInternalTableSave} /> <CreateTableModal {promptUpload} afterSave={handleInternalTableSave} />
</Modal> </Modal>
<Modal bind:this={externalDatasourceModal}> <Modal
{#if integration?.auth?.type === "google"} bind:this={externalDatasourceModal}
<GoogleDatasourceConfigModal {integration} /> on:hide={() => {
continueGoogleSetup = false
}}
>
{#if integration?.auth?.type === "google" || continueGoogleSetup}
<GoogleDatasourceConfigModal continueSetup={continueGoogleSetup} />
{:else} {:else}
<DatasourceConfigModal {integration} /> <DatasourceConfigModal {integration} />
{/if} {/if}