1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-11 00:08:30 +01:00

Merge pull request #45 from finn-no/add-description-to-features

Add features.description to db and ui
This commit is contained in:
Jari Bakken 2014-11-11 11:45:35 +01:00
commit 8286601522
6 changed files with 27 additions and 8 deletions

View File

@ -1,8 +1,10 @@
language: node_js
node_js:
node_js:
- "0.10"
script:
- npm install && npm test && npm run coverage-report
- npm install
- npm test
- npm run coverage-report || true
notifications:
hipchat:
rooms:

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>