Changing how flags are handled.
This commit is contained in:
parent
b21fe320c5
commit
1d6a350311
|
@ -38,9 +38,9 @@ export function createAdminStore() {
|
|||
async function multiTenancyEnabled() {
|
||||
let enabled = false
|
||||
try {
|
||||
const response = await api.get(`/api/global/tenants/enabled`)
|
||||
const response = await api.get(`/api/global/flags`)
|
||||
const json = await response.json()
|
||||
enabled = json.enabled
|
||||
enabled = json.multiTenancy
|
||||
} catch (err) {
|
||||
// just let it stay disabled
|
||||
}
|
||||
|
|
|
@ -10,10 +10,11 @@ CREATE TABLE Persons (
|
|||
CREATE TABLE Tasks (
|
||||
TaskID SERIAL PRIMARY KEY,
|
||||
PersonID INT,
|
||||
Completed BOOLEAN,
|
||||
TaskName varchar(255),
|
||||
CONSTRAINT fkPersons
|
||||
FOREIGN KEY(PersonID)
|
||||
REFERENCES Persons(PersonID)
|
||||
REFERENCES Persons(PersonID)
|
||||
);
|
||||
CREATE TABLE Products (
|
||||
ProductID SERIAL PRIMARY KEY,
|
||||
|
@ -24,15 +25,15 @@ CREATE TABLE Products_Tasks (
|
|||
TaskID INT NOT NULL,
|
||||
CONSTRAINT fkProducts
|
||||
FOREIGN KEY(ProductID)
|
||||
REFERENCES Products(ProductID),
|
||||
REFERENCES Products(ProductID),
|
||||
CONSTRAINT fkTasks
|
||||
FOREIGN KEY(TaskID)
|
||||
REFERENCES Tasks(TaskID),
|
||||
REFERENCES Tasks(TaskID),
|
||||
PRIMARY KEY (ProductID, TaskID)
|
||||
);
|
||||
INSERT INTO Persons (FirstName, LastName, Address, City) VALUES ('Mike', 'Hughes', '123 Fake Street', 'Belfast');
|
||||
INSERT INTO Tasks (PersonID, TaskName) VALUES (1, 'assembling');
|
||||
INSERT INTO Tasks (PersonID, TaskName) VALUES (1, 'processing');
|
||||
INSERT INTO Tasks (PersonID, TaskName, Completed) VALUES (1, 'assembling', TRUE);
|
||||
INSERT INTO Tasks (PersonID, TaskName, Completed) VALUES (1, 'processing', FALSE);
|
||||
INSERT INTO Products (ProductName) VALUES ('Computers');
|
||||
INSERT INTO Products (ProductName) VALUES ('Laptops');
|
||||
INSERT INTO Products (ProductName) VALUES ('Chairs');
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
const env = require("../../../environment")
|
||||
|
||||
exports.fetch = async ctx => {
|
||||
ctx.body = {
|
||||
multiTenancy: !!env.MULTI_TENANCY,
|
||||
}
|
||||
}
|
|
@ -1,13 +1,6 @@
|
|||
const env = require("../../../environment")
|
||||
const CouchDB = require("../../../db")
|
||||
const { StaticDatabases } = require("@budibase/auth/db")
|
||||
|
||||
exports.multiTenancyEnabled = async ctx => {
|
||||
ctx.body = {
|
||||
enabled: false,
|
||||
}
|
||||
}
|
||||
|
||||
exports.exists = async ctx => {
|
||||
const tenantId = ctx.request.params
|
||||
const db = new CouchDB(StaticDatabases.PLATFORM_INFO.name)
|
||||
|
|
|
@ -21,7 +21,7 @@ const PUBLIC_ENDPOINTS = [
|
|||
method: "GET",
|
||||
},
|
||||
{
|
||||
route: "api/global/tenants/enabled",
|
||||
route: "api/global/flags",
|
||||
method: "GET",
|
||||
},
|
||||
{
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
const Router = require("@koa/router")
|
||||
const controller = require("../../controllers/global/flags")
|
||||
|
||||
const router = Router()
|
||||
|
||||
router
|
||||
.get("/api/global/flags", controller.fetch)
|
||||
|
||||
module.exports = router
|
|
@ -5,7 +5,6 @@ const adminOnly = require("../../../middleware/adminOnly")
|
|||
const router = Router()
|
||||
|
||||
router
|
||||
.get("/api/global/tenants/enabled", controller.multiTenancyEnabled)
|
||||
.get("/api/global/tenants/:tenantId/exists", controller.exists)
|
||||
.get("/api/global/tenants", adminOnly, controller.fetch)
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ const emailRoutes = require("./global/email")
|
|||
const authRoutes = require("./global/auth")
|
||||
const roleRoutes = require("./global/roles")
|
||||
const sessionRoutes = require("./global/sessions")
|
||||
const flagRoutes = require("./global/flags")
|
||||
const appRoutes = require("./app")
|
||||
|
||||
exports.routes = [
|
||||
|
@ -20,4 +21,5 @@ exports.routes = [
|
|||
emailRoutes,
|
||||
sessionRoutes,
|
||||
roleRoutes,
|
||||
flagRoutes,
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue