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

eslint --fix

This commit is contained in:
sveisvei 2016-06-18 21:55:46 +02:00 committed by Ivar Conradi Østhus
parent 65c927726f
commit 065be3d37d
56 changed files with 327 additions and 330 deletions

View File

@ -32,7 +32,7 @@ module.exports = function(config) {
app.use(bodyParser.json({ strict: false })); app.use(bodyParser.json({ strict: false }));
app.use(log4js.connectLogger(logger, { app.use(log4js.connectLogger(logger, {
format: ':remote-addr :status :method :url :response-timems', format: ':remote-addr :status :method :url :response-timems',
level: 'auto' // 3XX=WARN, 4xx/5xx=ERROR level: 'auto', // 3XX=WARN, 4xx/5xx=ERROR
})); }));
// Setup API routes // Setup API routes

View File

@ -5,6 +5,6 @@ module.exports = function(databaseConnection) {
return knex({ return knex({
client: 'pg', client: 'pg',
connection: databaseConnection, connection: databaseConnection,
pool: { min: 2, max: 20 } pool: { min: 2, max: 20 },
}); });
}; };

View File

@ -6,7 +6,7 @@ module.exports = function(db) {
return db('events').insert({ return db('events').insert({
type: event.type, type: event.type,
created_by: event.createdBy, // eslint-disable-line created_by: event.createdBy, // eslint-disable-line
data: event.data data: event.data,
}); });
} }
@ -22,7 +22,7 @@ module.exports = function(db) {
return db return db
.select(EVENT_COLUMNS) .select(EVENT_COLUMNS)
.from('events') .from('events')
.whereRaw("data ->> 'name' = ?", [name]) .whereRaw('data ->> \'name\' = ?', [name])
.orderBy('created_at', 'desc') .orderBy('created_at', 'desc')
.map(rowToEvent); .map(rowToEvent);
} }
@ -33,14 +33,14 @@ module.exports = function(db) {
type: row.type, type: row.type,
createdBy: row.created_by, createdBy: row.created_by,
createdAt: row.created_at, createdAt: row.created_at,
data: row.data data: row.data,
}; };
} }
return { return {
store: storeEvent, store: storeEvent,
getEvents, getEvents,
getEventsFilterByName getEventsFilterByName,
}; };
}; };

View File

@ -50,7 +50,7 @@ module.exports = function(db, eventStore) {
description: row.description, description: row.description,
enabled: row.enabled > 0, enabled: row.enabled > 0,
strategy: row.strategy_name, // eslint-disable-line strategy: row.strategy_name, // eslint-disable-line
parameters: row.parameters parameters: row.parameters,
}; };
} }
@ -61,7 +61,7 @@ module.exports = function(db, eventStore) {
enabled: data.enabled ? 1 : 0, enabled: data.enabled ? 1 : 0,
archived: data.archived ? 1 :0, archived: data.archived ? 1 :0,
strategy_name: data.strategy, // eslint-disable-line strategy_name: data.strategy, // eslint-disable-line
parameters: data.parameters parameters: data.parameters,
}; };
} }
@ -106,6 +106,6 @@ module.exports = function(db, eventStore) {
getFeature, getFeature,
getArchivedFeatures, getArchivedFeatures,
_createFeature: createFeature, // visible for testing _createFeature: createFeature, // visible for testing
_updateFeature: updateFeature // visible for testing _updateFeature: updateFeature, // visible for testing
}; };
}; };

View File

@ -40,7 +40,7 @@ module.exports = function(db, eventStore) {
return { return {
name: row.name, name: row.name,
description: row.description, description: row.description,
parametersTemplate: row.parameters_template parametersTemplate: row.parameters_template,
}; };
} }
@ -63,7 +63,7 @@ module.exports = function(db, eventStore) {
return { return {
getStrategies, getStrategies,
getStrategy, getStrategy,
_createStrategy: createStrategy // visible for testing _createStrategy: createStrategy, // visible for testing
}; };
}; };

View File

@ -1,11 +1,11 @@
'use strict'; 'use strict';
const Promise = require("bluebird"); const Promise = require('bluebird');
const ValidationError = require('./ValidationError'); const ValidationError = require('./ValidationError');
function validateRequest(req) { function validateRequest(req) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (req.validationErrors()) { if (req.validationErrors()) {
reject(new ValidationError("Invalid syntax")); reject(new ValidationError('Invalid syntax'));
} else { } else {
resolve(req); resolve(req);
} }

View File

@ -4,14 +4,14 @@ const diff = require('deep-diff').diff;
const strategyTypes = [ const strategyTypes = [
eventType.strategyCreated, eventType.strategyCreated,
eventType.strategyDeleted eventType.strategyDeleted,
]; ];
const featureTypes = [ const featureTypes = [
eventType.featureCreated, eventType.featureCreated,
eventType.featureUpdated, eventType.featureUpdated,
eventType.featureArchived, eventType.featureArchived,
eventType.featureRevived eventType.featureRevived,
]; ];
function baseTypeFor(event) { function baseTypeFor(event) {
@ -74,5 +74,5 @@ function addDiffs(events) {
module.exports = { module.exports = {
addDiffs addDiffs,
}; };

View File

@ -5,5 +5,5 @@ module.exports = {
featureArchived: 'feature-archived', featureArchived: 'feature-archived',
featureRevived: 'feature-revived', featureRevived: 'feature-revived',
strategyCreated: 'strategy-created', strategyCreated: 'strategy-created',
strategyDeleted: 'strategy-deleted' strategyDeleted: 'strategy-deleted',
}; };

View File

@ -1,5 +1,5 @@
'use strict'; 'use strict';
function extractUsername(req) { function extractUsername(req) {
return req.cookies.username || "unknown"; return req.cookies.username || 'unknown';
} }
module.exports = extractUsername; module.exports = extractUsername;

View File

@ -19,16 +19,16 @@ module.exports = function (app, config) {
validateRequest(req) validateRequest(req)
.then(() => eventStore.create({ .then(() => eventStore.create({
type: eventType.featureRevived, type: eventType.featureRevived,
createdBy: req.connection.remoteAddress, createdBy: req.connection.remoteAddress,
data: req.body data: req.body,
})).then(() => { })).then(() => {
res.status(200).end(); res.status(200).end();
}).catch(ValidationError, () => { }).catch(ValidationError, () => {
res.status(400).json(req.validationErrors()); res.status(400).json(req.validationErrors());
}) })
.catch(err => { .catch(err => {
logger.error("Could not revive feature toggle", err); logger.error('Could not revive feature toggle', err);
res.status(500).end(); res.status(500).end();
}); });
}); });

View File

