2020-04-26 20:33:39 +00:00
|
|
|
// @flow
|
|
|
|
import * as React from 'react';
|
|
|
|
import autobind from 'autobind-decorator';
|
2020-06-30 23:54:56 +00:00
|
|
|
import { Breadcrumb, Header } from 'insomnia-components';
|
2020-04-26 20:33:39 +00:00
|
|
|
import PageLayout from './page-layout';
|
|
|
|
import type { WrapperProps } from './wrapper';
|
2020-11-02 22:09:45 +00:00
|
|
|
import RequestPane from './panes/request-pane';
|
2020-04-26 20:33:39 +00:00
|
|
|
import ErrorBoundary from './error-boundary';
|
2020-11-02 22:09:45 +00:00
|
|
|
import ResponsePane from './panes/response-pane';
|
2020-04-26 20:33:39 +00:00
|
|
|
import SidebarChildren from './sidebar/sidebar-children';
|
|
|
|
import SidebarFilter from './sidebar/sidebar-filter';
|
|
|
|
import EnvironmentsDropdown from './dropdowns/environments-dropdown';
|
|
|
|
import designerLogo from '../images/insomnia-designer-logo.svg';
|
|
|
|
import WorkspaceDropdown from './dropdowns/workspace-dropdown';
|
2020-06-30 23:54:56 +00:00
|
|
|
import { ACTIVITY_HOME, isInsomnia } from '../../common/constants';
|
|
|
|
import ActivityToggle from './activity-toggle';
|
2020-11-02 00:55:22 +00:00
|
|
|
import { isGrpcRequest } from '../../models/helpers/is-model';
|
2020-11-02 22:09:45 +00:00
|
|
|
import type { ForceToWorkspace } from '../redux/modules/helpers';
|
|
|
|
import GrpcRequestPane from './panes/grpc-request-pane';
|
|
|
|
import GrpcResponsePane from './panes/grpc-response-pane';
|
2020-04-26 20:33:39 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
forceRefreshKey: string,
|
|
|
|
gitSyncDropdown: React.Node,
|
2020-06-30 23:54:56 +00:00
|
|
|
handleActivityChange: (workspaceId: string, activity: GlobalActivity) => Promise<void>,
|
2020-04-26 20:33:39 +00:00
|
|
|
handleChangeEnvironment: Function,
|
|
|
|
handleDeleteResponse: Function,
|
|
|
|
handleDeleteResponses: Function,
|
|
|
|
handleForceUpdateRequest: Function,
|
|
|
|
handleForceUpdateRequestHeaders: Function,
|
|
|
|
handleImport: Function,
|
2020-11-02 22:09:45 +00:00
|
|
|
handleImportFile: (forceToWorkspace?: ForceToWorkspace) => void,
|
2020-04-26 20:33:39 +00:00
|
|
|
handleRequestCreate: Function,
|
|
|
|
handleRequestGroupCreate: Function,
|
|
|
|
handleSendAndDownloadRequestWithActiveEnvironment: Function,
|
|
|
|
handleSendRequestWithActiveEnvironment: Function,
|
|
|
|
handleSetActiveResponse: Function,
|
|
|
|
handleSetPreviewMode: Function,
|
|
|
|
handleSetResponseFilter: Function,
|
|
|
|
handleShowCookiesModal: Function,
|
|
|
|
handleShowRequestSettingsModal: Function,
|
2020-12-01 00:37:57 +00:00
|
|
|
handleSidebarSort: (sortOrder: SortOrder) => void,
|
2020-04-26 20:33:39 +00:00
|
|
|
handleUpdateRequestAuthentication: Function,
|
|
|
|
handleUpdateRequestBody: Function,
|
|
|
|
handleUpdateRequestHeaders: Function,
|
|
|
|
handleUpdateRequestMethod: Function,
|
|
|
|
handleUpdateRequestParameters: Function,
|
|
|
|
handleUpdateRequestUrl: Function,
|
|
|
|
handleUpdateSettingsShowPasswords: Function,
|
|
|
|
handleUpdateSettingsUseBulkHeaderEditor: Function,
|
|
|
|
wrapperProps: WrapperProps,
|
|
|
|
};
|
|
|
|
|
|
|
|
@autobind
|
|
|
|
class WrapperDebug extends React.PureComponent<Props> {
|
|
|
|
_handleBreadcrumb() {
|
|
|
|
this.props.wrapperProps.handleSetActiveActivity(ACTIVITY_HOME);
|
|
|
|
}
|
|
|
|
|
|
|
|
_renderPageHeader() {
|
|
|
|
const {
|
|
|
|
gitSyncDropdown,
|
2020-06-30 23:54:56 +00:00
|
|
|
handleActivityChange,
|
2020-07-09 21:59:22 +00:00
|
|
|
wrapperProps: { activeApiSpec, activeWorkspace, activity },
|
2020-04-26 20:33:39 +00:00
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Header
|
|
|
|
className="app-header"
|
|
|
|
gridLeft={
|
|
|
|
<React.Fragment>
|
2020-04-28 20:38:31 +00:00
|
|
|
<img src={designerLogo} alt="Insomnia" width="32" height="32" />
|
2020-04-26 20:33:39 +00:00
|
|
|
<Breadcrumb
|
|
|
|
className="breadcrumb"
|
2020-04-28 18:29:51 +00:00
|
|
|
crumbs={['Documents', activeApiSpec.fileName]}
|
2020-04-26 20:33:39 +00:00
|
|
|
onClick={this._handleBreadcrumb}
|
|
|
|
/>
|
|
|
|
</React.Fragment>
|
|
|
|
}
|
|
|
|
gridCenter={
|
2020-06-30 23:54:56 +00:00
|
|
|
<ActivityToggle
|
|
|
|
activity={activity}
|
|
|
|
handleActivityChange={handleActivityChange}
|
|
|
|
workspace={activeWorkspace}
|
2020-04-26 20:33:39 +00:00
|
|
|
/>
|
|
|
|
}
|
|
|
|
gridRight={gitSyncDropdown}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-11-02 00:55:22 +00:00
|
|
|
_renderPageSidebar() {
|
2020-04-26 20:33:39 +00:00
|
|
|
const {
|
|
|
|
handleChangeEnvironment,
|
2020-11-02 00:55:22 +00:00
|
|
|
handleRequestCreate,
|
|
|
|
handleRequestGroupCreate,
|
|
|
|
handleShowCookiesModal,
|
2020-12-01 00:37:57 +00:00
|
|
|
handleSidebarSort,
|
2020-11-02 00:55:22 +00:00
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const {
|
|
|
|
activity,
|
|
|
|
activeEnvironment,
|
|
|
|
activeRequest,
|
|
|
|
activeWorkspace,
|
|
|
|
environments,
|
|
|
|
handleActivateRequest,
|
|
|
|
handleSetActiveWorkspace,
|
|
|
|
handleCopyAsCurl,
|
|
|
|
handleCreateRequest,
|
|
|
|
handleCreateRequestGroup,
|
|
|
|
handleDuplicateRequest,
|
|
|
|
handleDuplicateRequestGroup,
|
|
|
|
handleGenerateCode,
|
|
|
|
handleMoveDoc,
|
|
|
|
handleMoveRequestGroup,
|
|
|
|
handleRender,
|
|
|
|
handleSetRequestGroupCollapsed,
|
|
|
|
handleSetRequestPinned,
|
|
|
|
handleSetSidebarFilter,
|
|
|
|
isLoading,
|
|
|
|
settings,
|
|
|
|
sidebarChildren,
|
|
|
|
sidebarFilter,
|
|
|
|
sidebarHidden,
|
|
|
|
sidebarWidth,
|
|
|
|
unseenWorkspaces,
|
|
|
|
vcs,
|
|
|
|
workspaces,
|
|
|
|
} = this.props.wrapperProps;
|
|
|
|
|
|
|
|
const insomnia = isInsomnia(activity);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<React.Fragment>
|
|
|
|
{insomnia && (
|
|
|
|
<WorkspaceDropdown
|
|
|
|
className="sidebar__header theme--sidebar__header"
|
|
|
|
activeEnvironment={activeEnvironment}
|
|
|
|
activeWorkspace={activeWorkspace}
|
|
|
|
workspaces={workspaces}
|
|
|
|
unseenWorkspaces={unseenWorkspaces}
|
|
|
|
hotKeyRegistry={settings.hotKeyRegistry}
|
|
|
|
handleSetActiveWorkspace={handleSetActiveWorkspace}
|
|
|
|
isLoading={isLoading}
|
|
|
|
vcs={vcs}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
<div className="sidebar__menu">
|
|
|
|
<EnvironmentsDropdown
|
|
|
|
handleChangeEnvironment={handleChangeEnvironment}
|
|
|
|
activeEnvironment={activeEnvironment}
|
|
|
|
environments={environments}
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
environmentHighlightColorStyle={settings.environmentHighlightColorStyle}
|
|
|
|
hotKeyRegistry={settings.hotKeyRegistry}
|
|
|
|
/>
|
|
|
|
<button className="btn btn--super-compact" onClick={handleShowCookiesModal}>
|
|
|
|
<div className="sidebar__menu__thing">
|
|
|
|
<span>Cookies</span>
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<SidebarFilter
|
|
|
|
key={`${activeWorkspace._id}::filter`}
|
|
|
|
onChange={handleSetSidebarFilter}
|
|
|
|
requestCreate={handleRequestCreate}
|
|
|
|
requestGroupCreate={handleRequestGroupCreate}
|
2020-12-01 00:37:57 +00:00
|
|
|
sidebarSort={handleSidebarSort}
|
2020-11-02 00:55:22 +00:00
|
|
|
filter={sidebarFilter || ''}
|
|
|
|
hotKeyRegistry={settings.hotKeyRegistry}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<SidebarChildren
|
|
|
|
childObjects={sidebarChildren}
|
|
|
|
handleActivateRequest={handleActivateRequest}
|
|
|
|
handleCreateRequest={handleCreateRequest}
|
|
|
|
handleCreateRequestGroup={handleCreateRequestGroup}
|
|
|
|
handleSetRequestGroupCollapsed={handleSetRequestGroupCollapsed}
|
|
|
|
handleSetRequestPinned={handleSetRequestPinned}
|
|
|
|
handleDuplicateRequest={handleDuplicateRequest}
|
|
|
|
handleDuplicateRequestGroup={handleDuplicateRequestGroup}
|
|
|
|
handleMoveRequestGroup={handleMoveRequestGroup}
|
|
|
|
handleGenerateCode={handleGenerateCode}
|
|
|
|
handleCopyAsCurl={handleCopyAsCurl}
|
|
|
|
handleRender={handleRender}
|
|
|
|
moveDoc={handleMoveDoc}
|
|
|
|
hidden={sidebarHidden}
|
|
|
|
width={sidebarWidth}
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
activeRequest={activeRequest}
|
|
|
|
filter={sidebarFilter || ''}
|
|
|
|
hotKeyRegistry={settings.hotKeyRegistry}
|
|
|
|
activeEnvironment={activeEnvironment}
|
|
|
|
/>
|
|
|
|
</React.Fragment>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-11-19 00:13:24 +00:00
|
|
|
_renderRequestPane() {
|
2020-11-02 00:55:22 +00:00
|
|
|
const {
|
|
|
|
forceRefreshKey,
|
2020-04-26 20:33:39 +00:00
|
|
|
handleForceUpdateRequest,
|
|
|
|
handleForceUpdateRequestHeaders,
|
|
|
|
handleImport,
|
|
|
|
handleImportFile,
|
|
|
|
handleSendAndDownloadRequestWithActiveEnvironment,
|
|
|
|
handleSendRequestWithActiveEnvironment,
|
|
|
|
handleUpdateRequestAuthentication,
|
|
|
|
handleUpdateRequestBody,
|
|
|
|
handleUpdateRequestHeaders,
|
|
|
|
handleUpdateRequestMethod,
|
|
|
|
handleUpdateRequestParameters,
|
|
|
|
handleUpdateRequestUrl,
|
|
|
|
handleUpdateSettingsShowPasswords,
|
|
|
|
handleUpdateSettingsUseBulkHeaderEditor,
|
2020-08-03 10:13:08 +00:00
|
|
|
handleUpdateSettingsUseBulkParametersEditor,
|
2020-04-26 20:33:39 +00:00
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const {
|
|
|
|
activeEnvironment,
|
|
|
|
activeRequest,
|
2020-07-01 21:17:14 +00:00
|
|
|
activeUnitTest,
|
2020-04-26 20:33:39 +00:00
|
|
|
activeWorkspace,
|
|
|
|
handleCreateRequestForWorkspace,
|
|
|
|
handleGenerateCodeForActiveRequest,
|
|
|
|
handleGetRenderContext,
|
|
|
|
handleRender,
|
|
|
|
handleUpdateDownloadPath,
|
|
|
|
handleUpdateRequestMimeType,
|
|
|
|
headerEditorKey,
|
|
|
|
isVariableUncovered,
|
|
|
|
oAuth2Token,
|
|
|
|
responseDownloadPath,
|
|
|
|
settings,
|
|
|
|
} = this.props.wrapperProps;
|
|
|
|
|
2020-11-02 00:55:22 +00:00
|
|
|
// activeRequest being truthy only needs to be checked for isGrpcRequest (for now)
|
|
|
|
// The RequestPane and ResponsePane components already handle the case where activeRequest is null
|
|
|
|
if (activeRequest && isGrpcRequest(activeRequest)) {
|
2020-11-02 22:09:45 +00:00
|
|
|
return (
|
2020-11-02 00:55:22 +00:00
|
|
|
<ErrorBoundary showAlert>
|
2020-11-19 00:13:24 +00:00
|
|
|
<GrpcRequestPane
|
|
|
|
activeRequest={activeRequest}
|
2020-12-17 11:38:21 +00:00
|
|
|
environmentId={activeEnvironment ? activeEnvironment._id : ''}
|
|
|
|
workspaceId={activeWorkspace._id}
|
2020-11-02 00:55:22 +00:00
|
|
|
forceRefreshCounter={forceRefreshKey}
|
|
|
|
settings={settings}
|
2020-12-17 11:38:21 +00:00
|
|
|
handleRender={handleRender}
|
|
|
|
isVariableUncovered={isVariableUncovered}
|
|
|
|
handleGetRenderContext={handleGetRenderContext}
|
2020-11-02 00:55:22 +00:00
|
|
|
/>
|
|
|
|
</ErrorBoundary>
|
2020-11-19 00:13:24 +00:00
|
|
|
);
|
|
|
|
}
|
2020-04-26 20:33:39 +00:00
|
|
|
|
2020-11-19 00:13:24 +00:00
|
|
|
return (
|
|
|
|
<ErrorBoundary showAlert>
|
|
|
|
<RequestPane
|
|
|
|
downloadPath={responseDownloadPath}
|
|
|
|
environmentId={activeEnvironment ? activeEnvironment._id : ''}
|
|
|
|
forceRefreshCounter={forceRefreshKey}
|
|
|
|
forceUpdateRequest={handleForceUpdateRequest}
|
|
|
|
forceUpdateRequestHeaders={handleForceUpdateRequestHeaders}
|
|
|
|
handleCreateRequest={handleCreateRequestForWorkspace}
|
|
|
|
handleGenerateCode={handleGenerateCodeForActiveRequest}
|
|
|
|
handleGetRenderContext={handleGetRenderContext}
|
|
|
|
handleImport={handleImport}
|
|
|
|
handleImportFile={handleImportFile}
|
|
|
|
handleRender={handleRender}
|
|
|
|
handleSend={handleSendRequestWithActiveEnvironment}
|
|
|
|
handleSendAndDownload={handleSendAndDownloadRequestWithActiveEnvironment}
|
|
|
|
handleUpdateDownloadPath={handleUpdateDownloadPath}
|
|
|
|
headerEditorKey={headerEditorKey}
|
|
|
|
isVariableUncovered={isVariableUncovered}
|
|
|
|
nunjucksPowerUserMode={settings.nunjucksPowerUserMode}
|
|
|
|
oAuth2Token={oAuth2Token}
|
|
|
|
request={activeRequest}
|
|
|
|
unitTest={activeUnitTest}
|
|
|
|
settings={settings}
|
|
|
|
updateRequestAuthentication={handleUpdateRequestAuthentication}
|
|
|
|
updateRequestBody={handleUpdateRequestBody}
|
|
|
|
updateRequestHeaders={handleUpdateRequestHeaders}
|
|
|
|
updateRequestMethod={handleUpdateRequestMethod}
|
|
|
|
updateRequestMimeType={handleUpdateRequestMimeType}
|
|
|
|
updateRequestParameters={handleUpdateRequestParameters}
|
|
|
|
updateRequestUrl={handleUpdateRequestUrl}
|
|
|
|
updateSettingsShowPasswords={handleUpdateSettingsShowPasswords}
|
|
|
|
updateSettingsUseBulkHeaderEditor={handleUpdateSettingsUseBulkHeaderEditor}
|
|
|
|
updateSettingsUseBulkParametersEditor={handleUpdateSettingsUseBulkParametersEditor}
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
/>
|
|
|
|
</ErrorBoundary>
|
|
|
|
);
|
|
|
|
}
|
2020-04-26 20:33:39 +00:00
|
|
|
|
2020-11-19 00:13:24 +00:00
|
|
|
_renderResponsePane() {
|
|
|
|
const {
|
|
|
|
forceRefreshKey,
|
|
|
|
handleDeleteResponse,
|
|
|
|
handleDeleteResponses,
|
|
|
|
handleSetActiveResponse,
|
|
|
|
handleSetPreviewMode,
|
|
|
|
handleSetResponseFilter,
|
|
|
|
handleShowCookiesModal,
|
|
|
|
handleShowRequestSettingsModal,
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const {
|
|
|
|
activeEnvironment,
|
|
|
|
activeRequest,
|
|
|
|
activeRequestResponses,
|
|
|
|
activeResponse,
|
|
|
|
activeUnitTestResult,
|
|
|
|
loadStartTime,
|
|
|
|
requestVersions,
|
|
|
|
responseFilter,
|
|
|
|
responseFilterHistory,
|
|
|
|
responsePreviewMode,
|
|
|
|
settings,
|
|
|
|
} = this.props.wrapperProps;
|
|
|
|
|
|
|
|
// activeRequest being truthy only needs to be checked for isGrpcRequest (for now)
|
|
|
|
// The RequestPane and ResponsePane components already handle the case where activeRequest is null
|
|
|
|
if (activeRequest && isGrpcRequest(activeRequest)) {
|
|
|
|
return (
|
2020-11-02 00:55:22 +00:00
|
|
|
<ErrorBoundary showAlert>
|
2020-11-19 00:13:24 +00:00
|
|
|
<GrpcResponsePane
|
|
|
|
activeRequest={activeRequest}
|
|
|
|
forceRefreshCounter={forceRefreshKey}
|
|
|
|
settings={settings}
|
2020-11-02 00:55:22 +00:00
|
|
|
/>
|
|
|
|
</ErrorBoundary>
|
2020-11-19 00:13:24 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ErrorBoundary showAlert>
|
|
|
|
<ResponsePane
|
|
|
|
disableHtmlPreviewJs={settings.disableHtmlPreviewJs}
|
|
|
|
disableResponsePreviewLinks={settings.disableResponsePreviewLinks}
|
|
|
|
editorFontSize={settings.editorFontSize}
|
|
|
|
editorIndentSize={settings.editorIndentSize}
|
|
|
|
editorKeyMap={settings.editorKeyMap}
|
|
|
|
editorLineWrapping={settings.editorLineWrapping}
|
|
|
|
environment={activeEnvironment}
|
|
|
|
filter={responseFilter}
|
|
|
|
filterHistory={responseFilterHistory}
|
|
|
|
handleDeleteResponse={handleDeleteResponse}
|
|
|
|
handleDeleteResponses={handleDeleteResponses}
|
|
|
|
handleSetActiveResponse={handleSetActiveResponse}
|
|
|
|
handleSetFilter={handleSetResponseFilter}
|
|
|
|
handleSetPreviewMode={handleSetPreviewMode}
|
|
|
|
handleShowRequestSettings={handleShowRequestSettingsModal}
|
|
|
|
showCookiesModal={handleShowCookiesModal}
|
|
|
|
hotKeyRegistry={settings.hotKeyRegistry}
|
|
|
|
loadStartTime={loadStartTime}
|
|
|
|
previewMode={responsePreviewMode}
|
|
|
|
request={activeRequest}
|
|
|
|
requestVersions={requestVersions}
|
|
|
|
response={activeResponse}
|
|
|
|
responses={activeRequestResponses}
|
|
|
|
unitTestResult={activeUnitTestResult}
|
|
|
|
/>
|
|
|
|
</ErrorBoundary>
|
2020-11-02 00:55:22 +00:00
|
|
|
);
|
|
|
|
}
|
2020-04-26 20:33:39 +00:00
|
|
|
|
2020-11-02 00:55:22 +00:00
|
|
|
render() {
|
|
|
|
const { activity } = this.props.wrapperProps;
|
2020-04-26 20:33:39 +00:00
|
|
|
|
2020-11-02 00:55:22 +00:00
|
|
|
const insomnia = isInsomnia(activity);
|
|
|
|
const designer = !insomnia;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<PageLayout
|
|
|
|
wrapperProps={this.props.wrapperProps}
|
|
|
|
renderPageHeader={designer && this._renderPageHeader}
|
|
|
|
renderPageSidebar={this._renderPageSidebar}
|
2020-11-19 00:13:24 +00:00
|
|
|
renderPaneOne={this._renderRequestPane}
|
|
|
|
renderPaneTwo={this._renderResponsePane}
|
2020-04-26 20:33:39 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default WrapperDebug;
|