From 50f139ac02f8c76c1688d85bdd85b26a1b11d761 Mon Sep 17 00:00:00 2001 From: Juha Mustonen Date: Sat, 18 Jun 2016 19:02:18 +0300 Subject: [PATCH] Initial commit --- .babelrc | 6 ++++ .gitignore | 1 + package.json | 66 ++++++++++++++++++++++++++++++++++++++ src/client.js | 16 +++++++++ src/components/Channel.jsx | 34 ++++++++++++++++++++ src/components/index.js | 0 tests/client.test.js | 5 +++ 7 files changed, 128 insertions(+) create mode 100644 .babelrc create mode 100644 .gitignore create mode 100644 package.json create mode 100644 src/client.js create mode 100644 src/components/Channel.jsx create mode 100644 src/components/index.js create mode 100644 tests/client.test.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..bd20dc1 --- /dev/null +++ b/.babelrc @@ -0,0 +1,6 @@ +{ + "presets": [ + "es2015", + "react" + ] +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/package.json b/package.json new file mode 100644 index 0000000..f7d7df2 --- /dev/null +++ b/package.json @@ -0,0 +1,66 @@ +{ + "name": "mozaik-ext-slack", + "version": "0.1.0", + "description": "Slack widgets to Mozaik dashboard", + "main": "index.js", + "scripts": { + "test": "ava" + }, + "keywords": [ + "slack", + "mozaik", + "dashboard", + "extension" + ], + "author": "Juha Mustonen ", + "license": "MIT", + "dependencies": { + "babel-core": "6.7.6", + "babel-preset-es2015": "6.6.0", + "babel-preset-react": "6.5.0", + "babelify": "7.2.0", + "bluebird": "3.3.5", + "chalk": "1.1.3", + "convict": "^0.6.1", + "lodash": "^3.5.0", + "react-mixin": "3.0.4", + "reflux": "0.4.1", + "superagent": "1.8.3", + "superagent-bluebird-promise": "3.0.0", + "dotenv": "^0.5.1", + "pretty-print": "^1.0.0", + "react-classset": "0.0.2", + "validator": "^3.30.0" + }, + "devDependencies": { + "ava": "^0.15.2", + "babel-eslint": "6.0.2", + "babel-register": "6.7.2", + "eslint": "^2.13.0", + "eslint-plugin-react": "^5.2.2", + "gulp": "^3.8.11", + "jsdom": "^9.2.1", + "proxyquire": "^1.7.9", + "touch": "0.0.3" + }, + "peerDependencies": { + "mozaik": ">=1.4.2", + "react": "^0.13.3" + }, + "browserify": { + "transform": [ + "babelify" + ] + }, + "ava": { + "files": [ + "tests/*.test.js" + ], + "tap": false, + "failFast": true, + "require": [ + "babel-register" + ], + "babel": "inherit" + } +} diff --git a/src/client.js b/src/client.js new file mode 100644 index 0000000..c583b7d --- /dev/null +++ b/src/client.js @@ -0,0 +1,16 @@ +import Promise from 'bluebird'; + +const client = mozaik => { + const count = 0; + + return { + channel(send, params) { + setInterval(() => { + count += 1; + send({ count }); + }, 800); + } + }; +}; + +export default client; diff --git a/src/components/Channel.jsx b/src/components/Channel.jsx new file mode 100644 index 0000000..e78f169 --- /dev/null +++ b/src/components/Channel.jsx @@ -0,0 +1,34 @@ +import React, { Component } from 'react'; +import reactMixin from 'react-mixin'; +import { ListenerMixin } from 'reflux'; +import Mozaik from 'mozaik/browser'; + +class Channel extends Component { + constructor(props) { + super(props); + this.state = { count: 0 }; + } + + getApiRequest() { + return { id: 'slack.channel.123' }; + } + + onApiData(data) { + console.log(data); + this.setState({ count: data.count }); + } + + render() { + const { count } = this.state; + + return ( +
{count}
+ ); + } +} + +// apply the mixins on the component +reactMixin(ClientConsumer.prototype, ListenerMixin); +reactMixin(ClientConsumer.prototype, Mozaik.Mixin.ApiConsumer); + +export default ClientConsumer; diff --git a/src/components/index.js b/src/components/index.js new file mode 100644 index 0000000..e69de29 diff --git a/tests/client.test.js b/tests/client.test.js new file mode 100644 index 0000000..bcbfe34 --- /dev/null +++ b/tests/client.test.js @@ -0,0 +1,5 @@ +import test from 'ava'; + +test('returns methods', t => { + t.true(true); +});