Skip to content

Commit

Permalink
fix(xod-client, xod-client-browser, xod-client-electron): show create…
Browse files Browse the repository at this point in the history
… new patch popup even when the project browser is hidden
  • Loading branch information
brusherru committed Nov 5, 2020
1 parent a7d88dd commit 02f3642
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 24 deletions.
2 changes: 2 additions & 0 deletions packages/xod-client-browser/src/containers/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ class App extends client.App {
{this.renderPopupProjectPreferences()}
{this.renderPopupPublishProject()}
{this.renderPopupCreateNewProject()}
{this.renderPatchCreatingPopup()}
</HotKeys>
);
}
Expand All @@ -397,6 +398,7 @@ const mapStateToProps = R.applySpec({
isSimulationAbortable: client.isSimulationAbortable,
popups: {
createProject: client.getPopupVisibility(client.POPUP_ID.CREATING_PROJECT),
createPatch: client.getPopupVisibility(client.POPUP_ID.CREATING_PATCH),
showCode: client.getPopupVisibility(client.POPUP_ID.SHOWING_CODE),
projectPreferences: client.getPopupVisibility(
client.POPUP_ID.EDITING_PROJECT_PREFERENCES
Expand Down
2 changes: 2 additions & 0 deletions packages/xod-client-electron/src/view/containers/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,7 @@ class App extends client.App {
{this.renderPopupPublishProject()}
{this.renderPopupCreateNewProject()}
{this.renderPopupCheckArduinoPackageUpdates()}
{this.renderPatchCreatingPopup()}
<PopupSetWorkspace
workspace={this.state.workspace}
isClosable={R.propOr(
Expand Down Expand Up @@ -1097,6 +1098,7 @@ const mapStateToProps = R.applySpec({
updateArduinoPackages: client.getPopupVisibility(
client.POPUP_ID.UPDATE_ARDUINO_PACKAGES_POPUP
),
createPatch: client.getPopupVisibility(client.POPUP_ID.CREATING_PATCH),
},
popupsData: {
projectSelection: client.getPopupData(client.POPUP_ID.OPENING_PROJECT),
Expand Down
27 changes: 26 additions & 1 deletion packages/xod-client/src/core/containers/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
Project,
isValidIdentifier,
IDENTIFIER_RULES,
isValidUserDefinedPatchBasename,
PATCH_BASENAME_RULES,
getPatchByPath,
getProjectName,
} from 'xod-project';
Expand All @@ -36,7 +38,10 @@ import {
} from 'xod-arduino';

import { isInputTarget } from '../../utils/browser';
import { lowercaseKebabMask } from '../../utils/inputFormatting';
import {
lowercaseKebabMask,
patchBasenameMask,
} from '../../utils/inputFormatting';
import sanctuaryPropType from '../../utils/sanctuaryPropType';

import PopupPrompt from '../../utils/components/PopupPrompt';
Expand Down Expand Up @@ -285,6 +290,24 @@ export default class App extends React.Component {
);
}

renderPatchCreatingPopup() {
if (!this.props.popups.createPatch) return null;

return (
<PopupPrompt
key="new_patch"
title="Create new patch"
onConfirm={this.props.actions.addPatch}
onClose={this.props.actions.hideAllPopups}
inputMask={patchBasenameMask}
inputValidator={isValidUserDefinedPatchBasename}
helpText={PATCH_BASENAME_RULES}
>
Type the name for new patch:
</PopupPrompt>
);
}

render() {
return <div />;
}
Expand Down Expand Up @@ -314,6 +337,7 @@ App.propTypes = {
createPatch: PropTypes.func.isRequired,
publishProject: PropTypes.func.isRequired,
addComment: PropTypes.func.isRequired,
addPatch: PropTypes.func.isRequired,
undoCurrentPatch: PropTypes.func.isRequired,
redoCurrentPatch: PropTypes.func.isRequired,
setMode: PropTypes.func.isRequired,
Expand Down Expand Up @@ -352,6 +376,7 @@ App.actions = {
publishProject: actions.publishProject,
createPatch: actions.requestCreatePatch,
addComment: actions.addComment,
addPatch: actions.addPatch,
undoCurrentPatch: actions.undoCurrentPatch,
redoCurrentPatch: actions.redoCurrentPatch,
setMode: actions.setMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,6 @@ class ProjectBrowserPopups extends React.PureComponent {
return this.props.selectedPatchName;
}

renderPatchCreatingPopup() {
return (
<PopupPrompt
key="new_patch"
title="Create new patch"
onConfirm={this.props.onPatchCreate}
onClose={this.props.onCloseAllPopups}
inputMask={patchBasenameMask}
inputValidator={isValidUserDefinedPatchBasename}
helpText={PATCH_BASENAME_RULES}
>
Type the name for new patch:
</PopupPrompt>
);
}

renderPatchRenamingPopup() {
const selectedPatchName = this.getSelectedPatchName();

Expand Down Expand Up @@ -93,9 +77,6 @@ class ProjectBrowserPopups extends React.PureComponent {
if (isPopupVisible(POPUP_ID.DELETING_PATCH, this.props.popups)) {
return this.renderPatchDeletingPopup();
}
if (isPopupVisible(POPUP_ID.CREATING_PATCH, this.props.popups)) {
return this.renderPatchCreatingPopup();
}

return null;
}
Expand All @@ -107,7 +88,6 @@ ProjectBrowserPopups.propTypes = {
popups: PropTypes.object,
projectName: PropTypes.string,

onPatchCreate: PropTypes.func.isRequired,
onPatchRename: PropTypes.func.isRequired,
onPatchDelete: PropTypes.func.isRequired,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ class ProjectBrowser extends React.Component {
popups={this.props.popups}
onPatchDelete={this.props.actions.deletePatch}
onPatchRename={this.props.actions.renamePatch}
onPatchCreate={this.props.actions.addPatch}
onCloseAllPopups={this.props.actions.closeAllPopups}
/>
<SidebarPanel
Expand Down Expand Up @@ -406,7 +405,6 @@ ProjectBrowser.propTypes = {
requestDelete: PropTypes.func.isRequired,
setSelection: PropTypes.func.isRequired,
removeSelection: PropTypes.func.isRequired,
addPatch: PropTypes.func.isRequired,
renamePatch: PropTypes.func.isRequired,
deletePatch: PropTypes.func.isRequired,
clonePatch: PropTypes.func.isRequired,
Expand Down Expand Up @@ -447,7 +445,6 @@ const mapDispatchToProps = dispatch => ({
removeSelection: ProjectBrowserActions.removeSelection,

addNode: ProjectActions.addNode,
addPatch: ProjectActions.addPatch,
renamePatch: ProjectActions.renamePatch,
deletePatch: ProjectActions.deletePatch,
clonePatch: ProjectActions.clonePatch,
Expand Down

0 comments on commit 02f3642

Please sign in to comment.