mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
feat: Check for missing wakatime cli. And display modal and alert message.
This commit is contained in:
@@ -3,13 +3,14 @@ import React from 'react'
|
|||||||
import CSSModules from 'browser/lib/CSSModules'
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
import styles from './ConfigTab.styl'
|
import styles from './ConfigTab.styl'
|
||||||
import ConfigManager from 'browser/main/lib/ConfigManager'
|
import ConfigManager from 'browser/main/lib/ConfigManager'
|
||||||
import store from 'browser/main/store'
|
import { store } from 'browser/main/store'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import i18n from 'browser/lib/i18n'
|
import i18n from 'browser/lib/i18n'
|
||||||
|
import { sync as commandExists } from 'command-exists'
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
const ipc = electron.ipcRenderer
|
const ipc = electron.ipcRenderer
|
||||||
|
const { remote } = electron
|
||||||
|
const { dialog } = remote
|
||||||
class PluginsTab extends React.Component {
|
class PluginsTab extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
@@ -59,6 +60,35 @@ class PluginsTab extends React.Component {
|
|||||||
ipc.removeListener('APP_SETTING_ERROR', this.handleSettingError)
|
ipc.removeListener('APP_SETTING_ERROR', this.handleSettingError)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkPluginsRequirements() {
|
||||||
|
this.checkWakatimePluginRequirement()
|
||||||
|
}
|
||||||
|
|
||||||
|
checkWakatimePluginRequirement() {
|
||||||
|
if (!commandExists('wakatime-cli')) {
|
||||||
|
this.setState({
|
||||||
|
wakatimePlugin: {
|
||||||
|
type: i18n.__('Warning'),
|
||||||
|
message: i18n.__('Missing wakatime-cli')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const alertConfig = {
|
||||||
|
type: 'warning',
|
||||||
|
message: i18n.__('Missing Wakatime CLI'),
|
||||||
|
detail: i18n.__(
|
||||||
|
`Please install Wakatime CLI to use Wakatime tracker feature.`
|
||||||
|
),
|
||||||
|
buttons: [i18n.__('OK')]
|
||||||
|
}
|
||||||
|
dialog.showMessageBox(remote.getCurrentWindow(), alertConfig)
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
wakatimePlugin: null
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
handleSaveButtonClick(e) {
|
handleSaveButtonClick(e) {
|
||||||
const newConfig = {
|
const newConfig = {
|
||||||
wakatime: this.state.config.wakatime
|
wakatime: this.state.config.wakatime
|
||||||
@@ -72,6 +102,7 @@ class PluginsTab extends React.Component {
|
|||||||
})
|
})
|
||||||
this.clearMessage()
|
this.clearMessage()
|
||||||
this.props.haveToSave()
|
this.props.haveToSave()
|
||||||
|
this.checkPluginsRequirements()
|
||||||
}
|
}
|
||||||
|
|
||||||
handleWakatimeKeyChange(e) {
|
handleWakatimeKeyChange(e) {
|
||||||
@@ -105,6 +136,13 @@ class PluginsTab extends React.Component {
|
|||||||
pluginsAlert != null ? (
|
pluginsAlert != null ? (
|
||||||
<p className={`alert ${pluginsAlert.type}`}>{pluginsAlert.message}</p>
|
<p className={`alert ${pluginsAlert.type}`}>{pluginsAlert.message}</p>
|
||||||
) : null
|
) : null
|
||||||
|
|
||||||
|
const wakatimeAlert = this.state.wakatimePlugin
|
||||||
|
const wakatimePluginAlertElement =
|
||||||
|
wakatimeAlert != null ? (
|
||||||
|
<p className={`alert ${wakatimeAlert.type}`}>{wakatimeAlert.message}</p>
|
||||||
|
) : null
|
||||||
|
|
||||||
const { config } = this.state
|
const { config } = this.state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -121,6 +159,7 @@ class PluginsTab extends React.Component {
|
|||||||
value={config.wakatime.key}
|
value={config.wakatime.key}
|
||||||
type='text'
|
type='text'
|
||||||
/>
|
/>
|
||||||
|
{wakatimePluginAlertElement}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div styleName='group-control'>
|
<div styleName='group-control'>
|
||||||
|
|||||||
@@ -61,6 +61,7 @@
|
|||||||
"chart.js": "^2.7.2",
|
"chart.js": "^2.7.2",
|
||||||
"codemirror": "^5.40.2",
|
"codemirror": "^5.40.2",
|
||||||
"codemirror-mode-elixir": "^1.1.1",
|
"codemirror-mode-elixir": "^1.1.1",
|
||||||
|
"command-exists": "^1.2.9",
|
||||||
"connected-react-router": "^6.4.0",
|
"connected-react-router": "^6.4.0",
|
||||||
"electron-config": "^1.0.0",
|
"electron-config": "^1.0.0",
|
||||||
"electron-gh-releases": "^2.0.4",
|
"electron-gh-releases": "^2.0.4",
|
||||||
|
|||||||
@@ -1966,6 +1966,11 @@ combined-stream@1.0.6, combined-stream@~1.0.5:
|
|||||||
dependencies:
|
dependencies:
|
||||||
delayed-stream "~1.0.0"
|
delayed-stream "~1.0.0"
|
||||||
|
|
||||||
|
command-exists@^1.2.9:
|
||||||
|
version "1.2.9"
|
||||||
|
resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.9.tgz#c50725af3808c8ab0260fd60b01fbfa25b954f69"
|
||||||
|
integrity sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==
|
||||||
|
|
||||||
commander@2:
|
commander@2:
|
||||||
version "2.16.0"
|
version "2.16.0"
|
||||||
resolved "http://registry.npm.taobao.org/commander/download/commander-2.16.0.tgz#f16390593996ceb4f3eeb020b31d78528f7f8a50"
|
resolved "http://registry.npm.taobao.org/commander/download/commander-2.16.0.tgz#f16390593996ceb4f3eeb020b31d78528f7f8a50"
|
||||||
|
|||||||
Reference in New Issue
Block a user