diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..a3a2c1d4 --- /dev/null +++ b/.babelrc @@ -0,0 +1,20 @@ +{ + "stage": 0, + "env": { + "development": { + "plugins": ["react-transform"], + "extra": { + "react-transform": { + "transforms": [{ + "transform": "react-transform-hmr", + "imports": ["react"], + "locals": ["module"] + }, { + "transform": "react-transform-catch-errors", + "imports": ["react", "redbox-react"] + }] + } + } + } + } +} diff --git a/.bowerrc b/.bowerrc deleted file mode 100644 index 0c16bd5a..00000000 --- a/.bowerrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "directory": "browser/vendor/" -} diff --git a/.gitignore b/.gitignore index bb20f469..ee5430eb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -build/ -node_modules/ -electron_build/ .env -dist/ -vendor/ +node_modules/* +!node_modules/boost +Boost-darwin-x64/ +backup/ +compiled diff --git a/.gitmodules b/.gitmodules index 73ca057a..e274b379 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,4 @@ -[submodule "browser/ace"] - path = browser/ace +[submodule "submodules/ace"] + path = submodules/ace url = https://github.com/ajaxorg/ace-builds.git -[submodule "browser/electron-stylus"] - path = browser/electron-stylus - url = https://github.com/Rokt33r/electron-stylus.git + branch = master diff --git a/atom-lib/finder-window.js b/atom-lib/finder-window.js new file mode 100644 index 00000000..529f33a2 --- /dev/null +++ b/atom-lib/finder-window.js @@ -0,0 +1,29 @@ +var BrowserWindow = require('browser-window') +var path = require('path') + +var finderWindow = new BrowserWindow({ + width: 640, + height: 400, + show: false, + frame: false, + resizable: false, + 'zoom-factor': 1.0, + 'always-on-top': true, + 'web-preferences': { + 'overlay-scrollbars': true, + 'skip-taskbar': true + }, + 'standard-window': false +}) + +var url = path.resolve(__dirname, '../browser/finder/index.html') + +finderWindow.loadUrl('file://' + url) + +finderWindow.on('blur', function () { + finderWindow.hide() +}) + +finderWindow.setVisibleOnAllWorkspaces(true) + +module.exports = finderWindow diff --git a/atom-lib/main-window.js b/atom-lib/main-window.js new file mode 100644 index 00000000..5c6f70eb --- /dev/null +++ b/atom-lib/main-window.js @@ -0,0 +1,24 @@ +var BrowserWindow = require('browser-window') +var path = require('path') + +var mainWindow = new BrowserWindow({ + width: 1080, + height: 720, + 'zoom-factor': 1.0, + 'web-preferences': { + 'overlay-scrollbars': true + }, + 'standard-window': false +}) + +var url = path.resolve(__dirname, '../browser/main/index.html') + +mainWindow.loadUrl('file://' + url) + +mainWindow.setVisibleOnAllWorkspaces(true) + +mainWindow.webContents.on('new-window', function (e) { + e.preventDefault() +}) + +module.exports = mainWindow diff --git a/modules/menu-template.js b/atom-lib/menu-template.js similarity index 100% rename from modules/menu-template.js rename to atom-lib/menu-template.js diff --git a/atom-lib/updater.js b/atom-lib/updater.js new file mode 100644 index 00000000..d506b643 --- /dev/null +++ b/atom-lib/updater.js @@ -0,0 +1,37 @@ +var autoUpdater = require('auto-updater') +var nn = require('node-notifier') +var app = require('app') +var path = require('path') + +var version = app.getVersion() +var versionText = (version == null || version.length === 0) ? 'DEV version' : 'v' + version + +autoUpdater + .on('error', function (err, message) { + console.error(err) + console.error(message) + nn.notify({ + title: 'Error! ' + versionText, + icon: path.join(__dirname, 'browser/main/resources/favicon-230x230.png'), + message: message + }) + }) + // .on('checking-for-update', function () { + // // Connecting + // }) + .on('update-available', function () { + nn.notify({ + title: 'Update is available!! ' + versionText, + icon: path.join(__dirname, 'browser/main/resources/favicon-230x230.png'), + message: 'Download started.. wait for the update ready.' + }) + }) + .on('update-not-available', function () { + nn.notify({ + title: 'Latest Build!! ' + versionText, + icon: path.join(__dirname, 'browser/main/resources/favicon-230x230.png'), + message: 'Hope you to enjoy our app :D' + }) + }) + +module.exports = autoUpdater diff --git a/bower.json b/bower.json deleted file mode 100644 index 85708203..00000000 --- a/bower.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "codexen-app", - "dependencies": { - "react": "~0.13.3", - "fontawesome": "~4.3.0", - "react-router": "~0.13.3", - "reflux": "~0.2.8", - "moment": "~2.10.3", - "markdown-it": "~4.3.1" - } -} diff --git a/browser/ace b/browser/ace deleted file mode 160000 index 0982db48..00000000 --- a/browser/ace +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0982db4853e3c967756b83b70638b9761d7f801d diff --git a/browser/electron-stylus b/browser/electron-stylus deleted file mode 160000 index 6d86de7c..00000000 --- a/browser/electron-stylus +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6d86de7c6666363c6c62a1c4ef95a3c1204e10ec diff --git a/browser/finder/Components/FinderDetail.jsx b/browser/finder/Components/FinderDetail.jsx deleted file mode 100644 index afc29762..00000000 --- a/browser/finder/Components/FinderDetail.jsx +++ /dev/null @@ -1,42 +0,0 @@ -var React = require('react/addons') - -var CodeViewer = require('../../main/Components/CodeViewer') - -var MarkdownPreview = require('../../main/Components/MarkdownPreview') - -module.exports = React.createClass({ - propTypes: { - currentArticle: React.PropTypes.object - }, - render: function () { - var article = this.props.currentArticle - - if (article != null) { - if (article.type === 'code') { - return ( -
-
{article.description}
-
- -
-
- ) - } else if (article.type === 'note') { - - return ( -
-
{article.title}
-
- -
-
- ) - } - } - return ( -
-
Nothing selected
-
- ) - } -}) diff --git a/browser/finder/Components/FinderInput.jsx b/browser/finder/Components/FinderInput.jsx deleted file mode 100644 index 467d5a40..00000000 --- a/browser/finder/Components/FinderInput.jsx +++ /dev/null @@ -1,15 +0,0 @@ -var React = require('react/addons') - -module.exports = React.createClass({ - propTypes: { - onChange: React.PropTypes.func, - search: React.PropTypes.string - }, - render: function () { - return ( -
- -
- ) - } -}) diff --git a/browser/finder/Components/FinderList.jsx b/browser/finder/Components/FinderList.jsx deleted file mode 100644 index 5b3898f3..00000000 --- a/browser/finder/Components/FinderList.jsx +++ /dev/null @@ -1,79 +0,0 @@ -var React = require('react/addons') - -module.exports = React.createClass({ - propTypes: { - articles: React.PropTypes.arrayOf, - currentArticle: React.PropTypes.shape({ - id: React.PropTypes.number, - type: React.PropTypes.string - }), - selectArticle: React.PropTypes.func - }, - componentDidUpdate: function () { - var index = this.props.articles.indexOf(this.props.currentArticle) - var el = React.findDOMNode(this) - var li = el.querySelectorAll('li')[index] - - if (li == null) { - return - } - - var overflowBelow = el.clientHeight + el.scrollTop < li.offsetTop + li.clientHeight - if (overflowBelow) { - el.scrollTop = li.offsetTop + li.clientHeight - el.clientHeight - } - var overflowAbove = el.scrollTop > li.offsetTop - if (overflowAbove) { - el.scrollTop = li.offsetTop - } - }, - handleArticleClick: function (article) { - return function () { - this.props.selectArticle(article) - }.bind(this) - }, - render: function () { - var list = this.props.articles.map(function (article) { - if (article == null) { - return ( -
  • -
    Undefined
    -
    -
  • - ) - } - - var isActive = this.props.currentArticle != null && (article.type === this.props.currentArticle.type && article.id === this.props.currentArticle.id) - if (article.type === 'code') { - return ( -
  • -
    {article.description}
    -
    -
  • - ) - } - if (article.type === 'note') { - return ( -
  • -
    {article.title}
    -
    -
  • - ) - } - return ( -
  • -
    Undefined
    -
    -
  • - ) - }.bind(this)) - - return ( -
    -
      - {list} -
    -
    - ) - } -}) diff --git a/browser/finder/FinderDetail.js b/browser/finder/FinderDetail.js new file mode 100644 index 00000000..b50392fa --- /dev/null +++ b/browser/finder/FinderDetail.js @@ -0,0 +1,34 @@ +import React, { PropTypes } from 'react' +import CodeEditor from 'boost/components/CodeEditor' +import MarkdownPreview from 'boost/components/MarkdownPreview' +import ModeIcon from 'boost/components/ModeIcon' + +export default class FinderDetail extends React.Component { + render () { + let { activeArticle } = this.props + + if (activeArticle != null) { + return ( +
    +
    + {activeArticle.title}
    +
    + {activeArticle.mode === 'markdown' + ? + : + } +
    +
    + ) + } + return ( +
    +
    Nothing selected
    +
    + ) + } +} + +FinderDetail.propTypes = { + activeArticle: PropTypes.shape() +} diff --git a/browser/finder/FinderInput.js b/browser/finder/FinderInput.js new file mode 100644 index 00000000..d23fa98d --- /dev/null +++ b/browser/finder/FinderInput.js @@ -0,0 +1,16 @@ +import React, { PropTypes } from 'react' + +export default class FinderInput extends React.Component { + render () { + return ( +
    + +
    + ) + } +} + +FinderInput.propTypes = { + handleSearchChange: PropTypes.func, + value: PropTypes.string +} diff --git a/browser/finder/FinderList.js b/browser/finder/FinderList.js new file mode 100644 index 00000000..1833ee4a --- /dev/null +++ b/browser/finder/FinderList.js @@ -0,0 +1,71 @@ +import React, { PropTypes } from 'react' +import ReactDOM from 'react-dom' +import ModeIcon from 'boost/components/ModeIcon' +import { selectArticle } from './actions' + +export default class FinderList extends React.Component { + componentDidUpdate () { + var index = this.props.articles.indexOf(this.props.activeArticle) + var el = ReactDOM.findDOMNode(this) + var li = el.querySelectorAll('li')[index] + + if (li == null) { + return + } + + var overflowBelow = el.clientHeight + el.scrollTop < li.offsetTop + li.clientHeight + if (overflowBelow) { + el.scrollTop = li.offsetTop + li.clientHeight - el.clientHeight + } + var overflowAbove = el.scrollTop > li.offsetTop + if (overflowAbove) { + el.scrollTop = li.offsetTop + } + } + + handleArticleClick (article) { + return (e) => { + let { dispatch } = this.props + dispatch(selectArticle(article.key)) + } + } + + render () { + let articleElements = this.props.articles.map(function (article) { + if (article == null) { + return ( +
  • +
    Undefined
    +
    +
  • + ) + } + + var isActive = this.props.activeArticle != null && (article.key === this.props.activeArticle.key) + return ( +
  • +
    + {article.title}
    +
    +
  • + ) + }.bind(this)) + + return ( +
    +
      + {articleElements} +
    +
    + ) + } +} + +FinderList.propTypes = { + articles: PropTypes.array, + activeArticle: PropTypes.shape({ + type: PropTypes.string, + key: PropTypes.string + }), + dispatch: PropTypes.func +} diff --git a/browser/finder/actions.js b/browser/finder/actions.js new file mode 100644 index 00000000..616d7953 --- /dev/null +++ b/browser/finder/actions.js @@ -0,0 +1,33 @@ +export const SELECT_ARTICLE = 'SELECT_ARTICLE' +export const SEARCH_ARTICLE = 'SEARCH_ARTICLE' +export const REFRESH_DATA = 'REFRESH_DATA' + +export function selectArticle (key) { + return { + type: SELECT_ARTICLE, + data: { key } + } +} + +export function searchArticle (input) { + return { + type: SEARCH_ARTICLE, + data: { input } + } +} + +export function refreshData () { + console.log('refreshing data') + let data = JSON.parse(localStorage.getItem('local')) + if (data == null) return null + + let { folders, articles } = data + + return { + type: REFRESH_DATA, + data: { + articles, + folders + } + } +} diff --git a/browser/finder/index.electron.html b/browser/finder/index.electron.html deleted file mode 100644 index 9aa524c9..00000000 --- a/browser/finder/index.electron.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - CodeXen Popup - - - - - - - - - -
    - - - - diff --git a/browser/finder/index.html b/browser/finder/index.html index e69de29b..0a058ce7 100644 --- a/browser/finder/index.html +++ b/browser/finder/index.html @@ -0,0 +1,40 @@ + + + + + CodeXen Popup + + + + + + + + + + + +
    + + + + diff --git a/browser/finder/index.js b/browser/finder/index.js new file mode 100644 index 00000000..fb2a40a7 --- /dev/null +++ b/browser/finder/index.js @@ -0,0 +1,183 @@ +import React, { PropTypes } from 'react' +import ReactDOM from 'react-dom' +import { connect, Provider } from 'react-redux' +import reducer from './reducer' +import { createStore } from 'redux' +import FinderInput from './FinderInput' +import FinderList from './FinderList' +import FinderDetail from './FinderDetail' +import { selectArticle, searchArticle, refreshData } from './actions' +import _ from 'lodash' + +import remote from 'remote' +var hideFinder = remote.getGlobal('hideFinder') +import clipboard from 'clipboard' + +require('../styles/finder/index.styl') + +const FOLDER_FILTER = 'FOLDER_FILTER' +const TEXT_FILTER = 'TEXT_FILTER' +const TAG_FILTER = 'TAG_FILTER' + +class FinderMain extends React.Component { + constructor (props) { + super(props) + } + + componentDidMount () { + ReactDOM.findDOMNode(this.refs.finderInput.refs.input).focus() + } + + handleClick (e) { + ReactDOM.findDOMNode(this.refs.finderInput.refs.input).focus() + } + + handleKeyDown (e) { + if (e.keyCode === 38) { + this.selectPrevious() + e.preventDefault() + } + + if (e.keyCode === 40) { + this.selectNext() + e.preventDefault() + } + + if (e.keyCode === 13) { + let { activeArticle } = this.props + clipboard.writeText(activeArticle.content) + hideFinder() + e.preventDefault() + } + if (e.keyCode === 27) { + hideFinder() + e.preventDefault() + } + } + + handleSearchChange (e) { + let { dispatch } = this.props + + dispatch(searchArticle(e.target.value)) + } + + selectArticle (article) { + this.setState({currentArticle: article}) + } + + selectPrevious () { + let { activeArticle, dispatch } = this.props + let index = this.refs.finderList.props.articles.indexOf(activeArticle) + let previousArticle = this.refs.finderList.props.articles[index - 1] + if (previousArticle != null) dispatch(selectArticle(previousArticle.key)) + } + + selectNext () { + let { activeArticle, dispatch } = this.props + let index = this.refs.finderList.props.articles.indexOf(activeArticle) + let previousArticle = this.refs.finderList.props.articles[index + 1] + if (previousArticle != null) dispatch(selectArticle(previousArticle.key)) + } + + render () { + let { articles, activeArticle, status, dispatch } = this.props + return ( +
    this.handleClick(e)} onKeyDown={e => this.handleKeyDown(e)} className='Finder'> + this.handleSearchChange(e)} + ref='finderInput' + onChange={this.handleChange} + value={status.search} + /> + this.selectArticle(article)} + /> + +
    + ) + } +} + +FinderMain.propTypes = { + articles: PropTypes.array, + activeArticle: PropTypes.shape({ + key: PropTypes.string, + tags: PropTypes.array, + title: PropTypes.string, + content: PropTypes.string + }), + status: PropTypes.shape(), + dispatch: PropTypes.func +} + +function remap (state) { + let { articles, folders, status } = state + + let filters = status.search.split(' ').map(key => key.trim()).filter(key => key.length > 0 && !key.match(/^#$/)).map(key => { + if (key.match(/^in:.+$/)) { + return {type: FOLDER_FILTER, value: key.match(/^in:(.+)$/)[1]} + } + if (key.match(/^#(.+)/)) { + return {type: TAG_FILTER, value: key.match(/^#(.+)$/)[1]} + } + return {type: TEXT_FILTER, value: key} + }) + let folderFilters = filters.filter(filter => filter.type === FOLDER_FILTER) + let textFilters = filters.filter(filter => filter.type === TEXT_FILTER) + let tagFilters = filters.filter(filter => filter.type === TAG_FILTER) + + if (folders != null) { + let targetFolders = folders.filter(folder => { + return _.findWhere(folderFilters, {value: folder.name}) + }) + status.targetFolders = targetFolders + + if (targetFolders.length > 0) { + articles = articles.filter(article => { + return _.findWhere(targetFolders, {key: article.FolderKey}) + }) + } + + if (textFilters.length > 0) { + articles = textFilters.reduce((articles, textFilter) => { + return articles.filter(article => { + return article.title.match(new RegExp(textFilter.value, 'i')) || article.content.match(new RegExp(textFilter.value, 'i')) + }) + }, articles) + } + + if (tagFilters.length > 0) { + articles = tagFilters.reduce((articles, tagFilter) => { + return articles.filter(article => { + return _.find(article.tags, tag => tag.match(new RegExp(tagFilter.value, 'i'))) + }) + }, articles) + } + } + + let activeArticle = _.findWhere(articles, {key: status.articleKey}) + if (activeArticle == null) activeArticle = articles[0] + + return { + articles, + activeArticle, + status + } +} + +var Finder = connect(remap)(FinderMain) +var store = createStore(reducer) + +window.onfocus = e => { + store.dispatch(refreshData()) +} + +ReactDOM.render(( + + + +), document.getElementById('content')) diff --git a/browser/finder/index.jsx b/browser/finder/index.jsx deleted file mode 100644 index 7de3859a..00000000 --- a/browser/finder/index.jsx +++ /dev/null @@ -1,135 +0,0 @@ -/* global localStorage */ -var remote = require('remote') -var hideFinder = remote.getGlobal('hideFinder') -var clipboard = require('clipboard') - -var React = require('react/addons') - -var ArticleFilter = require('../main/Mixins/ArticleFilter') - -var FinderInput = require('./Components/FinderInput') -var FinderList = require('./Components/FinderList') -var FinderDetail = require('./Components/FinderDetail') - -// Filter end - -function fetchArticles () { - var user = JSON.parse(localStorage.getItem('currentUser')) - if (user == null) { - console.log('need to login') - return [] - } - - var articles = [] - user.Planets.forEach(function (planet) { - var _planet = JSON.parse(localStorage.getItem('planet-' + planet.id)) - articles = articles.concat(_planet.Codes, _planet.Notes) - }) - user.Teams.forEach(function (team) { - team.Planets.forEach(function (planet) { - var _planet = JSON.parse(localStorage.getItem('planet-' + planet.id)) - articles = articles.concat(_planet.Codes, _planet.Notes) - }) - }) - - return articles -} - -var Finder = React.createClass({ - mixins: [ArticleFilter], - getInitialState: function () { - var articles = fetchArticles() - return { - articles: articles, - currentArticle: articles[0], - search: '' - } - }, - componentDidMount: function () { - document.addEventListener('keydown', this.handleKeyDown) - document.addEventListener('click', this.handleClick) - window.addEventListener('focus', this.handleFinderFocus) - this.handleFinderFocus() - }, - componentWillUnmount: function () { - document.removeEventListener('keydown', this.handleKeyDown) - document.removeEventListener('click', this.handleClick) - window.removeEventListener('focus', this.handleFinderFocus) - }, - handleFinderFocus: function () { - console.log('focusseeddddd') - this.focusInput() - var articles = fetchArticles() - this.setState({ - articles: articles, - search: '' - }, function () { - var firstArticle = this.refs.finderList.props.articles[0] - if (firstArticle) { - this.setState({ - currentArticle: firstArticle - }) - } - }) - }, - handleKeyDown: function (e) { - if (e.keyCode === 38) { - this.selectPrevious() - e.preventDefault() - } - - if (e.keyCode === 40) { - this.selectNext() - e.preventDefault() - } - - if (e.keyCode === 13) { - var article = this.state.currentArticle - clipboard.writeText(article.content) - hideFinder() - e.preventDefault() - } - if (e.keyCode === 27) { - hideFinder() - e.preventDefault() - } - }, - focusInput: function () { - React.findDOMNode(this.refs.finderInput).querySelector('input').focus() - }, - handleClick: function () { - this.focusInput() - }, - selectPrevious: function () { - var index = this.refs.finderList.props.articles.indexOf(this.state.currentArticle) - if (index > 0) { - this.setState({currentArticle: this.refs.finderList.props.articles[index - 1]}) - } - }, - selectNext: function () { - var index = this.refs.finderList.props.articles.indexOf(this.state.currentArticle) - if (index > -1 && index < this.refs.finderList.props.articles.length - 1) { - this.setState({currentArticle: this.refs.finderList.props.articles[index + 1]}) - } - }, - selectArticle: function (article) { - this.setState({currentArticle: article}) - }, - handleChange: function (e) { - this.setState({search: e.target.value}, function () { - this.setState({currentArticle: this.refs.finderList.props.articles[0]}) - }) - }, - render: function () { - var articles = this.searchArticle(this.state.search, this.state.articles) - return ( -
    - - - -
    - ) - } -}) - -React.render(, document.getElementById('content')) diff --git a/browser/finder/reducer.js b/browser/finder/reducer.js new file mode 100644 index 00000000..72b087c3 --- /dev/null +++ b/browser/finder/reducer.js @@ -0,0 +1,49 @@ +import { combineReducers } from 'redux' +import { SELECT_ARTICLE, SEARCH_ARTICLE, REFRESH_DATA } from './actions' + +let data = JSON.parse(localStorage.getItem('local')) + +let initialArticles = data != null ? data.articles : [] +let initialFolders = data != null ? data.folders : [] +let initialStatus = { + articleKey: null, + search: '' +} + +function status (state = initialStatus, action) { + switch (action.type) { + case SELECT_ARTICLE: + state.articleKey = action.data.key + return state + case SEARCH_ARTICLE: + state.search = action.data.input + return state + default: + return state + } +} + +function articles (state = initialArticles, action) { + switch (action.type) { + case REFRESH_DATA: + return action.data.articles + default: + return state + } +} + +function folders (state = initialFolders, action) { + switch (action.type) { + case REFRESH_DATA: + console.log(action) + return action.data.folders + default: + return state + } +} + +export default combineReducers({ + status, + folders, + articles +}) diff --git a/browser/index.html b/browser/index.html deleted file mode 100644 index cbb53cad..00000000 --- a/browser/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - Go Main - Go Popup - - diff --git a/browser/main/Components/AboutModal.jsx b/browser/main/Components/AboutModal.jsx deleted file mode 100644 index d1f1a3eb..00000000 --- a/browser/main/Components/AboutModal.jsx +++ /dev/null @@ -1,38 +0,0 @@ -var React = require('react/addons') - -var ExternalLink = require('../Mixins/ExternalLink') -var KeyCaster = require('../Mixins/KeyCaster') - -module.exports = React.createClass({ - mixins: [ExternalLink, KeyCaster('aboutModal')], - propTypes: { - close: React.PropTypes.func - }, - onKeyCast: function (e) { - switch (e.status) { - case 'closeModal': - this.props.close() - break - } - }, - render: function () { - var version = global.version - return ( -
    -
    - -
    Boost {version == null || version.length === 0 ? 'DEV version' : 'v' + version}
    -
    - -
    -
    External links
    - -
    -
    - ) - } -}) diff --git a/browser/main/Components/AddMemberModal.jsx b/browser/main/Components/AddMemberModal.jsx deleted file mode 100644 index f79ce647..00000000 --- a/browser/main/Components/AddMemberModal.jsx +++ /dev/null @@ -1,99 +0,0 @@ -var React = require('react/addons') -var Select = require('react-select') - -var LinkedState = require('../Mixins/LinkedState') - -var Hq = require('../Services/Hq') - -var KeyCaster = require('../Mixins/KeyCaster') - -var getOptions = function (input, callback) { - Hq.searchUser(input) - .then(function (res) { - callback(null, { - options: res.body.map(function (user) { - return { - label: user.name, - value: user.name - } - }), - complete: false - }) - }) - .catch(function (err) { - console.error(err) - }) -} - -module.exports = React.createClass({ - mixins: [LinkedState, KeyCaster('addMemberModal')], - propTypes: { - team: React.PropTypes.object, - close: React.PropTypes.func - }, - getInitialState: function () { - return { - userName: '', - role: 'member' - } - }, - onKeyCast: function (e) { - switch (e.status) { - case 'closeModal': - this.props.close() - break - case 'submitAddMemberModal': - this.handleSubmit() - break - } - }, - handleSubmit: function () { - this.setState({errorMessage: null}, function () { - Hq - .addMember(this.props.team.name, { - userName: this.state.userName, - role: this.state.role - }) - .then(function (res) { - console.log(res.body) - this.props.close() - }.bind(this)) - .catch(function (err) { - console.error(err) - if (err.status === 403) { - this.setState({errorMessage: err.response.body.message}) - } - }.bind(this)) - }) - }, - handleChange: function (value) { - this.setState({userName: value}) - }, - render: function () { - return ( -
    - - - - - role -
    - - {this.state.errorMessage != null ? (

    {this.state.errorMessage}

    ) : null} - - - - ) - } -}) diff --git a/browser/main/Components/CodeDeleteModal.jsx b/browser/main/Components/CodeDeleteModal.jsx deleted file mode 100644 index e6ef467e..00000000 --- a/browser/main/Components/CodeDeleteModal.jsx +++ /dev/null @@ -1,55 +0,0 @@ -var React = require('react') - -var Hq = require('../Services/Hq') - -var KeyCaster = require('../Mixins/KeyCaster') - -var PlanetStore = require('../Stores/PlanetStore') - -module.exports = React.createClass({ - mixins: [KeyCaster('codeDeleteModal')], - propTypes: { - planet: React.PropTypes.object, - code: React.PropTypes.object, - close: React.PropTypes.func - }, - onKeyCast: function (e) { - switch (e.status) { - case 'submitCodeDeleteModal': - this.submit() - break - case 'closeModal': - this.props.close() - break - } - }, - submit: function () { - var planet = this.props.planet - Hq.destroyCode(planet.Owner.name, planet.name, this.props.code.localId) - .then(function (res) { - PlanetStore.Actions.destroyCode(res.body) - this.props.close() - }.bind(this)) - .catch(function (err) { - console.error(err) - }) - }, - render: function () { - return ( -
    -
    -

    Delete Code

    -
    -
    -

    Are you sure to delete it?

    -
    -
    -
    - - -
    -
    -
    - ) - } -}) diff --git a/browser/main/Components/CodeEditModal.jsx b/browser/main/Components/CodeEditModal.jsx deleted file mode 100644 index 7b070db6..00000000 --- a/browser/main/Components/CodeEditModal.jsx +++ /dev/null @@ -1,26 +0,0 @@ -var React = require('react') -var CodeForm = require('./CodeForm') - -module.exports = React.createClass({ - propTypes: { - close: React.PropTypes.func, - code: React.PropTypes.object, - planet: React.PropTypes.object - }, - componentDidMount: function () { - // TODO: Hacked!! should fix later - setTimeout(function () { - React.findDOMNode(this.refs.form.refs.description).focus() - }.bind(this), 1) - }, - render: function () { - return ( -
    -
    -

    Edit Code

    -
    - -
    - ) - } -}) diff --git a/browser/main/Components/CodeForm.jsx b/browser/main/Components/CodeForm.jsx deleted file mode 100644 index c172a2cb..00000000 --- a/browser/main/Components/CodeForm.jsx +++ /dev/null @@ -1,162 +0,0 @@ -var React = require('react/addons') -var CodeEditor = require('./CodeEditor') -var Select = require('react-select') - -var Hq = require('../Services/Hq') - -var LinkedState = require('../Mixins/LinkedState') -var KeyCaster = require('../Mixins/KeyCaster') - -var PlanetStore = require('../Stores/PlanetStore') - -var aceModes = require('../../../modules/ace-modes') - -var getOptions = function (input, callback) { - Hq.searchTag(input) - .then(function (res) { - callback(null, { - options: res.body.map(function (tag) { - return { - label: tag.name, - value: tag.name - } - }), - complete: false - }) - }) - .catch(function (err) { - console.log(err) - }) -} - -module.exports = React.createClass({ - mixins: [LinkedState, KeyCaster('codeForm')], - propTypes: { - planet: React.PropTypes.object, - close: React.PropTypes.func, - transitionTo: React.PropTypes.func, - code: React.PropTypes.object - }, - getInitialState: function () { - var code = Object.assign({ - description: '', - mode: '', - content: '', - Tags: [] - }, this.props.code) - - code.Tags = code.Tags.map(function (tag) { - return { - label: tag.name, - value: tag.name - } - }) - - return { - code: code - } - }, - onKeyCast: function (e) { - switch (e.status) { - case 'submitCodeForm': - this.submit() - break - case 'closeModal': - this.props.close() - break - } - }, - handleModeChange: function (selected) { - var code = this.state.code - code.mode = selected - this.setState({code: code}) - }, - handleTagsChange: function (selected, all) { - var code = this.state.code - code.Tags = all - this.setState({code: code}) - }, - handleContentChange: function (e, value) { - var code = this.state.code - code.content = value - this.setState({code: code}) - }, - submit: function () { - var planet = this.props.planet - var code = this.state.code - code.Tags = code.Tags.map(function (tag) { - return tag.value - }) - if (this.props.code == null) { - Hq.createCode(planet.Owner.name, planet.name, this.state.code) - .then(function (res) { - var code = res.body - PlanetStore.Actions.updateCode(code) - this.props.close() - this.props.transitionTo('codes', {userName: planet.Owner.name, planetName: planet.name, localId: code.localId}) - }.bind(this)) - .catch(function (err) { - console.error(err) - }) - } else { - Hq.updateCode(planet.Owner.name, planet.name, this.props.code.localId, this.state.code) - .then(function (res) { - var code = res.body - PlanetStore.Actions.updateCode(code) - this.props.close() - }.bind(this)) - } - }, - handleKeyDown: function (e) { - if (e.keyCode === 13 && e.metaKey) { - this.submit() - e.stopPropagation() - } - }, - render: function () { - var modeOptions = aceModes.map(function (mode) { - return { - label: mode, - value: mode - } - }) - return ( -
    -
    -
    -