@ -1,5 +1,5 @@
'use strict'; 'use strict';
const Promise = require("bluebird"); const Promise = require('bluebird');
const logger = require('../logger'); const logger = require('../logger');
const eventType = require('../eventType'); const eventType = require('../eventType');
const NameExistsError = require('../error/NameExistsError'); const NameExistsError = require('../error/NameExistsError');
@ -35,23 +35,23 @@ module.exports = function (app, config) {
validateRequest(req) validateRequest(req)
.then(validateUniqueName) .then(validateUniqueName)
.then(() => eventStore.create({ .then(() => eventStore.create({
type: eventType.featureCreated, type: eventType.featureCreated,
createdBy: extractUser(req), createdBy: extractUser(req),
data: req.body data: req.body,
})) }))
.then(() => { .then(() => {
res.status(201).end(); res.status(201).end();
}) })
.catch(NameExistsError, () => { .catch(NameExistsError, () => {
res.status(403).json([{ res.status(403).json([{
msg: `A feature named '${req.body.name}' already exists. It could be archived.` msg: `A feature named '${req.body.name}' already exists. It could be archived.`,
}]).end(); }]).end();
}) })
.catch(ValidationError, () => { .catch(ValidationError, () => {
res.status(400).json(req.validationErrors()); res.status(400).json(req.validationErrors());
}) })
.catch(err => { .catch(err => {
logger.error("Could not create feature toggle", err); logger.error('Could not create feature toggle', err);
res.status(500).end(); res.status(500).end();
}); });
}); });
@ -65,10 +65,10 @@ module.exports = function (app, config) {
featureDb.getFeature(featureName) featureDb.getFeature(featureName)
.then(() => eventStore.create({ .then(() => eventStore.create({
type: eventType.featureUpdated, type: eventType.featureUpdated,
createdBy: userName, createdBy: userName,
data: updatedFeature data: updatedFeature,
})) }))
.then(() => { .then(() => {
res.status(200).end(); res.status(200).end();
}) })
@ -87,12 +87,12 @@ module.exports = function (app, config) {
featureDb.getFeature(featureName) featureDb.getFeature(featureName)
.then(() => eventStore.create({ .then(() => eventStore.create({
type: eventType.featureArchived, type: eventType.featureArchived,
createdBy: userName, createdBy: userName,
data: { data: {
name: featureName name: featureName,
} },
})) }))
.then(() => { .then(() => {
res.status(200).end(); res.status(200).end();
}) })
@ -109,7 +109,7 @@ module.exports = function (app, config) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
featureDb.getFeature(req.body.name) featureDb.getFeature(req.body.name)
.then(() => { .then(() => {
reject(new NameExistsError("Feature name already exist")); reject(new NameExistsError('Feature name already exist'));
}, () => { }, () => {
resolve(req); resolve(req);
}); });

View File

@ -1,5 +1,5 @@
'use strict'; 'use strict';
const Promise = require("bluebird"); const Promise = require('bluebird');
const eventType = require('../eventType'); const eventType = require('../eventType');
const logger = require('../logger'); const logger = require('../logger');
const NameExistsError = require('../error/NameExistsError'); const NameExistsError = require('../error/NameExistsError');
@ -33,12 +33,12 @@ module.exports = function (app, config) {
strategyDb.getStrategy(strategyName) strategyDb.getStrategy(strategyName)
.then(() => eventStore.create({ .then(() => eventStore.create({
type: eventType.strategyDeleted, type: eventType.strategyDeleted,
createdBy: extractUser(req), createdBy: extractUser(req),
data: { data: {
name: strategyName name: strategyName,
} },
})) }))
.then(() => { .then(() => {
res.status(200).end(); res.status(200).end();
}) })
@ -60,10 +60,10 @@ module.exports = function (app, config) {
validateRequest(req) validateRequest(req)
.then(validateStrategyName) .then(validateStrategyName)
.then(() => eventStore.create({ .then(() => eventStore.create({
type: eventType.strategyCreated, type: eventType.strategyCreated,
createdBy: extractUser(req), createdBy: extractUser(req),
data: newStrategy data: newStrategy,
})) }))
.then(() => { .then(() => {
res.status(201).end(); res.status(201).end();
}) })
@ -74,7 +74,7 @@ module.exports = function (app, config) {
res.status(400).json(req.validationErrors()); res.status(400).json(req.validationErrors());
}) })
.catch(err => { .catch(err => {
logger.error("Could not create strategy", err); logger.error('Could not create strategy', err);
res.status(500).end(); res.status(500).end();
}); });
}); });
@ -83,7 +83,7 @@ module.exports = function (app, config) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
strategyDb.getStrategy(req.body.name) strategyDb.getStrategy(req.body.name)
.then(() => { .then(() => {
reject(new NameExistsError("Feature name already exist")); reject(new NameExistsError('Feature name already exist'));
}, () => { }, () => {
resolve(req); resolve(req);
}); });

View File

@ -13,7 +13,7 @@ module.exports = {
return { return {
up: runMigration.bind(null, util.format(format, name, 'up')), up: runMigration.bind(null, util.format(format, name, 'up')),
down: runMigration.bind(null, util.format(format, name, 'down')) down: runMigration.bind(null, util.format(format, name, 'down')),
}; };
} },
}; };

View File

@ -21,7 +21,7 @@ function start(options) {
eventStore, eventStore,
featureDb, featureDb,
strategyDb, strategyDb,
publicFolder: options.publicFolder publicFolder: options.publicFolder,
}; };
const app = require('./app')(config); const app = require('./app')(config);
@ -33,7 +33,7 @@ function start(options) {
return { return {
app, app,
server, server,
config config,
}; };
} }
@ -43,5 +43,5 @@ process.on('uncaughtException', err => {
}); });
module.exports = { module.exports = {
start start,
}; };

View File

@ -7,5 +7,5 @@ function getDatabaseUri() {
} }
} }
module.exports = { module.exports = {
getDatabaseUri getDatabaseUri,
}; };

View File

