Wrap lines in all editors (#89)

This commit is contained in:
Gregory Schier 2017-02-26 15:47:45 -08:00 committed by GitHub
parent 4043e321f3
commit 187bbd53bd
6 changed files with 37 additions and 22 deletions

View File

@ -322,11 +322,13 @@ class Wrapper extends Component {
ref={registerModal}
editorFontSize={settings.editorFontSize}
editorKeyMap={settings.editorKeyMap}
lineWrapping={settings.editorLineWrapping}
onChange={models.requestGroup.update}
/>
<WorkspaceEnvironmentsEditModal
ref={registerModal}
onChange={models.workspace.update}
lineWrapping={settings.editorLineWrapping}
editorFontSize={settings.editorFontSize}
editorKeyMap={settings.editorKeyMap}
/>

View File

@ -23,19 +23,6 @@ class RequestActionsDropdown extends Component {
trackEvent('Request', 'Generate Code', 'Request Action');
};
_handleAdvancedSend = () => {
trackEvent('Request', 'Advanced Send Hint', 'Request Action');
showModal(AlertModal, {
title: 'Advanced Sending',
message: (
<div>
For advanced sending options, hold <code>{MOD_SYM.replace('+', '')}</code> while
clicking the send button next to the Url.
</div>
)
});
};
_handlePromptUpdateName = async () => {
const {request} = this.props;
@ -78,9 +65,6 @@ class RequestActionsDropdown extends Component {
<DropdownItem onClick={this._handleGenerateCode}>
<i className="fa fa-code"></i> Generate Code
</DropdownItem>
<DropdownItem onClick={this._handleAdvancedSend}>
<i className="fa fa-refresh"></i> Advanced Sending
</DropdownItem>
<DropdownItem buttonClass={PromptButton} onClick={this._handleRemove} addIcon={true}>
<i className="fa fa-trash-o"></i> Delete
</DropdownItem>

View File

@ -22,12 +22,19 @@ class EnvironmentEditor extends Component {
}
render () {
const {environment, editorFontSize, editorKeyMap, ...props} = this.props;
const {
environment,
editorFontSize,
editorKeyMap,
lineWrapping,
...props
} = this.props;
return (
<Editor
ref={this._setEditorRef}
fontSize={editorFontSize}
lineWrapping={lineWrapping}
keyMap={editorKeyMap}
onChange={this._handleChange}
value={JSON.stringify(environment)}
@ -44,6 +51,7 @@ EnvironmentEditor.propTypes = {
didChange: PropTypes.func.isRequired,
editorFontSize: PropTypes.number.isRequired,
editorKeyMap: PropTypes.string.isRequired,
lineWrapping: PropTypes.bool.isRequired,
};
export default EnvironmentEditor;

View File

@ -45,8 +45,17 @@ class EnvironmentEditModal extends Component {
}
render () {
const {editorKeyMap, editorFontSize, ...extraProps} = this.props;
const {requestGroup, isValid} = this.state;
const {
editorKeyMap,
editorFontSize,
lineWrapping,
...extraProps
} = this.props;
const {
requestGroup,
isValid
} = this.state;
return (
<Modal ref={m => this.modal = m} tall={true} top={true} {...extraProps}>
@ -57,6 +66,7 @@ class EnvironmentEditModal extends Component {
editorKeyMap={editorKeyMap}
ref={node => this._envEditor = node}
key={requestGroup ? requestGroup._id : 'n/a'}
lineWrapping={lineWrapping}
environment={requestGroup ? requestGroup.environment : {}}
didChange={this._didChange.bind(this)}
lightTheme={true}
@ -79,6 +89,7 @@ EnvironmentEditModal.propTypes = {
onChange: PropTypes.func.isRequired,
editorFontSize: PropTypes.number.isRequired,
editorKeyMap: PropTypes.string.isRequired,
lineWrapping: PropTypes.bool.isRequired,
};
export default EnvironmentEditModal;

View File

@ -93,8 +93,16 @@ class RequestSwitcherModal extends Component {
if (searchString) {
matchedRequests = matchedRequests.filter(r => {
const name = r.name.toLowerCase();
const id = r._id.toLowerCase();
const toMatch = searchString.toLowerCase();
return name.indexOf(toMatch) !== -1
// Match substring of name
const matchesName = name.indexOf(toMatch) >= 0;
// Match exact Id
const matchesId = id === toMatch;
return matchesName || matchesId;
});
}
@ -120,7 +128,7 @@ class RequestSwitcherModal extends Component {
.filter(w => {
const name = w.name.toLowerCase();
const toMatch = searchString.toLowerCase();
return name.indexOf(toMatch) !== -1
return name.indexOf(toMatch) !== -1;
});
const activeIndex = searchString ? 0 : -1;

View File

@ -142,7 +142,7 @@ class WorkspaceEnvironmentsEditModal extends Component {
}
render () {
const {editorFontSize, editorKeyMap} = this.props;
const {editorFontSize, editorKeyMap, lineWrapping} = this.props;
const {subEnvironments, rootEnvironment, isValid, forceRefreshKey} = this.state;
const activeEnvironment = this._getActiveEnvironment();
@ -224,6 +224,7 @@ class WorkspaceEnvironmentsEditModal extends Component {
<EnvironmentEditor
editorFontSize={editorFontSize}
editorKeyMap={editorKeyMap}
lineWrapping={lineWrapping}
ref={n => this._envEditor = n}
key={`${forceRefreshKey}::${(activeEnvironment ? activeEnvironment._id : 'n/a')}`}
environment={activeEnvironment ? activeEnvironment.data : {}}
@ -254,6 +255,7 @@ WorkspaceEnvironmentsEditModal.propTypes = {
onChange: PropTypes.func.isRequired,
editorFontSize: PropTypes.number.isRequired,
editorKeyMap: PropTypes.string.isRequired,
lineWrapping: PropTypes.bool.isRequired,
};
export default WorkspaceEnvironmentsEditModal;