feat(xod-client, xod-client-browser, xod-client-electron): add Show Code With Debug menu item for development env

This commit is contained in:
Kirill Shumilov
2020-10-23 16:06:28 +03:00
parent f86d53f109
commit f89e7f74c9
5 changed files with 27 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ import { HotKeys } from 'react-hotkeys';
import * as XP from 'xod-project';
import client from 'xod-client';
import { foldEither, notNil } from 'xod-func-tools';
import { LIVENESS } from 'xod-arduino';
import packageJson from '../../package.json';
import PopupInstallApp from '../components/PopupInstallApp';
@@ -275,6 +276,13 @@ class App extends client.App {
]),
submenu(items.deploy, [
onClick(items.showCodeForArduino, this.onShowCodeArduino),
...(process.env.IS_DEV
? [
onClick(items.showCodeWithDebug, () =>
this.onShowCodeArduino(LIVENESS.DEBUG)
),
]
: []),
onClick(items.uploadToArduino, this.onUpload),
onClick(items.runSimulation, this.onRunSimulation),
]),

View File

@@ -1,5 +1,6 @@
const path = require('path');
/* eslint-disable import/no-extraneous-dependencies */
const webpack = require('webpack');
const merge = require('webpack-merge');
/* eslint-enable import/no-extraneous-dependencies */
const baseConfig = require('./webpack.config.js');
@@ -18,4 +19,9 @@ module.exports = merge.smart(baseConfig, {
contentBase: pkgpath('dist'),
compress: true,
},
plugins: [
new webpack.DefinePlugin({
'process.env.IS_DEV': true,
}),
],
});

View File

@@ -61,7 +61,7 @@ import {
proceedPackageUpgrade,
} from '../../arduinoDependencies/actions';
import { loadWorkspacePath } from '../../app/workspaceActions';
import { getPathToBundledWorkspace } from '../../app/utils';
import { getPathToBundledWorkspace, IS_DEV } from '../../app/utils';
import getLibraryNames from '../../arduinoDependencies/getLibraryNames';
@@ -677,6 +677,13 @@ class App extends client.App {
]),
submenu(items.deploy, [
onClick(items.showCodeForArduino, this.onShowCodeArduino),
...(IS_DEV
? [
onClick(items.showCodeWithDebug, () =>
this.onShowCodeArduino(LIVENESS.DEBUG)
),
]
: []),
onClick(items.uploadToArduino, this.onUploadToArduinoClicked),
onClick(items.runSimulation, this.onRunSimulation),
onClick(

View File

@@ -93,7 +93,7 @@ export default class App extends React.Component {
this.props.actions.fetchGrant(/* startup */ true);
}
onShowCodeArduino() {
onShowCodeArduino(liveness = LIVENESS.NONE) {
R.compose(
foldEither(
R.compose(
@@ -104,7 +104,7 @@ export default class App extends React.Component {
),
R.map(transpile),
this.transformProjectForTranspiler
)(LIVENESS.NONE);
)(liveness);
}
onRunSimulation() {

View File

@@ -103,6 +103,9 @@ const rawItems = {
showCodeForArduino: {
label: 'Show Code for Arduino',
},
showCodeWithDebug: {
label: 'Show Code with Debug',
},
uploadToArduino: {
label: 'Upload to Arduino...',
},