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