Merge branch 'feature/draft-apps' into admin/user-management-ui

This commit is contained in:
Keviin Åberg Kultalahti 2021-05-14 17:49:09 +02:00
commit 771467fba1
10 changed files with 18 additions and 21 deletions

View File

@ -147,7 +147,9 @@ exports.getRoleParams = (roleId = null, otherProps = {}) => {
exports.getAllApps = async (devApps = false) => {
const CouchDB = getCouch()
let allDbs = await CouchDB.allDbs()
const appDbNames = allDbs.filter(dbName => dbName.startsWith(exports.APP_PREFIX))
const appDbNames = allDbs.filter(dbName =>
dbName.startsWith(exports.APP_PREFIX)
)
const appPromises = appDbNames.map(db => new CouchDB(db).get(db))
if (appPromises.length === 0) {
return []

View File

@ -1,7 +1,12 @@
const { getDB } = require("../db")
const { cloneDeep } = require("lodash/fp")
const { BUILTIN_PERMISSION_IDS, higherPermission } = require("./permissions")
const { generateRoleID, getRoleParams, DocumentTypes, SEPARATOR } = require("../db/utils")
const {
generateRoleID,
getRoleParams,
DocumentTypes,
SEPARATOR,
} = require("../db/utils")
const BUILTIN_IDS = {
ADMIN: "ADMIN",
@ -153,7 +158,7 @@ async function getAllUserRoles(appId, userRoleId) {
currentRole &&
currentRole.inherits &&
roleIds.indexOf(currentRole.inherits) === -1
) {
) {
roleIds.push(currentRole.inherits)
currentRole = await exports.getRole(appId, currentRole.inherits)
roles.push(currentRole)

View File

@ -20,10 +20,7 @@ const {
DocumentTypes,
AppStatus,
} = require("../../db/utils")
const {
BUILTIN_ROLE_IDS,
AccessController,
} = require("@budibase/auth/roles")
const { BUILTIN_ROLE_IDS, AccessController } = require("@budibase/auth/roles")
const { BASE_LAYOUTS } = require("../../constants/layouts")
const {
createHomeScreen,

View File

@ -1,10 +1,7 @@
const Router = require("@koa/router")
const controller = require("../controllers/permission")
const authorized = require("../../middleware/authorized")
const {
BUILDER,
PermissionLevels,
} = require("@budibase/auth/permissions")
const { BUILDER, PermissionLevels } = require("@budibase/auth/permissions")
const Joi = require("joi")
const joiValidator = require("../../middleware/joi-validator")

View File

@ -14,7 +14,7 @@ exports.getAllTableRows = async config => {
}
exports.clearAllApps = async () => {
const req = { query: { status: "dev"} }
const req = { query: { status: "dev" } }
await appController.fetch(req)
const apps = req.body
if (!apps || apps.length <= 0) {

View File

@ -1,7 +1,5 @@
const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles")
const {
BUILTIN_PERMISSION_IDS,
} = require("@budibase/auth/permissions")
const { BUILTIN_PERMISSION_IDS } = require("@budibase/auth/permissions")
const { createHomeScreen } = require("../../constants/screens")
const { EMPTY_LAYOUT } = require("../../constants/layouts")
const { cloneDeep } = require("lodash/fp")

View File

@ -4,10 +4,7 @@ const {
getBuiltinPermissionByID,
isPermissionLevelHigherThanRead,
} = require("@budibase/auth/permissions")
const {
lowerBuiltinRoleID,
getBuiltinRoles,
} = require("@budibase/auth/roles")
const { lowerBuiltinRoleID, getBuiltinRoles } = require("@budibase/auth/roles")
const { DocumentTypes } = require("../db/utils")
const CURRENTLY_SUPPORTED_LEVELS = [

View File

@ -19,6 +19,6 @@ exports.fetch = async ctx => {
exports.find = async ctx => {
const appId = ctx.params.appId
ctx.body = {
roles: await getAllRoles(appId)
roles: await getAllRoles(appId),
}
}

View File

@ -3,7 +3,6 @@ const controller = require("../../controllers/admin/roles")
const router = Router()
router
.get("/api/admin/roles", controller.fetch)
.get("/api/admin/roles/:appId", controller.find)

View File

@ -4,6 +4,7 @@ const groupRoutes = require("./admin/groups")
const templateRoutes = require("./admin/templates")
const emailRoutes = require("./admin/email")
const authRoutes = require("./admin/auth")
const roleRoutes = require("./admin/roles")
const appRoutes = require("./app")
exports.routes = [
@ -14,4 +15,5 @@ exports.routes = [
appRoutes,
templateRoutes,
emailRoutes,
roleRoutes,
]