-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10808 from Budibase/undo_wrong_merge_from_develop
Revert "Merge branch 'develop' into master"
- Loading branch information
Showing
9 changed files
with
212 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 20 additions & 87 deletions
107
...lder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,43 @@ | ||
<script> | ||
import { | ||
ModalContent, | ||
Body, | ||
Layout, | ||
Link, | ||
notifications, | ||
} from "@budibase/bbui" | ||
import { IntegrationNames, IntegrationTypes } from "constants/backend" | ||
import { ModalContent, Body, Layout, Link } from "@budibase/bbui" | ||
import { IntegrationNames } from "constants/backend" | ||
import cloneDeep from "lodash/cloneDeepWith" | ||
import GoogleButton from "../_components/GoogleButton.svelte" | ||
import { saveDatasource as save } from "builderStore/datasource" | ||
import { organisation } from "stores/portal" | ||
import { onMount } from "svelte" | ||
import { validateDatasourceConfig } from "builderStore/datasource" | ||
import cloneDeep from "lodash/cloneDeepWith" | ||
import IntegrationConfigForm from "../TableIntegrationMenu/IntegrationConfigForm.svelte" | ||
import { goto } from "@roxi/routify" | ||
import { saveDatasource } from "builderStore/datasource" | ||
import { DatasourceFeature } from "@budibase/types" | ||
export let integration | ||
export let continueSetupId = false | ||
// kill the reference so the input isn't saved | ||
let datasource = cloneDeep(integration) | ||
datasource.config.continueSetupId = continueSetupId | ||
$: isGoogleConfigured = !!$organisation.googleDatasourceConfigured | ||
onMount(async () => { | ||
await organisation.init() | ||
}) | ||
const integrationName = IntegrationNames[IntegrationTypes.GOOGLE_SHEETS] | ||
export const GoogleDatasouceConfigStep = { | ||
AUTH: "Auth", | ||
SET_URL: "Set_url", | ||
} | ||
let step = continueSetupId | ||
? GoogleDatasouceConfigStep.SET_URL | ||
: GoogleDatasouceConfigStep.AUTH | ||
let isValid = false | ||
const modalConfig = { | ||
[GoogleDatasouceConfigStep.AUTH]: {}, | ||
[GoogleDatasouceConfigStep.SET_URL]: { | ||
confirmButtonText: "Connect", | ||
onConfirm: async () => { | ||
if (integration.features[DatasourceFeature.CONNECTION_CHECKING]) { | ||
const resp = await validateDatasourceConfig(datasource) | ||
if (!resp.connected) { | ||
notifications.error(`Unable to connect - ${resp.error}`) | ||
return false | ||
} | ||
} | ||
try { | ||
const resp = await saveDatasource(datasource) | ||
$goto(`./datasource/${resp._id}`) | ||
notifications.success(`Datasource created successfully.`) | ||
} catch (err) { | ||
notifications.error(err?.message ?? "Error saving datasource") | ||
// prevent the modal from closing | ||
return false | ||
} | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<ModalContent | ||
title={`Connect to ${integrationName}`} | ||
cancelText="Cancel" | ||
title={`Connect to ${IntegrationNames[datasource.type]}`} | ||
cancelText="Back" | ||
size="L" | ||
confirmText={modalConfig[step].confirmButtonText} | ||
showConfirmButton={!!modalConfig[step].onConfirm} | ||
onConfirm={modalConfig[step].onConfirm} | ||
disabled={!isValid} | ||
> | ||
{#if step === GoogleDatasouceConfigStep.AUTH} | ||
<!-- check true and false directly, don't render until flag is set --> | ||
{#if isGoogleConfigured === true} | ||
<Layout noPadding> | ||
<Body size="S" | ||
>Authenticate with your google account to use the {integrationName} integration.</Body | ||
> | ||
</Layout> | ||
<GoogleButton samePage /> | ||
{:else if isGoogleConfigured === false} | ||
<!-- check true and false directly, don't render until flag is set --> | ||
{#if isGoogleConfigured === true} | ||
<Layout noPadding> | ||
<Body size="S" | ||
>Google authentication is not enabled, please complete Google SSO | ||
configuration.</Body | ||
>Authenticate with your google account to use the {IntegrationNames[ | ||
datasource.type | ||
]} integration.</Body | ||
> | ||
<Link href="/builder/portal/settings/auth">Configure Google SSO</Link> | ||
{/if} | ||
{/if} | ||
{#if step === GoogleDatasouceConfigStep.SET_URL} | ||
<Layout noPadding no> | ||
<Body size="S">Add the URL of the sheet you want to connect.</Body> | ||
<IntegrationConfigForm | ||
schema={datasource.schema} | ||
bind:datasource | ||
creating={true} | ||
on:valid={e => (isValid = e.detail)} | ||
/> | ||
</Layout> | ||
<GoogleButton preAuthStep={() => save(datasource, true)} /> | ||
{:else if isGoogleConfigured === false} | ||
<Body size="S" | ||
>Google authentication is not enabled, please complete Google SSO | ||
configuration.</Body | ||
> | ||
<Link href="/builder/portal/settings/auth">Configure Google SSO</Link> | ||
{/if} | ||
</ModalContent> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.