@ -7,7 +7,7 @@ describe('eventDiffer', () => {
it('fails if events include an unknown event type', () => { it('fails if events include an unknown event type', () => {
const events = [ const events = [
{ type: eventType.featureCreated, data: {} }, { type: eventType.featureCreated, data: {} },
{ type: 'unknown-type', data: {} } { type: 'unknown-type', data: {} },
]; ];
assert.throws(() => { assert.throws(() => {
@ -22,19 +22,19 @@ describe('eventDiffer', () => {
const events = [ const events = [
{ {
type: eventType.featureUpdated, type: eventType.featureUpdated,
data: { name, description: desc, strategy: 'default', enabled: true, parameters: { value: 2 } } data: { name, description: desc, strategy: 'default', enabled: true, parameters: { value: 2 } },
}, },
{ {
type: eventType.featureCreated, type: eventType.featureCreated,
data: { name, description: desc, strategy: 'default', enabled: false, parameters: { value: 1 } } data: { name, description: desc, strategy: 'default', enabled: false, parameters: { value: 1 } },
} },
]; ];
eventDiffer.addDiffs(events); eventDiffer.addDiffs(events);
assert.deepEqual(events[0].diffs, [ assert.deepEqual(events[0].diffs, [
{ kind: 'E', path: ["enabled"], lhs: false, rhs: true }, { kind: 'E', path: ['enabled'], lhs: false, rhs: true },
{ kind: 'E', path: ["parameters", "value"], lhs: 1, rhs: 2 } { kind: 'E', path: ['parameters', 'value'], lhs: 1, rhs: 2 },
]); ]);
assert.strictEqual(events[1].diffs, null); assert.strictEqual(events[1].diffs, null);
@ -44,20 +44,20 @@ describe('eventDiffer', () => {
const events = [ const events = [
{ {
type: eventType.featureUpdated, type: eventType.featureUpdated,
data: { name: 'bar', description: 'desc', strategy: 'default', enabled: true, parameters: {} } data: { name: 'bar', description: 'desc', strategy: 'default', enabled: true, parameters: {} },
}, },
{ {
type: eventType.featureUpdated, type: eventType.featureUpdated,
data: { name: 'foo', description: 'desc', strategy: 'default', enabled: false, parameters: {} } data: { name: 'foo', description: 'desc', strategy: 'default', enabled: false, parameters: {} },
}, },
{ {
type: eventType.featureCreated, type: eventType.featureCreated,
data: { name: 'bar', description: 'desc', strategy: 'default', enabled: false, parameters: {} } data: { name: 'bar', description: 'desc', strategy: 'default', enabled: false, parameters: {} },
}, },
{ {
type: eventType.featureCreated, type: eventType.featureCreated,
data: { name: 'foo', description: 'desc', strategy: 'default', enabled: true, parameters: {} } data: { name: 'foo', description: 'desc', strategy: 'default', enabled: true, parameters: {} },
} },
]; ];
eventDiffer.addDiffs(events); eventDiffer.addDiffs(events);
@ -72,12 +72,12 @@ describe('eventDiffer', () => {
const events = [ const events = [
{ {
type: eventType.featureUpdated, type: eventType.featureUpdated,
data: { name: 'foo', description: 'desc', strategy: 'default', enabled: true, parameters: {} } data: { name: 'foo', description: 'desc', strategy: 'default', enabled: true, parameters: {} },
}, },
{ {
type: eventType.featureCreated, type: eventType.featureCreated,
data: { name: 'foo', description: 'desc', strategy: 'default', enabled: true, parameters: {} } data: { name: 'foo', description: 'desc', strategy: 'default', enabled: true, parameters: {} },
} },
]; ];
eventDiffer.addDiffs(events); eventDiffer.addDiffs(events);
@ -88,8 +88,8 @@ describe('eventDiffer', () => {
const events = [ const events = [
{ {
type: eventType.featureUpdated, type: eventType.featureUpdated,
data: { name: 'foo', description: 'desc', strategy: 'default', enabled: true, parameters: {} } data: { name: 'foo', description: 'desc', strategy: 'default', enabled: true, parameters: {} },
} },
]; ];
eventDiffer.addDiffs(events); eventDiffer.addDiffs(events);

View File

@ -17,7 +17,7 @@ const app = require('../app')({
eventDb, eventDb,
eventStore, eventStore,
featureDb, featureDb,
strategyDb strategyDb,
}); });
Promise.promisifyAll(request); Promise.promisifyAll(request);
@ -26,73 +26,73 @@ request = request(app);
function createStrategies() { function createStrategies() {
return Promise.map([ return Promise.map([
{ {
name: "default", name: 'default',
description: "Default on or off Strategy.", description: 'Default on or off Strategy.',
parametersTemplate: {} parametersTemplate: {},
}, },
{ {
name: "usersWithEmail", name: 'usersWithEmail',
description: "Active for users defined in the comma-separated emails-parameter.", description: 'Active for users defined in the comma-separated emails-parameter.',
parametersTemplate: { parametersTemplate: {
emails: "String" emails: 'String',
} },
} },
], strategy => strategyDb._createStrategy(strategy)); ], strategy => strategyDb._createStrategy(strategy));
} }
function createFeatures() { function createFeatures() {
return Promise.map([ return Promise.map([
{ {
name: "featureX", name: 'featureX',
description: "the #1 feature", description: 'the #1 feature',
enabled: true, enabled: true,
strategy: "default" strategy: 'default',
}, },
{ {
name: "featureY", name: 'featureY',
description: "soon to be the #1 feature", description: 'soon to be the #1 feature',
enabled: false, enabled: false,
strategy: "baz", strategy: 'baz',
parameters: { parameters: {
foo: "bar" foo: 'bar',
} },
}, },
{ {
name: "featureZ", name: 'featureZ',
description: "terrible feature", description: 'terrible feature',
enabled: true, enabled: true,
strategy: "baz", strategy: 'baz',
parameters: { parameters: {
foo: "rab" foo: 'rab',
} },
}, },
{ {
name: "featureArchivedX", name: 'featureArchivedX',
description: "the #1 feature", description: 'the #1 feature',
enabled: true, enabled: true,
archived: true, archived: true,
strategy: "default" strategy: 'default',
}, },
{ {
name: "featureArchivedY", name: 'featureArchivedY',
description: "soon to be the #1 feature", description: 'soon to be the #1 feature',
enabled: false, enabled: false,
archived: true, archived: true,
strategy: "baz", strategy: 'baz',
parameters: { parameters: {
foo: "bar" foo: 'bar',
} },
}, },
{ {
name: "featureArchivedZ", name: 'featureArchivedZ',
description: "terrible feature", description: 'terrible feature',
enabled: true, enabled: true,
archived: true, archived: true,
strategy: "baz", strategy: 'baz',
parameters: { parameters: {
foo: "rab" foo: 'rab',
} },
} },
], feature => featureDb._createFeature(feature)); ], feature => featureDb._createFeature(feature));
} }
@ -119,6 +119,6 @@ module.exports = {
setup: setupDatabase, setup: setupDatabase,
resetAndSetup() { resetAndSetup() {
return resetDatabase().then(setupDatabase); return resetDatabase().then(setupDatabase);
} },
} },
}; };

View File

@ -5,5 +5,5 @@ const ReactTools = require('react-tools');
module.exports = { module.exports = {
process(src) { process(src) {
return ReactTools.transform(src); return ReactTools.transform(src);
} },
}; };

View File

@ -2,5 +2,5 @@
const path = require('path'); const path = require('path');
module.exports = { module.exports = {
publicFolder: path.join(__dirname, '..', 'public') publicFolder: path.join(__dirname, '..', 'public'),
}; };

View File

@ -12,5 +12,5 @@ const compiler = webpack(webpackConfig);
app.use(config.baseUriPath, webpackDevMiddleware(compiler, { app.use(config.baseUriPath, webpackDevMiddleware(compiler, {
publicPath: '/js', publicPath: '/js',
noInfo: true noInfo: true,
})); }));

View File

@ -12,32 +12,32 @@ const RouteHandler = Router.RouteHandler;
const UnleashApp = React.createClass({ const UnleashApp = React.createClass({
contextTypes: { contextTypes: {
router: React.PropTypes.func router: React.PropTypes.func,
}, },
getInitialState() { getInitialState() {
return { return {
features: FeatureToggleStore.getFeatureToggles(), features: FeatureToggleStore.getFeatureToggles(),
strategies: StrategyStore.getStrategies(), strategies: StrategyStore.getStrategies(),
archivedFeatures: ArchiveStore.getArchivedToggles() archivedFeatures: ArchiveStore.getArchivedToggles(),
}; };
}, },
onFeatureToggleChange() { onFeatureToggleChange() {
this.setState({ this.setState({
features: FeatureToggleStore.getFeatureToggles() features: FeatureToggleStore.getFeatureToggles(),
}); });
}, },
onStrategiesChange() { onStrategiesChange() {
this.setState({ this.setState({
strategies: StrategyStore.getStrategies() strategies: StrategyStore.getStrategies(),
}); });
}, },
onArchiveChange() { onArchiveChange() {
this.setState({ this.setState({
archivedFeatures: ArchiveStore.getArchivedToggles() archivedFeatures: ArchiveStore.getArchivedToggles(),
}); });
}, },
@ -68,10 +68,10 @@ const UnleashApp = React.createClass({
return ( return (
<div> <div>
<Menu> <Menu>
{this.renderLink("features", "Toggles")} {this.renderLink('features', 'Toggles')}
{this.renderLink("strategies", "Strategies")} {this.renderLink('strategies', 'Strategies')}
{this.renderLink("log", "Log")} {this.renderLink('log', 'Log')}
{this.renderLink("archive", "Archive")} {this.renderLink('archive', 'Archive')}
</Menu> </Menu>
<div className="container"> <div className="container">
<div className="page"> <div className="page">
@ -91,7 +91,7 @@ const UnleashApp = React.createClass({
</div> </div>
</div> </div>
); );
} },
}); });

View File

@ -2,10 +2,10 @@
'use strict'; 'use strict';
jest.dontMock("../../components/Menu"); jest.dontMock('../../components/Menu');
const Menu = require("../../components/Menu"); const Menu = require('../../components/Menu');
const React = require("react/addons"); const React = require('react/addons');
const TestUtils = React.addons.TestUtils; const TestUtils = React.addons.TestUtils;
describe('Menu test', () => { describe('Menu test', () => {

View File

@ -1,19 +1,19 @@
'use strict'; 'use strict';
jest.dontMock("../../../components/feature/ArchiveFeatureComponent"); jest.dontMock('../../../components/feature/ArchiveFeatureComponent');
jest.mock("../../../stores/FeatureToggleActions"); jest.mock('../../../stores/FeatureToggleActions');
jest.autoMockOff(); jest.autoMockOff();
const React = require("react/addons"); const React = require('react/addons');
const TestUtils = React.addons.TestUtils; const TestUtils = React.addons.TestUtils;
const FeatureArchive = require("../../../components/feature/ArchiveFeatureComponent"); const FeatureArchive = require('../../../components/feature/ArchiveFeatureComponent');
const FeatureActions = require("../../../stores/FeatureToggleActions"); const FeatureActions = require('../../../stores/FeatureToggleActions');
describe("FeatureForm", () => { describe('FeatureForm', () => {
let Component; let Component;
beforeEach(() => { beforeEach(() => {
const archivedToggles = [ const archivedToggles = [
{ name: "featureX" }, { name: 'featureX' },
{ name: "featureY" } { name: 'featureY' },
]; ];
Component = TestUtils.renderIntoDocument( Component = TestUtils.renderIntoDocument(
@ -24,14 +24,14 @@ describe("FeatureForm", () => {
React.unmountComponentAtNode(document.body); React.unmountComponentAtNode(document.body);
}); });
it("should render two archived features", () => { it('should render two archived features', () => {
const rows = Component.getDOMNode().querySelectorAll("tbody tr"); const rows = Component.getDOMNode().querySelectorAll('tbody tr');
expect(rows.length).toEqual(2); expect(rows.length).toEqual(2);
}); });
it("should revive archived feature toggle", () => { it('should revive archived feature toggle', () => {
const button = Component.getDOMNode().querySelector("tbody button"); const button = Component.getDOMNode().querySelector('tbody button');
TestUtils.Simulate.click(button); TestUtils.Simulate.click(button);
jest.runAllTimers(); jest.runAllTimers();

View File

@ -1,35 +1,35 @@
'use strict'; 'use strict';
jest.dontMock("../../../components/feature/FeatureForm"); jest.dontMock('../../../components/feature/FeatureForm');
const React = require("react/addons"); const React = require('react/addons');
const TestUtils = React.addons.TestUtils; const TestUtils = React.addons.TestUtils;
const FeatureForm = require("../../../components/feature/FeatureForm"); const FeatureForm = require('../../../components/feature/FeatureForm');
describe("FeatureForm", () => { describe('FeatureForm', () => {
let Component; let Component;
const strategies = [ const strategies = [
{ name: "default" } { name: 'default' },
]; ];
afterEach(() => { afterEach(() => {
React.unmountComponentAtNode(document.body); React.unmountComponentAtNode(document.body);
}); });
describe("new", () => { describe('new', () => {
it("should render empty form", () => { it('should render empty form', () => {
Component = TestUtils .renderIntoDocument(<FeatureForm strategies={strategies} />); Component = TestUtils .renderIntoDocument(<FeatureForm strategies={strategies} />);
const name = Component.getDOMNode().querySelectorAll("input"); const name = Component.getDOMNode().querySelectorAll('input');
expect(name[0].value).toEqual(""); expect(name[0].value).toEqual('');
}); });
}); });
describe("edit", () => { describe('edit', () => {
const feature = { name: "Test", strategy: "unknown" }; const feature = { name: 'Test', strategy: 'unknown' };
it("should show unknown strategy as default", () => { it('should show unknown strategy as default', () => {
Component = TestUtils .renderIntoDocument(<FeatureForm feature={feature} strategies={strategies} />); Component = TestUtils .renderIntoDocument(<FeatureForm feature={feature} strategies={strategies} />);
const strategySelect = Component.getDOMNode().querySelector("select"); const strategySelect = Component.getDOMNode().querySelector('select');
expect(strategySelect.value).toEqual("default"); expect(strategySelect.value).toEqual('default');
}); });
}); });
}); });

View File

@ -1,22 +1,22 @@
'use strict'; 'use strict';
jest.dontMock("../../../components/feature/FeatureList"); jest.dontMock('../../../components/feature/FeatureList');
jest.dontMock("../../../components/feature/Feature"); jest.dontMock('../../../components/feature/Feature');
const React = require("react/addons"); const React = require('react/addons');
const TestUtils = React.addons.TestUtils; const TestUtils = React.addons.TestUtils;
const FeatureList = require("../../../components/feature/FeatureList"); const FeatureList = require('../../../components/feature/FeatureList');
describe("FeatureList", () => { describe('FeatureList', () => {
let Component; let Component;
let features; let features;
beforeEach(() => { beforeEach(() => {
features = [ features = [
{ name: "featureX", strategy: "other" }, { name: 'featureX', strategy: 'other' },
{ name: "group.featureY", strategy: "default" } { name: 'group.featureY', strategy: 'default' },
]; ];
const strategies=[ const strategies=[
{ name: "default" } { name: 'default' },
]; ];
Component = TestUtils .renderIntoDocument(<FeatureList features={features} strategies={strategies} />); Component = TestUtils .renderIntoDocument(<FeatureList features={features} strategies={strategies} />);
}); });
@ -25,34 +25,34 @@ describe("FeatureList", () => {
React.unmountComponentAtNode(document.body); React.unmountComponentAtNode(document.body);
}); });
it("should render all features", () => { it('should render all features', () => {
const features = Component.getDOMNode().querySelectorAll(".feature"); const features = Component.getDOMNode().querySelectorAll('.feature');
expect(features.length).toEqual(2); expect(features.length).toEqual(2);
}); });
it("should filter list of features", () => { it('should filter list of features', () => {
const filterNode = Component.refs.filter.getDOMNode(); const filterNode = Component.refs.filter.getDOMNode();
TestUtils.Simulate.change(filterNode, { target: { value: "group" } }); TestUtils.Simulate.change(filterNode, { target: { value: 'group' } });
const features = Component.getDOMNode().querySelectorAll(".feature"); const features = Component.getDOMNode().querySelectorAll('.feature');
expect(features.length).toEqual(1); expect(features.length).toEqual(1);
}); });
it("should filter list of features ignoring case", () => { it('should filter list of features ignoring case', () => {
const filterNode = Component.refs.filter.getDOMNode(); const filterNode = Component.refs.filter.getDOMNode();
TestUtils.Simulate.change(filterNode, { target: { value: "GROUP" } }); TestUtils.Simulate.change(filterNode, { target: { value: 'GROUP' } });
const features = Component.getDOMNode().querySelectorAll(".feature"); const features = Component.getDOMNode().querySelectorAll('.feature');
expect(features.length).toEqual(1); expect(features.length).toEqual(1);
expect(features[0].textContent).toMatch("group"); expect(features[0].textContent).toMatch('group');
}); });
it("should filter list of features by strategy name", () => { it('should filter list of features by strategy name', () => {
const searchString = "other"; const searchString = 'other';
const filterNode = Component.refs.filter.getDOMNode(); const filterNode = Component.refs.filter.getDOMNode();
TestUtils.Simulate.change(filterNode, { target: { value: searchString } }); TestUtils.Simulate.change(filterNode, { target: { value: searchString } });
const features = Component.getDOMNode().querySelectorAll(".feature"); const features = Component.getDOMNode().querySelectorAll('.feature');
expect(features.length).toEqual(1); expect(features.length).toEqual(1);
expect(features[0].textContent).toMatch(searchString); expect(features[0].textContent).toMatch(searchString);
}); });

View File

@ -12,7 +12,7 @@ describe('FeatureToggleStore', () => {
Actions = require('../../stores/FeatureToggleActions'); Actions = require('../../stores/FeatureToggleActions');
Store = require('../../stores/FeatureToggleStore'); Store = require('../../stores/FeatureToggleStore');
toggles = [ toggles = [
{ name: "app.feature", enabled: true, strategy: "default" } { name: 'app.feature', enabled: true, strategy: 'default' },
]; ];
}); });
@ -25,19 +25,19 @@ describe('FeatureToggleStore', () => {
jest.runAllTimers(); jest.runAllTimers();
expect(Store.getFeatureToggles().length).toBe(1); expect(Store.getFeatureToggles().length).toBe(1);
expect(Store.getFeatureToggles()[0].name).toEqual("app.feature"); expect(Store.getFeatureToggles()[0].name).toEqual('app.feature');
}); });
it('should add a another toggle', () => { it('should add a another toggle', () => {
Actions.init.completed(toggles); Actions.init.completed(toggles);
const newToggle = { name: "app.featureB", enabled: true, strategy: "default" }; const newToggle = { name: 'app.featureB', enabled: true, strategy: 'default' };
Actions.create.completed(newToggle); Actions.create.completed(newToggle);
jest.runAllTimers(); jest.runAllTimers();
expect(Store.getFeatureToggles().length).toBe(2); expect(Store.getFeatureToggles().length).toBe(2);
expect(Store.getFeatureToggles()[1].name).toEqual("app.featureB"); expect(Store.getFeatureToggles()[1].name).toEqual('app.featureB');
}); });
it('should archive toggle', () => { it('should archive toggle', () => {
@ -51,17 +51,17 @@ describe('FeatureToggleStore', () => {
it('should keep toggles in sorted order', () => { it('should keep toggles in sorted order', () => {
Actions.init.completed([ Actions.init.completed([
{ name: "A" }, { name: 'A' },
{ name: "B" }, { name: 'B' },
{ name: "C" } { name: 'C' },
]); ]);
Actions.create.completed({ name: "AA" }); Actions.create.completed({ name: 'AA' });
jest.runAllTimers(); jest.runAllTimers();
expect(Store.getFeatureToggles()[0].name).toEqual("A"); expect(Store.getFeatureToggles()[0].name).toEqual('A');
expect(Store.getFeatureToggles()[1].name).toEqual("AA"); expect(Store.getFeatureToggles()[1].name).toEqual('AA');
expect(Store.getFeatureToggles()[3].name).toEqual("C"); expect(Store.getFeatureToggles()[3].name).toEqual('C');
}); });
it('should update toggle', () => { it('should update toggle', () => {

View File

@ -6,23 +6,23 @@ const ErrorActions = require('../stores/ErrorActions');
const ErrorMessages = React.createClass({ const ErrorMessages = React.createClass({
getInitialState() { getInitialState() {
return { return {
errors: ErrorStore.getErrors() errors: ErrorStore.getErrors(),
}; };
}, },
onStoreChange() { onStoreChange() {
this.setState({ this.setState({
errors: ErrorStore.getErrors() errors: ErrorStore.getErrors(),
}); });
}, },
componentDidMount() { componentDidMount() {
this.unsubscribe = ErrorStore.listen(this.onStoreChange); this.unsubscribe = ErrorStore.listen(this.onStoreChange);
}, },
componentWillUnmount() { componentWillUnmount() {
this.unsubscribe(); this.unsubscribe();
}, },
onClearErrors() { onClearErrors() {
@ -33,7 +33,7 @@ const ErrorMessages = React.createClass({
return ( return (
<Ui errors={this.state.errors} onClearErrors={this.onClearErrors}></Ui> <Ui errors={this.state.errors} onClearErrors={this.onClearErrors}></Ui>
); );
} },
}); });
module.exports = ErrorMessages; module.exports = ErrorMessages;

View File

@ -29,7 +29,7 @@ const ErrorMessages = React.createClass({
</div> </div>
</div> </div>
); );
} },
}); });
module.exports = ErrorMessages; module.exports = ErrorMessages;

View File

@ -57,7 +57,7 @@ const Menu = React.createClass({
</div> </div>
</div> </div>
); );
} },
}); });
module.exports = Menu; module.exports = Menu;

View File

@ -4,13 +4,13 @@ const UserStore = require('../stores/UserStore');
const User = React.createClass({ const User = React.createClass({
onSave() { onSave() {
const value = this.refs.username.getDOMNode().value.trim(); const value = this.refs.username.getDOMNode().value.trim();
UserStore.set(value); UserStore.set(value);
}, },
render() { render() {
return ( return (
<div className="r-pvm"> <div className="r-pvm">
<input type="text" placeholder="username" <input type="text" placeholder="username"
ref="username" ref="username"
@ -18,7 +18,7 @@ const User = React.createClass({
onBlur={this.onSave} /> onBlur={this.onSave} />
</div> </div>
); );
} },
}); });
module.exports = User; module.exports = User;

View File

@ -1,5 +1,5 @@
'use strict'; 'use strict';
const React = require("react"); const React = require('react');
const FeatureActions = require('../../stores/FeatureToggleActions'); const FeatureActions = require('../../stores/FeatureToggleActions');
const ArchiveFeatureComponent = React.createClass({ const ArchiveFeatureComponent = React.createClass({
@ -41,7 +41,7 @@ const ArchiveFeatureComponent = React.createClass({
</button> </button>
</td> </td>
</tr>); </tr>);
} },
}); });
module.exports = ArchiveFeatureComponent; module.exports = ArchiveFeatureComponent;

View File

@ -9,22 +9,22 @@ const Feature = React.createClass({
return { return {
editMode: false, editMode: false,
showHistory: false, showHistory: false,
events: [] events: [],
}; };
}, },
handleEventsResponse(response) { handleEventsResponse(response) {
this.setState({events: response}); this.setState({ events: response });
}, },
toggleHistory() { toggleHistory() {
eventStore.getEventsByName(this.props.feature.name).then(this.handleEventsResponse); eventStore.getEventsByName(this.props.feature.name).then(this.handleEventsResponse);
this.setState({showHistory: !this.state.showHistory}); this.setState({ showHistory: !this.state.showHistory });
}, },
toggleEditMode() { toggleEditMode() {
this.setState({editMode: !this.state.editMode}); this.setState({ editMode: !this.state.editMode });
}, },
saveFeature(feature) { saveFeature(feature) {
@ -51,16 +51,15 @@ const Feature = React.createClass({
</td> </td>
</tr> </tr>
); );
}, },
render() { render() {
return ( return (
<tbody className="feature"> <tbody className="feature">
<tr className={this.state.editMode ? "edit bg-lilac-xlt" : ""}> <tr className={this.state.editMode ? 'edit bg-lilac-xlt' : ''}>
<td width="20"> <td width="20">
<span className= <span className=
{this.props.feature.enabled ? "toggle-active" : "toggle-inactive"} title="Status"> {this.props.feature.enabled ? 'toggle-active' : 'toggle-inactive'} title="Status">
</span> </span>
</td> </td>
<td> <td>
@ -78,23 +77,23 @@ const Feature = React.createClass({
<div className="line"> <div className="line">
<div className="unit size1of3"> <div className="unit size1of3">
<button <button
title='Archive' title="Archive"
onClick={this.archiveFeature}> onClick={this.archiveFeature}>
<span className="icon-kryss1" /> <span className="icon-kryss1" />
</button> </button>
</div> </div>
<div className="unit size1of3"> <div className="unit size1of3">
<button <button
className={this.state.editMode ? "primary" : ""} className={this.state.editMode ? 'primary' : ''}
title='Edit' title="Edit"
onClick={this.toggleEditMode}> onClick={this.toggleEditMode}>
<span className="icon-redigere" /> <span className="icon-redigere" />
</button> </button>
</div> </div>
<div className="unit size1of3"> <div className="unit size1of3">
<button <button
className={this.state.showHistory ? "primary" : ""} className={this.state.showHistory ? 'primary' : ''}
title='History' title="History"
onClick={this.toggleHistory}> onClick={this.toggleHistory}>
<span className="icon-visning_liste" /> <span className="icon-visning_liste" />
</button> </button>
@ -118,7 +117,7 @@ const Feature = React.createClass({
<LogEntryList events={this.state.events} /> <LogEntryList events={this.state.events} />
</td> </td>
</tr>); </tr>);
} },
}); });

View File

@ -7,38 +7,38 @@ const FeatureForm = React.createClass({
return { return {
strategyOptions: this.props.strategies, strategyOptions: this.props.strategies,
requiredParams: [], requiredParams: [],
currentStrategy: this.props.feature ? this.props.feature.strategy : "default" currentStrategy: this.props.feature ? this.props.feature.strategy : 'default',
}; };
}, },
componentWillMount() { componentWillMount() {
if(this.props.feature) { if (this.props.feature) {
this.setSelectedStrategy(this.props.feature.strategy); this.setSelectedStrategy(this.props.feature.strategy);
} }
}, },
onStrategyChange(e) { onStrategyChange(e) {
this.setSelectedStrategy(e.target.value); this.setSelectedStrategy(e.target.value);
this.setState({currentStrategy: e.target.value}); this.setState({ currentStrategy: e.target.value });
}, },
getParameterValue(name) { getParameterValue(name) {
if(this.props.feature && this.props.feature.parameters) { if (this.props.feature && this.props.feature.parameters) {
return this.props.feature.parameters[name]; return this.props.feature.parameters[name];
} else { } else {
return ""; return '';
} }
}, },
setSelectedStrategy(name) { setSelectedStrategy(name) {
const selectedStrategy = this.props.strategies.filter(strategy => strategy.name === name)[0]; const selectedStrategy = this.props.strategies.filter(strategy => strategy.name === name)[0];
if(selectedStrategy) { if (selectedStrategy) {
this.setStrategyParams(selectedStrategy); this.setStrategyParams(selectedStrategy);
} else { } else {
this.setState({ this.setState({
currentStrategy: 'default', currentStrategy: 'default',
requiredParams: [] requiredParams: [],
}); });
} }
}, },
@ -46,17 +46,17 @@ const FeatureForm = React.createClass({
setStrategyParams(strategy) { setStrategyParams(strategy) {
const requiredParams = []; const requiredParams = [];
let key; let key;
for(key in strategy.parametersTemplate) { for (key in strategy.parametersTemplate) {
requiredParams.push({name: key, value: this.getParameterValue(key)}); requiredParams.push({ name: key, value: this.getParameterValue(key) });
} }
this.setState({requiredParams}); this.setState({ requiredParams });
}, },
render() { render() {
const feature = this.props.feature || { const feature = this.props.feature || {
name: '', name: '',
strategy: 'default', strategy: 'default',
enabled: false enabled: false,
}; };
const idPrefix = this.props.feature ? this.props.feature.name : 'new'; const idPrefix = this.props.feature ? this.props.feature.name : 'new';
@ -66,7 +66,7 @@ const FeatureForm = React.createClass({
<form ref="form" className="r-size1of2"> <form ref="form" className="r-size1of2">
<fieldset> <fieldset>
{this.props.feature ? "" : <legend>Create new toggle</legend>} {this.props.feature ? '' : <legend>Create new toggle</legend>}
<TextInput <TextInput
id={`${idPrefix}-name`} id={`${idPrefix}-name`}
@ -150,7 +150,7 @@ const FeatureForm = React.createClass({
description: this.refs.description.getValue(), description: this.refs.description.getValue(),
strategy: this.state.currentStrategy, strategy: this.state.currentStrategy,
enabled: this.refs.enabled.getDOMNode().checked, enabled: this.refs.enabled.getDOMNode().checked,
parameters: this.getParameters() parameters: this.getParameters(),
}; };
this.props.onSubmit(feature); this.props.onSubmit(feature);
@ -167,7 +167,7 @@ const FeatureForm = React.createClass({
parameters[param.name] = this.refs[param.name].getValue(); parameters[param.name] = this.refs[param.name].getValue();
}); });
return parameters; return parameters;
} },
}); });
module.exports = FeatureForm; module.exports = FeatureForm;

View File

@ -7,37 +7,35 @@ const noop = function() {};
const FeatureList = React.createClass({ const FeatureList = React.createClass({
propTypes: { propTypes: {
features: React.PropTypes.array.isRequired, features: React.PropTypes.array.isRequired,
strategies: React.PropTypes.array.isRequired strategies: React.PropTypes.array.isRequired,
}, },
getDefaultProps() { getDefaultProps() {
return { return {
onFeatureChanged: noop, onFeatureChanged: noop,
onFeatureArchive: noop onFeatureArchive: noop,
}; };
}, },
getInitialState() { getInitialState() {
return { return {
filter: undefined filter: undefined,
}; };
}, },
onFilterChange(e) { onFilterChange(e) {
e.preventDefault(); e.preventDefault();
this.setState({filter: e.target.value.trim()}); this.setState({ filter: e.target.value.trim() });
}, },
filteredFeatures() { filteredFeatures() {
if(this.state.filter) { if (this.state.filter) {
const regex = new RegExp(this.state.filter, "i"); const regex = new RegExp(this.state.filter, 'i');
return this.props.features.filter(item => regex.test(item.name) || regex.test(item.strategy)); return this.props.features.filter(item => regex.test(item.name) || regex.test(item.strategy));
} else { } else {
return this.props.features; return this.props.features;
} }
}, },
render() { render() {
@ -50,8 +48,8 @@ const FeatureList = React.createClass({
/>); />);
return ( return (
<div className=''> <div className="">
<table className='outerborder man'> <table className="outerborder man">
<thead> <thead>
<tr> <tr>
<th></th> <th></th>
@ -78,7 +76,7 @@ const FeatureList = React.createClass({
</table> </table>
</div> </div>
); );
} },
}); });
module.exports = FeatureList; module.exports = FeatureList;

View File

@ -8,12 +8,12 @@ const ErrorActions = require('../../stores/ErrorActions');
const FeatureTogglesComponent = React.createClass({ const FeatureTogglesComponent = React.createClass({
getInitialState() { getInitialState() {
return { return {
createView: false createView: false,
}; };
}, },
updateFeature(feature) { updateFeature(feature) {
FeatureActions.update.triggerPromise(feature); FeatureActions.update.triggerPromise(feature);
}, },
archiveFeature(feature) { archiveFeature(feature) {
@ -26,11 +26,11 @@ const FeatureTogglesComponent = React.createClass({
}, },
newFeature() { newFeature() {
this.setState({createView: true}); this.setState({ createView: true });
}, },
cancelNewFeature() { cancelNewFeature() {
this.setState({createView: false}); this.setState({ createView: false });
ErrorActions.clear(); ErrorActions.clear();
}, },
@ -55,15 +55,15 @@ const FeatureTogglesComponent = React.createClass({
}, },
renderCreateView() { renderCreateView() {
return <FeatureForm return (<FeatureForm
onCancel={this.cancelNewFeature} onCancel={this.cancelNewFeature}
onSubmit={this.createFeature} onSubmit={this.createFeature}
strategies={this.props.strategies} />; strategies={this.props.strategies} />);
}, },
renderCreateButton() { renderCreateButton() {
return <button className="mal" onClick={this.newFeature}>Create feature toggle</button>; return <button className="mal" onClick={this.newFeature}>Create feature toggle</button>;
} },
}); });
module.exports = FeatureTogglesComponent; module.exports = FeatureTogglesComponent;

View File

@ -8,12 +8,12 @@ const TextInput = React.createClass({
id: React.PropTypes.string.isRequired, id: React.PropTypes.string.isRequired,
placeholder: React.PropTypes.string, placeholder: React.PropTypes.string,
value: React.PropTypes.string, value: React.PropTypes.string,
required: React.PropTypes.bool required: React.PropTypes.bool,
}, },
getDefaultProps() { getDefaultProps() {
return { return {
required: false required: false,
}; };
}, },
@ -41,7 +41,7 @@ const TextInput = React.createClass({
</div> </div>
</div> </div>
); );
} },
}); });
module.exports = TextInput; module.exports = TextInput;

View File

@ -8,18 +8,18 @@ const LogEntriesComponent = React.createClass({
getInitialState() { getInitialState() {
return { return {
createView: false, createView: false,
events: [] events: [],
}; };
}, },
componentDidMount() { componentDidMount() {
eventStore.getEvents().then(res => { eventStore.getEvents().then(res => {
this.setState({events: res.events}); this.setState({ events: res.events });
}, this.initError); }, this.initError);
}, },
initError() { initError() {
ErrorActions.error("Could not load events from server"); ErrorActions.error('Could not load events from server');
}, },
render() { render() {

View File

@ -6,7 +6,7 @@ const DIFF_PREFIXES = {
A: ' ', A: ' ',
E: ' ', E: ' ',
D: '-', D: '-',
N: '+' N: '+',
}; };
const SPADEN_CLASS = { const SPADEN_CLASS = {
@ -18,7 +18,7 @@ const SPADEN_CLASS = {
const LogEntry = React.createClass({ const LogEntry = React.createClass({
propTypes: { propTypes: {
event: React.PropTypes.object.isRequired event: React.PropTypes.object.isRequired,
}, },
render() { render() {
@ -33,7 +33,7 @@ const LogEntry = React.createClass({
<td> <td>
<strong>{this.props.event.data.name}</strong><em>[{this.props.event.type}]</em> <strong>{this.props.event.data.name}</strong><em>[{this.props.event.type}]</em>
</td> </td>
<td style={{maxWidth: 300}}> <td style={{ maxWidth: 300 }}>
{this.renderEventDiff()} {this.renderEventDiff()}
</td> </td>
<td>{this.props.event.createdBy}</td> <td>{this.props.event.createdBy}</td>
@ -48,14 +48,14 @@ const LogEntry = React.createClass({
const prettyPrinted = JSON.stringify(localEventData, null, 2); const prettyPrinted = JSON.stringify(localEventData, null, 2);
return (<code className='JSON smalltext man'>{prettyPrinted}</code>); return (<code className="JSON smalltext man">{prettyPrinted}</code>);
}, },
renderEventDiff() { renderEventDiff() {
if (!this.props.showFullEvents && this.props.event.diffs) { if (!this.props.showFullEvents && this.props.event.diffs) {
const changes = this.props.event.diffs.map(this.buildDiff); const changes = this.props.event.diffs.map(this.buildDiff);
return ( return (
<code className='smalltext man'>{changes.length === 0 ? '(no changes)' : changes}</code> <code className="smalltext man">{changes.length === 0 ? '(no changes)' : changes}</code>
); );
} else { } else {
return this.renderFullEventData(); return this.renderFullEventData();
@ -81,7 +81,7 @@ const LogEntry = React.createClass({
} }
return (<div key={idx}>{change}</div>); return (<div key={idx}>{change}</div>);
} },
}); });

View File

@ -4,12 +4,12 @@ const LogEntry = require('./LogEntry');
const LogEntryList = React.createClass({ const LogEntryList = React.createClass({
propTypes: { propTypes: {
events: React.PropTypes.array.isRequired events: React.PropTypes.array.isRequired,
}, },
getInitialState() { getInitialState() {
return { return {
showFullEvents: false showFullEvents: false,
}; };
}, },
@ -28,7 +28,7 @@ const LogEntryList = React.createClass({
</input> </input>
</label> </label>
<table className='outerborder zebra-striped'> <table className="outerborder zebra-striped">
<thead> <thead>
<tr> <tr>
<th>When</th> <th>When</th>
@ -48,8 +48,8 @@ const LogEntryList = React.createClass({
}, },
toggleFullEvents() { toggleFullEvents() {
this.setState({showFullEvents: !this.state.showFullEvents}); this.setState({ showFullEvents: !this.state.showFullEvents });
} },
}); });

View File

@ -7,16 +7,16 @@ const StrategyActions = require('../../stores/StrategyActions');
const StrategiesComponent = React.createClass({ const StrategiesComponent = React.createClass({
getInitialState() { getInitialState() {
return { return {
createView: false createView: false,
}; };
}, },
onNewStrategy() { onNewStrategy() {
this.setState({createView: true}); this.setState({ createView: true });
}, },
onCancelNewStrategy() { onCancelNewStrategy() {
this.setState({createView: false}); this.setState({ createView: false });
}, },
onSave(strategy) { onSave(strategy) {
@ -48,15 +48,15 @@ const StrategiesComponent = React.createClass({
onCancelNewStrategy={this.onCancelNewStrategy} onCancelNewStrategy={this.onCancelNewStrategy}
onSave={this.onSave} onSave={this.onSave}
/>); />);
}, },
renderCreateButton() { renderCreateButton() {
return ( return (
<button className="mal" onClick={this.onNewStrategy}> <button className="mal" onClick={this.onNewStrategy}>
Create strategy Create strategy
</button> </button>
); );
} },
}); });
module.exports = StrategiesComponent; module.exports = StrategiesComponent;

View File

@ -3,7 +3,7 @@ const React = require('react');
const Strategy = React.createClass({ const Strategy = React.createClass({
propTypes: { propTypes: {
strategy: React.PropTypes.object.isRequired strategy: React.PropTypes.object.isRequired,
}, },
onRemove(event) { onRemove(event) {
@ -25,7 +25,7 @@ const Strategy = React.createClass({
</div> </div>
</div> </div>
); );
} },
}); });
module.exports = Strategy; module.exports = Strategy;

View File

@ -6,13 +6,13 @@ const StrategyForm = React.createClass({
getDefaultProps() { getDefaultProps() {
return { return {
maxParams: 4 maxParams: 4,
}; };
}, },
getInitialState() { getInitialState() {
return { return {
parameters: [] parameters: [],
}; };
}, },
@ -27,9 +27,9 @@ const StrategyForm = React.createClass({
const that = this; const that = this;
this.state.parameters.forEach(parameter => { this.state.parameters.forEach(parameter => {
const name = that.refs[parameter.name].getDOMNode().value.trim(); const name = that.refs[parameter.name].getDOMNode().value.trim();
if(name) { if (name) {
strategy.parametersTemplate[name] = "string"; strategy.parametersTemplate[name] = 'string';
} }
}); });
@ -45,15 +45,15 @@ const StrategyForm = React.createClass({
onAddParam(event) { onAddParam(event) {
event.preventDefault(); event.preventDefault();
const id = this.state.parameters.length + 1; const id = this.state.parameters.length + 1;
const params = this.state.parameters.concat([{id, name: `param_${id}`, label: `Parameter ${id}`}]); const params = this.state.parameters.concat([{ id, name: `param_${id}`, label: `Parameter ${id}` }]);
this.setState({parameters: params}); this.setState({ parameters: params });
}, },
onRemoveParam(event) { onRemoveParam(event) {
event.preventDefault(); event.preventDefault();
const params = this.state.parameters.slice(0, -1); const params = this.state.parameters.slice(0, -1);
this.setState({parameters: params}); this.setState({ parameters: params });
}, },
render() { render() {
@ -119,12 +119,12 @@ const StrategyForm = React.createClass({
}, },
renderAddLink() { renderAddLink() {
if(this.state.parameters.length < this.props.maxParams) { if (this.state.parameters.length < this.props.maxParams) {
return <a href="#add" onClick={this.onAddParam}>+ Add required parameter</a>; return <a href="#add" onClick={this.onAddParam}>+ Add required parameter</a>;
} }
}, },
renderRemoveLink() { renderRemoveLink() {
if(this.state.parameters.length > 0) { if (this.state.parameters.length > 0) {
return ( return (
<div className="formelement mtn"> <div className="formelement mtn">
<a href="#add" <a href="#add"
@ -135,7 +135,7 @@ const StrategyForm = React.createClass({
</div> </div>
); );
} }
} },
}); });
module.exports = StrategyForm; module.exports = StrategyForm;

View File

@ -4,7 +4,7 @@ const Strategy = require('./Strategy');
const StrategyList = React.createClass({ const StrategyList = React.createClass({
propTypes: { propTypes: {
strategies: React.PropTypes.array.isRequired strategies: React.PropTypes.array.isRequired,
}, },
render() { render() {
@ -12,7 +12,7 @@ const StrategyList = React.createClass({
return ( return (
<div>{strategyNodes}</div> <div>{strategyNodes}</div>
); );
} },
}); });
module.exports = StrategyList; module.exports = StrategyList;

View File

@ -40,7 +40,7 @@ const FeatureStore = Reflux.createStore({
initStore(archivedToggles) { initStore(archivedToggles) {
_archivedToggles = archivedToggles; _archivedToggles = archivedToggles;
} },
}); });
module.exports = FeatureStore; module.exports = FeatureStore;

View File

@ -2,8 +2,8 @@
const Reflux = require('reflux'); const Reflux = require('reflux');
const ErrorActions = Reflux.createActions([ const ErrorActions = Reflux.createActions([
"clear", 'clear',
"error" 'error',
]); ]);
module.exports = ErrorActions; module.exports = ErrorActions;

View File

@ -24,7 +24,7 @@ const FeatureStore = Reflux.createStore({
this.addError(e.msg); this.addError(e.msg);
}); });
} else if (error.status === 0) { } else if (error.status === 0) {
this.addError("server unreachable"); this.addError('server unreachable');
} else { } else {
this.addError(error); this.addError(error);
} }
@ -52,7 +52,7 @@ const FeatureStore = Reflux.createStore({
} catch (e) { } catch (e) {
if (e instanceof SyntaxError) { if (e instanceof SyntaxError) {
// fall through; // fall through;
console.log("Syntax error!"); console.log('Syntax error!');
} else { } else {
throw e; throw e;
} }
@ -63,7 +63,7 @@ const FeatureStore = Reflux.createStore({
getErrors() { getErrors() {
return this.errors; return this.errors;
} },
}); });
module.exports = FeatureStore; module.exports = FeatureStore;

View File

@ -8,7 +8,7 @@ const EventStore = {
return reqwest({ return reqwest({
url: 'events', url: 'events',
method: 'get', method: 'get',
type: TYPE type: TYPE,
}); });
}, },
@ -16,9 +16,9 @@ const EventStore = {
return reqwest({ return reqwest({
url: `events/${name}`, url: `events/${name}`,
method: 'get', method: 'get',
type: TYPE type: TYPE,
}); });
} },
}; };

View File

@ -1,5 +1,5 @@
'use strict'; 'use strict';
const Reflux = require("reflux"); const Reflux = require('reflux');
const Server = require('./FeatureToggleServerFacade'); const Server = require('./FeatureToggleServerFacade');
const FeatureToggleActions = Reflux.createActions({ const FeatureToggleActions = Reflux.createActions({
@ -8,7 +8,7 @@ const FeatureToggleActions = Reflux.createActions({
create: { asyncResult: true }, create: { asyncResult: true },
update: { asyncResult: true }, update: { asyncResult: true },
archive: { asyncResult: true }, archive: { asyncResult: true },
revive: { asyncResult: true } revive: { asyncResult: true },
}); });
FeatureToggleActions.init.listen(function() { FeatureToggleActions.init.listen(function() {

View File

@ -17,7 +17,7 @@ const FeatureToggleServerFacade = {
}, },
success() { success() {
cb(); cb();
} },
}); });
}, },
@ -33,7 +33,7 @@ const FeatureToggleServerFacade = {
}, },
success() { success() {
cb(); cb();
} },
}); });
}, },
@ -47,7 +47,7 @@ const FeatureToggleServerFacade = {
}, },
success() { success() {
cb(); cb();
} },
}); });
}, },
@ -61,7 +61,7 @@ const FeatureToggleServerFacade = {
}, },
success(data) { success(data) {
cb(null, data.features); cb(null, data.features);
} },
}); });
}, },
@ -75,7 +75,7 @@ const FeatureToggleServerFacade = {
}, },
success(data) { success(data) {
cb(null, data.features); cb(null, data.features);
} },
}); });
}, },
@ -91,9 +91,9 @@ const FeatureToggleServerFacade = {
}, },
success() { success() {
cb(); cb();
} },
}); });
} },
}; };
module.exports = FeatureToggleServerFacade; module.exports = FeatureToggleServerFacade;

