mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +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:
commit
8286601522
@ -1,8 +1,10 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- "0.10"
|
- "0.10"
|
||||||
script:
|
script:
|
||||||
- npm install && npm test && npm run coverage-report
|
- npm install
|
||||||
|
- npm test
|
||||||
|
- npm run coverage-report || true
|
||||||
notifications:
|
notifications:
|
||||||
hipchat:
|
hipchat:
|
||||||
rooms:
|
rooms:
|
||||||
|
@ -5,9 +5,11 @@ var eventStore = require('./eventStore'),
|
|||||||
dbPool = require('./dbPool');
|
dbPool = require('./dbPool');
|
||||||
|
|
||||||
eventStore.on(eventType.featureCreated, function (event) {
|
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 = [
|
var params = [
|
||||||
event.data.name,
|
event.data.name,
|
||||||
|
event.data.description,
|
||||||
event.data.enabled ? 1 : 0,
|
event.data.enabled ? 1 : 0,
|
||||||
event.data.strategy,
|
event.data.strategy,
|
||||||
event.data.parameters
|
event.data.parameters
|
||||||
@ -34,6 +36,10 @@ eventStore.on(eventType.featureUpdated, function (event) {
|
|||||||
sql = 'UPDATE features SET strategy_name = $1 WHERE name=$2';
|
sql = 'UPDATE features SET strategy_name = $1 WHERE name=$2';
|
||||||
params = [event.data.value, event.data.name];
|
params = [event.data.value, event.data.name];
|
||||||
break;
|
break;
|
||||||
|
case 'description':
|
||||||
|
sql = 'UPDATE features SET description = $1 WHERE name=$2';
|
||||||
|
params = [event.data.value, event.data.name];
|
||||||
|
break;
|
||||||
case 'parameters':
|
case 'parameters':
|
||||||
sql = 'UPDATE features SET parameters = $1 WHERE name=$2';
|
sql = 'UPDATE features SET parameters = $1 WHERE name=$2';
|
||||||
params = [event.data.value, event.data.name];
|
params = [event.data.value, event.data.name];
|
||||||
@ -57,7 +63,8 @@ eventStore.on(eventType.featureUpdated, function (event) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
function getFeatures() {
|
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) {
|
return new Promise(function (resolve, reject) {
|
||||||
dbPool.query(sql, function(err, res) {
|
dbPool.query(sql, function(err, res) {
|
||||||
if(err) {reject(err);}
|
if(err) {reject(err);}
|
||||||
@ -67,7 +74,8 @@ function getFeatures() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getFeature(name) {
|
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) {
|
return new Promise(function (resolve, reject) {
|
||||||
dbPool.query(sql, [name], function(err, res) {
|
dbPool.query(sql, [name], function(err, res) {
|
||||||
@ -85,6 +93,7 @@ function getFeature(name) {
|
|||||||
function mapToToggle(row) {
|
function mapToToggle(row) {
|
||||||
return {
|
return {
|
||||||
name: row.name,
|
name: row.name,
|
||||||
|
description: row.description,
|
||||||
enabled: row.enabled > 0,
|
enabled: row.enabled > 0,
|
||||||
strategy: row.strategy,
|
strategy: row.strategy,
|
||||||
parameters: row.parameters
|
parameters: row.parameters
|
||||||
|
2
migrations/20141110144153-add-description-to-features.js
Normal file
2
migrations/20141110144153-add-description-to-features.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
module.exports = require('../lib/migrationRunner').create('002-add-description-to-features');
|
||||||
|
|
1
migrations/sql/002-add-description-to-features.down.sql
Normal file
1
migrations/sql/002-add-description-to-features.down.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE features DROP COLUMN "description";
|
1
migrations/sql/002-add-description-to-features.up.sql
Normal file
1
migrations/sql/002-add-description-to-features.up.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE features ADD "description" text;
|
@ -12,15 +12,19 @@ var Feature = React.createClass({
|
|||||||
render: function() {
|
render: function() {
|
||||||
return (
|
return (
|
||||||
<div className='line mal'>
|
<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} />
|
<input type='checkbox' checked={this.props.feature.enabled} onChange={this.onChange} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='unit r-size2of5' title={this.props.feature.description}>
|
<div className='unit r-size1of5'>
|
||||||
{this.props.feature.name}
|
{this.props.feature.name}
|
||||||
</div>
|
</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}
|
{this.props.feature.strategy}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user