Merge remote-tracking branch 'origin/develop' into feature/templates-home-screen

This commit is contained in:
Dean 2022-03-29 09:05:18 +01:00
commit af19b41c2d
21 changed files with 101 additions and 87 deletions

View File

@ -110,6 +110,10 @@ spec:
value: {{ .Values.globals.cookieDomain | quote }} value: {{ .Values.globals.cookieDomain | quote }}
- name: HTTP_MIGRATIONS - name: HTTP_MIGRATIONS
value: {{ .Values.globals.httpMigrations | quote }} value: {{ .Values.globals.httpMigrations | quote }}
- name: GOOGLE_CLIENT_ID
value: {{ .Values.globals.google.clientId | quote }}
- name: GOOGLE_CLIENT_SECRET
value: {{ .Values.globals.google.secret | quote }}
image: budibase/apps:{{ .Values.globals.appVersion }} image: budibase/apps:{{ .Values.globals.appVersion }}
imagePullPolicy: Always imagePullPolicy: Always
name: bbapps name: bbapps

View File

@ -1,5 +1,5 @@
{ {
"version": "1.0.98-alpha.2", "version": "1.0.98-alpha.4",
"npmClient": "yarn", "npmClient": "yarn",
"packages": [ "packages": [
"packages/*" "packages/*"

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/backend-core", "name": "@budibase/backend-core",
"version": "1.0.98-alpha.2", "version": "1.0.98-alpha.4",
"description": "Budibase backend core libraries used in server and worker", "description": "Budibase backend core libraries used in server and worker",
"main": "src/index.js", "main": "src/index.js",
"author": "Budibase", "author": "Budibase",

View File

@ -1,15 +1,29 @@
const google = require("../google") const google = require("../google")
const { Cookies } = require("../../../constants") const { Cookies, Configs } = require("../../../constants")
const { clearCookie, getCookie } = require("../../../utils") const { clearCookie, getCookie } = require("../../../utils")
const { getDB } = require("../../../db") const { getDB } = require("../../../db")
const { getScopedConfig } = require("../../../db/utils")
const environment = require("../../../environment") const environment = require("../../../environment")
const { getGlobalDB } = require("../../../tenancy")
async function preAuth(passport, ctx, next) { async function fetchGoogleCreds() {
// get the relevant config // try and get the config from the tenant
const googleConfig = { const db = getGlobalDB()
const googleConfig = await getScopedConfig(db, {
type: Configs.GOOGLE,
})
// or fall back to env variables
const config = googleConfig || {
clientID: environment.GOOGLE_CLIENT_ID, clientID: environment.GOOGLE_CLIENT_ID,
clientSecret: environment.GOOGLE_CLIENT_SECRET, clientSecret: environment.GOOGLE_CLIENT_SECRET,
} }
return config
}
async function preAuth(passport, ctx, next) {
// get the relevant config
const googleConfig = await fetchGoogleCreds()
let callbackUrl = `${environment.PLATFORM_URL}/api/global/auth/datasource/google/callback` let callbackUrl = `${environment.PLATFORM_URL}/api/global/auth/datasource/google/callback`
const strategy = await google.strategyFactory(googleConfig, callbackUrl) const strategy = await google.strategyFactory(googleConfig, callbackUrl)
@ -26,10 +40,7 @@ async function preAuth(passport, ctx, next) {
async function postAuth(passport, ctx, next) { async function postAuth(passport, ctx, next) {
// get the relevant config // get the relevant config
const config = { const config = await fetchGoogleCreds()
clientID: environment.GOOGLE_CLIENT_ID,
clientSecret: environment.GOOGLE_CLIENT_SECRET,
}
let callbackUrl = `${environment.PLATFORM_URL}/api/global/auth/datasource/google/callback` let callbackUrl = `${environment.PLATFORM_URL}/api/global/auth/datasource/google/callback`
const strategy = await google.strategyFactory( const strategy = await google.strategyFactory(

View File

@ -51,7 +51,10 @@ exports.strategyFactory = async function (
) )
} catch (err) { } catch (err) {
console.error(err) console.error(err)
throw new Error("Error constructing google authentication strategy", err) throw new Error(
`Error constructing google authentication strategy: ${err}`,
err
)
} }
} }
// expose for testing // expose for testing

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/bbui", "name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.", "description": "A UI solution used in the different Budibase projects.",
"version": "1.0.98-alpha.2", "version": "1.0.98-alpha.4",
"license": "MPL-2.0", "license": "MPL-2.0",
"svelte": "src/index.js", "svelte": "src/index.js",
"module": "dist/bbui.es.js", "module": "dist/bbui.es.js",
@ -38,7 +38,7 @@
], ],
"dependencies": { "dependencies": {
"@adobe/spectrum-css-workflow-icons": "^1.2.1", "@adobe/spectrum-css-workflow-icons": "^1.2.1",
"@budibase/string-templates": "^1.0.98-alpha.2", "@budibase/string-templates": "^1.0.98-alpha.4",
"@spectrum-css/actionbutton": "^1.0.1", "@spectrum-css/actionbutton": "^1.0.1",
"@spectrum-css/actiongroup": "^1.0.1", "@spectrum-css/actiongroup": "^1.0.1",
"@spectrum-css/avatar": "^3.0.2", "@spectrum-css/avatar": "^3.0.2",

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/builder", "name": "@budibase/builder",
"version": "1.0.98-alpha.2", "version": "1.0.98-alpha.4",
"license": "GPL-3.0", "license": "GPL-3.0",
"private": true, "private": true,
"scripts": { "scripts": {
@ -65,10 +65,10 @@
} }
}, },
"dependencies": { "dependencies": {
"@budibase/bbui": "^1.0.98-alpha.2", "@budibase/bbui": "^1.0.98-alpha.4",
"@budibase/client": "^1.0.98-alpha.2", "@budibase/client": "^1.0.98-alpha.4",
"@budibase/frontend-core": "^1.0.98-alpha.2", "@budibase/frontend-core": "^1.0.98-alpha.4",
"@budibase/string-templates": "^1.0.98-alpha.2", "@budibase/string-templates": "^1.0.98-alpha.4",
"@sentry/browser": "5.19.1", "@sentry/browser": "5.19.1",
"@spectrum-css/page": "^3.0.1", "@spectrum-css/page": "^3.0.1",
"@spectrum-css/vars": "^3.0.1", "@spectrum-css/vars": "^3.0.1",

View File

@ -162,7 +162,7 @@
<Select <Select
on:change={e => onChange(e, key)} on:change={e => onChange(e, key)}
value={inputData[key]} value={inputData[key]}
options={Object.keys(table.schema)} options={Object.keys(table?.schema || {})}
/> />
{:else if value.customType === "filters"} {:else if value.customType === "filters"}
<ActionButton on:click={drawer.show}>Define filters</ActionButton> <ActionButton on:click={drawer.show}>Define filters</ActionButton>

View File

@ -1,5 +1,5 @@
<script> <script>
import { Input, Select } from "@budibase/bbui" import { Input, Select, Button } from "@budibase/bbui"
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
@ -62,9 +62,6 @@
</script> </script>
<div class="root"> <div class="root">
<div class="add-field">
<i class="ri-add-line" on:click={addField} />
</div>
<div class="spacer" /> <div class="spacer" />
{#each fieldsArray as field} {#each fieldsArray as field}
<div class="field"> <div class="field">
@ -88,6 +85,7 @@
/> />
</div> </div>
{/each} {/each}
<Button quiet secondary icon="Add" on:click={addField}>Add field</Button>
</div> </div>
<style> <style>
@ -103,52 +101,11 @@
.field { .field {
max-width: 100%; max-width: 100%;
background-color: var(--grey-2);
margin-bottom: var(--spacing-m); margin-bottom: var(--spacing-m);
border-style: solid;
border-width: 1px;
border-color: var(--grey-4);
display: grid; display: grid;
/*grid-template-rows: auto auto; grid-template-columns: 1fr 1fr auto;
grid-template-columns: auto;*/
position: relative; position: relative;
} align-items: center;
gap: var(--spacing-m);
.field :global(select) {
padding: var(--spacing-xs) 2rem var(--spacing-m) var(--spacing-s) !important;
font-size: var(--font-size-xs);
color: var(--grey-7);
}
.field :global(.pointer) {
padding-bottom: var(--spacing-m) !important;
color: var(--grey-2);
}
.field :global(input) {
padding: var(--spacing-m) var(--spacing-xl) var(--spacing-xs)
var(--spacing-m);
font-size: var(--font-size-s);
font-weight: bold;
}
.remove-field {
cursor: pointer;
color: var(--grey-6);
position: absolute;
top: var(--spacing-m);
right: 3px;
}
.remove-field:hover {
color: var(--black);
}
.add-field {
text-align: right;
}
.add-field > i {
cursor: pointer;
} }
</style> </style>

View File

@ -15,6 +15,7 @@
import ArrayRenderer from "components/common/renderers/ArrayRenderer.svelte" import ArrayRenderer from "components/common/renderers/ArrayRenderer.svelte"
import ConfirmDialog from "components/common/ConfirmDialog.svelte" import ConfirmDialog from "components/common/ConfirmDialog.svelte"
import { goto } from "@roxi/routify" import { goto } from "@roxi/routify"
import GoogleButton from "../_components/GoogleButton.svelte"
export let datasource export let datasource
export let save export let save
@ -160,6 +161,11 @@
Fetch tables Fetch tables
</Button> </Button>
<Button cta icon="Add" on:click={createNewTable}>New table</Button> <Button cta icon="Add" on:click={createNewTable}>New table</Button>
{#if integration.auth}
{#if integration.auth.type === "google"}
<GoogleButton {datasource} />
{/if}
{/if}
</div> </div>
</div> </div>
<Body> <Body>

View File

@ -12,8 +12,8 @@
const enrichBindings = bindings => { const enrichBindings = bindings => {
return bindings?.map(binding => ({ return bindings?.map(binding => ({
...binding, ...binding,
readableBinding: binding.label || binding.readableBinding, readableBinding: binding.readableBinding || binding.label,
runtimeBinding: binding.path || binding.runtimeBinding, runtimeBinding: binding.runtimeBinding || binding.path,
})) }))
} }
</script> </script>

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/cli", "name": "@budibase/cli",
"version": "1.0.98-alpha.2", "version": "1.0.98-alpha.4",
"description": "Budibase CLI, for developers, self hosting and migrations.", "description": "Budibase CLI, for developers, self hosting and migrations.",
"main": "src/index.js", "main": "src/index.js",
"bin": { "bin": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/client", "name": "@budibase/client",
"version": "1.0.98-alpha.2", "version": "1.0.98-alpha.4",
"license": "MPL-2.0", "license": "MPL-2.0",
"module": "dist/budibase-client.js", "module": "dist/budibase-client.js",
"main": "dist/budibase-client.js", "main": "dist/budibase-client.js",
@ -19,9 +19,9 @@
"dev:builder": "rollup -cw" "dev:builder": "rollup -cw"
}, },
"dependencies": { "dependencies": {
"@budibase/bbui": "^1.0.98-alpha.2", "@budibase/bbui": "^1.0.98-alpha.4",
"@budibase/frontend-core": "^1.0.98-alpha.2", "@budibase/frontend-core": "^1.0.98-alpha.4",
"@budibase/string-templates": "^1.0.98-alpha.2", "@budibase/string-templates": "^1.0.98-alpha.4",
"@spectrum-css/button": "^3.0.3", "@spectrum-css/button": "^3.0.3",
"@spectrum-css/card": "^3.0.3", "@spectrum-css/card": "^3.0.3",
"@spectrum-css/divider": "^1.0.3", "@spectrum-css/divider": "^1.0.3",

View File

@ -1,12 +1,12 @@
{ {
"name": "@budibase/frontend-core", "name": "@budibase/frontend-core",
"version": "1.0.98-alpha.2", "version": "1.0.98-alpha.4",
"description": "Budibase frontend core libraries used in builder and client", "description": "Budibase frontend core libraries used in builder and client",
"author": "Budibase", "author": "Budibase",
"license": "MPL-2.0", "license": "MPL-2.0",
"svelte": "src/index.js", "svelte": "src/index.js",
"dependencies": { "dependencies": {
"@budibase/bbui": "^1.0.98-alpha.2", "@budibase/bbui": "^1.0.98-alpha.4",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"svelte": "^3.46.2" "svelte": "^3.46.2"
} }

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/server", "name": "@budibase/server",
"email": "hi@budibase.com", "email": "hi@budibase.com",
"version": "1.0.98-alpha.2", "version": "1.0.98-alpha.4",
"description": "Budibase Web Server", "description": "Budibase Web Server",
"main": "src/index.ts", "main": "src/index.ts",
"repository": { "repository": {
@ -68,9 +68,9 @@
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"@apidevtools/swagger-parser": "^10.0.3", "@apidevtools/swagger-parser": "^10.0.3",
"@budibase/backend-core": "^1.0.98-alpha.2", "@budibase/backend-core": "^1.0.98-alpha.4",
"@budibase/client": "^1.0.98-alpha.2", "@budibase/client": "^1.0.98-alpha.4",
"@budibase/string-templates": "^1.0.98-alpha.2", "@budibase/string-templates": "^1.0.98-alpha.4",
"@bull-board/api": "^3.7.0", "@bull-board/api": "^3.7.0",
"@bull-board/koa": "^3.7.0", "@bull-board/koa": "^3.7.0",
"@elastic/elasticsearch": "7.10.0", "@elastic/elasticsearch": "7.10.0",

View File

@ -1,8 +1,24 @@
const { cloneDeep } = require("lodash")
const { definitions } = require("../../integrations") const { definitions } = require("../../integrations")
const { getTenantId } = require("@budibase/backend-core/tenancy")
const { SourceNames } = require("../../definitions/datasource")
const googlesheets = require("../../integrations/googlesheets")
const env = require("../../environment")
exports.fetch = async function (ctx) { exports.fetch = async function (ctx) {
ctx.status = 200 ctx.status = 200
ctx.body = definitions const defs = cloneDeep(definitions)
// for google sheets integration google verification
if (env.EXCLUDE_QUOTAS_TENANTS) {
const excludedTenants = env.EXCLUDE_QUOTAS_TENANTS.split(",")
const tenantId = getTenantId()
if (excludedTenants.includes(tenantId)) {
defs[SourceNames.GOOGLE_SHEETS] = googlesheets.schema
}
}
ctx.body = defs
} }
exports.find = async function (ctx) { exports.find = async function (ctx) {

View File

@ -46,6 +46,8 @@ module.exports = {
MULTI_TENANCY: process.env.MULTI_TENANCY, MULTI_TENANCY: process.env.MULTI_TENANCY,
HTTP_MIGRATIONS: process.env.HTTP_MIGRATIONS, HTTP_MIGRATIONS: process.env.HTTP_MIGRATIONS,
API_REQ_LIMIT_PER_SEC: process.env.API_REQ_LIMIT_PER_SEC, API_REQ_LIMIT_PER_SEC: process.env.API_REQ_LIMIT_PER_SEC,
GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,
GOOGLE_CLIENT_SECRET: process.env.GOOGLE_CLIENT_SECRET,
// environment // environment
NODE_ENV: process.env.NODE_ENV, NODE_ENV: process.env.NODE_ENV,
JEST_WORKER_ID: process.env.JEST_WORKER_ID, JEST_WORKER_ID: process.env.JEST_WORKER_ID,

View File

@ -10,6 +10,7 @@ import { Table, TableSchema } from "../definitions/common"
import { buildExternalTableId } from "./utils" import { buildExternalTableId } from "./utils"
import { DataSourceOperation, FieldTypes } from "../constants" import { DataSourceOperation, FieldTypes } from "../constants"
import { GoogleSpreadsheet } from "google-spreadsheet" import { GoogleSpreadsheet } from "google-spreadsheet"
import env from "../environment"
module GoogleSheetsModule { module GoogleSheetsModule {
const { getGlobalDB } = require("@budibase/backend-core/tenancy") const { getGlobalDB } = require("@budibase/backend-core/tenancy")
@ -138,13 +139,27 @@ module GoogleSheetsModule {
try { try {
// Initialise oAuth client // Initialise oAuth client
const db = getGlobalDB() const db = getGlobalDB()
const googleConfig = await getScopedConfig(db, { let googleConfig = await getScopedConfig(db, {
type: Configs.GOOGLE, type: Configs.GOOGLE,
}) })
if (!googleConfig) {
googleConfig = {
clientID: env.GOOGLE_CLIENT_ID,
clientSecret: env.GOOGLE_CLIENT_SECRET,
}
}
const oauthClient = new OAuth2Client({ const oauthClient = new OAuth2Client({
clientId: googleConfig.clientID, clientId: googleConfig.clientID,
clientSecret: googleConfig.clientSecret, clientSecret: googleConfig.clientSecret,
}) })
oauthClient.on("tokens", tokens => {
oauthClient.setCredentials({
refresh_token: googleConfig.refreshToken,
access_token: tokens.access_token,
})
})
oauthClient.credentials.access_token = this.config.auth.accessToken oauthClient.credentials.access_token = this.config.auth.accessToken
oauthClient.credentials.refresh_token = this.config.auth.refreshToken oauthClient.credentials.refresh_token = this.config.auth.refreshToken
this.client.useOAuth2Client(oauthClient) this.client.useOAuth2Client(oauthClient)

View File

@ -42,6 +42,7 @@ const INTEGRATIONS = {
[SourceNames.ARANGODB]: arangodb.integration, [SourceNames.ARANGODB]: arangodb.integration,
[SourceNames.REST]: rest.integration, [SourceNames.REST]: rest.integration,
[SourceNames.FIREBASE]: firebase.integration, [SourceNames.FIREBASE]: firebase.integration,
[SourceNames.GOOGLE_SHEETS]: googlesheets.integration,
} }
// optionally add oracle integration if the oracle binary can be installed // optionally add oracle integration if the oracle binary can be installed
@ -53,7 +54,6 @@ if (!(process.arch === "arm64" && process.platform === "darwin")) {
if (environment.SELF_HOSTED) { if (environment.SELF_HOSTED) {
DEFINITIONS[SourceNames.GOOGLE_SHEETS] = googlesheets.schema DEFINITIONS[SourceNames.GOOGLE_SHEETS] = googlesheets.schema
INTEGRATIONS[SourceNames.GOOGLE_SHEETS] = googlesheets.integration
} }
module.exports = { module.exports = {

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/string-templates", "name": "@budibase/string-templates",
"version": "1.0.98-alpha.2", "version": "1.0.98-alpha.4",
"description": "Handlebars wrapper for Budibase templating.", "description": "Handlebars wrapper for Budibase templating.",
"main": "src/index.cjs", "main": "src/index.cjs",
"module": "dist/bundle.mjs", "module": "dist/bundle.mjs",

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/worker", "name": "@budibase/worker",
"email": "hi@budibase.com", "email": "hi@budibase.com",
"version": "1.0.98-alpha.2", "version": "1.0.98-alpha.4",
"description": "Budibase background service", "description": "Budibase background service",
"main": "src/index.ts", "main": "src/index.ts",
"repository": { "repository": {
@ -31,8 +31,8 @@
"author": "Budibase", "author": "Budibase",
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"@budibase/backend-core": "^1.0.98-alpha.2", "@budibase/backend-core": "^1.0.98-alpha.4",
"@budibase/string-templates": "^1.0.98-alpha.2", "@budibase/string-templates": "^1.0.98-alpha.4",
"@koa/router": "^8.0.0", "@koa/router": "^8.0.0",
"@sentry/node": "^6.0.0", "@sentry/node": "^6.0.0",
"@techpass/passport-openidconnect": "^0.3.0", "@techpass/passport-openidconnect": "^0.3.0",