Fix sidebar renaming (Closes #947)

This commit is contained in:
Gregory Schier 2018-05-24 21:44:49 -04:00
parent e0d91fade3
commit 03b088d53b
5 changed files with 26 additions and 28 deletions

View File

@ -8,7 +8,7 @@ export const canDuplicate = false;
export function init () {
return {
parentId: null,
collapsed: true
collapsed: false
};
}

View File

@ -92,15 +92,7 @@ class Editable extends PureComponent {
...extra
};
if (renderReadView) {
return renderReadView(value, readViewProps);
}
return (
<div {...readViewProps}>
{value}
</div>
);
return renderReadView(value, readViewProps);
}
}
}
@ -108,6 +100,7 @@ class Editable extends PureComponent {
Editable.propTypes = {
onSubmit: PropTypes.func.isRequired,
value: PropTypes.string.isRequired,
renderReadView: PropTypes.func.isRequired,
// Optional
singleClick: PropTypes.bool,

View File

@ -1,7 +1,7 @@
// @flow
import * as React from 'react';
import autobind from 'autobind-decorator';
import fuzzysort from 'fuzzysort';
import fuzzySort from 'fuzzysort';
import {fuzzyMatch} from '../../../common/misc';
type Props = {|
@ -21,15 +21,23 @@ class Highlight extends React.PureComponent<Props> {
const results = fuzzyMatch(search, text);
if (results.searchTermsMatched === 0) {
return <span>{text}</span>;
return (
<span {...otherProps}>{text}</span>
);
}
return <span
{...otherProps}
dangerouslySetInnerHTML={{ __html: fuzzysort.highlight(results,
'<strong style="color: #695eb8; text-decoration: underline;">',
'</strong>') }}
/>;
return (
<span
{...otherProps}
dangerouslySetInnerHTML={{
__html: fuzzySort.highlight(
results,
'<strong style="font-style: italic; text-decoration: underline;">',
'</strong>'
)
}}
/>
);
}
}

View File

@ -111,15 +111,13 @@ class SidebarRequestRow extends PureComponent {
onContextMenu={this._handleShowRequestActions}>
<div className="sidebar__clickable">
<MethodTag method={request.method}/>
<div>
<Editable value={request.name}
className="inline-block"
onEditStart={this._handleEditStart}
onSubmit={this._handleRequestUpdateName}
renderReadView={() => (
<Highlight search={filter} text={request.name} />
)}/>
</div>
<Editable
value={request.name}
className="inline-block"
onEditStart={this._handleEditStart}
onSubmit={this._handleRequestUpdateName}
renderReadView={(value, props) => <Highlight search={filter} text={value} {...props}/>}
/>
</div>
</button>
<div className="sidebar__actions">

View File

@ -21,7 +21,6 @@ class ResponseWebView extends PureComponent {
_setBody () {
const {body, contentType, url} = this.props;
const newBody = body.replace('<head>', `<head><base href="${url}">`);
console.log('HELLO?', contentType);
this._webview.loadURL(`data:${contentType},${encodeURIComponent(newBody)}`);
// This is kind of hacky but electron-context-menu fails to save images if