View File

@ -50,7 +50,7 @@ const FeatureStore = Reflux.createStore({
initStore(toggles) { initStore(toggles) {
_featureToggles = toggles; _featureToggles = toggles;
} },
}); });
module.exports = FeatureStore; module.exports = FeatureStore;

View File

@ -17,7 +17,7 @@ const StrategyAPI = {
}, },
success() { success() {
cb(null, strategy); cb(null, strategy);
} },
}); });
}, },
@ -31,7 +31,7 @@ const StrategyAPI = {
}, },
success() { success() {
cb(null, strategy); cb(null, strategy);
} },
}); });
}, },
@ -45,9 +45,9 @@ const StrategyAPI = {
}, },
success(data) { success(data) {
cb(null, data.strategies); cb(null, data.strategies);
} },
}); });
} },
}; };
module.exports = StrategyAPI; module.exports = StrategyAPI;

View File

@ -1,5 +1,5 @@
'use strict'; 'use strict';
const Reflux = require("reflux"); const Reflux = require('reflux');
const StrategyAPI = require('./StrategyAPI'); const StrategyAPI = require('./StrategyAPI');
const StrategyActions = Reflux.createActions({ const StrategyActions = Reflux.createActions({

View File

@ -35,7 +35,7 @@ const StrategyStore = Reflux.createStore({
initStore(strategies) { initStore(strategies) {
_strategies = strategies; _strategies = strategies;
} },
}); });
module.exports = StrategyStore; module.exports = StrategyStore;

View File

@ -19,7 +19,7 @@ function readCookie(name) {
const UserStore = { const UserStore = {
init() { init() {
_username = readCookie("username"); _username = readCookie('username');
}, },
set(username) { set(username) {
@ -29,7 +29,7 @@ const UserStore = {
get() { get() {
return _username; return _username;
} },
}; };
module.exports = UserStore; module.exports = UserStore;

View File

@ -7,7 +7,7 @@ const Timer = function(cb, interval) {
Timer.prototype.start = function() { Timer.prototype.start = function() {
if (this.timerId != null) { if (this.timerId != null) {
console.warn("timer already started"); console.warn('timer already started');
} }
console.log('starting timer'); console.log('starting timer');

View File

@ -14,25 +14,25 @@ module.exports = {
output: { output: {
path: jsroot, path: jsroot,
filename: 'bundle.js', filename: 'bundle.js',
publicPath: '/js/' publicPath: '/js/',
}, },
resolve: { resolve: {
root: [jsroot], root: [jsroot],
extensions: ['', '.js', '.jsx'], extensions: ['', '.js', '.jsx'],
modulesDirectories: ["web_modules", "node_modules"] modulesDirectories: ['web_modules', 'node_modules'],
}, },
module: { module: {
loaders: [ loaders: [
{ test: /\.jsx$/, loader: 'jsx?harmony' } { test: /\.jsx$/, loader: 'jsx?harmony' },
] ],
}, },
devtool: "source-map", devtool: 'source-map',
externals: { externals: {
// stuff not in node_modules can be resolved here. // stuff not in node_modules can be resolved here.
} },
}; };