Fixing up everything found when testing with Cypress.

This commit is contained in:
mike12345567 2021-07-26 13:19:47 +01:00
parent a630bfb515
commit 4606248ffd
9 changed files with 17 additions and 10 deletions

View File

@ -209,11 +209,10 @@ exports.getDeployedAppID = appId => {
* different users/companies apps as there is no security around it - all apps are returned. * different users/companies apps as there is no security around it - all apps are returned.
* @return {Promise<object[]>} returns the app information document stored in each app database. * @return {Promise<object[]>} returns the app information document stored in each app database.
*/ */
exports.getAllApps = async ({ tenantId, dev, all } = {}) => { exports.getAllApps = async (CouchDB, { tenantId, dev, all } = {}) => {
if (!tenantId) { if (!tenantId) {
tenantId = DEFAULT_TENANT_ID tenantId = DEFAULT_TENANT_ID
} }
const CouchDB = getCouch()
let allDbs = await CouchDB.allDbs() let allDbs = await CouchDB.allDbs()
const appDbNames = allDbs.filter(dbName => { const appDbNames = allDbs.filter(dbName => {
const split = dbName.split(SEPARATOR) const split = dbName.split(SEPARATOR)

View File

@ -7,6 +7,7 @@
import { onMount } from "svelte" import { onMount } from "svelte"
let tenantId = get(auth).tenantSet ? get(auth).tenantId : "" let tenantId = get(auth).tenantSet ? get(auth).tenantId : ""
$: multiTenancyEnabled = $admin.multiTenancy
async function setOrg() { async function setOrg() {
if (tenantId == null || tenantId === "") { if (tenantId == null || tenantId === "") {
@ -24,6 +25,9 @@
onMount(() => { onMount(() => {
auth.checkQueryString() auth.checkQueryString()
if (!multiTenancyEnabled) {
$goto("../")
}
}) })
</script> </script>

View File

@ -47,7 +47,7 @@ async function init() {
COUCH_DB_PASSWORD: "budibase", COUCH_DB_PASSWORD: "budibase",
COUCH_DB_USER: "budibase", COUCH_DB_USER: "budibase",
SELF_HOSTED: 1, SELF_HOSTED: 1,
MULTI_TENANCY: 0, MULTI_TENANCY: "",
} }
let envFile = "" let envFile = ""
Object.keys(envFileJson).forEach(key => { Object.keys(envFileJson).forEach(key => {

View File

@ -129,7 +129,7 @@ exports.fetch = async function (ctx) {
const dev = ctx.query && ctx.query.status === AppStatus.DEV const dev = ctx.query && ctx.query.status === AppStatus.DEV
const all = ctx.query && ctx.query.status === AppStatus.ALL const all = ctx.query && ctx.query.status === AppStatus.ALL
const tenantId = ctx.user.tenantId const tenantId = ctx.user.tenantId
const apps = await getAllApps({ tenantId, dev, all }) const apps = await getAllApps(CouchDB, { tenantId, dev, all })
// get the locks for all the dev apps // get the locks for all the dev apps
if (dev || all) { if (dev || all) {
@ -226,7 +226,8 @@ exports.create = async function (ctx) {
updatedAt: new Date().toISOString(), updatedAt: new Date().toISOString(),
createdAt: new Date().toISOString(), createdAt: new Date().toISOString(),
} }
await db.put(newApplication, { force: true }) const response = await db.put(newApplication, { force: true })
newApplication._rev = response.rev
await createEmptyAppPackage(ctx, newApplication) await createEmptyAppPackage(ctx, newApplication)
/* istanbul ignore next */ /* istanbul ignore next */

View File

@ -6,11 +6,11 @@ const { BUILDER } = require("@budibase/auth/permissions")
const router = Router() const router = Router()
router router
.post("/api/applications", authorized(BUILDER), controller.create)
.get("/api/applications/:appId/definition", controller.fetchAppDefinition) .get("/api/applications/:appId/definition", controller.fetchAppDefinition)
.get("/api/applications", controller.fetch) .get("/api/applications", controller.fetch)
.get("/api/applications/:appId/appPackage", controller.fetchAppPackage) .get("/api/applications/:appId/appPackage", controller.fetchAppPackage)
.put("/api/applications/:appId", authorized(BUILDER), controller.update) .put("/api/applications/:appId", authorized(BUILDER), controller.update)
.post("/api/applications", authorized(BUILDER), controller.create)
.post( .post(
"/api/applications/:appId/client/update", "/api/applications/:appId/client/update",
authorized(BUILDER), authorized(BUILDER),

View File

@ -16,7 +16,8 @@ async function init() {
REDIS_PASSWORD: "budibase", REDIS_PASSWORD: "budibase",
MINIO_URL: "http://localhost:10000/", MINIO_URL: "http://localhost:10000/",
COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/", COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/",
MULTI_TENANCY: 0, // empty string is false
MULTI_TENANCY: "",
} }
let envFile = "" let envFile = ""
Object.keys(envFileJson).forEach(key => { Object.keys(envFileJson).forEach(key => {

View File

@ -1,10 +1,11 @@
const { getAllApps } = require("@budibase/auth/db") const { getAllApps } = require("@budibase/auth/db")
const CouchDB = require("../../db")
const URL_REGEX_SLASH = /\/|\\/g const URL_REGEX_SLASH = /\/|\\/g
exports.getApps = async ctx => { exports.getApps = async ctx => {
const tenantId = ctx.user.tenantId const tenantId = ctx.user.tenantId
const apps = await getAllApps({ tenantId }) const apps = await getAllApps(CouchDB, { tenantId })
const body = {} const body = {}
for (let app of apps) { for (let app of apps) {

View File

@ -10,6 +10,7 @@ const {
const { Configs } = require("../../../constants") const { Configs } = require("../../../constants")
const email = require("../../../utilities/email") const email = require("../../../utilities/email")
const { upload, ObjectStoreBuckets } = require("@budibase/auth").objectStore const { upload, ObjectStoreBuckets } = require("@budibase/auth").objectStore
const CouchDB = require("../../../db")
exports.save = async function (ctx) { exports.save = async function (ctx) {
const db = getGlobalDBFromCtx(ctx) const db = getGlobalDBFromCtx(ctx)
@ -224,7 +225,7 @@ exports.configChecklist = async function (ctx) {
// TODO: Watch get started video // TODO: Watch get started video
// Apps exist // Apps exist
const apps = await getAllApps({ tenantId }) const apps = await getAllApps(CouchDB, { tenantId })
// They have set up SMTP // They have set up SMTP
const smtpConfig = await getScopedFullConfig(db, { const smtpConfig = await getScopedFullConfig(db, {

View File

@ -9,7 +9,7 @@ const CouchDB = require("../../../db")
exports.fetch = async ctx => { exports.fetch = async ctx => {
const tenantId = ctx.user.tenantId const tenantId = ctx.user.tenantId
// always use the dev apps as they'll be most up to date (true) // always use the dev apps as they'll be most up to date (true)
const apps = await getAllApps({ tenantId, all: true }) const apps = await getAllApps(CouchDB, { tenantId, all: true })
const promises = [] const promises = []
for (let app of apps) { for (let app of apps) {
// use dev app IDs // use dev app IDs