mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
Requested Review
This commit is contained in:
@@ -32,10 +32,7 @@ class HotkeyTab extends React.Component {
|
||||
message: err.message != null ? err.message : 'Error occurs!'
|
||||
}})
|
||||
}
|
||||
if (JSON.parse(localStorage.getItem('config'))) {
|
||||
const {hotkey} = JSON.parse(localStorage.getItem('config'))
|
||||
this.hotkey = hotkey
|
||||
}
|
||||
this.oldHotkey = this.state.config.hotkey
|
||||
ipc.addListener('APP_SETTING_DONE', this.handleSettingDone)
|
||||
ipc.addListener('APP_SETTING_ERROR', this.handleSettingError)
|
||||
}
|
||||
@@ -57,7 +54,7 @@ class HotkeyTab extends React.Component {
|
||||
config: newConfig
|
||||
})
|
||||
this.clearMessage()
|
||||
this.props.haveToSave(null)
|
||||
this.props.haveToSave()
|
||||
}
|
||||
|
||||
handleHintToggleButtonClick (e) {
|
||||
@@ -75,8 +72,8 @@ class HotkeyTab extends React.Component {
|
||||
this.setState({
|
||||
config
|
||||
})
|
||||
if (JSON.stringify(this.hotkey) === JSON.stringify(config.hotkey)) {
|
||||
this.props.haveToSave(null)
|
||||
if (JSON.stringify(this.oldHotkey) === JSON.stringify(config.hotkey)) {
|
||||
this.props.haveToSave()
|
||||
} else {
|
||||
this.props.haveToSave({
|
||||
tab: 'Hotkey',
|
||||
|
||||
@@ -43,9 +43,7 @@ top-bar--height = 50px
|
||||
color $ui-text-color
|
||||
font-size 16px
|
||||
.saving--warning
|
||||
color #FFA500
|
||||
font-size 10px
|
||||
margin-top 3px
|
||||
haveToSave()
|
||||
|
||||
.nav-button--active
|
||||
@extend .nav-button
|
||||
@@ -54,9 +52,7 @@ top-bar--height = 50px
|
||||
&:hover
|
||||
color $ui-text-color
|
||||
.saving--warning
|
||||
color #FFA500
|
||||
font-size 10px
|
||||
margin-top 3px
|
||||
haveToSave()
|
||||
|
||||
.nav-button-icon
|
||||
display block
|
||||
|
||||
@@ -20,3 +20,8 @@ $tab--dark-text-color = #E5E5E5
|
||||
body[data-theme="dark"]
|
||||
.header
|
||||
color $tab--dark-text-color
|
||||
|
||||
haveToSave()
|
||||
color #FFA500
|
||||
font-size 10px
|
||||
margin-top 3px
|
||||
@@ -20,8 +20,7 @@ class UiTab extends React.Component {
|
||||
super(props)
|
||||
this.state = {
|
||||
config: props.config,
|
||||
codemirrorTheme: props.config.editor.theme,
|
||||
haveToSave: null
|
||||
codemirrorTheme: props.config.editor.theme
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,18 +92,16 @@ class UiTab extends React.Component {
|
||||
checkHighLight.setAttribute('href', `../node_modules/codemirror/theme/${newCodemirrorTheme.split(' ')[0]}.css`)
|
||||
}
|
||||
this.setState({ config: newConfig, codemirrorTheme: newCodemirrorTheme }, () => {
|
||||
if (JSON.parse(localStorage.getItem('config'))) {
|
||||
const {ui, editor, preview} = JSON.parse(localStorage.getItem('config'))
|
||||
this.currentConfig = {ui, editor, preview}
|
||||
if (JSON.stringify(this.currentConfig) === JSON.stringify(this.state.config)) {
|
||||
this.props.haveToSave(null)
|
||||
} else {
|
||||
this.props.haveToSave({
|
||||
tab: 'UI',
|
||||
type: 'warning',
|
||||
message: 'You have to save!'
|
||||
})
|
||||
}
|
||||
const {ui, editor, preview} = this.props.config
|
||||
this.currentConfig = {ui, editor, preview}
|
||||
if (JSON.stringify(this.currentConfig) === JSON.stringify(this.state.config)) {
|
||||
this.props.haveToSave()
|
||||
} else {
|
||||
this.props.haveToSave({
|
||||
tab: 'UI',
|
||||
type: 'warning',
|
||||
message: 'You have to save!'
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -123,7 +120,7 @@ class UiTab extends React.Component {
|
||||
config: newConfig
|
||||
})
|
||||
this.clearMessage()
|
||||
this.props.haveToSave(null)
|
||||
this.props.haveToSave()
|
||||
}
|
||||
|
||||
clearMessage () {
|
||||
|
||||
@@ -18,8 +18,8 @@ class Preferences extends React.Component {
|
||||
|
||||
this.state = {
|
||||
currentTab: 'STORAGES',
|
||||
UI: null,
|
||||
Hotkey: null
|
||||
UIAlert: '',
|
||||
HotkeyAlert: ''
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class Preferences extends React.Component {
|
||||
<HotkeyTab
|
||||
dispatch={dispatch}
|
||||
config={config}
|
||||
haveToSave={msg => this.setState({Hotkey: msg})}
|
||||
haveToSave={msg => this.setState({HotkeyAlert: msg})}
|
||||
/>
|
||||
)
|
||||
case 'UI':
|
||||
@@ -68,7 +68,7 @@ class Preferences extends React.Component {
|
||||
<UiTab
|
||||
dispatch={dispatch}
|
||||
config={config}
|
||||
haveToSave={msg => this.setState({UI: msg})}
|
||||
haveToSave={msg => this.setState({UIAlert: msg})}
|
||||
/>
|
||||
)
|
||||
case 'CROWDFUNDING':
|
||||
@@ -97,21 +97,27 @@ class Preferences extends React.Component {
|
||||
const node = ReactDOM.findDOMNode(this.refs.content)
|
||||
return node.getBoundingClientRect()
|
||||
}
|
||||
|
||||
haveToSaveNotif (tab) {
|
||||
return (
|
||||
<p styleName={`saving--${tab[tab.label].type}`}>{tab[tab.label].message}</p>
|
||||
)
|
||||
}
|
||||
|
||||
render () {
|
||||
const content = this.renderContent()
|
||||
|
||||
const tabs = [
|
||||
{target: 'STORAGES', label: 'Storages'},
|
||||
{target: 'HOTKEY', label: 'Hotkey', Hotkey: this.state.Hotkey},
|
||||
{target: 'UI', label: 'UI', UI: this.state.UI},
|
||||
{target: 'HOTKEY', label: 'Hotkey', Hotkey: this.state.HotkeyAlert},
|
||||
{target: 'UI', label: 'UI', UI: this.state.UIAlert},
|
||||
{target: 'INFO', label: 'Community / Info'},
|
||||
{target: 'CROWDFUNDING', label: 'Crowdfunding'}
|
||||
]
|
||||
|
||||
const navButtons = tabs.map((tab) => {
|
||||
const isActive = this.state.currentTab === tab.target
|
||||
const isOk = typeof tab[tab.label] !== 'undefined' && tab[tab.label] !== null
|
||||
const isUiHotkeyTab = _.isObject(tab[tab.label]) && tab.label === tab[tab.label].tab
|
||||
return (
|
||||
<button styleName={isActive
|
||||
? 'nav-button--active'
|
||||
@@ -123,7 +129,7 @@ class Preferences extends React.Component {
|
||||
<span styleName='nav-button-label'>
|
||||
{tab.label}
|
||||
</span>
|
||||
{isOk && tab.label === tab[tab.label].tab ? <p styleName={`saving--${tab[tab.label].type}`}>{tab[tab.label].message}</p> : null}
|
||||
{isUiHotkeyTab ? this.haveToSaveNotif(tab) : null}
|
||||
</button>
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user