+
+
Planet setting
+
-
)
+ },
+ renderPlanetProfileTab: function () {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
on Sending...
+
+
Connection failed.. Try again.
+
+
Successfully done!!
+
+
+ )
+ },
+ renderPlanetDeleteTab: function () {
+ var disabled = !this.state.deleteConfirmation.match(new RegExp('^' + this.props.planet.userName + '/' + this.props.planet.name + '$'))
+
+ return (
+
+
Are you sure to destroy '{this.props.planet.userName + '/' + this.props.planet.name}'?
+
If you are sure, write '{this.props.planet.userName + '/' + this.props.planet.name}' to input below and click '{this.state.randomDeleteText}' button.
+
+
+
+
+
on Sending...
+
+
Connection failed.. Try again.
+
+
Successfully done!!
+
+
+ )
}
})
diff --git a/browser/main/Components/PreferencesModal.jsx b/browser/main/Components/PreferencesModal.jsx
deleted file mode 100644
index 7ba97c09..00000000
--- a/browser/main/Components/PreferencesModal.jsx
+++ /dev/null
@@ -1,240 +0,0 @@
-/* global localStorage */
-var React = require('react/addons')
-var ReactRouter = require('react-router')
-var Navigation = ReactRouter.Navigation
-var request = require('superagent')
-
-var LinkedState = require('../Mixins/LinkedState')
-
-var ProfileImage = require('./ProfileImage')
-
-var apiUrl = require('../../../config').apiUrl
-
-module.exports = React.createClass({
- mixins: [LinkedState, Navigation],
- propTypes: {
- close: React.PropTypes.func,
- currentUser: React.PropTypes.object
- },
- getInitialState: function () {
- return {
- currentTab: 'profile',
- profileName: this.props.currentUser.profileName,
- userName: this.props.currentUser.name,
- email: this.props.currentUser.email,
- currentPassword: '',
- newPassword: '',
- confirmation: '',
- contactTitle: '',
- contactContent: ''
- }
- },
- componentDidMount: function () {
- },
- componentWillUnmount: function () {
- },
- onListen: function (res) {
- },
- activeProfile: function () {
- this.setState({currentTab: 'profile'})
- },
- activeContact: function () {
- this.setState({currentTab: 'contact'})
- },
- activeInfo: function () {
- this.setState({currentTab: 'info'})
- },
- activeLogout: function () {
- this.setState({currentTab: 'logout'})
- },
- saveProfile: function () {
- },
- savePassword: function () {
- this.setState({
- isChangingPassword: true,
- isChangingPasswordDone: false,
- isChangingPasswordFailed: false
- })
- if (this.state.newPassword === this.state.confirmation) {
- request
- .put(apiUrl + 'auth/password')
- .set({
- Authorization: 'Bearer ' + localStorage.getItem('token')
- })
- .send({
- currentPassword: this.state.currentPassword,
- newPassword: this.state.newPassword
- })
- .end(function (err, res) {
- if (err) {
- console.error(err)
- this.setState({
- currentPassword: '',
- newPassword: '',
- confirmation: '',
- isChangingPassword: false,
- isChangingPasswordDone: false,
- isChangingPasswordFailed: true
- })
- return
- }
-
- this.setState({
- currentPassword: '',
- newPassword: '',
- confirmation: '',
- isChangingPassword: false,
- isChangingPasswordDone: true,
- isChangingPasswordFailed: false
- })
-
- }.bind(this))
- }
- },
- sendEmail: function () {
- this.setState({
- isSending: true,
- isSendingDone: false,
- isSendingFailed: false
- }, function () {
- request
- .post(apiUrl + 'mail')
- .set({
- Authorization: 'Bearer ' + localStorage.getItem('token')
- })
- .send({
- title: this.state.contactTitle,
- content: this.state.contactContent
- })
- .end(function (err, res) {
- if (err) {
- console.error(err)
- this.setState({
- isSending: false,
- isSendingDone: false,
- isSendingFailed: true
- })
- return
- }
- this.setState({
- isSending: false,
- isSendingDone: true,
- isSendingFailed: false,
- contactTitle: '',
- contactContent: ''
- })
- }.bind(this))
- })
- },
- logOut: function () {
- localStorage.removeItem('currentUser')
- localStorage.removeItem('token')
- },
- interceptClick: function (e) {
- e.stopPropagation()
- },
- render: function () {
- var content
- if (this.state.currentTab === 'profile') {
- content = (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Updating profile...
-
Successfully updated
-
An Error occurred
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Changing password...
-
Successfully changed
-
An Error occurred
-
-
-
- )
- } else if (this.state.currentTab === 'contact') {
- content = (
-
-
- Let us know your opinion about CodeXen.
- Your feedback might be used to improvement of CodeXen.
-
-
-
-
-
-
Sending...
-
Successfully sent
-
An Error occurred
-
-
- )
- } else if (this.state.currentTab === 'info') {
- content = (
-
- )
- } else {
- content = (
-
-
Are you sure to logout?
-
-
-
-
- )
- }
-
- return (
-
-
-
Personal setting
-
-
-
- {content}
-
-
- )
- }
-})
diff --git a/browser/main/Containers/PlanetContainer.jsx b/browser/main/Containers/PlanetContainer.jsx
index 3aa78e77..9c8eb1ad 100644
--- a/browser/main/Containers/PlanetContainer.jsx
+++ b/browser/main/Containers/PlanetContainer.jsx
@@ -89,10 +89,25 @@ module.exports = React.createClass({
},
onPlanetChange: function (res) {
if (this.state.planet == null) return
- console.log(res.data)
- var code, note, articleIndex, articlesCount
+ var planet, code, note, articleIndex, articlesCount
switch (res.status) {
+ case 'updated':
+ planet = res.data
+ if (this.state.planet.id === planet.id) {
+ if (this.state.planet.name === planet.name) {
+ this.setState({planet: planet})
+ } else {
+ this.transitionTo('planetHome', {userName: planet.userName, planetName: planet.name})
+ }
+ }
+ break
+ case 'destroyed':
+ planet = res.data
+ if (this.state.planet.id === planet.id) {
+ this.transitionTo('userHome', {userName: this.state.planet.userName})
+ }
+ break
case 'codeUpdated':
code = res.data
if (code.PlanetId === this.state.planet.id) {
diff --git a/browser/main/Containers/SignupContainer.jsx b/browser/main/Containers/SignupContainer.jsx
index 71c20f63..dd0c1d29 100644
--- a/browser/main/Containers/SignupContainer.jsx
+++ b/browser/main/Containers/SignupContainer.jsx
@@ -30,14 +30,15 @@ module.exports = React.createClass({
}, function () {
Hq.signup(this.state.user)
.then(function (res) {
+ console.log(res.body)
localStorage.setItem('token', res.body.token)
localStorage.setItem('currentUser', JSON.stringify(res.body.user))
this.transitionTo('userHome', {userName: res.body.user.name})
}.bind(this))
.catch(function (err) {
+ console.error(err)
var res = err.response
- console.error(res.body)
if (err.status === 409) {
// Confliction
var emailConflicted = res.body.errors[0].path === 'email'
@@ -90,12 +91,6 @@ module.exports = React.createClass({
-
-
or
diff --git a/browser/main/Mixins/ExternalLink.js b/browser/main/Mixins/ExternalLink.js
new file mode 100644
index 00000000..45005a04
--- /dev/null
+++ b/browser/main/Mixins/ExternalLink.js
@@ -0,0 +1,8 @@
+var shell = require('shell')
+
+module.exports = {
+ openExternal: function (e) {
+ shell.openExternal(e.currentTarget.href)
+ e.preventDefault()
+ }
+}
diff --git a/browser/main/Services/Hq.js b/browser/main/Services/Hq.js
index 42d775a0..e2d33897 100644
--- a/browser/main/Services/Hq.js
+++ b/browser/main/Services/Hq.js
@@ -64,6 +64,21 @@ module.exports = {
return request
.get(apiUrl + 'resources/' + userName + '/planets/' + planetName)
},
+ updatePlanet: function (userName, planetName, input) {
+ return request
+ .put(apiUrl + 'resources/' + userName + '/planets/' + planetName)
+ .set({
+ Authorization: 'Bearer ' + localStorage.getItem('token')
+ })
+ .send(input)
+ },
+ destroyPlanet: function (userName, planetName) {
+ return request
+ .del(apiUrl + 'resources/' + userName + '/planets/' + planetName)
+ .set({
+ Authorization: 'Bearer ' + localStorage.getItem('token')
+ })
+ },
createCode: function (userName, planetName, input) {
return request
.post(apiUrl + 'resources/' + userName + '/planets/' + planetName + '/codes')
diff --git a/browser/main/Stores/PlanetStore.js b/browser/main/Stores/PlanetStore.js
index 08dcac47..7cadc956 100644
--- a/browser/main/Stores/PlanetStore.js
+++ b/browser/main/Stores/PlanetStore.js
@@ -84,6 +84,43 @@ module.exports = Reflux.createStore({
data: planet
})
},
+ onDestroy: function (planet) {
+ // Check if the planet should be updated to currentUser
+ var currentUser = JSON.parse(localStorage.getItem('currentUser'))
+
+ var ownedByCurrentUser = currentUser.id === planet.OwnerId
+
+ if (ownedByCurrentUser) {
+ currentUser.Planets = deleteItemFromTargetArray(planet, currentUser.Planets)
+ }
+
+ if (!ownedByCurrentUser) {
+ var team = null
+ currentUser.Teams.some(function (_team) {
+ if (_team.id === planet.OwnerId) {
+ team = _team
+ return true
+ }
+ return
+ })
+
+ if (team) {
+ team.Planets = deleteItemFromTargetArray(planet, team.Planets)
+ }
+ }
+
+ // Update currentUser
+ localStorage.setItem('currentUser', JSON.stringify(currentUser))
+ UserStore.Actions.update(currentUser)
+
+ // Update the planet
+ localStorage.setItem('planet-' + planet.id, JSON.stringify(planet))
+
+ this.trigger({
+ status: 'destroyed',
+ data: planet
+ })
+ },
onUpdateCode: function (code) {
code.type = 'code'
diff --git a/browser/styles/shared/modal.styl b/browser/styles/shared/modal.styl
index 65a804f3..92e601a3 100644
--- a/browser/styles/shared/modal.styl
+++ b/browser/styles/shared/modal.styl
@@ -32,7 +32,7 @@
.modal-control
float right
- .EditProfileModal
+ .tabModal
height 500px
.leftPane
absolute top bottom left
@@ -56,54 +56,103 @@
absolute top bottom right
left 175px
padding 15px
- .userInfoTab, .paswordTab
- padding-top 45px
- .formField
- position relative
- clearfix()
- margin-bottom 15px
- label
- width 30%
- display block
- line-height 33px
- float left
- input
- width 70%
- display block
- borderInput()
- height 33px
- font-size 1em
- border-radius 10px
- float left
- .formConfirm
- position relative
- clearfix()
- margin-bottom 15px
- button
- float right
- btnDefault()
- padding 10px 15px
- border-radius 5px
- font-size 1em
- margin-left 5px
- .alertInfo, .alertSuccess, .alertError
- float right
- padding 12px 10px
- border-radius 5px
- width 200px
- font-size 1em
- overflow-x hidden
- white-space nowrap
- transition 0.1s
- &.hide
- width 0
- padding 12px 0
- .alertInfo
- alertInfo()
- .alertSuccess
- alertSuccess()
- .alertError
- alertError()
+
+ .EditProfileModal, .PlanetSettingModal
+ .userInfoTab, .paswordTab, .planetProfileTab
+ padding-top 45px
+ .formField
+ position relative
+ clearfix()
+ margin-bottom 15px
+ label
+ width 30%
+ display block
+ line-height 33px
+ float left
+ input
+ width 70%
+ display block
+ borderInput()
+ height 33px
+ font-size 1em
+ border-radius 10px
+ float left
+ .formRadioField
+ margin-bottom 15px
+ input
+ margin-left 25px
+ .formConfirm
+ position relative
+ clearfix()
+ margin-bottom 15px
+ button
+ float right
+ btnDefault()
+ padding 10px 15px
+ border-radius 5px
+ font-size 1em
+ margin-left 5px
+ .alertInfo, .alertSuccess, .alertError
+ float right
+ padding 12px 10px
+ border-radius 5px
+ width 200px
+ font-size 1em
+ overflow-x hidden
+ white-space nowrap
+ transition 0.1s
+ &.hide
+ width 0
+ padding 12px 0
+ .alertInfo
+ alertInfo()
+ .alertSuccess
+ alertSuccess()
+ .alertError
+ alertError()
+ .planetDeleteTab
+ padding-top 65px
+ p
+ margin-bottom 25px
+ strong
+ color brandColor
+ font-size 1.1em
+ input
+ borderInput()
+ margin-right 5px
+ height 33px
+ font-size 1em
+ border-radius 10px
+ .formConfirm
+ position relative
+ clearfix()
+ margin-bottom 15px
+ button
+ float right
+ btnDefault()
+ padding 10px 15px
+ border-radius 5px
+ font-size 1em
+ margin-left 5px
+ .alertInfo, .alertSuccess, .alertError
+ float right
+ padding 12px 10px
+ border-radius 5px
+ width 200px
+ font-size 1em
+ overflow-x hidden
+ white-space nowrap
+ transition 0.1s
+ &.hide
+ width 0
+ padding 12px 0
+ .alertInfo
+ alertInfo()
+ .alertSuccess
+ alertSuccess()
+ .alertError
+ alertError()
+
.LaunchModal
.modal-tab
@@ -171,6 +220,27 @@
border-radius 5px
marked()
+ .AboutModal
+ width 320px
+ .about1
+ margin-bottom 25px
+ .logo
+ display block
+ margin 0 auto
+ .appInfo
+ font-size 1.5em
+ text-align center
+ .about2
+ width 200px
+ margin 0 auto
+ .externalLabel
+ font-size 1.2em
+ margin-bottom 15px
+ .externalList
+ li
+ margin-bottom 15px
+
+
.PlanetCreateModal.modal, .TeamCreateModal.modal
padding 60px 0
.nameInput
@@ -203,162 +273,3 @@
height 55px
circle()
btnPrimary()
- .PlanetSettingModal.modal, .PersonalSettingModal.modal
- width 720px
- height 500px
- .settingNav
- absolute top bottom left
- width 200px
- box-sizing border-box
- padding 10px
- border-right solid 1px borderColor
- h1
- margin 40px auto
- font-size 1.5em
- color brandColor
- text-align center
- nav
- button
- font-size 1em
- display block
- box-sizing border-box
- padding 15px 15px
- margin 10px 0
- border none
- border-radius 10px
- width 100%
- text-align left
- background-color transparent
- color textColor
- cursor pointer
- transition 0.1s
- &:hover, &.hover
- background-color hoverBackgroundColor
- &:active, &.active
- color brandColor
- .settingBody
- absolute top bottom right
- left 200px
- padding 15px
- .PreferencesModal.modal
- .settingBody
- .profile
- height 500px
- padding-top 50px
- .profileTop
- box-sizing border-box
- height 200px
- border-bottom solid 1px borderColor
- .profileBottom
- margin-top 25px
- height 200px
- .profileFormRow
- clearfix()
- margin-bottom 15px
- label
- display block
- float left
- width 150px
- line-height 33px
- text-align left
- input
- float left
- width 250px
- .alertSuccess, .alertError, .alertInfo
- float right
- transition 0.1s
- overflow hidden
- white-space nowrap
- width 200px
- text-align center
- &.hide
- width 0
- .alertSuccess
- alertSuccess()
- .alertError
- alertError()
- .alertInfo
- alertInfo()
- .saveButton
- float right
- .contact
- height 500px
- padding-top 50px
- p
- text-align left
- margin-bottom 15px
- line-height 140%
- input
- margin-bottom 15px
- textarea
- margin-bottom 15px
- max-height 250px
- .contactFormRow
- clearfix()
- .saveButton
- float right
- .alertSuccess, .alertError, .alertInfo
- float right
- transition 0.1s
- overflow hidden
- white-space nowrap
- width 200px
- text-align center
- &.hide
- width 0
- .alertSuccess
- alertSuccess()
- .alertError
- alertError()
- .alertInfo
- alertInfo()
- .info
- text-align left
- .infoLabel
- margin 75px 0 25px
- .externalList
- padding-left 10px
- li
- margin 15px
- .logout
- text-align center
- .logoutLabel
- margin 100px 0 25px
- font-size 1.4em
- .userPhoto
- margin-bottom 25px
- circle()
- box-shadow 1px 1px 4px 0px #C5C5C5
-
- .PlanetSettingModal.modal
- .settingBody
- .planetProfile
- height 500px
- padding-top 50px
- .planetProfileForm
- height 275px
- box-sizing border-box
- border-bottom solid 1px borderColor
- .planetDeleteForm
- height 225px
- .planetDeleteControl
- margin-top 15px
- clearfix()
- .toggle
- float left
- transition width 0.3s, color 0.1s, border-color 0.1s
- overflow hidden
- white-space nowrap
- width 345px
- height 44px
- &.hide
- width 0
- .planetDeleteLabel
- display inline-block
- line-height 44px
- .cancelButton
- display inline-block
- margin-left 15px
- margin-right 0
- .deleteButton
- float left
diff --git a/main.js b/main.js
index 6663b2f7..fc7cc0d7 100644
--- a/main.js
+++ b/main.js
@@ -18,6 +18,7 @@ var update = null
// })
var version = app.getVersion()
+global.version = version
var nn = require('node-notifier')
var autoUpdater = require('auto-updater')