Skip to content

Commit

Permalink
feat(xod-client, xod-client-browser, xod-client-electron): add `Show …
Browse files Browse the repository at this point in the history
…Code With Debug` menu item for development env
  • Loading branch information
brusherru committed Oct 23, 2020
1 parent 0d17fa7 commit 672bab8
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
8 changes: 8 additions & 0 deletions packages/xod-client-browser/src/containers/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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),
]),
Expand Down
6 changes: 6 additions & 0 deletions packages/xod-client-browser/webpack.config.dev.js
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -18,4 +19,9 @@ module.exports = merge.smart(baseConfig, {
contentBase: pkgpath('dist'),
compress: true,
},
plugins: [
new webpack.DefinePlugin({
'process.env.IS_DEV': true,
}),
],
});
9 changes: 8 additions & 1 deletion packages/xod-client-electron/src/view/containers/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions packages/xod-client/src/core/containers/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -104,7 +104,7 @@ export default class App extends React.Component {
),
R.map(transpile),
this.transformProjectForTranspiler
)(LIVENESS.NONE);
)(liveness);
}

onRunSimulation() {
Expand Down
3 changes: 3 additions & 0 deletions packages/xod-client/src/utils/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ const rawItems = {
showCodeForArduino: {
label: 'Show Code for Arduino',
},
showCodeWithDebug: {
label: 'Show Code with Debug',
},
uploadToArduino: {
label: 'Upload to Arduino...',
},
Expand Down

0 comments on commit 672bab8

Please sign in to comment.