2017-07-19 04:48:28 +00:00
|
|
|
// @flow
|
|
|
|
import type {Settings} from '../../models/settings';
|
|
|
|
import type {Response} from '../../models/response';
|
|
|
|
import type {OAuth2Token} from '../../models/o-auth-2-token';
|
|
|
|
import type {Workspace} from '../../models/workspace';
|
|
|
|
import type {Request, RequestAuthentication, RequestBody, RequestHeader, RequestParameter} from '../../models/request';
|
|
|
|
|
|
|
|
import React from 'react';
|
2017-03-03 01:44:07 +00:00
|
|
|
import autobind from 'autobind-decorator';
|
2016-11-16 17:18:39 +00:00
|
|
|
import classnames from 'classnames';
|
2017-03-28 22:45:23 +00:00
|
|
|
import {registerModal, showModal} from './modals/index';
|
2017-03-08 05:52:17 +00:00
|
|
|
import AlertModal from './modals/alert-modal';
|
|
|
|
import ChangelogModal from './modals/changelog-modal';
|
|
|
|
import CookiesModal from './modals/cookies-modal';
|
|
|
|
import EnvironmentEditModal from './modals/environment-edit-modal';
|
|
|
|
import GenerateCodeModal from './modals/generate-code-modal';
|
|
|
|
import LoginModal from './modals/login-modal';
|
|
|
|
import PaymentNotificationModal from './modals/payment-notification-modal';
|
2017-03-09 06:23:23 +00:00
|
|
|
import NunjucksModal from './modals/nunjucks-modal';
|
2017-03-08 05:52:17 +00:00
|
|
|
import PromptModal from './modals/prompt-modal';
|
2017-07-03 20:51:55 +00:00
|
|
|
import AskModal from './modals/ask-modal';
|
2017-03-08 05:52:17 +00:00
|
|
|
import RequestCreateModal from './modals/request-create-modal';
|
|
|
|
import RequestPane from './request-pane';
|
|
|
|
import RequestSwitcherModal from './modals/request-switcher-modal';
|
|
|
|
import SetupSyncModal from './modals/setup-sync-modal';
|
|
|
|
import SettingsModal from './modals/settings-modal';
|
2017-03-12 00:31:23 +00:00
|
|
|
import FilterHelpModal from './modals/filter-help-modal';
|
2017-03-08 05:52:17 +00:00
|
|
|
import ResponsePane from './response-pane';
|
2017-03-28 22:45:23 +00:00
|
|
|
import RequestSettingsModal from './modals/request-settings-modal';
|
|
|
|
import RequestRenderErrorModal from './modals/request-render-error-modal';
|
2017-03-08 05:52:17 +00:00
|
|
|
import Sidebar from './sidebar/sidebar';
|
|
|
|
import WorkspaceEnvironmentsEditModal from './modals/workspace-environments-edit-modal';
|
|
|
|
import WorkspaceSettingsModal from './modals/workspace-settings-modal';
|
|
|
|
import WorkspaceShareSettingsModal from './modals/workspace-share-settings-modal';
|
2017-06-09 21:42:19 +00:00
|
|
|
import CodePromptModal from './modals/code-prompt-modal';
|
2016-11-16 17:18:39 +00:00
|
|
|
import * as models from '../../models/index';
|
2016-11-22 19:42:10 +00:00
|
|
|
import {updateMimeType} from '../../models/request';
|
2016-11-26 00:37:59 +00:00
|
|
|
import {trackEvent} from '../../analytics/index';
|
|
|
|
import * as importers from 'insomnia-importers';
|
2016-11-16 17:18:39 +00:00
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
const rUpdate = (request, ...args) => {
|
|
|
|
if (!request) {
|
|
|
|
throw new Error('Tried to update null request');
|
|
|
|
}
|
|
|
|
|
|
|
|
return models.request.update(request, ...args);
|
|
|
|
};
|
|
|
|
|
2016-11-26 00:37:59 +00:00
|
|
|
const sUpdate = models.settings.update;
|
2016-11-16 17:18:39 +00:00
|
|
|
|
2017-07-21 18:59:17 +00:00
|
|
|
@autobind
|
|
|
|
class Wrapper extends React.PureComponent {
|
|
|
|
props: {
|
|
|
|
// Helper Functions
|
|
|
|
handleActivateRequest: Function,
|
|
|
|
handleSetSidebarFilter: Function,
|
|
|
|
handleToggleMenuBar: Function,
|
|
|
|
handleImportFileToWorkspace: Function,
|
|
|
|
handleImportUriToWorkspace: Function,
|
|
|
|
handleExportFile: Function,
|
|
|
|
handleSetActiveWorkspace: Function,
|
|
|
|
handleSetActiveEnvironment: Function,
|
|
|
|
handleMoveDoc: Function,
|
|
|
|
handleCreateRequest: Function,
|
|
|
|
handleDuplicateRequest: Function,
|
|
|
|
handleDuplicateRequestGroup: Function,
|
|
|
|
handleDuplicateWorkspace: Function,
|
|
|
|
handleCreateRequestGroup: Function,
|
|
|
|
handleGenerateCodeForActiveRequest: Function,
|
|
|
|
handleGenerateCode: Function,
|
|
|
|
handleCopyAsCurl: Function,
|
|
|
|
handleCreateRequestForWorkspace: Function,
|
|
|
|
handleSetRequestPaneRef: Function,
|
|
|
|
handleSetResponsePaneRef: Function,
|
|
|
|
handleSetResponsePreviewMode: Function,
|
|
|
|
handleRender: Function,
|
|
|
|
handleGetRenderContext: Function,
|
|
|
|
handleSetResponseFilter: Function,
|
|
|
|
handleSetActiveResponse: Function,
|
|
|
|
handleSetSidebarRef: Function,
|
|
|
|
handleStartDragSidebar: Function,
|
|
|
|
handleResetDragSidebar: Function,
|
|
|
|
handleStartDragPaneHorizontal: Function,
|
|
|
|
handleStartDragPaneVertical: Function,
|
|
|
|
handleResetDragPaneHorizontal: Function,
|
|
|
|
handleResetDragPaneVertical: Function,
|
|
|
|
handleSetRequestGroupCollapsed: Function,
|
|
|
|
handleSendRequestWithEnvironment: Function,
|
|
|
|
handleSendAndDownloadRequestWithEnvironment: Function,
|
2017-07-19 04:48:28 +00:00
|
|
|
|
2017-07-21 18:59:17 +00:00
|
|
|
// Properties
|
|
|
|
loadStartTime: number,
|
|
|
|
isLoading: boolean,
|
|
|
|
paneWidth: number,
|
|
|
|
paneHeight: number,
|
|
|
|
responsePreviewMode: string,
|
|
|
|
responseFilter: string,
|
|
|
|
responseFilterHistory: Array<string>,
|
|
|
|
sidebarWidth: number,
|
|
|
|
sidebarHidden: boolean,
|
|
|
|
sidebarFilter: string,
|
|
|
|
sidebarChildren: Array<Object>,
|
|
|
|
settings: Settings,
|
|
|
|
workspaces: Array<Workspace>,
|
2017-07-27 22:59:07 +00:00
|
|
|
unseenWorkspaces: Array<Workspace>,
|
2017-07-21 18:59:17 +00:00
|
|
|
workspaceChildren: Array<Object>,
|
|
|
|
environments: Array<Object>,
|
|
|
|
activeRequestResponses: Array<Response>,
|
|
|
|
activeWorkspace: Workspace,
|
2017-07-19 04:48:28 +00:00
|
|
|
|
2017-07-21 18:59:17 +00:00
|
|
|
// Optional
|
|
|
|
oAuth2Token: ?OAuth2Token,
|
|
|
|
activeRequest: ?Request,
|
|
|
|
activeResponse: ?Response,
|
|
|
|
activeEnvironment: ?Object
|
|
|
|
};
|
2017-07-19 04:48:28 +00:00
|
|
|
|
2017-07-21 18:59:17 +00:00
|
|
|
state: {
|
|
|
|
forceRefreshKey: number
|
|
|
|
};
|
2017-07-19 04:48:28 +00:00
|
|
|
|
2017-07-21 18:59:17 +00:00
|
|
|
constructor (props: any) {
|
2017-03-03 01:44:07 +00:00
|
|
|
super(props);
|
|
|
|
this.state = {
|
2017-03-06 17:51:58 +00:00
|
|
|
forceRefreshKey: Date.now()
|
2017-03-03 01:44:07 +00:00
|
|
|
};
|
|
|
|
}
|
2016-11-26 00:37:59 +00:00
|
|
|
|
|
|
|
// Request updaters
|
2017-07-19 04:48:28 +00:00
|
|
|
async _handleForceUpdateRequest (patch: Object): Promise<Request> {
|
2017-02-02 18:30:13 +00:00
|
|
|
const newRequest = await rUpdate(this.props.activeRequest, patch);
|
2017-02-28 21:32:23 +00:00
|
|
|
|
|
|
|
// Give it a second for the app to render first. If we don't wait, it will refresh
|
|
|
|
// on the old request and won't catch the newest one.
|
|
|
|
window.setTimeout(this._forceRequestPaneRefresh, 100);
|
|
|
|
|
2017-02-02 18:30:13 +00:00
|
|
|
return newRequest;
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleUpdateRequestBody (body: RequestBody): Promise<Request> {
|
|
|
|
return rUpdate(this.props.activeRequest, {body});
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-28 07:12:17 +00:00
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleUpdateRequestMethod (method: string): Promise<Request> {
|
|
|
|
return rUpdate(this.props.activeRequest, {method});
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleUpdateRequestParameters (parameters: Array<RequestParameter>): Promise<Request> {
|
|
|
|
return rUpdate(this.props.activeRequest, {parameters});
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleUpdateRequestAuthentication (authentication: RequestAuthentication): Promise<Request> {
|
|
|
|
return rUpdate(this.props.activeRequest, {authentication});
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleUpdateRequestHeaders (headers: Array<RequestHeader>): Promise<Request> {
|
|
|
|
return rUpdate(this.props.activeRequest, {headers});
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleUpdateRequestUrl (url: string): Promise<Request> {
|
|
|
|
return rUpdate(this.props.activeRequest, {url});
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-26 00:37:59 +00:00
|
|
|
|
|
|
|
// Special request updaters
|
2017-07-19 04:48:28 +00:00
|
|
|
async _handleUpdateRequestMimeType (mimeType: string): Promise<Request | null> {
|
|
|
|
if (!this.props.activeRequest) {
|
|
|
|
console.warn('Tried to update request mime-type when no active request');
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const newRequest = await updateMimeType(this.props.activeRequest, mimeType);
|
2017-03-12 09:03:57 +00:00
|
|
|
|
|
|
|
// Force it to update, because other editor components (header editor)
|
2017-03-28 22:45:23 +00:00
|
|
|
// needs to change. Need to wait a delay so the next render can finish
|
|
|
|
setTimeout(this._forceRequestPaneRefresh, 300);
|
2017-07-19 04:48:28 +00:00
|
|
|
|
|
|
|
return newRequest;
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleStartDragSidebar (e: Event): void {
|
2017-03-06 17:51:58 +00:00
|
|
|
e.preventDefault();
|
|
|
|
this.props.handleStartDragSidebar();
|
|
|
|
}
|
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
async _handleImport (text: string): Promise<Request | null> {
|
2016-11-26 00:37:59 +00:00
|
|
|
// Allow user to paste any import file into the url. If it results in
|
|
|
|
// only one item, it will overwrite the current request.
|
|
|
|
try {
|
2017-01-28 06:09:01 +00:00
|
|
|
const {data} = importers.convert(text);
|
2016-12-01 03:54:26 +00:00
|
|
|
const {resources} = data;
|
2016-11-26 00:37:59 +00:00
|
|
|
const r = resources[0];
|
|
|
|
|
|
|
|
if (r && r._type === 'request') {
|
|
|
|
trackEvent('Import', 'Url Bar');
|
2016-11-25 23:09:17 +00:00
|
|
|
|
2016-11-26 00:37:59 +00:00
|
|
|
// Only pull fields that we want to update
|
2017-02-02 18:30:13 +00:00
|
|
|
return this._handleForceUpdateRequest({
|
2016-11-26 00:37:59 +00:00
|
|
|
url: r.url,
|
|
|
|
method: r.method,
|
|
|
|
headers: r.headers,
|
|
|
|
body: r.body,
|
|
|
|
authentication: r.authentication,
|
2017-03-03 20:09:08 +00:00
|
|
|
parameters: r.parameters
|
2016-11-26 00:37:59 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
// Import failed, that's alright
|
|
|
|
}
|
2017-02-02 18:30:13 +00:00
|
|
|
|
|
|
|
return null;
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2017-01-28 06:09:01 +00:00
|
|
|
|
2016-11-26 00:37:59 +00:00
|
|
|
// Settings updaters
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleUpdateSettingsShowPasswords (showPasswords: boolean): Promise<Request> {
|
|
|
|
return sUpdate(this.props.settings, {showPasswords});
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleUpdateSettingsUseBulkHeaderEditor (useBulkHeaderEditor: boolean): Promise<Request> {
|
|
|
|
return sUpdate(this.props.settings, {useBulkHeaderEditor});
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-26 00:37:59 +00:00
|
|
|
|
|
|
|
// Other Helpers
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleImportFile (): void {
|
2016-12-01 03:54:26 +00:00
|
|
|
this.props.handleImportFileToWorkspace(this.props.activeWorkspace._id);
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleImportUri (uri: string): void {
|
2017-05-03 17:48:23 +00:00
|
|
|
this.props.handleImportUriToWorkspace(this.props.activeWorkspace._id, uri);
|
|
|
|
}
|
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleExportWorkspaceToFile (): void {
|
2017-03-03 01:44:07 +00:00
|
|
|
this.props.handleExportFile(this.props.activeWorkspace._id);
|
|
|
|
}
|
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleSetActiveResponse (responseId: string | null): void {
|
|
|
|
if (!this.props.activeRequest) {
|
|
|
|
console.warn('Tried to set active response when request not active');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-03 01:44:07 +00:00
|
|
|
this.props.handleSetActiveResponse(this.props.activeRequest._id, responseId);
|
|
|
|
}
|
2016-12-07 17:57:01 +00:00
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleShowEnvironmentsModal (): void {
|
2017-03-03 01:44:07 +00:00
|
|
|
showModal(WorkspaceEnvironmentsEditModal, this.props.activeWorkspace);
|
|
|
|
}
|
2016-11-26 00:37:59 +00:00
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleShowCookiesModal (): void {
|
2017-03-03 01:44:07 +00:00
|
|
|
showModal(CookiesModal, this.props.activeWorkspace);
|
|
|
|
}
|
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleShowRequestSettingsModal (): void {
|
2017-06-16 20:29:22 +00:00
|
|
|
showModal(RequestSettingsModal, {request: this.props.activeRequest});
|
2017-03-29 23:09:28 +00:00
|
|
|
}
|
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleDeleteResponses (): void {
|
|
|
|
if (!this.props.activeRequest) {
|
|
|
|
console.warn('Tried to delete responses when request not active');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-11-27 21:42:38 +00:00
|
|
|
models.response.removeForRequest(this.props.activeRequest._id);
|
|
|
|
this._handleSetActiveResponse(null);
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-27 21:42:38 +00:00
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
async _handleDeleteResponse (response: Response): Promise<void> {
|
2017-06-12 21:48:17 +00:00
|
|
|
if (response) {
|
|
|
|
await models.response.remove(response);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Also unset active response it's the one we're deleting
|
2017-07-17 18:20:38 +00:00
|
|
|
if (this.props.activeResponse && this.props.activeResponse._id === response._id) {
|
2017-06-12 21:48:17 +00:00
|
|
|
this._handleSetActiveResponse(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
async _handleRemoveActiveWorkspace (): Promise<void> {
|
2016-11-29 20:55:31 +00:00
|
|
|
const {workspaces, activeWorkspace} = this.props;
|
|
|
|
if (workspaces.length <= 1) {
|
|
|
|
showModal(AlertModal, {
|
|
|
|
title: 'Deleting Last Workspace',
|
|
|
|
message: 'Since you deleted your only workspace, a new one has been created for you.'
|
|
|
|
});
|
|
|
|
|
|
|
|
models.workspace.create({name: 'Insomnia'});
|
|
|
|
trackEvent('Workspace', 'Delete', 'Last');
|
|
|
|
} else {
|
|
|
|
trackEvent('Workspace', 'Delete');
|
|
|
|
}
|
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
await models.workspace.remove(activeWorkspace);
|
2017-06-06 21:21:06 +00:00
|
|
|
}
|
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleSendRequestWithActiveEnvironment (): void {
|
2016-11-26 00:37:59 +00:00
|
|
|
const {activeRequest, activeEnvironment, handleSendRequestWithEnvironment} = this.props;
|
|
|
|
const activeRequestId = activeRequest ? activeRequest._id : 'n/a';
|
|
|
|
const activeEnvironmentId = activeEnvironment ? activeEnvironment._id : 'n/a';
|
|
|
|
handleSendRequestWithEnvironment(activeRequestId, activeEnvironmentId);
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-25 23:09:17 +00:00
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleSendAndDownloadRequestWithActiveEnvironment (filename: string): void {
|
2017-02-01 20:21:14 +00:00
|
|
|
const {activeRequest, activeEnvironment, handleSendAndDownloadRequestWithEnvironment} = this.props;
|
|
|
|
const activeRequestId = activeRequest ? activeRequest._id : 'n/a';
|
|
|
|
const activeEnvironmentId = activeEnvironment ? activeEnvironment._id : 'n/a';
|
|
|
|
handleSendAndDownloadRequestWithEnvironment(activeRequestId, activeEnvironmentId, filename);
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2017-02-01 20:21:14 +00:00
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleSetPreviewMode (previewMode: string): void {
|
2016-11-25 23:09:17 +00:00
|
|
|
const activeRequest = this.props.activeRequest;
|
|
|
|
const activeRequestId = activeRequest ? activeRequest._id : 'n/a';
|
|
|
|
this.props.handleSetResponsePreviewMode(activeRequestId, previewMode);
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-25 23:09:17 +00:00
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_handleSetResponseFilter (filter: string): void {
|
2016-11-25 23:09:17 +00:00
|
|
|
const activeRequest = this.props.activeRequest;
|
|
|
|
const activeRequestId = activeRequest ? activeRequest._id : 'n/a';
|
|
|
|
this.props.handleSetResponseFilter(activeRequestId, filter);
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-25 23:09:17 +00:00
|
|
|
|
2017-07-19 04:48:28 +00:00
|
|
|
_forceRequestPaneRefresh (): void {
|
2017-03-06 17:51:58 +00:00
|
|
|
this.setState({forceRefreshKey: Date.now()});
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-25 23:09:17 +00:00
|
|
|
|
|
|
|
render () {
|
|
|
|
const {
|
|
|
|
activeEnvironment,
|
2016-11-27 21:42:38 +00:00
|
|
|
activeRequest,
|
|
|
|
activeWorkspace,
|
2017-07-17 18:20:38 +00:00
|
|
|
activeRequestResponses,
|
|
|
|
activeResponse,
|
2016-11-25 23:09:17 +00:00
|
|
|
environments,
|
2016-11-27 21:42:38 +00:00
|
|
|
handleActivateRequest,
|
2016-11-25 23:09:17 +00:00
|
|
|
handleCreateRequest,
|
|
|
|
handleCreateRequestForWorkspace,
|
|
|
|
handleCreateRequestGroup,
|
2016-11-27 21:42:38 +00:00
|
|
|
handleDuplicateRequest,
|
2016-11-28 07:12:17 +00:00
|
|
|
handleDuplicateRequestGroup,
|
2016-11-25 23:09:17 +00:00
|
|
|
handleExportFile,
|
2017-06-13 20:45:15 +00:00
|
|
|
handleMoveDoc,
|
2017-03-28 22:45:23 +00:00
|
|
|
handleResetDragPaneHorizontal,
|
|
|
|
handleResetDragPaneVertical,
|
2016-11-27 21:42:38 +00:00
|
|
|
handleResetDragSidebar,
|
|
|
|
handleSetActiveEnvironment,
|
|
|
|
handleSetActiveWorkspace,
|
|
|
|
handleSetRequestGroupCollapsed,
|
2016-11-25 23:09:17 +00:00
|
|
|
handleSetRequestPaneRef,
|
|
|
|
handleSetResponsePaneRef,
|
|
|
|
handleSetSidebarRef,
|
2017-03-28 22:45:23 +00:00
|
|
|
handleStartDragPaneHorizontal,
|
|
|
|
handleStartDragPaneVertical,
|
2016-12-01 01:50:59 +00:00
|
|
|
handleSetSidebarFilter,
|
2017-05-17 16:35:44 +00:00
|
|
|
handleToggleMenuBar,
|
2017-02-13 08:12:02 +00:00
|
|
|
handleRender,
|
2017-03-12 00:31:23 +00:00
|
|
|
handleGetRenderContext,
|
2017-06-07 00:07:09 +00:00
|
|
|
handleDuplicateWorkspace,
|
2017-02-01 20:21:14 +00:00
|
|
|
handleGenerateCodeForActiveRequest,
|
2016-11-28 07:12:17 +00:00
|
|
|
handleGenerateCode,
|
2017-06-29 18:27:29 +00:00
|
|
|
handleCopyAsCurl,
|
2016-11-27 21:42:38 +00:00
|
|
|
isLoading,
|
|
|
|
loadStartTime,
|
|
|
|
paneWidth,
|
2017-03-28 22:45:23 +00:00
|
|
|
paneHeight,
|
2016-11-27 21:42:38 +00:00
|
|
|
responseFilter,
|
2017-06-08 02:42:16 +00:00
|
|
|
responseFilterHistory,
|
2016-11-27 21:42:38 +00:00
|
|
|
responsePreviewMode,
|
2017-03-23 22:10:42 +00:00
|
|
|
oAuth2Token,
|
2016-11-27 21:42:38 +00:00
|
|
|
settings,
|
2016-11-25 23:09:17 +00:00
|
|
|
sidebarChildren,
|
2016-11-27 21:42:38 +00:00
|
|
|
sidebarFilter,
|
|
|
|
sidebarHidden,
|
|
|
|
sidebarWidth,
|
|
|
|
workspaceChildren,
|
2017-07-27 22:59:07 +00:00
|
|
|
workspaces,
|
|
|
|
unseenWorkspaces
|
2016-11-25 23:09:17 +00:00
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const realSidebarWidth = sidebarHidden ? 0 : sidebarWidth;
|
2017-03-28 22:45:23 +00:00
|
|
|
|
|
|
|
const columns = `${realSidebarWidth}rem 0 minmax(0, ${paneWidth}fr) 0 minmax(0, ${1 - paneWidth}fr)`;
|
|
|
|
const rows = `minmax(0, ${paneHeight}fr) 0 minmax(0, ${1 - paneHeight}fr)`;
|
2016-11-25 23:09:17 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div id="wrapper"
|
|
|
|
className={classnames('wrapper', {'wrapper--vertical': settings.forceVerticalLayout})}
|
2017-03-28 22:45:23 +00:00
|
|
|
style={{gridTemplateColumns: columns, gridTemplateRows: rows}}>
|
2016-11-26 00:37:59 +00:00
|
|
|
|
2016-11-25 23:09:17 +00:00
|
|
|
<Sidebar
|
|
|
|
ref={handleSetSidebarRef}
|
2016-11-26 00:37:59 +00:00
|
|
|
showEnvironmentsModal={this._handleShowEnvironmentsModal}
|
|
|
|
showCookiesModal={this._handleShowCookiesModal}
|
2016-11-25 23:09:17 +00:00
|
|
|
handleActivateRequest={handleActivateRequest}
|
2016-12-01 01:50:59 +00:00
|
|
|
handleChangeFilter={handleSetSidebarFilter}
|
2016-11-25 23:09:17 +00:00
|
|
|
handleImportFile={this._handleImportFile}
|
|
|
|
handleExportFile={handleExportFile}
|
|
|
|
handleSetActiveWorkspace={handleSetActiveWorkspace}
|
2016-11-27 21:42:38 +00:00
|
|
|
handleDuplicateRequest={handleDuplicateRequest}
|
2016-11-28 07:12:17 +00:00
|
|
|
handleGenerateCode={handleGenerateCode}
|
2017-06-29 18:27:29 +00:00
|
|
|
handleCopyAsCurl={handleCopyAsCurl}
|
2016-11-28 07:12:17 +00:00
|
|
|
handleDuplicateRequestGroup={handleDuplicateRequestGroup}
|
2016-11-25 23:09:17 +00:00
|
|
|
handleSetActiveEnvironment={handleSetActiveEnvironment}
|
2017-06-13 20:45:15 +00:00
|
|
|
moveDoc={handleMoveDoc}
|
2016-11-25 23:09:17 +00:00
|
|
|
handleSetRequestGroupCollapsed={handleSetRequestGroupCollapsed}
|
|
|
|
activeRequest={activeRequest}
|
|
|
|
activeEnvironment={activeEnvironment}
|
|
|
|
handleCreateRequest={handleCreateRequest}
|
|
|
|
handleCreateRequestGroup={handleCreateRequestGroup}
|
|
|
|
filter={sidebarFilter || ''}
|
|
|
|
hidden={sidebarHidden || false}
|
|
|
|
workspace={activeWorkspace}
|
2017-07-27 22:59:07 +00:00
|
|
|
unseenWorkspaces={unseenWorkspaces}
|
2017-03-08 05:52:17 +00:00
|
|
|
childObjects={sidebarChildren}
|
2016-11-25 23:09:17 +00:00
|
|
|
width={sidebarWidth}
|
|
|
|
isLoading={isLoading}
|
|
|
|
workspaces={workspaces}
|
|
|
|
environments={environments}
|
2016-11-16 17:18:39 +00:00
|
|
|
/>
|
|
|
|
|
2016-11-25 23:09:17 +00:00
|
|
|
<div className="drag drag--sidebar">
|
2017-03-06 17:51:58 +00:00
|
|
|
<div onDoubleClick={handleResetDragSidebar} onMouseDown={this._handleStartDragSidebar}>
|
|
|
|
</div>
|
2016-11-25 23:09:17 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<RequestPane
|
|
|
|
ref={handleSetRequestPaneRef}
|
|
|
|
handleImportFile={this._handleImportFile}
|
|
|
|
request={activeRequest}
|
|
|
|
showPasswords={settings.showPasswords}
|
|
|
|
useBulkHeaderEditor={settings.useBulkHeaderEditor}
|
|
|
|
editorFontSize={settings.editorFontSize}
|
2017-04-14 21:47:15 +00:00
|
|
|
editorIndentSize={settings.editorIndentSize}
|
2017-01-24 22:18:11 +00:00
|
|
|
editorKeyMap={settings.editorKeyMap}
|
2016-11-25 23:09:17 +00:00
|
|
|
editorLineWrapping={settings.editorLineWrapping}
|
2016-11-29 20:55:31 +00:00
|
|
|
workspace={activeWorkspace}
|
2017-03-23 22:10:42 +00:00
|
|
|
oAuth2Token={oAuth2Token}
|
2017-02-02 18:30:13 +00:00
|
|
|
forceUpdateRequest={this._handleForceUpdateRequest}
|
2016-11-25 23:09:17 +00:00
|
|
|
handleCreateRequest={handleCreateRequestForWorkspace}
|
2017-02-01 20:21:14 +00:00
|
|
|
handleGenerateCode={handleGenerateCodeForActiveRequest}
|
2017-02-02 18:30:13 +00:00
|
|
|
handleImport={this._handleImport}
|
2017-02-13 08:12:02 +00:00
|
|
|
handleRender={handleRender}
|
2017-03-12 00:31:23 +00:00
|
|
|
handleGetRenderContext={handleGetRenderContext}
|
2016-11-26 00:37:59 +00:00
|
|
|
updateRequestBody={this._handleUpdateRequestBody}
|
|
|
|
updateRequestUrl={this._handleUpdateRequestUrl}
|
|
|
|
updateRequestMethod={this._handleUpdateRequestMethod}
|
|
|
|
updateRequestParameters={this._handleUpdateRequestParameters}
|
|
|
|
updateRequestAuthentication={this._handleUpdateRequestAuthentication}
|
|
|
|
updateRequestHeaders={this._handleUpdateRequestHeaders}
|
|
|
|
updateRequestMimeType={this._handleUpdateRequestMimeType}
|
|
|
|
updateSettingsShowPasswords={this._handleUpdateSettingsShowPasswords}
|
|
|
|
updateSettingsUseBulkHeaderEditor={this._handleUpdateSettingsUseBulkHeaderEditor}
|
2017-03-06 17:51:58 +00:00
|
|
|
forceRefreshCounter={this.state.forceRefreshKey}
|
2016-11-26 00:37:59 +00:00
|
|
|
handleSend={this._handleSendRequestWithActiveEnvironment}
|
2017-02-01 20:21:14 +00:00
|
|
|
handleSendAndDownload={this._handleSendAndDownloadRequestWithActiveEnvironment}
|
2016-11-25 23:09:17 +00:00
|
|
|
/>
|
|
|
|
|
2017-03-28 22:45:23 +00:00
|
|
|
<div className="drag drag--pane-horizontal">
|
|
|
|
<div
|
|
|
|
onMouseDown={handleStartDragPaneHorizontal}
|
|
|
|
onDoubleClick={handleResetDragPaneHorizontal}>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="drag drag--pane-vertical">
|
|
|
|
<div
|
|
|
|
onMouseDown={handleStartDragPaneVertical}
|
|
|
|
onDoubleClick={handleResetDragPaneVertical}>
|
2017-03-06 17:51:58 +00:00
|
|
|
</div>
|
2016-11-25 23:09:17 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<ResponsePane
|
|
|
|
ref={handleSetResponsePaneRef}
|
|
|
|
request={activeRequest}
|
2017-07-17 18:20:38 +00:00
|
|
|
responses={activeRequestResponses}
|
|
|
|
response={activeResponse}
|
2016-11-25 23:09:17 +00:00
|
|
|
editorFontSize={settings.editorFontSize}
|
2017-04-14 21:47:15 +00:00
|
|
|
editorIndentSize={settings.editorIndentSize}
|
2017-01-24 22:18:11 +00:00
|
|
|
editorKeyMap={settings.editorKeyMap}
|
2016-11-25 23:09:17 +00:00
|
|
|
editorLineWrapping={settings.editorLineWrapping}
|
|
|
|
previewMode={responsePreviewMode}
|
|
|
|
filter={responseFilter}
|
2017-06-08 02:42:16 +00:00
|
|
|
filterHistory={responseFilterHistory}
|
2016-11-25 23:09:17 +00:00
|
|
|
loadStartTime={loadStartTime}
|
|
|
|
showCookiesModal={this._handleShowCookiesModal}
|
2017-03-29 23:09:28 +00:00
|
|
|
handleShowRequestSettings={this._handleShowRequestSettingsModal}
|
2016-11-27 21:42:38 +00:00
|
|
|
handleSetActiveResponse={this._handleSetActiveResponse}
|
2016-11-25 23:09:17 +00:00
|
|
|
handleSetPreviewMode={this._handleSetPreviewMode}
|
2016-11-27 21:42:38 +00:00
|
|
|
handleDeleteResponses={this._handleDeleteResponses}
|
2017-06-12 21:48:17 +00:00
|
|
|
handleDeleteResponse={this._handleDeleteResponse}
|
2016-11-25 23:09:17 +00:00
|
|
|
handleSetFilter={this._handleSetResponseFilter}
|
|
|
|
/>
|
2016-11-16 17:18:39 +00:00
|
|
|
|
2017-03-08 05:52:17 +00:00
|
|
|
<div className="modals">
|
|
|
|
<AlertModal ref={registerModal}/>
|
|
|
|
<ChangelogModal ref={registerModal}/>
|
|
|
|
<LoginModal ref={registerModal}/>
|
|
|
|
<PromptModal ref={registerModal}/>
|
2017-07-03 20:51:55 +00:00
|
|
|
<AskModal ref={registerModal}/>
|
2017-03-08 05:52:17 +00:00
|
|
|
<RequestCreateModal ref={registerModal}/>
|
|
|
|
<PaymentNotificationModal ref={registerModal}/>
|
2017-03-12 00:31:23 +00:00
|
|
|
<FilterHelpModal ref={registerModal}/>
|
2017-03-28 22:45:23 +00:00
|
|
|
<RequestRenderErrorModal ref={registerModal}/>
|
2017-06-01 22:58:09 +00:00
|
|
|
|
2017-06-09 21:42:19 +00:00
|
|
|
<CodePromptModal
|
|
|
|
ref={registerModal}
|
|
|
|
handleRender={handleRender}
|
|
|
|
handleGetRenderContext={handleGetRenderContext}
|
|
|
|
editorFontSize={settings.editorFontSize}
|
|
|
|
editorIndentSize={settings.editorIndentSize}
|
|
|
|
editorKeyMap={settings.editorKeyMap}
|
|
|
|
editorLineWrapping={settings.editorLineWrapping}
|
|
|
|
/>
|
|
|
|
|
2017-06-01 22:58:09 +00:00
|
|
|
<RequestSettingsModal
|
|
|
|
ref={registerModal}
|
|
|
|
editorFontSize={settings.editorFontSize}
|
|
|
|
editorIndentSize={settings.editorIndentSize}
|
|
|
|
editorKeyMap={settings.editorKeyMap}
|
|
|
|
editorLineWrapping={settings.editorLineWrapping}
|
|
|
|
handleRender={handleRender}
|
|
|
|
handleGetRenderContext={handleGetRenderContext}
|
|
|
|
/>
|
|
|
|
|
2017-03-12 00:31:23 +00:00
|
|
|
<CookiesModal
|
|
|
|
ref={registerModal}
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
/>
|
2017-03-09 06:23:23 +00:00
|
|
|
<NunjucksModal
|
2017-03-31 21:59:12 +00:00
|
|
|
uniqueKey={`key::${this.state.forceRefreshKey}`}
|
2017-03-08 05:52:17 +00:00
|
|
|
ref={registerModal}
|
|
|
|
handleRender={handleRender}
|
2017-03-12 00:31:23 +00:00
|
|
|
handleGetRenderContext={handleGetRenderContext}
|
2017-05-23 22:05:31 +00:00
|
|
|
workspace={activeWorkspace}
|
2017-03-08 05:52:17 +00:00
|
|
|
/>
|
|
|
|
<WorkspaceSettingsModal
|
|
|
|
ref={registerModal}
|
|
|
|
workspace={activeWorkspace}
|
2017-06-01 22:58:09 +00:00
|
|
|
editorFontSize={settings.editorFontSize}
|
|
|
|
editorIndentSize={settings.editorIndentSize}
|
|
|
|
editorKeyMap={settings.editorKeyMap}
|
|
|
|
editorLineWrapping={settings.editorLineWrapping}
|
|
|
|
handleRender={handleRender}
|
|
|
|
handleGetRenderContext={handleGetRenderContext}
|
2017-06-06 21:21:06 +00:00
|
|
|
handleRemoveWorkspace={this._handleRemoveActiveWorkspace}
|
2017-06-07 00:07:09 +00:00
|
|
|
handleDuplicateWorkspace={handleDuplicateWorkspace}
|
2017-06-06 21:21:06 +00:00
|
|
|
/>
|
2017-03-08 05:52:17 +00:00
|
|
|
<WorkspaceShareSettingsModal
|
|
|
|
ref={registerModal}
|
2017-06-06 21:21:06 +00:00
|
|
|
workspace={activeWorkspace}
|
|
|
|
/>
|
2017-03-08 05:52:17 +00:00
|
|
|
<GenerateCodeModal
|
|
|
|
ref={registerModal}
|
|
|
|
environmentId={activeEnvironment ? activeEnvironment._id : 'n/a'}
|
|
|
|
editorFontSize={settings.editorFontSize}
|
2017-04-14 21:47:15 +00:00
|
|
|
editorIndentSize={settings.editorIndentSize}
|
2017-03-08 05:52:17 +00:00
|
|
|
editorKeyMap={settings.editorKeyMap}
|
|
|
|
/>
|
|
|
|
<SettingsModal
|
|
|
|
ref={registerModal}
|
|
|
|
handleExportWorkspaceToFile={this._handleExportWorkspaceToFile}
|
|
|
|
handleExportAllToFile={handleExportFile}
|
|
|
|
handleImportFile={this._handleImportFile}
|
2017-05-03 17:48:23 +00:00
|
|
|
handleImportUri={this._handleImportUri}
|
2017-05-17 16:35:44 +00:00
|
|
|
handleToggleMenuBar={handleToggleMenuBar}
|
2017-03-08 05:52:17 +00:00
|
|
|
settings={settings}
|
|
|
|
/>
|
|
|
|
<RequestSwitcherModal
|
|
|
|
ref={registerModal}
|
|
|
|
workspaces={workspaces}
|
|
|
|
workspaceChildren={workspaceChildren}
|
|
|
|
workspaceId={activeWorkspace._id}
|
|
|
|
activeRequestParentId={activeRequest ? activeRequest.parentId : activeWorkspace._id}
|
|
|
|
activateRequest={handleActivateRequest}
|
|
|
|
handleSetActiveWorkspace={handleSetActiveWorkspace}
|
|
|
|
/>
|
|
|
|
<EnvironmentEditModal
|
|
|
|
ref={registerModal}
|
|
|
|
editorFontSize={settings.editorFontSize}
|
2017-04-14 21:47:15 +00:00
|
|
|
editorIndentSize={settings.editorIndentSize}
|
2017-03-08 05:52:17 +00:00
|
|
|
editorKeyMap={settings.editorKeyMap}
|
|
|
|
lineWrapping={settings.editorLineWrapping}
|
|
|
|
onChange={models.requestGroup.update}
|
|
|
|
render={handleRender}
|
2017-03-12 00:31:23 +00:00
|
|
|
getRenderContext={handleGetRenderContext}
|
2017-03-08 05:52:17 +00:00
|
|
|
/>
|
|
|
|
<SetupSyncModal
|
|
|
|
ref={registerModal}
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
/>
|
|
|
|
<WorkspaceEnvironmentsEditModal
|
|
|
|
ref={registerModal}
|
|
|
|
onChange={models.workspace.update}
|
|
|
|
lineWrapping={settings.editorLineWrapping}
|
|
|
|
editorFontSize={settings.editorFontSize}
|
2017-04-14 21:47:15 +00:00
|
|
|
editorIndentSize={settings.editorIndentSize}
|
2017-03-08 05:52:17 +00:00
|
|
|
editorKeyMap={settings.editorKeyMap}
|
|
|
|
render={handleRender}
|
2017-03-12 00:31:23 +00:00
|
|
|
getRenderContext={handleGetRenderContext}
|
2017-03-08 05:52:17 +00:00
|
|
|
/>
|
|
|
|
</div>
|
2016-11-25 23:09:17 +00:00
|
|
|
</div>
|
2017-03-03 20:09:08 +00:00
|
|
|
);
|
2016-11-25 23:09:17 +00:00
|
|
|
}
|
|
|
|
}
|
2016-11-16 17:18:39 +00:00
|
|
|
|
|
|
|
export default Wrapper;
|