adding endpoint to cloud to check for beta access
This commit is contained in:
parent
61da3a7be0
commit
2a15ac97bb
|
@ -24,6 +24,7 @@
|
|||
|
||||
// Get Package and set store
|
||||
let promise = getPackage()
|
||||
let betaAccess = false
|
||||
|
||||
// Sync once when you load the app
|
||||
let hasSynced = false
|
||||
|
@ -74,6 +75,9 @@
|
|||
if (!hasSynced && application) {
|
||||
try {
|
||||
await API.syncApp(application)
|
||||
// check if user has beta access
|
||||
const betaResponse = await API.checkBetaAccess($auth?.user?.email)
|
||||
betaAccess = betaResponse.access
|
||||
} catch (error) {
|
||||
notifications.error("Failed to sync with production database")
|
||||
}
|
||||
|
@ -91,9 +95,14 @@
|
|||
<div class="loading" />
|
||||
{:then _}
|
||||
<div class="root">
|
||||
<Banner extraButtonText="Try New UI (Beta)" extraButtonAction={newDesignUi}>
|
||||
Try the <b>all new</b> budibase design interface.
|
||||
</Banner>
|
||||
{#if betaAccess}
|
||||
<Banner
|
||||
extraButtonText="Try New UI (Beta)"
|
||||
extraButtonAction={newDesignUi}
|
||||
>
|
||||
Try the <b>all new</b> budibase design interface.
|
||||
</Banner>
|
||||
{/if}
|
||||
<div class="top-nav">
|
||||
<div class="topleftnav">
|
||||
<button class="home-logo">
|
||||
|
|
|
@ -33,6 +33,9 @@ export default ({ mode }) => {
|
|||
),
|
||||
"process.env.POSTHOG_URL": JSON.stringify(process.env.POSTHOG_URL),
|
||||
"process.env.SENTRY_DSN": JSON.stringify(process.env.SENTRY_DSN),
|
||||
"process.env.FEATURE_PREVIEW_URL": JSON.stringify(
|
||||
process.env.FEATURE_PREVIEW_URL
|
||||
),
|
||||
}),
|
||||
],
|
||||
optimizeDeps: {
|
||||
|
|
|
@ -54,4 +54,13 @@ export const buildOtherEndpoints = API => ({
|
|||
url: "/api/permission/builtin",
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if they are part of the budibase beta program.
|
||||
*/
|
||||
checkBetaAccess: async email => {
|
||||
return await API.get({
|
||||
url: `${process.env.FEATURE_PREVIEW_URL}/api/beta/access?email=${email}`,
|
||||
})
|
||||
},
|
||||
})
|
||||
|
|
|
@ -3,8 +3,12 @@ const env = require("../../environment")
|
|||
const { checkSlashesInUrl } = require("../../utilities")
|
||||
const { request } = require("../../utilities/workerRequests")
|
||||
const { clearLock } = require("../../utilities/redis")
|
||||
const { Replication, getProdAppID } = require("@budibase/backend-core/db")
|
||||
const { DocumentTypes } = require("../../db/utils")
|
||||
const {
|
||||
Replication,
|
||||
getProdAppID,
|
||||
dangerousGetDB,
|
||||
} = require("@budibase/backend-core/db")
|
||||
const { DocumentTypes, getRowParams } = require("../../db/utils")
|
||||
const { app: appCache } = require("@budibase/backend-core/cache")
|
||||
const { getProdAppDB, getAppDB } = require("@budibase/backend-core/context")
|
||||
|
||||
|
@ -125,3 +129,33 @@ exports.getBudibaseVersion = async ctx => {
|
|||
version: require("../../../package.json").version,
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: remove as part of beta program
|
||||
exports.checkBetaAccess = async ctx => {
|
||||
const userToCheck = ctx.query.email
|
||||
// const BETA_USERS_DB = "app_bb_f9b77d06b9db4e3ca185476ab87a2364"
|
||||
const TEST_BETA_USERS_DB = "app_de3eaf5d6a9849c3827e529bbf833813"
|
||||
const BETA_USERS_TABLE = "ta_8c2c6df1c03f49cfb6340e85e066dd15"
|
||||
|
||||
try {
|
||||
const db = dangerousGetDB(TEST_BETA_USERS_DB)
|
||||
const betaUsers = (
|
||||
await db.allDocs(
|
||||
getRowParams(BETA_USERS_TABLE, null, {
|
||||
include_docs: true,
|
||||
})
|
||||
)
|
||||
).rows.map(row => row.doc)
|
||||
|
||||
let access = false
|
||||
for (let betaUser of betaUsers) {
|
||||
if (betaUser["Email address"].trim() === userToCheck) {
|
||||
access = true
|
||||
break
|
||||
}
|
||||
}
|
||||
ctx.body = { access }
|
||||
} catch (err) {
|
||||
ctx.body = { access: false }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,5 +22,6 @@ router
|
|||
.get("/api/dev/version", authorized(BUILDER), controller.getBudibaseVersion)
|
||||
.delete("/api/dev/:appId/lock", authorized(BUILDER), controller.clearLock)
|
||||
.post("/api/dev/:appId/revert", authorized(BUILDER), controller.revert)
|
||||
.get("/api/beta/access", controller.checkBetaAccess)
|
||||
|
||||
module.exports = router
|
||||
|
|
|
@ -1014,10 +1014,10 @@
|
|||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
|
||||
"@budibase/backend-core@1.0.197":
|
||||
version "1.0.197"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.197.tgz#3458d70c6d44376b7930672d6af8c6e89ddf4069"
|
||||
integrity sha512-Cgzr1bJWKRg3+jqte7rnKPziWiH5Q+r/piRvHuD7EVmh2+xJLfWUz9iml72aFfcgRIOX8SyhejG7KTwxILx/vg==
|
||||
"@budibase/backend-core@1.0.198":
|
||||
version "1.0.198"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.198.tgz#4b9a4dc4dabc73da31b5f95e38c6cfd2c87bfd09"
|
||||
integrity sha512-IYTY3yuZQ0YVFy4v9zqX0L3ZhFowzY40DgthfbdCbdwHiaoLFpSi0+ynLHxholz3a7eCTcW6M5a3dHqy4kXtIQ==
|
||||
dependencies:
|
||||
"@techpass/passport-openidconnect" "^0.3.0"
|
||||
aws-sdk "^2.901.0"
|
||||
|
@ -1092,21 +1092,12 @@
|
|||
svelte-flatpickr "^3.2.3"
|
||||
svelte-portal "^1.0.0"
|
||||
|
||||
<<<<<<< HEAD
|
||||
"@budibase/pro@1.0.192-alpha.1":
|
||||
version "1.0.192-alpha.1"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.192-alpha.1.tgz#f3dece7ee153ac81080be9f96c7459e5dd8510ff"
|
||||
integrity sha512-BRzoRTIcIW/o2bckSmOrOYCz5HPJyeq4PurfEZFHh16dXPXSBSTIuIiC7Q1jic2CBq5DJOfT/SYTgj/OTVga3g==
|
||||
"@budibase/pro@1.0.198":
|
||||
version "1.0.198"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.198.tgz#b585e269e12317ede722e2b3814329bc63b60185"
|
||||
integrity sha512-ow3R2MZZKwTsAZQ8knPQsVdzS28frAP5/csj0rW1O53mOsVu6K5LZLJMlZ72cLsLDZPHKtAku7Xgb+b+YWtbvA==
|
||||
dependencies:
|
||||
"@budibase/backend-core" "1.0.192-alpha.1"
|
||||
=======
|
||||
"@budibase/pro@1.0.197":
|
||||
version "1.0.197"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.197.tgz#a171b46bb8ee6251881ae9262136270533b3958d"
|
||||
integrity sha512-SCVKjNgpzefmrXnLmkpQJLvYViykyzA6B9TwL7qrb6fBeXwAiSZ3hXGjNgZkVpy/v43hccPWt9BJFzFp457wgQ==
|
||||
dependencies:
|
||||
"@budibase/backend-core" "1.0.197"
|
||||
>>>>>>> bd0ea6fd3ce54fc0f7f8774656d127a91771ea2d
|
||||
"@budibase/backend-core" "1.0.198"
|
||||
node-fetch "^2.6.1"
|
||||
|
||||
"@budibase/standard-components@^0.9.139":
|
||||
|
|
|
@ -293,10 +293,10 @@
|
|||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
|
||||
"@budibase/backend-core@1.0.197":
|
||||
version "1.0.197"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.197.tgz#3458d70c6d44376b7930672d6af8c6e89ddf4069"
|
||||
integrity sha512-Cgzr1bJWKRg3+jqte7rnKPziWiH5Q+r/piRvHuD7EVmh2+xJLfWUz9iml72aFfcgRIOX8SyhejG7KTwxILx/vg==
|
||||
"@budibase/backend-core@1.0.198":
|
||||
version "1.0.198"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.198.tgz#4b9a4dc4dabc73da31b5f95e38c6cfd2c87bfd09"
|
||||
integrity sha512-IYTY3yuZQ0YVFy4v9zqX0L3ZhFowzY40DgthfbdCbdwHiaoLFpSi0+ynLHxholz3a7eCTcW6M5a3dHqy4kXtIQ==
|
||||
dependencies:
|
||||
"@techpass/passport-openidconnect" "^0.3.0"
|
||||
aws-sdk "^2.901.0"
|
||||
|
@ -322,12 +322,12 @@
|
|||
uuid "^8.3.2"
|
||||
zlib "^1.0.5"
|
||||
|
||||
"@budibase/pro@1.0.197":
|
||||
version "1.0.197"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.197.tgz#a171b46bb8ee6251881ae9262136270533b3958d"
|
||||
integrity sha512-SCVKjNgpzefmrXnLmkpQJLvYViykyzA6B9TwL7qrb6fBeXwAiSZ3hXGjNgZkVpy/v43hccPWt9BJFzFp457wgQ==
|
||||
"@budibase/pro@1.0.198":
|
||||
version "1.0.198"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.198.tgz#b585e269e12317ede722e2b3814329bc63b60185"
|
||||
integrity sha512-ow3R2MZZKwTsAZQ8knPQsVdzS28frAP5/csj0rW1O53mOsVu6K5LZLJMlZ72cLsLDZPHKtAku7Xgb+b+YWtbvA==
|
||||
dependencies:
|
||||
"@budibase/backend-core" "1.0.197"
|
||||
"@budibase/backend-core" "1.0.198"
|
||||
node-fetch "^2.6.1"
|
||||
|
||||
"@cspotcode/source-map-consumer@0.8.0":
|
||||
|
|
Loading…
Reference in New Issue