1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

Add features.description to db and ui

This commit is contained in:
Jari Bakken 2014-11-10 16:21:22 +01:00 committed by Ivar Conradi Østhus
parent f17167876e
commit fdf324a9f5
5 changed files with 23 additions and 6 deletions

View File

@ -5,9 +5,11 @@ var eventStore = require('./eventStore'),
dbPool = require('./dbPool');
eventStore.on(eventType.featureCreated, function (event) {
var sql = 'INSERT INTO features(name, enabled, strategy_name, parameters) VALUES ($1, $2, $3, $4)';
var sql = 'INSERT INTO features(name, description, enabled, strategy_name, parameters) ' +
'VALUES ($1, $2, $3, $4, $5)';
var params = [
event.data.name,
event.data.description,
event.data.enabled ? 1 : 0,
event.data.strategy,
event.data.parameters
@ -34,6 +36,10 @@ eventStore.on(eventType.featureUpdated, function (event) {
sql = 'UPDATE features SET strategy_name = $1 WHERE name=$2';
params = [event.data.value, event.data.name];
break;
case 'description':
sql = 'UPDATE features SET description = $1 WHERE name=$2';
params = [event.data.value, event.data.name];
break;
case 'parameters':
sql = 'UPDATE features SET parameters = $1 WHERE name=$2';
params = [event.data.value, event.data.name];
@ -57,7 +63,8 @@ eventStore.on(eventType.featureUpdated, function (event) {
);
function getFeatures() {
var sql = 'SELECT name, enabled, strategy_name as strategy, parameters FROM features ORDER BY created_at DESC';
var sql = 'SELECT name, description, enabled, strategy_name as strategy, parameters ' +
'FROM features ORDER BY created_at DESC';
return new Promise(function (resolve, reject) {
dbPool.query(sql, function(err, res) {
if(err) {reject(err);}
@ -67,7 +74,8 @@ function getFeatures() {
}
function getFeature(name) {
var sql = 'SELECT name, enabled, strategy_name as strategy, parameters FROM features WHERE name=$1';
var sql = 'SELECT name, description, enabled, strategy_name as strategy, parameters ' +
'FROM features WHERE name=$1';
return new Promise(function (resolve, reject) {
dbPool.query(sql, [name], function(err, res) {
@ -85,6 +93,7 @@ function getFeature(name) {
function mapToToggle(row) {
return {
name: row.name,
description: row.description,
enabled: row.enabled > 0,
strategy: row.strategy,
parameters: row.parameters

View File

@ -0,0 +1,2 @@
module.exports = require('../lib/migrationRunner').create('002-add-description-to-features');

View File

@ -0,0 +1 @@
ALTER TABLE features DROP COLUMN "description";

View File

@ -0,0 +1 @@
ALTER TABLE features ADD "description" text;

View File

@ -12,15 +12,19 @@ var Feature = React.createClass({
render: function() {
return (
<div className='line mal'>
<div className='unit r-size1of6'>
<div className='unit r-size1of5'>
<input type='checkbox' checked={this.props.feature.enabled} onChange={this.onChange} />
</div>
<div className='unit r-size2of5' title={this.props.feature.description}>
<div className='unit r-size1of5'>
{this.props.feature.name}
</div>
<div className='unit '>
<div className='unit r-size2of5 opaque smalltext truncate'>
{this.props.feature.description || '\u00a0'}
</div>
<div className='unit'>
{this.props.feature.strategy}
</div>
</div>