Merge branch 'master' into BUDI-8885/only-select-required-columns-from-sql-databases
This commit is contained in:
commit
3168b42407
|
@ -10,7 +10,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bulma": "^0.9.3",
|
"bulma": "^0.9.3",
|
||||||
"next": "14.2.10",
|
"next": "14.2.15",
|
||||||
"node-fetch": "^3.2.10",
|
"node-fetch": "^3.2.10",
|
||||||
"sass": "^1.52.3",
|
"sass": "^1.52.3",
|
||||||
"react": "17.0.2",
|
"react": "17.0.2",
|
||||||
|
|
|
@ -46,10 +46,10 @@
|
||||||
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45"
|
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45"
|
||||||
integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==
|
integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==
|
||||||
|
|
||||||
"@next/env@14.2.10":
|
"@next/env@14.2.15":
|
||||||
version "14.2.10"
|
version "14.2.15"
|
||||||
resolved "https://registry.yarnpkg.com/@next/env/-/env-14.2.10.tgz#1d3178340028ced2d679f84140877db4f420333c"
|
resolved "https://registry.yarnpkg.com/@next/env/-/env-14.2.15.tgz#06d984e37e670d93ddd6790af1844aeb935f332f"
|
||||||
integrity sha512-dZIu93Bf5LUtluBXIv4woQw2cZVZ2DJTjax5/5DOs3lzEOeKLy7GxRSr4caK9/SCPdaW6bCgpye6+n4Dh9oJPw==
|
integrity sha512-S1qaj25Wru2dUpcIZMjxeMVSwkt8BK4dmWHHiBuRstcIyOsMapqT4A4jSB6onvqeygkSSmOkyny9VVx8JIGamQ==
|
||||||
|
|
||||||
"@next/eslint-plugin-next@12.1.0":
|
"@next/eslint-plugin-next@12.1.0":
|
||||||
version "12.1.0"
|
version "12.1.0"
|
||||||
|
@ -58,50 +58,50 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
glob "7.1.7"
|
glob "7.1.7"
|
||||||
|
|
||||||
"@next/swc-darwin-arm64@14.2.10":
|
"@next/swc-darwin-arm64@14.2.15":
|
||||||
version "14.2.10"
|
version "14.2.15"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.10.tgz#49d10ca4086fbd59ee68e204f75d7136eda2aa80"
|
resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.15.tgz#6386d585f39a1c490c60b72b1f76612ba4434347"
|
||||||
integrity sha512-V3z10NV+cvMAfxQUMhKgfQnPbjw+Ew3cnr64b0lr8MDiBJs3eLnM6RpGC46nhfMZsiXgQngCJKWGTC/yDcgrDQ==
|
integrity sha512-Rvh7KU9hOUBnZ9TJ28n2Oa7dD9cvDBKua9IKx7cfQQ0GoYUwg9ig31O2oMwH3wm+pE3IkAQ67ZobPfEgurPZIA==
|
||||||
|
|
||||||
"@next/swc-darwin-x64@14.2.10":
|
"@next/swc-darwin-x64@14.2.15":
|
||||||
version "14.2.10"
|
version "14.2.15"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.10.tgz#0ebeae3afb8eac433882b79543295ab83624a1a8"
|
resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.15.tgz#b7baeedc6a28f7545ad2bc55adbab25f7b45cb89"
|
||||||
integrity sha512-Y0TC+FXbFUQ2MQgimJ/7Ina2mXIKhE7F+GUe1SgnzRmwFY3hX2z8nyVCxE82I2RicspdkZnSWMn4oTjIKz4uzA==
|
integrity sha512-5TGyjFcf8ampZP3e+FyCax5zFVHi+Oe7sZyaKOngsqyaNEpOgkKB3sqmymkZfowy3ufGA/tUgDPPxpQx931lHg==
|
||||||
|
|
||||||
"@next/swc-linux-arm64-gnu@14.2.10":
|
"@next/swc-linux-arm64-gnu@14.2.15":
|
||||||
version "14.2.10"
|
version "14.2.15"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.10.tgz#7e602916d2fb55a3c532f74bed926a0137c16f20"
|
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.15.tgz#fa13c59d3222f70fb4cb3544ac750db2c6e34d02"
|
||||||
integrity sha512-ZfQ7yOy5zyskSj9rFpa0Yd7gkrBnJTkYVSya95hX3zeBG9E55Z6OTNPn1j2BTFWvOVVj65C3T+qsjOyVI9DQpA==
|
integrity sha512-3Bwv4oc08ONiQ3FiOLKT72Q+ndEMyLNsc/D3qnLMbtUYTQAmkx9E/JRu0DBpHxNddBmNT5hxz1mYBphJ3mfrrw==
|
||||||
|
|
||||||
"@next/swc-linux-arm64-musl@14.2.10":
|
"@next/swc-linux-arm64-musl@14.2.15":
|
||||||
version "14.2.10"
|
version "14.2.15"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.10.tgz#6b143f628ccee490b527562e934f8de578d4be47"
|
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.15.tgz#30e45b71831d9a6d6d18d7ac7d611a8d646a17f9"
|
||||||
integrity sha512-n2i5o3y2jpBfXFRxDREr342BGIQCJbdAUi/K4q6Env3aSx8erM9VuKXHw5KNROK9ejFSPf0LhoSkU/ZiNdacpQ==
|
integrity sha512-k5xf/tg1FBv/M4CMd8S+JL3uV9BnnRmoe7F+GWC3DxkTCD9aewFRH1s5rJ1zkzDa+Do4zyN8qD0N8c84Hu96FQ==
|
||||||
|
|
||||||
"@next/swc-linux-x64-gnu@14.2.10":
|
"@next/swc-linux-x64-gnu@14.2.15":
|
||||||
version "14.2.10"
|
version "14.2.15"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.10.tgz#086f2f16a0678890a1eb46518c4dda381b046082"
|
resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.15.tgz#5065db17fc86f935ad117483f21f812dc1b39254"
|
||||||
integrity sha512-GXvajAWh2woTT0GKEDlkVhFNxhJS/XdDmrVHrPOA83pLzlGPQnixqxD8u3bBB9oATBKB//5e4vpACnx5Vaxdqg==
|
integrity sha512-kE6q38hbrRbKEkkVn62reLXhThLRh6/TvgSP56GkFNhU22TbIrQDEMrO7j0IcQHcew2wfykq8lZyHFabz0oBrA==
|
||||||
|
|
||||||
"@next/swc-linux-x64-musl@14.2.10":
|
"@next/swc-linux-x64-musl@14.2.15":
|
||||||
version "14.2.10"
|
version "14.2.15"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.10.tgz#1befef10ed8dbcc5047b5d637a25ae3c30a0bfc3"
|
resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.15.tgz#3c4a4568d8be7373a820f7576cf33388b5dab47e"
|
||||||
integrity sha512-opFFN5B0SnO+HTz4Wq4HaylXGFV+iHrVxd3YvREUX9K+xfc4ePbRrxqOuPOFjtSuiVouwe6uLeDtabjEIbkmDA==
|
integrity sha512-PZ5YE9ouy/IdO7QVJeIcyLn/Rc4ml9M2G4y3kCM9MNf1YKvFY4heg3pVa/jQbMro+tP6yc4G2o9LjAz1zxD7tQ==
|
||||||
|
|
||||||
"@next/swc-win32-arm64-msvc@14.2.10":
|
"@next/swc-win32-arm64-msvc@14.2.15":
|
||||||
version "14.2.10"
|
version "14.2.15"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.10.tgz#731f52c3ae3c56a26cf21d474b11ae1529531209"
|
resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.15.tgz#fb812cc4ca0042868e32a6a021da91943bb08b98"
|
||||||
integrity sha512-9NUzZuR8WiXTvv+EiU/MXdcQ1XUvFixbLIMNQiVHuzs7ZIFrJDLJDaOF1KaqttoTujpcxljM/RNAOmw1GhPPQQ==
|
integrity sha512-2raR16703kBvYEQD9HNLyb0/394yfqzmIeyp2nDzcPV4yPjqNUG3ohX6jX00WryXz6s1FXpVhsCo3i+g4RUX+g==
|
||||||
|
|
||||||
"@next/swc-win32-ia32-msvc@14.2.10":
|
"@next/swc-win32-ia32-msvc@14.2.15":
|
||||||
version "14.2.10"
|
version "14.2.15"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.10.tgz#32723ef7f04e25be12af357cc72ddfdd42fd1041"
|
resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.15.tgz#ec26e6169354f8ced240c1427be7fd485c5df898"
|
||||||
integrity sha512-fr3aEbSd1GeW3YUMBkWAu4hcdjZ6g4NBl1uku4gAn661tcxd1bHs1THWYzdsbTRLcCKLjrDZlNp6j2HTfrw+Bg==
|
integrity sha512-fyTE8cklgkyR1p03kJa5zXEaZ9El+kDNM5A+66+8evQS5e/6v0Gk28LqA0Jet8gKSOyP+OTm/tJHzMlGdQerdQ==
|
||||||
|
|
||||||
"@next/swc-win32-x64-msvc@14.2.10":
|
"@next/swc-win32-x64-msvc@14.2.15":
|
||||||
version "14.2.10"
|
version "14.2.15"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.10.tgz#ee1d036cb5ec871816f96baee7991035bb242455"
|
resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.15.tgz#18d68697002b282006771f8d92d79ade9efd35c4"
|
||||||
integrity sha512-UjeVoRGKNL2zfbcQ6fscmgjBAS/inHBh63mjIlfPg/NG8Yn2ztqylXt5qilYb6hoHIwaU2ogHknHWWmahJjgZQ==
|
integrity sha512-SzqGbsLsP9OwKNUG9nekShTwhj6JSB9ZLMWQ8g1gG6hdE5gQLncbnbymrwy2yVmH9nikSLYRYxYMFu78Ggp7/g==
|
||||||
|
|
||||||
"@nodelib/fs.scandir@2.1.5":
|
"@nodelib/fs.scandir@2.1.5":
|
||||||
version "2.1.5"
|
version "2.1.5"
|
||||||
|
@ -1253,12 +1253,12 @@ natural-compare@^1.4.0:
|
||||||
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
|
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
|
||||||
integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=
|
integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=
|
||||||
|
|
||||||
next@14.2.10:
|
next@14.2.15:
|
||||||
version "14.2.10"
|
version "14.2.15"
|
||||||
resolved "https://registry.yarnpkg.com/next/-/next-14.2.10.tgz#331981a4fecb1ae8af1817d4db98fc9687ee1cb6"
|
resolved "https://registry.yarnpkg.com/next/-/next-14.2.15.tgz#348e5603e22649775d19c785c09a89c9acb5189a"
|
||||||
integrity sha512-sDDExXnh33cY3RkS9JuFEKaS4HmlWmDKP1VJioucCG6z5KuA008DPsDZOzi8UfqEk3Ii+2NCQSJrfbEWtZZfww==
|
integrity sha512-h9ctmOokpoDphRvMGnwOJAedT6zKhwqyZML9mDtspgf4Rh3Pn7UTYKqePNoDvhsWBAO5GoPNYshnAUGIazVGmw==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@next/env" "14.2.10"
|
"@next/env" "14.2.15"
|
||||||
"@swc/helpers" "0.5.5"
|
"@swc/helpers" "0.5.5"
|
||||||
busboy "1.6.0"
|
busboy "1.6.0"
|
||||||
caniuse-lite "^1.0.30001579"
|
caniuse-lite "^1.0.30001579"
|
||||||
|
@ -1266,15 +1266,15 @@ next@14.2.10:
|
||||||
postcss "8.4.31"
|
postcss "8.4.31"
|
||||||
styled-jsx "5.1.1"
|
styled-jsx "5.1.1"
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
"@next/swc-darwin-arm64" "14.2.10"
|
"@next/swc-darwin-arm64" "14.2.15"
|
||||||
"@next/swc-darwin-x64" "14.2.10"
|
"@next/swc-darwin-x64" "14.2.15"
|
||||||
"@next/swc-linux-arm64-gnu" "14.2.10"
|
"@next/swc-linux-arm64-gnu" "14.2.15"
|
||||||
"@next/swc-linux-arm64-musl" "14.2.10"
|
"@next/swc-linux-arm64-musl" "14.2.15"
|
||||||
"@next/swc-linux-x64-gnu" "14.2.10"
|
"@next/swc-linux-x64-gnu" "14.2.15"
|
||||||
"@next/swc-linux-x64-musl" "14.2.10"
|
"@next/swc-linux-x64-musl" "14.2.15"
|
||||||
"@next/swc-win32-arm64-msvc" "14.2.10"
|
"@next/swc-win32-arm64-msvc" "14.2.15"
|
||||||
"@next/swc-win32-ia32-msvc" "14.2.10"
|
"@next/swc-win32-ia32-msvc" "14.2.15"
|
||||||
"@next/swc-win32-x64-msvc" "14.2.10"
|
"@next/swc-win32-x64-msvc" "14.2.15"
|
||||||
|
|
||||||
node-domexception@^1.0.0:
|
node-domexception@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
...datasource,
|
...datasource,
|
||||||
name,
|
name,
|
||||||
}
|
}
|
||||||
await datasources.update({
|
await datasources.save({
|
||||||
datasource: updatedDatasource,
|
datasource: updatedDatasource,
|
||||||
integration: integrationForDatasource(get(integrations), datasource),
|
integration: integrationForDatasource(get(integrations), datasource),
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
export let name
|
export let name
|
||||||
export let config
|
export let config
|
||||||
export let showModal = () => {}
|
export let showModal = () => {}
|
||||||
|
export let placeholder
|
||||||
|
|
||||||
const selectComponent = type => {
|
const selectComponent = type => {
|
||||||
if (type === "object") {
|
if (type === "object") {
|
||||||
|
@ -40,6 +41,7 @@
|
||||||
{name}
|
{name}
|
||||||
{config}
|
{config}
|
||||||
{showModal}
|
{showModal}
|
||||||
|
{placeholder}
|
||||||
on:blur
|
on:blur
|
||||||
on:change
|
on:change
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
export let name
|
export let name
|
||||||
export let value
|
export let value
|
||||||
export let error
|
export let error
|
||||||
|
export let placeholder
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<Label>{name}</Label>
|
<Label>{name}</Label>
|
||||||
<TextArea on:blur on:change {type} {value} {error} />
|
<TextArea on:blur on:change {type} {value} {error} {placeholder} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
export let value
|
export let value
|
||||||
export let error
|
export let error
|
||||||
export let config
|
export let config
|
||||||
|
export let placeholder
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
|
@ -17,6 +18,7 @@
|
||||||
{type}
|
{type}
|
||||||
value={value || undefined}
|
value={value || undefined}
|
||||||
{error}
|
{error}
|
||||||
|
{placeholder}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
export let name
|
export let name
|
||||||
export let value
|
export let value
|
||||||
export let error
|
export let error
|
||||||
|
export let placeholder
|
||||||
export let showModal = () => {}
|
export let showModal = () => {}
|
||||||
|
|
||||||
async function handleUpgradePanel() {
|
async function handleUpgradePanel() {
|
||||||
|
@ -22,6 +23,7 @@
|
||||||
type={type === "port" ? "string" : type}
|
type={type === "port" ? "string" : type}
|
||||||
{value}
|
{value}
|
||||||
{error}
|
{error}
|
||||||
|
{placeholder}
|
||||||
variables={$environment.variables}
|
variables={$environment.variables}
|
||||||
environmentVariablesEnabled={$licensing.environmentVariablesEnabled}
|
environmentVariablesEnabled={$licensing.environmentVariablesEnabled}
|
||||||
{showModal}
|
{showModal}
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#each $configStore.validatedConfig as { type, key, value, error, name, hidden, config }}
|
{#each $configStore.validatedConfig as { type, key, value, error, name, hidden, config, placeholder }}
|
||||||
{#if hidden === undefined || !eval(processStringSync(hidden, $configStore.config))}
|
{#if hidden === undefined || !eval(processStringSync(hidden, $configStore.config))}
|
||||||
<ConfigInput
|
<ConfigInput
|
||||||
{type}
|
{type}
|
||||||
|
@ -93,6 +93,7 @@
|
||||||
{error}
|
{error}
|
||||||
{name}
|
{name}
|
||||||
{config}
|
{config}
|
||||||
|
{placeholder}
|
||||||
showModal={() =>
|
showModal={() =>
|
||||||
showModal(newValue => configStore.updateFieldValue(key, newValue))}
|
showModal(newValue => configStore.updateFieldValue(key, newValue))}
|
||||||
on:blur={() => configStore.markFieldActive(key)}
|
on:blur={() => configStore.markFieldActive(key)}
|
||||||
|
|
|
@ -114,6 +114,7 @@ export const createValidatedConfigStore = (integration, config) => {
|
||||||
value: getValue(),
|
value: getValue(),
|
||||||
error: $errorsStore[key],
|
error: $errorsStore[key],
|
||||||
name: capitalise(properties.display || key),
|
name: capitalise(properties.display || key),
|
||||||
|
placeholder: properties.placeholder,
|
||||||
type: properties.type,
|
type: properties.type,
|
||||||
hidden: properties.hidden,
|
hidden: properties.hidden,
|
||||||
config: properties.config,
|
config: properties.config,
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
get(integrations),
|
get(integrations),
|
||||||
datasource
|
datasource
|
||||||
)
|
)
|
||||||
await datasources.update({ datasource, integration })
|
await datasources.save({ datasource, integration })
|
||||||
|
|
||||||
await afterSave({ datasource, action })
|
await afterSave({ datasource, action })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -176,7 +176,7 @@
|
||||||
notifications.success(`Request saved successfully`)
|
notifications.success(`Request saved successfully`)
|
||||||
if (dynamicVariables) {
|
if (dynamicVariables) {
|
||||||
datasource.config.dynamicVariables = rebuildVariables(saveId)
|
datasource.config.dynamicVariables = rebuildVariables(saveId)
|
||||||
datasource = await datasources.update({
|
datasource = await datasources.save({
|
||||||
integration: integrationInfo,
|
integration: integrationInfo,
|
||||||
datasource,
|
datasource,
|
||||||
})
|
})
|
||||||
|
|
|
@ -368,20 +368,22 @@
|
||||||
const payload = [
|
const payload = [
|
||||||
{
|
{
|
||||||
email: newUserEmail,
|
email: newUserEmail,
|
||||||
builder: {
|
userInfo: {
|
||||||
global: creationRoleType === Constants.BudibaseRoles.Admin,
|
builder: {
|
||||||
creator: creationRoleType === Constants.BudibaseRoles.Creator,
|
global: creationRoleType === Constants.BudibaseRoles.Admin,
|
||||||
|
creator: creationRoleType === Constants.BudibaseRoles.Creator,
|
||||||
|
},
|
||||||
|
admin: { global: creationRoleType === Constants.BudibaseRoles.Admin },
|
||||||
},
|
},
|
||||||
admin: { global: creationRoleType === Constants.BudibaseRoles.Admin },
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
const notCreatingAdmin = creationRoleType !== Constants.BudibaseRoles.Admin
|
const notCreatingAdmin = creationRoleType !== Constants.BudibaseRoles.Admin
|
||||||
const isCreator = creationAccessType === Constants.Roles.CREATOR
|
const isCreator = creationAccessType === Constants.Roles.CREATOR
|
||||||
if (notCreatingAdmin && isCreator) {
|
if (notCreatingAdmin && isCreator) {
|
||||||
payload[0].builder.apps = [prodAppId]
|
payload[0].userInfo.builder.apps = [prodAppId]
|
||||||
} else if (notCreatingAdmin && !isCreator) {
|
} else if (notCreatingAdmin && !isCreator) {
|
||||||
payload[0].apps = { [prodAppId]: creationAccessType }
|
payload[0].userInfo.apps = { [prodAppId]: creationAccessType }
|
||||||
}
|
}
|
||||||
|
|
||||||
let userInviteResponse
|
let userInviteResponse
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
async function saveDatasource({ config, name }) {
|
async function saveDatasource({ config, name }) {
|
||||||
try {
|
try {
|
||||||
await datasources.update({
|
await datasources.save({
|
||||||
integration,
|
integration,
|
||||||
datasource: { ...datasource, config, name },
|
datasource: { ...datasource, config, name },
|
||||||
})
|
})
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
get(integrations),
|
get(integrations),
|
||||||
updatedDatasource
|
updatedDatasource
|
||||||
)
|
)
|
||||||
await datasources.update({ datasource: updatedDatasource, integration })
|
await datasources.save({ datasource: updatedDatasource, integration })
|
||||||
notifications.success(
|
notifications.success(
|
||||||
`Datasource ${updatedDatasource.name} updated successfully`
|
`Datasource ${updatedDatasource.name} updated successfully`
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,40 +1,22 @@
|
||||||
import { writable, Writable } from "svelte/store"
|
import { writable, Writable, Readable } from "svelte/store"
|
||||||
|
|
||||||
interface BudiStoreOpts {
|
interface BudiStoreOpts {
|
||||||
debug?: boolean
|
debug?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class BudiStore<T> implements Writable<T> {
|
export class BudiStore<T> {
|
||||||
store: Writable<T>
|
store: Writable<T>
|
||||||
subscribe: Writable<T>["subscribe"]
|
subscribe: Writable<T>["subscribe"]
|
||||||
update: Writable<T>["update"]
|
update: Writable<T>["update"]
|
||||||
set: Writable<T>["set"]
|
set: Writable<T>["set"]
|
||||||
|
|
||||||
constructor(init: T, opts?: BudiStoreOpts) {
|
constructor(init: T, opts?: BudiStoreOpts) {
|
||||||
const store = writable<T>(init)
|
this.store = writable<T>(init)
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal Svelte store
|
|
||||||
*/
|
|
||||||
this.store = store
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Exposes the svelte subscribe fn to allow $ notation access
|
|
||||||
* @example
|
|
||||||
* $navigation.selectedScreenId
|
|
||||||
*/
|
|
||||||
this.subscribe = this.store.subscribe
|
this.subscribe = this.store.subscribe
|
||||||
|
|
||||||
/**
|
|
||||||
* Exposes the svelte update fn.
|
|
||||||
* *Store modification should be kept to a minimum
|
|
||||||
*/
|
|
||||||
this.update = this.store.update
|
this.update = this.store.update
|
||||||
this.set = this.store.set
|
this.set = this.store.set
|
||||||
|
|
||||||
/**
|
// Optional debug mode to output the store updates to console
|
||||||
* Optional debug mode to output the store updates to console
|
|
||||||
*/
|
|
||||||
if (opts?.debug) {
|
if (opts?.debug) {
|
||||||
this.subscribe(state => {
|
this.subscribe(state => {
|
||||||
console.warn(`${this.constructor.name}`, state)
|
console.warn(`${this.constructor.name}`, state)
|
||||||
|
@ -42,3 +24,18 @@ export default class BudiStore<T> implements Writable<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class DerivedBudiStore<T, DerivedT extends T> extends BudiStore<T> {
|
||||||
|
derivedStore: Readable<DerivedT>
|
||||||
|
subscribe: Readable<DerivedT>["subscribe"]
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
init: T,
|
||||||
|
makeDerivedStore: (store: Writable<T>) => Readable<DerivedT>,
|
||||||
|
opts?: BudiStoreOpts
|
||||||
|
) {
|
||||||
|
super(init, opts)
|
||||||
|
this.derivedStore = makeDerivedStore(this.store)
|
||||||
|
this.subscribe = this.derivedStore.subscribe
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import BudiStore from "../BudiStore"
|
import { BudiStore } from "../BudiStore"
|
||||||
|
|
||||||
export const INITIAL_APP_META_STATE = {
|
export const INITIAL_APP_META_STATE = {
|
||||||
appId: "",
|
appId: "",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { createBuilderWebsocket } from "./websocket.js"
|
import { createBuilderWebsocket } from "./websocket.js"
|
||||||
import { BuilderSocketEvent } from "@budibase/shared-core"
|
import { BuilderSocketEvent } from "@budibase/shared-core"
|
||||||
import BudiStore from "../BudiStore.js"
|
import { BudiStore } from "../BudiStore.js"
|
||||||
import { TOUR_KEYS } from "components/portal/onboarding/tours.js"
|
import { TOUR_KEYS } from "components/portal/onboarding/tours.js"
|
||||||
|
|
||||||
export const INITIAL_BUILDER_STATE = {
|
export const INITIAL_BUILDER_STATE = {
|
||||||
|
|
|
@ -28,7 +28,7 @@ import {
|
||||||
DB_TYPE_INTERNAL,
|
DB_TYPE_INTERNAL,
|
||||||
DB_TYPE_EXTERNAL,
|
DB_TYPE_EXTERNAL,
|
||||||
} from "constants/backend"
|
} from "constants/backend"
|
||||||
import BudiStore from "../BudiStore"
|
import { BudiStore } from "../BudiStore"
|
||||||
import { Utils } from "@budibase/frontend-core"
|
import { Utils } from "@budibase/frontend-core"
|
||||||
import { FieldType } from "@budibase/types"
|
import { FieldType } from "@budibase/types"
|
||||||
import { utils } from "@budibase/shared-core"
|
import { utils } from "@budibase/shared-core"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { writable, derived, get } from "svelte/store"
|
import { derived, get, Writable } from "svelte/store"
|
||||||
import {
|
import {
|
||||||
IntegrationTypes,
|
IntegrationTypes,
|
||||||
DEFAULT_BB_DATASOURCE_ID,
|
DEFAULT_BB_DATASOURCE_ID,
|
||||||
|
@ -17,11 +17,7 @@ import {
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { TableNames } from "constants"
|
import { TableNames } from "constants"
|
||||||
|
import { DerivedBudiStore } from "stores/BudiStore"
|
||||||
// when building the internal DS - seems to represent it slightly differently to the backend typing of a DS
|
|
||||||
interface InternalDatasource extends Omit<Datasource, "entities"> {
|
|
||||||
entities: Table[]
|
|
||||||
}
|
|
||||||
|
|
||||||
class TableImportError extends Error {
|
class TableImportError extends Error {
|
||||||
errors: Record<string, string>
|
errors: Record<string, string>
|
||||||
|
@ -41,102 +37,138 @@ class TableImportError extends Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DatasourceStore {
|
// when building the internal DS - seems to represent it slightly differently to the backend typing of a DS
|
||||||
list: Datasource[]
|
interface InternalDatasource extends Omit<Datasource, "entities"> {
|
||||||
|
entities: Table[]
|
||||||
|
}
|
||||||
|
|
||||||
|
interface BuilderDatasourceStore {
|
||||||
|
rawList: Datasource[]
|
||||||
selectedDatasourceId: null | string
|
selectedDatasourceId: null | string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createDatasourcesStore() {
|
interface DerivedDatasourceStore extends BuilderDatasourceStore {
|
||||||
const store = writable<DatasourceStore>({
|
list: (Datasource | InternalDatasource)[]
|
||||||
list: [],
|
selected?: Datasource | InternalDatasource
|
||||||
selectedDatasourceId: null,
|
hasDefaultData: boolean
|
||||||
})
|
hasData: boolean
|
||||||
|
}
|
||||||
|
|
||||||
const derivedStore = derived([store, tables], ([$store, $tables]) => {
|
export class DatasourceStore extends DerivedBudiStore<
|
||||||
// Set the internal datasource entities from the table list, which we're
|
BuilderDatasourceStore,
|
||||||
// able to keep updated unlike the egress generated definition of the
|
DerivedDatasourceStore
|
||||||
// internal datasource
|
> {
|
||||||
let internalDS: Datasource | InternalDatasource | undefined =
|
constructor() {
|
||||||
$store.list?.find(ds => ds._id === BUDIBASE_INTERNAL_DB_ID)
|
const makeDerivedStore = (store: Writable<BuilderDatasourceStore>) => {
|
||||||
let otherDS = $store.list?.filter(ds => ds._id !== BUDIBASE_INTERNAL_DB_ID)
|
return derived([store, tables], ([$store, $tables]) => {
|
||||||
if (internalDS) {
|
// Set the internal datasource entities from the table list, which we're
|
||||||
const tables: Table[] = $tables.list?.filter((table: Table) => {
|
// able to keep updated unlike the egress generated definition of the
|
||||||
return (
|
// internal datasource
|
||||||
table.sourceId === BUDIBASE_INTERNAL_DB_ID &&
|
let internalDS: Datasource | InternalDatasource | undefined =
|
||||||
table._id !== TableNames.USERS
|
$store.rawList?.find(ds => ds._id === BUDIBASE_INTERNAL_DB_ID)
|
||||||
|
let otherDS = $store.rawList?.filter(
|
||||||
|
ds => ds._id !== BUDIBASE_INTERNAL_DB_ID
|
||||||
)
|
)
|
||||||
|
if (internalDS) {
|
||||||
|
const tables: Table[] = $tables.list?.filter((table: Table) => {
|
||||||
|
return (
|
||||||
|
table.sourceId === BUDIBASE_INTERNAL_DB_ID &&
|
||||||
|
table._id !== TableNames.USERS
|
||||||
|
)
|
||||||
|
})
|
||||||
|
internalDS = {
|
||||||
|
...internalDS,
|
||||||
|
entities: tables,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build up enriched DS list
|
||||||
|
// Only add the internal DS if we have at least one non-users table
|
||||||
|
let list: (InternalDatasource | Datasource)[] = []
|
||||||
|
if (internalDS?.entities?.length) {
|
||||||
|
list.push(internalDS)
|
||||||
|
}
|
||||||
|
list = list.concat(otherDS || [])
|
||||||
|
|
||||||
|
return {
|
||||||
|
...$store,
|
||||||
|
list,
|
||||||
|
selected: list?.find(ds => ds._id === $store.selectedDatasourceId),
|
||||||
|
hasDefaultData: list?.some(ds => ds._id === DEFAULT_BB_DATASOURCE_ID),
|
||||||
|
hasData: list?.length > 0,
|
||||||
|
}
|
||||||
})
|
})
|
||||||
internalDS = {
|
|
||||||
...internalDS,
|
|
||||||
entities: tables,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build up enriched DS list
|
super(
|
||||||
// Only add the internal DS if we have at least one non-users table
|
{
|
||||||
let list: (InternalDatasource | Datasource)[] = []
|
rawList: [],
|
||||||
if (internalDS?.entities?.length) {
|
selectedDatasourceId: null,
|
||||||
list.push(internalDS)
|
},
|
||||||
}
|
makeDerivedStore
|
||||||
list = list.concat(otherDS || [])
|
)
|
||||||
|
|
||||||
return {
|
this.fetch = this.fetch.bind(this)
|
||||||
...$store,
|
this.init = this.fetch.bind(this)
|
||||||
list,
|
this.select = this.select.bind(this)
|
||||||
selected: list?.find(ds => ds._id === $store.selectedDatasourceId),
|
this.updateSchema = this.updateSchema.bind(this)
|
||||||
hasDefaultData: list?.some(ds => ds._id === DEFAULT_BB_DATASOURCE_ID),
|
this.create = this.create.bind(this)
|
||||||
hasData: list?.length > 0,
|
this.delete = this.deleteDatasource.bind(this)
|
||||||
}
|
this.save = this.save.bind(this)
|
||||||
})
|
this.replaceDatasource = this.replaceDatasource.bind(this)
|
||||||
|
this.getTableNames = this.getTableNames.bind(this)
|
||||||
|
}
|
||||||
|
|
||||||
const fetch = async () => {
|
async fetch() {
|
||||||
const datasources = await API.getDatasources()
|
const datasources = await API.getDatasources()
|
||||||
store.update(state => ({
|
this.store.update(state => ({
|
||||||
...state,
|
...state,
|
||||||
list: datasources,
|
rawList: datasources,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
const select = (id: string) => {
|
async init() {
|
||||||
store.update(state => ({
|
return this.fetch()
|
||||||
|
}
|
||||||
|
|
||||||
|
select(id: string) {
|
||||||
|
this.store.update(state => ({
|
||||||
...state,
|
...state,
|
||||||
selectedDatasourceId: id,
|
selectedDatasourceId: id,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateDatasource = (
|
private updateDatasourceInStore(
|
||||||
response: { datasource: Datasource; errors?: Record<string, string> },
|
response: { datasource: Datasource; errors?: Record<string, string> },
|
||||||
{ ignoreErrors }: { ignoreErrors?: boolean } = {}
|
{ ignoreErrors }: { ignoreErrors?: boolean } = {}
|
||||||
) => {
|
) {
|
||||||
const { datasource, errors } = response
|
const { datasource, errors } = response
|
||||||
if (!ignoreErrors && errors && Object.keys(errors).length > 0) {
|
if (!ignoreErrors && errors && Object.keys(errors).length > 0) {
|
||||||
throw new TableImportError(errors)
|
throw new TableImportError(errors)
|
||||||
}
|
}
|
||||||
replaceDatasource(datasource._id!, datasource)
|
this.replaceDatasource(datasource._id!, datasource)
|
||||||
select(datasource._id!)
|
this.select(datasource._id!)
|
||||||
return datasource
|
return datasource
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateSchema = async (
|
async updateSchema(datasource: Datasource, tablesFilter: string[]) {
|
||||||
datasource: Datasource,
|
|
||||||
tablesFilter: string[]
|
|
||||||
) => {
|
|
||||||
const response = await API.buildDatasourceSchema(
|
const response = await API.buildDatasourceSchema(
|
||||||
datasource?._id!,
|
datasource?._id!,
|
||||||
tablesFilter
|
tablesFilter
|
||||||
)
|
)
|
||||||
updateDatasource(response)
|
this.updateDatasourceInStore(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
const sourceCount = (source: string) => {
|
sourceCount(source: string) {
|
||||||
return get(store).list.filter(datasource => datasource.source === source)
|
return get(this.store).rawList.filter(
|
||||||
.length
|
datasource => datasource.source === source
|
||||||
|
).length
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkDatasourceValidity = async (
|
async checkDatasourceValidity(
|
||||||
integration: Integration,
|
integration: Integration,
|
||||||
datasource: Datasource
|
datasource: Datasource
|
||||||
): Promise<{ valid: boolean; error?: string }> => {
|
): Promise<{ valid: boolean; error?: string }> {
|
||||||
if (integration.features?.[DatasourceFeature.CONNECTION_CHECKING]) {
|
if (integration.features?.[DatasourceFeature.CONNECTION_CHECKING]) {
|
||||||
const { connected, error } = await API.validateDatasource(datasource)
|
const { connected, error } = await API.validateDatasource(datasource)
|
||||||
if (connected) {
|
if (connected) {
|
||||||
|
@ -148,14 +180,14 @@ export function createDatasourcesStore() {
|
||||||
return { valid: true }
|
return { valid: true }
|
||||||
}
|
}
|
||||||
|
|
||||||
const create = async ({
|
async create({
|
||||||
integration,
|
integration,
|
||||||
config,
|
config,
|
||||||
}: {
|
}: {
|
||||||
integration: UIIntegration
|
integration: UIIntegration
|
||||||
config: Record<string, any>
|
config: Record<string, any>
|
||||||
}) => {
|
}) {
|
||||||
const count = sourceCount(integration.name)
|
const count = this.sourceCount(integration.name)
|
||||||
const nameModifier = count === 0 ? "" : ` ${count + 1}`
|
const nameModifier = count === 0 ? "" : ` ${count + 1}`
|
||||||
|
|
||||||
const datasource: Datasource = {
|
const datasource: Datasource = {
|
||||||
|
@ -167,7 +199,7 @@ export function createDatasourcesStore() {
|
||||||
isSQL: integration.isSQL,
|
isSQL: integration.isSQL,
|
||||||
}
|
}
|
||||||
|
|
||||||
const { valid, error } = await checkDatasourceValidity(
|
const { valid, error } = await this.checkDatasourceValidity(
|
||||||
integration,
|
integration,
|
||||||
datasource
|
datasource
|
||||||
)
|
)
|
||||||
|
@ -180,43 +212,47 @@ export function createDatasourcesStore() {
|
||||||
fetchSchema: integration.plus,
|
fetchSchema: integration.plus,
|
||||||
})
|
})
|
||||||
|
|
||||||
return updateDatasource(response, { ignoreErrors: true })
|
return this.updateDatasourceInStore(response, { ignoreErrors: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
const update = async ({
|
async save({
|
||||||
integration,
|
integration,
|
||||||
datasource,
|
datasource,
|
||||||
}: {
|
}: {
|
||||||
integration: Integration
|
integration: Integration
|
||||||
datasource: Datasource
|
datasource: Datasource
|
||||||
}) => {
|
}) {
|
||||||
if (await checkDatasourceValidity(integration, datasource)) {
|
if (!(await this.checkDatasourceValidity(integration, datasource)).valid) {
|
||||||
throw new Error("Unable to connect")
|
throw new Error("Unable to connect")
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await API.updateDatasource(datasource)
|
const response = await API.updateDatasource(datasource)
|
||||||
|
|
||||||
return updateDatasource(response)
|
return this.updateDatasourceInStore(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteDatasource = async (datasource: Datasource) => {
|
async deleteDatasource(datasource: Datasource) {
|
||||||
if (!datasource?._id || !datasource?._rev) {
|
if (!datasource?._id || !datasource?._rev) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await API.deleteDatasource(datasource._id, datasource._rev)
|
await API.deleteDatasource(datasource._id, datasource._rev)
|
||||||
replaceDatasource(datasource._id)
|
this.replaceDatasource(datasource._id)
|
||||||
}
|
}
|
||||||
|
|
||||||
const replaceDatasource = (datasourceId: string, datasource?: Datasource) => {
|
async delete(datasource: Datasource) {
|
||||||
|
return this.deleteDatasource(datasource)
|
||||||
|
}
|
||||||
|
|
||||||
|
replaceDatasource(datasourceId: string, datasource?: Datasource) {
|
||||||
if (!datasourceId) {
|
if (!datasourceId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle deletion
|
// Handle deletion
|
||||||
if (!datasource) {
|
if (!datasource) {
|
||||||
store.update(state => ({
|
this.store.update(state => ({
|
||||||
...state,
|
...state,
|
||||||
list: state.list.filter(x => x._id !== datasourceId),
|
rawList: state.rawList.filter(x => x._id !== datasourceId),
|
||||||
}))
|
}))
|
||||||
tables.removeDatasourceTables(datasourceId)
|
tables.removeDatasourceTables(datasourceId)
|
||||||
queries.removeDatasourceQueries(datasourceId)
|
queries.removeDatasourceQueries(datasourceId)
|
||||||
|
@ -224,11 +260,13 @@ export function createDatasourcesStore() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new datasource
|
// Add new datasource
|
||||||
const index = get(store).list.findIndex(x => x._id === datasource._id)
|
const index = get(this.store).rawList.findIndex(
|
||||||
|
x => x._id === datasource._id
|
||||||
|
)
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
store.update(state => ({
|
this.store.update(state => ({
|
||||||
...state,
|
...state,
|
||||||
list: [...state.list, datasource],
|
rawList: [...state.rawList, datasource],
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// If this is a new datasource then we should refresh the tables list,
|
// If this is a new datasource then we should refresh the tables list,
|
||||||
|
@ -238,30 +276,17 @@ export function createDatasourcesStore() {
|
||||||
|
|
||||||
// Update existing datasource
|
// Update existing datasource
|
||||||
else if (datasource) {
|
else if (datasource) {
|
||||||
store.update(state => {
|
this.store.update(state => {
|
||||||
state.list[index] = datasource
|
state.rawList[index] = datasource
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getTableNames = async (datasource: Datasource) => {
|
async getTableNames(datasource: Datasource) {
|
||||||
const info = await API.fetchInfoForDatasource(datasource)
|
const info = await API.fetchInfoForDatasource(datasource)
|
||||||
return info.tableNames || []
|
return info.tableNames || []
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
|
||||||
subscribe: derivedStore.subscribe,
|
|
||||||
fetch,
|
|
||||||
init: fetch,
|
|
||||||
select,
|
|
||||||
updateSchema,
|
|
||||||
create,
|
|
||||||
update,
|
|
||||||
delete: deleteDatasource,
|
|
||||||
replaceDatasource,
|
|
||||||
getTableNames,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const datasources = createDatasourcesStore()
|
export const datasources = new DatasourceStore()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { previewStore } from "stores/builder"
|
import { previewStore } from "stores/builder"
|
||||||
import BudiStore from "../BudiStore"
|
import { BudiStore } from "../BudiStore"
|
||||||
|
|
||||||
export const INITIAL_HOVER_STATE = {
|
export const INITIAL_HOVER_STATE = {
|
||||||
componentId: null,
|
componentId: null,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { derived, get } from "svelte/store"
|
import { derived, get } from "svelte/store"
|
||||||
import { componentStore } from "stores/builder"
|
import { componentStore } from "stores/builder"
|
||||||
import BudiStore from "../BudiStore"
|
import { BudiStore } from "../BudiStore"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
|
|
||||||
export const INITIAL_LAYOUT_STATE = {
|
export const INITIAL_LAYOUT_STATE = {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { appStore } from "stores/builder"
|
import { appStore } from "stores/builder"
|
||||||
import BudiStore from "../BudiStore"
|
import { BudiStore } from "../BudiStore"
|
||||||
|
|
||||||
export const INITIAL_NAVIGATION_STATE = {
|
export const INITIAL_NAVIGATION_STATE = {
|
||||||
navigation: "Top",
|
navigation: "Top",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { get, derived } from "svelte/store"
|
import { get, derived } from "svelte/store"
|
||||||
import BudiStore from "stores/BudiStore"
|
import { BudiStore } from "stores/BudiStore"
|
||||||
import { tables } from "./tables"
|
import { tables } from "./tables"
|
||||||
import { viewsV2 } from "./viewsV2"
|
import { viewsV2 } from "./viewsV2"
|
||||||
import { automationStore } from "./automations"
|
import { automationStore } from "./automations"
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
} from "stores/builder"
|
} from "stores/builder"
|
||||||
import { createHistoryStore } from "stores/builder/history"
|
import { createHistoryStore } from "stores/builder/history"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import BudiStore from "../BudiStore"
|
import { BudiStore } from "../BudiStore"
|
||||||
|
|
||||||
export const INITIAL_SCREENS_STATE = {
|
export const INITIAL_SCREENS_STATE = {
|
||||||
screens: [],
|
screens: [],
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { derived } from "svelte/store"
|
||||||
|
|
||||||
import { DatasourceTypes } from "constants/backend"
|
import { DatasourceTypes } from "constants/backend"
|
||||||
import { UIIntegration, Integration } from "@budibase/types"
|
import { UIIntegration, Integration } from "@budibase/types"
|
||||||
|
import { BudiStore } from "stores/BudiStore"
|
||||||
|
|
||||||
const getIntegrationOrder = (type: string | undefined) => {
|
const getIntegrationOrder = (type: string | undefined) => {
|
||||||
// if type is not known, sort to end
|
// if type is not known, sort to end
|
||||||
|
@ -18,29 +19,35 @@ const getIntegrationOrder = (type: string | undefined) => {
|
||||||
return type.charCodeAt(0) + 4
|
return type.charCodeAt(0) + 4
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createSortedIntegrationsStore = () => {
|
export class SortedIntegrationStore extends BudiStore<UIIntegration[]> {
|
||||||
return derived<typeof integrations, UIIntegration[]>(
|
constructor() {
|
||||||
integrations,
|
super([])
|
||||||
$integrations => {
|
|
||||||
const entries: [string, Integration][] = Object.entries($integrations)
|
|
||||||
const integrationsAsArray = entries.map(([name, integration]) => ({
|
|
||||||
name,
|
|
||||||
...integration,
|
|
||||||
}))
|
|
||||||
|
|
||||||
return integrationsAsArray.sort((integrationA, integrationB) => {
|
const derivedStore = derived<typeof integrations, UIIntegration[]>(
|
||||||
const integrationASortOrder = getIntegrationOrder(integrationA.type)
|
integrations,
|
||||||
const integrationBSortOrder = getIntegrationOrder(integrationB.type)
|
$integrations => {
|
||||||
if (integrationASortOrder === integrationBSortOrder) {
|
const entries: [string, Integration][] = Object.entries($integrations)
|
||||||
return integrationA.friendlyName.localeCompare(
|
const integrationsAsArray = entries.map(([name, integration]) => ({
|
||||||
integrationB.friendlyName
|
name,
|
||||||
)
|
...integration,
|
||||||
}
|
}))
|
||||||
|
|
||||||
return integrationASortOrder < integrationBSortOrder ? -1 : 1
|
return integrationsAsArray.sort((integrationA, integrationB) => {
|
||||||
})
|
const integrationASortOrder = getIntegrationOrder(integrationA.type)
|
||||||
}
|
const integrationBSortOrder = getIntegrationOrder(integrationB.type)
|
||||||
)
|
if (integrationASortOrder === integrationBSortOrder) {
|
||||||
|
return integrationA.friendlyName.localeCompare(
|
||||||
|
integrationB.friendlyName
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return integrationASortOrder < integrationBSortOrder ? -1 : 1
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
this.subscribe = derivedStore.subscribe
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const sortedIntegrations = createSortedIntegrationsStore()
|
export const sortedIntegrations = new SortedIntegrationStore()
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
import { it, expect, describe, beforeEach, vi } from "vitest"
|
import { it, expect, describe, beforeEach, vi } from "vitest"
|
||||||
import { createSortedIntegrationsStore } from "stores/builder/sortedIntegrations"
|
import { SortedIntegrationStore } from "stores/builder/sortedIntegrations"
|
||||||
import { DatasourceTypes } from "constants/backend"
|
import { DatasourceTypes } from "constants/backend"
|
||||||
|
|
||||||
import { derived } from "svelte/store"
|
import { derived } from "svelte/store"
|
||||||
import { integrations } from "stores/builder/integrations"
|
import { integrations } from "stores/builder/integrations"
|
||||||
|
|
||||||
vi.mock("svelte/store", () => ({
|
vi.mock("svelte/store", () => ({
|
||||||
derived: vi.fn(),
|
derived: vi.fn(() => ({
|
||||||
|
subscribe: vi.fn(),
|
||||||
|
})),
|
||||||
writable: vi.fn(() => ({
|
writable: vi.fn(() => ({
|
||||||
subscribe: vi.fn(),
|
subscribe: vi.fn(),
|
||||||
})),
|
})),
|
||||||
|
@ -14,6 +16,8 @@ vi.mock("svelte/store", () => ({
|
||||||
|
|
||||||
vi.mock("stores/builder/integrations", () => ({ integrations: vi.fn() }))
|
vi.mock("stores/builder/integrations", () => ({ integrations: vi.fn() }))
|
||||||
|
|
||||||
|
const mockedDerived = vi.mocked(derived)
|
||||||
|
|
||||||
const inputA = {
|
const inputA = {
|
||||||
nonRelationalA: {
|
nonRelationalA: {
|
||||||
friendlyName: "non-relational A",
|
friendlyName: "non-relational A",
|
||||||
|
@ -104,25 +108,28 @@ const expectedOutput = [
|
||||||
]
|
]
|
||||||
|
|
||||||
describe("sorted integrations store", () => {
|
describe("sorted integrations store", () => {
|
||||||
beforeEach(ctx => {
|
interface LocalContext {
|
||||||
|
returnedStore: SortedIntegrationStore
|
||||||
|
derivedCallback: any
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach<LocalContext>(ctx => {
|
||||||
vi.clearAllMocks()
|
vi.clearAllMocks()
|
||||||
|
|
||||||
ctx.returnedStore = createSortedIntegrationsStore()
|
ctx.returnedStore = new SortedIntegrationStore()
|
||||||
|
ctx.derivedCallback = mockedDerived.mock.calls[0]?.[1]
|
||||||
ctx.derivedCallback = derived.mock.calls[0][1]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("calls derived with the correct parameters", () => {
|
it("calls derived with the correct parameters", () => {
|
||||||
expect(derived).toHaveBeenCalledTimes(1)
|
expect(mockedDerived).toHaveBeenCalledTimes(1)
|
||||||
expect(derived).toHaveBeenCalledWith(integrations, expect.toBeFunc())
|
expect(mockedDerived).toHaveBeenCalledWith(
|
||||||
|
integrations,
|
||||||
|
expect.any(Function)
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("derived callback", () => {
|
describe("derived callback", () => {
|
||||||
it("When no integrations are loaded", ctx => {
|
it<LocalContext>("When integrations are present", ctx => {
|
||||||
expect(ctx.derivedCallback({})).toEqual([])
|
|
||||||
})
|
|
||||||
|
|
||||||
it("When integrations are present", ctx => {
|
|
||||||
expect(ctx.derivedCallback(inputA)).toEqual(expectedOutput)
|
expect(ctx.derivedCallback(inputA)).toEqual(expectedOutput)
|
||||||
expect(ctx.derivedCallback(inputB)).toEqual(expectedOutput)
|
expect(ctx.derivedCallback(inputB)).toEqual(expectedOutput)
|
||||||
})
|
})
|
|
@ -3,7 +3,7 @@ import { derived } from "svelte/store"
|
||||||
import { AppStatus } from "constants"
|
import { AppStatus } from "constants"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { auth } from "./auth"
|
import { auth } from "./auth"
|
||||||
import BudiStore from "../BudiStore"
|
import { BudiStore } from "../BudiStore"
|
||||||
import { App, UpdateAppRequest } from "@budibase/types"
|
import { App, UpdateAppRequest } from "@budibase/types"
|
||||||
|
|
||||||
interface AppIdentifierMetadata {
|
interface AppIdentifierMetadata {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { licensing } from "./licensing"
|
import { licensing } from "./licensing"
|
||||||
import BudiStore from "../BudiStore"
|
import { BudiStore } from "../BudiStore"
|
||||||
import {
|
import {
|
||||||
DownloadAuditLogsRequest,
|
DownloadAuditLogsRequest,
|
||||||
SearchAuditLogsRequest,
|
SearchAuditLogsRequest,
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { get } from "svelte/store"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { admin } from "stores/portal"
|
import { admin } from "stores/portal"
|
||||||
import analytics from "analytics"
|
import analytics from "analytics"
|
||||||
import BudiStore from "stores/BudiStore"
|
import { BudiStore } from "stores/BudiStore"
|
||||||
import {
|
import {
|
||||||
isSSOUser,
|
isSSOUser,
|
||||||
SetInitInfoRequest,
|
SetInitInfoRequest,
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 7fc699463b3957eb050351b983edef0d25a531ae
|
Subproject commit ae786121d923449b0ad5fcbd123d0a9fec28f65e
|
|
@ -12,6 +12,7 @@ interface FirebaseConfig {
|
||||||
email: string
|
email: string
|
||||||
privateKey: string
|
privateKey: string
|
||||||
projectId: string
|
projectId: string
|
||||||
|
databaseId?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const SCHEMA: Integration = {
|
const SCHEMA: Integration = {
|
||||||
|
@ -30,12 +31,21 @@ const SCHEMA: Integration = {
|
||||||
},
|
},
|
||||||
privateKey: {
|
privateKey: {
|
||||||
type: DatasourceFieldType.STRING,
|
type: DatasourceFieldType.STRING,
|
||||||
|
display: "Private Key",
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
projectId: {
|
projectId: {
|
||||||
type: DatasourceFieldType.STRING,
|
type: DatasourceFieldType.STRING,
|
||||||
|
display: "Project ID",
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
databaseId: {
|
||||||
|
type: DatasourceFieldType.STRING,
|
||||||
|
display: "Database ID",
|
||||||
|
required: false,
|
||||||
|
default: "(default)",
|
||||||
|
placeholder: "(default)",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
query: {
|
query: {
|
||||||
create: {
|
create: {
|
||||||
|
@ -97,6 +107,7 @@ class FirebaseIntegration implements IntegrationBase {
|
||||||
this.config = config
|
this.config = config
|
||||||
this.client = new Firestore({
|
this.client = new Firestore({
|
||||||
projectId: config.projectId,
|
projectId: config.projectId,
|
||||||
|
databaseId: config.databaseId || "(default)",
|
||||||
credentials: {
|
credentials: {
|
||||||
client_email: config.email,
|
client_email: config.email,
|
||||||
private_key: config.privateKey?.replace(/\\n/g, "\n"),
|
private_key: config.privateKey?.replace(/\\n/g, "\n"),
|
||||||
|
|
|
@ -119,6 +119,7 @@ interface DatasourceBasicFieldConfig {
|
||||||
default?: any
|
default?: any
|
||||||
deprecated?: boolean
|
deprecated?: boolean
|
||||||
hidden?: string
|
hidden?: string
|
||||||
|
placeholder?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DatasourceSelectFieldConfig extends DatasourceBasicFieldConfig {
|
interface DatasourceSelectFieldConfig extends DatasourceBasicFieldConfig {
|
||||||
|
|
Loading…
Reference in New Issue