Clean up new setting to disable links

This commit is contained in:
Gregory Schier 2020-01-07 11:35:21 -05:00
parent f874a77a2d
commit 01e225bd0a
6 changed files with 45 additions and 36 deletions

View File

@ -11,6 +11,7 @@ type BaseSettings = {
deviceId: string | null,
disableHtmlPreviewJs: boolean,
disableUpdateNotification: boolean,
disableResponsePreviewLinks: boolean,
editorFontSize: number,
editorIndentSize: number,
editorIndentWithTabs: boolean,
@ -60,6 +61,7 @@ export function init(): BaseSettings {
autocompleteDelay: 1200,
deviceId: null,
disableHtmlPreviewJs: false,
disableResponsePreviewLinks: false,
disableUpdateNotification: false,
editorFontSize: 11,
editorIndentSize: 2,

View File

@ -53,6 +53,7 @@ type Props = {
loadStartTime: number,
responses: Array<Response>,
hotKeyRegistry: HotKeyRegistry,
disableResponsePreviewLinks: boolean,
// Other
requestVersions: Array<RequestVersion>,
@ -61,7 +62,7 @@ type Props = {
};
@autobind
class ResponsePane extends React.PureComponent<Props, State> {
class ResponsePane extends React.PureComponent<Props> {
_responseViewer: any;
_setResponseViewerRef(n: any) {
@ -336,23 +337,22 @@ class ResponsePane extends React.PureComponent<Props, State> {
<TabPanel className="react-tabs__tab-panel">
<ResponseViewer
ref={this._setResponseViewerRef}
// Send larger one because legacy responses have bytesContent === -1
responseId={response._id}
bytes={Math.max(response.bytesContent, response.bytesRead)}
contentType={response.contentType || ''}
previewMode={response.error ? PREVIEW_MODE_SOURCE : previewMode}
filter={filter}
disableResponsePreviewLinks={disableResponsePreviewLinks}
filterHistory={filterHistory}
updateFilter={response.error ? null : handleSetFilter}
download={this._handleDownloadResponseBody}
disableHtmlPreviewJs={disableHtmlPreviewJs}
getBody={this._handleGetResponseBody}
error={response.error}
editorLineWrapping={editorLineWrapping}
disablePreviewLinks={disableResponsePreviewLinks}
download={this._handleDownloadResponseBody}
editorFontSize={editorFontSize}
editorIndentSize={editorIndentSize}
editorKeyMap={editorKeyMap}
editorLineWrapping={editorLineWrapping}
error={response.error}
filter={filter}
filterHistory={filterHistory}
getBody={this._handleGetResponseBody}
previewMode={response.error ? PREVIEW_MODE_SOURCE : previewMode}
responseId={response._id}
updateFilter={response.error ? null : handleSetFilter}
url={response.url}
/>
</TabPanel>

View File

@ -171,11 +171,6 @@ class General extends React.PureComponent<Props, State> {
'forceVerticalLayout',
'',
)}
{this.renderBooleanSetting(
'Disable Response Preview Links',
'disableResponsePreviewLinks',
'',
)}
</div>
<div>
{this.renderBooleanSetting('Reveal passwords', 'showPasswords', '')}
@ -315,6 +310,11 @@ class General extends React.PureComponent<Props, State> {
</div>
<div>
{this.renderBooleanSetting('Disable JS in HTML preview', 'disableHtmlPreviewJs', '')}
{this.renderBooleanSetting(
'Disable Links in response viewer',
'disableResponsePreviewLinks',
'',
)}
</div>
</div>

View File

@ -30,6 +30,7 @@ type Props = {
bodyBuffer: Buffer | null,
contentType: string,
disableHtmlPreviewJs: boolean,
disablePreviewLinks: boolean,
filter: string,
filterHistory: Array<string>,
editorFontSize: number,
@ -217,6 +218,7 @@ class ResponseMultipart extends React.PureComponent<Props, State> {
const {
download,
disableHtmlPreviewJs,
disablePreviewLinks,
editorFontSize,
editorIndentSize,
editorKeyMap,
@ -280,11 +282,11 @@ class ResponseMultipart extends React.PureComponent<Props, State> {
{selectedPart ? (
<div className="tall wide">
<ResponseViewer
key={`${responseId}::${activePart}`}
bytes={selectedPart.bytes || 0}
contentType={getContentTypeFromHeaders(selectedPart.headers, 'text/plain')}
download={download}
disableHtmlPreviewJs={disableHtmlPreviewJs}
disablePreviewLinks={disablePreviewLinks}
download={download}
editorFontSize={editorFontSize}
editorIndentSize={editorIndentSize}
editorKeyMap={editorKeyMap}
@ -293,6 +295,7 @@ class ResponseMultipart extends React.PureComponent<Props, State> {
filter={filter}
filterHistory={filterHistory}
getBody={this._getBody}
key={`${responseId}::${activePart}`}
previewMode={PREVIEW_MODE_FRIENDLY}
responseId={`${responseId}[${activePart}]`}
updateFilter={null}

View File

@ -23,20 +23,21 @@ import { hotKeyRefs } from '../../../common/hotkeys';
let alwaysShowLargeResponses = false;
type Props = {
getBody: Function,
bytes: number,
contentType: string,
disableHtmlPreviewJs: boolean,
disablePreviewLinks: boolean,
download: Function,
responseId: string,
previewMode: string,
filter: string,
filterHistory: Array<string>,
editorFontSize: number,
editorIndentSize: number,
editorKeyMap: string,
editorLineWrapping: boolean,
filter: string,
filterHistory: Array<string>,
getBody: Function,
previewMode: string,
responseId: string,
url: string,
bytes: number,
contentType: string,
disableHtmlPreviewJs: boolean,
// Optional
updateFilter: Function | null,
@ -197,6 +198,7 @@ class ResponseViewer extends React.Component<Props, State> {
const {
bytes,
disableHtmlPreviewJs,
disablePreviewLinks,
download,
editorFontSize,
editorIndentSize,
@ -208,7 +210,6 @@ class ResponseViewer extends React.Component<Props, State> {
previewMode,
responseId,
updateFilter,
disableResponsePreviewLinks,
url,
} = this.props;
let contentType = this.props.contentType;
@ -344,6 +345,7 @@ class ResponseViewer extends React.Component<Props, State> {
bodyBuffer={bodyBuffer}
contentType={contentType}
disableHtmlPreviewJs={disableHtmlPreviewJs}
disablePreviewLinks={disablePreviewLinks}
download={download}
editorFontSize={editorFontSize}
editorIndentSize={editorIndentSize}
@ -395,22 +397,23 @@ class ResponseViewer extends React.Component<Props, State> {
return (
<CodeEditor
uniquenessKey={responseId}
key={disablePreviewLinks ? 'links-no' : 'links-yes'}
ref={this._setSelectableViewRef}
onClickLink={disableResponsePreviewLinks ? null : this._handleOpenLink}
autoPrettify
defaultValue={body}
updateFilter={updateFilter}
filter={filter}
filterHistory={filterHistory}
autoPrettify
noMatchBrackets
readOnly
mode={mode}
lineWrapping={editorLineWrapping}
fontSize={editorFontSize}
indentSize={editorIndentSize}
keyMap={editorKeyMap}
lineWrapping={editorLineWrapping}
mode={mode}
noMatchBrackets
onClickLink={disablePreviewLinks ? null : this._handleOpenLink}
placeholder="..."
readOnly
uniquenessKey={responseId}
updateFilter={updateFilter}
/>
);
}

View File

@ -848,6 +848,7 @@ class Wrapper extends React.PureComponent<Props, State> {
<ResponsePane
ref={handleSetResponsePaneRef}
disableHtmlPreviewJs={settings.disableHtmlPreviewJs}
disableResponsePreviewLinks={settings.disableResponsePreviewLinks}
editorFontSize={settings.editorFontSize}
editorIndentSize={settings.editorIndentSize}
editorKeyMap={settings.editorKeyMap}