mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
Merge pull request #1220 from PaulRosset/add-notification-onChangeUi
Add notification on change ui
This commit is contained in:
@@ -76,8 +76,8 @@
|
|||||||
color #1EC38B
|
color #1EC38B
|
||||||
.error
|
.error
|
||||||
color red
|
color red
|
||||||
|
.warning
|
||||||
|
color #FFA500
|
||||||
|
|
||||||
.group-control-leftButton
|
.group-control-leftButton
|
||||||
colorDefaultButton()
|
colorDefaultButton()
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class HotkeyTab extends React.Component {
|
|||||||
message: err.message != null ? err.message : 'Error occurs!'
|
message: err.message != null ? err.message : 'Error occurs!'
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
this.oldHotkey = this.state.config.hotkey
|
||||||
ipc.addListener('APP_SETTING_DONE', this.handleSettingDone)
|
ipc.addListener('APP_SETTING_DONE', this.handleSettingDone)
|
||||||
ipc.addListener('APP_SETTING_ERROR', this.handleSettingError)
|
ipc.addListener('APP_SETTING_ERROR', this.handleSettingError)
|
||||||
}
|
}
|
||||||
@@ -53,6 +54,7 @@ class HotkeyTab extends React.Component {
|
|||||||
config: newConfig
|
config: newConfig
|
||||||
})
|
})
|
||||||
this.clearMessage()
|
this.clearMessage()
|
||||||
|
this.props.haveToSave()
|
||||||
}
|
}
|
||||||
|
|
||||||
handleHintToggleButtonClick (e) {
|
handleHintToggleButtonClick (e) {
|
||||||
@@ -70,6 +72,15 @@ class HotkeyTab extends React.Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
config
|
config
|
||||||
})
|
})
|
||||||
|
if (_.isEqual(this.oldHotkey, config.hotkey)) {
|
||||||
|
this.props.haveToSave()
|
||||||
|
} else {
|
||||||
|
this.props.haveToSave({
|
||||||
|
tab: 'Hotkey',
|
||||||
|
type: 'warning',
|
||||||
|
message: 'You have to save!'
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clearMessage () {
|
clearMessage () {
|
||||||
@@ -161,7 +172,8 @@ class HotkeyTab extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HotkeyTab.propTypes = {
|
HotkeyTab.propTypes = {
|
||||||
dispatch: PropTypes.func
|
dispatch: PropTypes.func,
|
||||||
|
haveToSave: PropTypes.func
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CSSModules(HotkeyTab, styles)
|
export default CSSModules(HotkeyTab, styles)
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ top-bar--height = 50px
|
|||||||
background-color transparent
|
background-color transparent
|
||||||
color $ui-text-color
|
color $ui-text-color
|
||||||
font-size 16px
|
font-size 16px
|
||||||
|
.saving--warning
|
||||||
|
haveToSave()
|
||||||
|
|
||||||
.nav-button--active
|
.nav-button--active
|
||||||
@extend .nav-button
|
@extend .nav-button
|
||||||
@@ -49,6 +51,8 @@ top-bar--height = 50px
|
|||||||
background-color $ui-button--active-backgroundColor
|
background-color $ui-button--active-backgroundColor
|
||||||
&:hover
|
&:hover
|
||||||
color $ui-text-color
|
color $ui-text-color
|
||||||
|
.saving--warning
|
||||||
|
haveToSave()
|
||||||
|
|
||||||
.nav-button-icon
|
.nav-button-icon
|
||||||
display block
|
display block
|
||||||
|
|||||||
@@ -20,3 +20,8 @@ $tab--dark-text-color = #E5E5E5
|
|||||||
body[data-theme="dark"]
|
body[data-theme="dark"]
|
||||||
.header
|
.header
|
||||||
color $tab--dark-text-color
|
color $tab--dark-text-color
|
||||||
|
|
||||||
|
haveToSave()
|
||||||
|
color #FFA500
|
||||||
|
font-size 10px
|
||||||
|
margin-top 3px
|
||||||
@@ -7,11 +7,10 @@ import store from 'browser/main/store'
|
|||||||
import consts from 'browser/lib/consts'
|
import consts from 'browser/lib/consts'
|
||||||
import ReactCodeMirror from 'react-codemirror'
|
import ReactCodeMirror from 'react-codemirror'
|
||||||
import CodeMirror from 'codemirror'
|
import CodeMirror from 'codemirror'
|
||||||
|
import _ from 'lodash'
|
||||||
|
|
||||||
const OSX = global.process.platform === 'darwin'
|
const OSX = global.process.platform === 'darwin'
|
||||||
|
|
||||||
import _ from 'lodash'
|
|
||||||
|
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
const ipc = electron.ipcRenderer
|
const ipc = electron.ipcRenderer
|
||||||
|
|
||||||
@@ -93,8 +92,19 @@ class UiTab extends React.Component {
|
|||||||
if (newCodemirrorTheme !== codemirrorTheme) {
|
if (newCodemirrorTheme !== codemirrorTheme) {
|
||||||
checkHighLight.setAttribute('href', `../node_modules/codemirror/theme/${newCodemirrorTheme.split(' ')[0]}.css`)
|
checkHighLight.setAttribute('href', `../node_modules/codemirror/theme/${newCodemirrorTheme.split(' ')[0]}.css`)
|
||||||
}
|
}
|
||||||
|
this.setState({ config: newConfig, codemirrorTheme: newCodemirrorTheme }, () => {
|
||||||
this.setState({ config: newConfig, codemirrorTheme: newCodemirrorTheme })
|
const {ui, editor, preview} = this.props.config
|
||||||
|
this.currentConfig = {ui, editor, preview}
|
||||||
|
if (_.isEqual(this.currentConfig, this.state.config)) {
|
||||||
|
this.props.haveToSave()
|
||||||
|
} else {
|
||||||
|
this.props.haveToSave({
|
||||||
|
tab: 'UI',
|
||||||
|
type: 'warning',
|
||||||
|
message: 'You have to save!'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSaveUIClick (e) {
|
handleSaveUIClick (e) {
|
||||||
@@ -111,6 +121,7 @@ class UiTab extends React.Component {
|
|||||||
config: newConfig
|
config: newConfig
|
||||||
})
|
})
|
||||||
this.clearMessage()
|
this.clearMessage()
|
||||||
|
this.props.haveToSave()
|
||||||
}
|
}
|
||||||
|
|
||||||
clearMessage () {
|
clearMessage () {
|
||||||
@@ -412,7 +423,8 @@ UiTab.propTypes = {
|
|||||||
user: PropTypes.shape({
|
user: PropTypes.shape({
|
||||||
name: PropTypes.string
|
name: PropTypes.string
|
||||||
}),
|
}),
|
||||||
dispatch: PropTypes.func
|
dispatch: PropTypes.func,
|
||||||
|
haveToSave: PropTypes.func
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CSSModules(UiTab, styles)
|
export default CSSModules(UiTab, styles)
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ class Preferences extends React.Component {
|
|||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
currentTab: 'STORAGES'
|
currentTab: 'STORAGES',
|
||||||
|
UIAlert: '',
|
||||||
|
HotkeyAlert: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +60,7 @@ class Preferences extends React.Component {
|
|||||||
<HotkeyTab
|
<HotkeyTab
|
||||||
dispatch={dispatch}
|
dispatch={dispatch}
|
||||||
config={config}
|
config={config}
|
||||||
|
haveToSave={alert => this.setState({HotkeyAlert: alert})}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
case 'UI':
|
case 'UI':
|
||||||
@@ -65,6 +68,7 @@ class Preferences extends React.Component {
|
|||||||
<UiTab
|
<UiTab
|
||||||
dispatch={dispatch}
|
dispatch={dispatch}
|
||||||
config={config}
|
config={config}
|
||||||
|
haveToSave={alert => this.setState({UIAlert: alert})}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
case 'CROWDFUNDING':
|
case 'CROWDFUNDING':
|
||||||
@@ -94,19 +98,26 @@ class Preferences extends React.Component {
|
|||||||
return node.getBoundingClientRect()
|
return node.getBoundingClientRect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
haveToSaveNotif (type, message) {
|
||||||
|
return (
|
||||||
|
<p styleName={`saving--${type}`}>{message}</p>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const content = this.renderContent()
|
const content = this.renderContent()
|
||||||
|
|
||||||
const tabs = [
|
const tabs = [
|
||||||
{target: 'STORAGES', label: 'Storages'},
|
{target: 'STORAGES', label: 'Storages'},
|
||||||
{target: 'HOTKEY', label: 'Hotkey'},
|
{target: 'HOTKEY', label: 'Hotkey', Hotkey: this.state.HotkeyAlert},
|
||||||
{target: 'UI', label: 'UI'},
|
{target: 'UI', label: 'UI', UI: this.state.UIAlert},
|
||||||
{target: 'INFO', label: 'Community / Info'},
|
{target: 'INFO', label: 'Community / Info'},
|
||||||
{target: 'CROWDFUNDING', label: 'Crowdfunding'}
|
{target: 'CROWDFUNDING', label: 'Crowdfunding'}
|
||||||
]
|
]
|
||||||
|
|
||||||
const navButtons = tabs.map((tab) => {
|
const navButtons = tabs.map((tab) => {
|
||||||
const isActive = this.state.currentTab === tab.target
|
const isActive = this.state.currentTab === tab.target
|
||||||
|
const isUiHotkeyTab = _.isObject(tab[tab.label]) && tab.label === tab[tab.label].tab
|
||||||
return (
|
return (
|
||||||
<button styleName={isActive
|
<button styleName={isActive
|
||||||
? 'nav-button--active'
|
? 'nav-button--active'
|
||||||
@@ -118,6 +129,7 @@ class Preferences extends React.Component {
|
|||||||
<span styleName='nav-button-label'>
|
<span styleName='nav-button-label'>
|
||||||
{tab.label}
|
{tab.label}
|
||||||
</span>
|
</span>
|
||||||
|
{isUiHotkeyTab ? this.haveToSaveNotif(tab[tab.label].type, tab[tab.label].message) : null}
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user