mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
feat: Add customizable ui config
This commit is contained in:
parent
e1dc9bdec1
commit
bb396b6c62
@ -55,6 +55,7 @@ Available unleash options include:
|
||||
- `none` - will disable authentication altogether
|
||||
- `unsecure` - (default) will use simple cookie based authentication. UI will require the user to specify an email in order to use unleash.
|
||||
- `custom` - use this when you implement your own custom authentication logic.
|
||||
- **ui** (object) - Set of UI specific overrides. You may set the following keys: `headerBackground`, `environment`, `slogan`.
|
||||
|
||||
### 3. Docker
|
||||
|
||||
|
@ -19,6 +19,7 @@ const DEFAULT_OPTIONS = {
|
||||
secret: 'UNLEASH-SECRET',
|
||||
sessionAge: THIRTY_DAYS,
|
||||
adminAuthentication: 'unsecure',
|
||||
ui: {},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
@ -36,6 +37,7 @@ module.exports = {
|
||||
'You must either pass databaseUrl option or set environemnt variable DATABASE_URL'
|
||||
);
|
||||
}
|
||||
|
||||
return options;
|
||||
},
|
||||
};
|
||||
|
19
lib/routes/admin-api/config.js
Normal file
19
lib/routes/admin-api/config.js
Normal file
@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
const Controller = require('../controller');
|
||||
|
||||
class ConfigController extends Controller {
|
||||
constructor(config) {
|
||||
super(config);
|
||||
this.uiConfig = config.ui;
|
||||
|
||||
this.get('/', this.getUIConfig);
|
||||
}
|
||||
|
||||
async getUIConfig(req, res) {
|
||||
const config = this.uiConfig;
|
||||
res.json(config);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ConfigController;
|
44
lib/routes/admin-api/config.test.js
Normal file
44
lib/routes/admin-api/config.test.js
Normal file
@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
|
||||
const test = require('ava');
|
||||
const store = require('./../../../test/fixtures/store');
|
||||
const supertest = require('supertest');
|
||||
const getApp = require('../../app');
|
||||
|
||||
const { EventEmitter } = require('events');
|
||||
const eventBus = new EventEmitter();
|
||||
|
||||
const uiConfig = {
|
||||
headerBackground: 'red',
|
||||
slogan: 'hello',
|
||||
};
|
||||
|
||||
function getSetup() {
|
||||
const base = `/random${Math.round(Math.random() * 1000)}`;
|
||||
const stores = store.createStores();
|
||||
const app = getApp({
|
||||
baseUriPath: base,
|
||||
stores,
|
||||
eventBus,
|
||||
extendedPermissions: false,
|
||||
ui: uiConfig,
|
||||
});
|
||||
|
||||
return {
|
||||
base,
|
||||
request: supertest(app),
|
||||
};
|
||||
}
|
||||
|
||||
test('should get ui config', t => {
|
||||
t.plan(2);
|
||||
const { request, base } = getSetup();
|
||||
return request
|
||||
.get(`${base}/api/admin/ui-config`)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.expect(res => {
|
||||
t.true(res.body.slogan === 'hello');
|
||||
t.true(res.body.headerBackground === 'red');
|
||||
});
|
||||
});
|
@ -7,6 +7,7 @@ const EventController = require('./event.js');
|
||||
const StrategyController = require('./strategy');
|
||||
const MetricsController = require('./metrics');
|
||||
const UserController = require('./user');
|
||||
const ConfigController = require('./config');
|
||||
const apiDef = require('./api-def.json');
|
||||
|
||||
class AdminApi extends Controller {
|
||||
@ -20,6 +21,7 @@ class AdminApi extends Controller {
|
||||
this.app.use('/events', new EventController(config).router);
|
||||
this.app.use('/metrics', new MetricsController(config).router);
|
||||
this.app.use('/user', new UserController(config).router);
|
||||
this.app.use('/ui-config', new ConfigController(config).router);
|
||||
}
|
||||
|
||||
index(req, res) {
|
||||
|
@ -79,7 +79,7 @@
|
||||
"prometheus-gc-stats": "^0.6.1",
|
||||
"response-time": "^2.3.2",
|
||||
"serve-favicon": "^2.5.0",
|
||||
"unleash-frontend": "3.2.1",
|
||||
"unleash-frontend": "3.2.2",
|
||||
"yallist": "^3.0.3",
|
||||
"yargs": "^13.2.1"
|
||||
},
|
||||
|
@ -5959,10 +5959,10 @@ universalify@^0.1.0:
|
||||
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
|
||||
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
|
||||
|
||||
unleash-frontend@3.2.1:
|
||||
version "3.2.1"
|
||||
resolved "https://registry.yarnpkg.com/unleash-frontend/-/unleash-frontend-3.2.1.tgz#d82e18841eb8d53107eb82b512738ccfed51ffba"
|
||||
integrity sha512-O/ckWWfFHqJN4Vt0w3YuacEIgeukFWj2iKH2dPRyLkjOjykvjHD8MyWdD6AnhVwdI3IRUWpJNvQjd5y7JX9gxw==
|
||||
unleash-frontend@3.2.2:
|
||||
version "3.2.2"
|
||||
resolved "https://registry.yarnpkg.com/unleash-frontend/-/unleash-frontend-3.2.2.tgz#0c43c291a3fa584710ebc28f5dce00af6f54256d"
|
||||
integrity sha512-jbYPn38l7q+2L23X/UYmpuYcgnuhfQ++gA1r0rFeVF202zKgtXlNTKp4grRvDDv/rxMWe05t8UjtVoRkL93p8Q==
|
||||
|
||||
unpipe@1.0.0, unpipe@~1.0.0:
|
||||
version "1.0.0"
|
||||
|
Loading…
Reference in New Issue
Block a user