2017-07-19 04:48:28 +00:00
|
|
|
// @flow
|
2018-06-25 17:42:50 +00:00
|
|
|
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';
|
2020-04-26 20:33:39 +00:00
|
|
|
import type { WorkspaceMeta } from '../../models/workspace-meta';
|
2018-06-25 17:42:50 +00:00
|
|
|
import type {
|
|
|
|
Request,
|
|
|
|
RequestAuthentication,
|
|
|
|
RequestBody,
|
|
|
|
RequestHeader,
|
2018-12-12 17:36:11 +00:00
|
|
|
RequestParameter,
|
2018-06-25 17:42:50 +00:00
|
|
|
} from '../../models/request';
|
2019-05-07 14:46:35 +00:00
|
|
|
import type { SidebarChildObjects } from './sidebar/sidebar-children';
|
2017-09-25 21:32:58 +00:00
|
|
|
import * as React from 'react';
|
2017-03-03 01:44:07 +00:00
|
|
|
import autobind from 'autobind-decorator';
|
2018-06-25 17:42:50 +00:00
|
|
|
import { registerModal, showModal } from './modals/index';
|
2017-03-08 05:52:17 +00:00
|
|
|
import AlertModal from './modals/alert-modal';
|
2017-11-13 01:18:27 +00:00
|
|
|
import WrapperModal from './modals/wrapper-modal';
|
2017-09-17 14:04:46 +00:00
|
|
|
import ErrorModal from './modals/error-modal';
|
2017-03-08 05:52:17 +00:00
|
|
|
import CookiesModal from './modals/cookies-modal';
|
2017-08-19 22:34:16 +00:00
|
|
|
import CookieModifyModal from '../components/modals/cookie-modify-modal';
|
2017-03-08 05:52:17 +00:00
|
|
|
import EnvironmentEditModal from './modals/environment-edit-modal';
|
|
|
|
import GenerateCodeModal from './modals/generate-code-modal';
|
|
|
|
import LoginModal from './modals/login-modal';
|
2018-07-01 20:18:18 +00:00
|
|
|
import ResponseDebugModal from './modals/response-debug-modal';
|
2017-03-08 05:52:17 +00:00
|
|
|
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';
|
2020-04-26 20:33:39 +00:00
|
|
|
import GenerateConfigModal from './modals/generate-config-modal';
|
2017-11-01 12:40:24 +00:00
|
|
|
import SelectModal from './modals/select-modal';
|
2017-03-08 05:52:17 +00:00
|
|
|
import RequestCreateModal from './modals/request-create-modal';
|
|
|
|
import RequestSwitcherModal from './modals/request-switcher-modal';
|
|
|
|
import SettingsModal from './modals/settings-modal';
|
2017-03-12 00:31:23 +00:00
|
|
|
import FilterHelpModal from './modals/filter-help-modal';
|
2017-03-28 22:45:23 +00:00
|
|
|
import RequestSettingsModal from './modals/request-settings-modal';
|
2019-04-18 00:50:03 +00:00
|
|
|
import SyncStagingModal from './modals/sync-staging-modal';
|
2020-04-26 20:33:39 +00:00
|
|
|
import GitRepositorySettingsModal from './modals/git-repository-settings-modal';
|
|
|
|
import GitStagingModal from './modals/git-staging-modal';
|
|
|
|
import GitBranchesModal from './modals/git-branches-modal';
|
|
|
|
import GitLogModal from './modals/git-log-modal';
|
2019-04-18 00:50:03 +00:00
|
|
|
import SyncMergeModal from './modals/sync-merge-modal';
|
|
|
|
import SyncHistoryModal from './modals/sync-history-modal';
|
|
|
|
import SyncShareModal from './modals/sync-share-modal';
|
|
|
|
import SyncBranchesModal from './modals/sync-branches-modal';
|
2020-11-09 22:56:13 +00:00
|
|
|
import SyncDeleteModal from './modals/sync-delete-modal';
|
2017-03-28 22:45:23 +00:00
|
|
|
import RequestRenderErrorModal from './modals/request-render-error-modal';
|
2017-03-08 05:52:17 +00:00
|
|
|
import WorkspaceEnvironmentsEditModal from './modals/workspace-environments-edit-modal';
|
|
|
|
import WorkspaceSettingsModal from './modals/workspace-settings-modal';
|
2017-06-09 21:42:19 +00:00
|
|
|
import CodePromptModal from './modals/code-prompt-modal';
|
2019-01-21 16:29:30 +00:00
|
|
|
import * as db from '../../common/database';
|
2016-11-16 17:18:39 +00:00
|
|
|
import * as models from '../../models/index';
|
2016-11-26 00:37:59 +00:00
|
|
|
import * as importers from 'insomnia-importers';
|
2018-06-25 17:42:50 +00:00
|
|
|
import type { CookieJar } from '../../models/cookie-jar';
|
|
|
|
import type { Environment } from '../../models/environment';
|
2017-10-13 13:01:27 +00:00
|
|
|
import ErrorBoundary from './error-boundary';
|
2018-06-25 17:42:50 +00:00
|
|
|
import type { ClientCertificate } from '../../models/client-certificate';
|
2018-03-29 13:57:24 +00:00
|
|
|
import MoveRequestGroupModal from './modals/move-request-group-modal';
|
2019-02-08 18:20:24 +00:00
|
|
|
import AddKeyCombinationModal from './modals/add-key-combination-modal';
|
2019-02-27 15:01:51 +00:00
|
|
|
import ExportRequestsModal from './modals/export-requests-modal';
|
2019-04-18 00:50:03 +00:00
|
|
|
import VCS from '../../sync/vcs';
|
|
|
|
import type { StatusCandidate } from '../../sync/types';
|
2019-05-10 01:18:34 +00:00
|
|
|
import type { RequestMeta } from '../../models/request-meta';
|
2019-06-07 15:25:02 +00:00
|
|
|
import type { RequestVersion } from '../../models/request-version';
|
2020-04-26 20:33:39 +00:00
|
|
|
import type { ApiSpec } from '../../models/api-spec';
|
|
|
|
import GitVCS from '../../sync/git/git-vcs';
|
|
|
|
import { trackPageView } from '../../common/analytics';
|
|
|
|
import type { GitRepository } from '../../models/git-repository';
|
|
|
|
import WrapperHome from './wrapper-home';
|
|
|
|
import WrapperDesign from './wrapper-design';
|
2020-07-01 21:17:14 +00:00
|
|
|
import WrapperUnitTest from './wrapper-unit-test';
|
2020-04-26 20:33:39 +00:00
|
|
|
import WrapperOnboarding from './wrapper-onboarding';
|
|
|
|
import WrapperDebug from './wrapper-debug';
|
|
|
|
import { importRaw } from '../../common/import';
|
|
|
|
import GitSyncDropdown from './dropdowns/git-sync-dropdown';
|
|
|
|
import { DropdownButton } from './base/dropdown';
|
|
|
|
import type { ForceToWorkspace } from '../redux/modules/helpers';
|
2020-07-01 21:17:14 +00:00
|
|
|
import type { UnitTest } from '../../models/unit-test';
|
|
|
|
import type { UnitTestResult } from '../../models/unit-test-result';
|
|
|
|
import type { UnitTestSuite } from '../../models/unit-test-suite';
|
|
|
|
import type { GlobalActivity } from '../../common/constants';
|
2020-06-30 23:54:56 +00:00
|
|
|
import {
|
|
|
|
ACTIVITY_DEBUG,
|
|
|
|
ACTIVITY_HOME,
|
|
|
|
ACTIVITY_INSOMNIA,
|
|
|
|
ACTIVITY_SPEC,
|
2020-07-01 21:17:14 +00:00
|
|
|
ACTIVITY_UNIT_TEST,
|
2020-06-30 23:54:56 +00:00
|
|
|
getAppName,
|
2020-12-01 00:37:57 +00:00
|
|
|
SortOrder,
|
2020-06-30 23:54:56 +00:00
|
|
|
} from '../../common/constants';
|
|
|
|
import { Spectral } from '@stoplight/spectral';
|
2020-10-22 19:14:46 +00:00
|
|
|
import ProtoFilesModal from './modals/proto-files-modal';
|
2020-11-16 22:01:50 +00:00
|
|
|
import { GrpcDispatchModalWrapper } from '../context/grpc';
|
2020-06-30 23:54:56 +00:00
|
|
|
|
|
|
|
const spectral = new Spectral();
|
2020-04-26 20:33:39 +00:00
|
|
|
|
|
|
|
export type WrapperProps = {
|
2017-09-25 21:32:58 +00:00
|
|
|
// Helper Functions
|
|
|
|
handleActivateRequest: Function,
|
|
|
|
handleSetSidebarFilter: Function,
|
|
|
|
handleToggleMenuBar: Function,
|
2020-04-26 20:33:39 +00:00
|
|
|
handleImportFileToWorkspace: (workspaceId: string, forceToWorkspace?: ForceToWorkspace) => void,
|
|
|
|
handleImportClipBoardToWorkspace: (
|
|
|
|
workspaceId: string,
|
|
|
|
forceToWorkspace?: ForceToWorkspace,
|
|
|
|
) => void,
|
|
|
|
handleImportUriToWorkspace: (
|
|
|
|
workspaceId: string,
|
|
|
|
uri: string,
|
|
|
|
forceToWorkspace?: ForceToWorkspace,
|
|
|
|
) => void,
|
2020-06-03 05:32:36 +00:00
|
|
|
handleInitializeEntities: () => Promise<void>,
|
2017-09-25 21:32:58 +00:00
|
|
|
handleExportFile: Function,
|
2019-03-05 06:53:45 +00:00
|
|
|
handleShowExportRequestsModal: Function,
|
2020-04-26 20:33:39 +00:00
|
|
|
handleShowSettingsModal: Function,
|
2019-02-27 15:01:51 +00:00
|
|
|
handleExportRequestsToFile: Function,
|
2020-06-08 22:32:49 +00:00
|
|
|
handleSetActiveWorkspace: (workspaceId: string | null) => void,
|
2017-09-25 21:32:58 +00:00
|
|
|
handleSetActiveEnvironment: Function,
|
|
|
|
handleMoveDoc: Function,
|
|
|
|
handleCreateRequest: Function,
|
|
|
|
handleDuplicateRequest: Function,
|
|
|
|
handleDuplicateRequestGroup: Function,
|
2018-03-29 13:57:24 +00:00
|
|
|
handleMoveRequestGroup: Function,
|
2017-09-25 21:32:58 +00:00
|
|
|
handleDuplicateWorkspace: Function,
|
2020-04-28 18:29:51 +00:00
|
|
|
handleDuplicateWorkspaceById: (onComplete: () => void, workspaceId: string) => void,
|
|
|
|
handleRenameWorkspaceById: (onComplete: () => void, workspaceId: string) => void,
|
|
|
|
handleDeleteWorkspaceById: (onComplete: () => void, workspaceId: string) => void,
|
2017-09-25 21:32:58 +00:00
|
|
|
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,
|
2020-12-01 00:37:57 +00:00
|
|
|
handleSidebarSort: (sortOrder: SortOrder) => void,
|
2017-09-25 21:32:58 +00:00
|
|
|
handleStartDragSidebar: Function,
|
|
|
|
handleResetDragSidebar: Function,
|
|
|
|
handleStartDragPaneHorizontal: Function,
|
|
|
|
handleStartDragPaneVertical: Function,
|
|
|
|
handleResetDragPaneHorizontal: Function,
|
|
|
|
handleResetDragPaneVertical: Function,
|
|
|
|
handleSetRequestGroupCollapsed: Function,
|
2019-05-07 14:46:35 +00:00
|
|
|
handleSetRequestPinned: Function,
|
2017-09-25 21:32:58 +00:00
|
|
|
handleSendRequestWithEnvironment: Function,
|
|
|
|
handleSendAndDownloadRequestWithEnvironment: Function,
|
2018-02-16 16:24:54 +00:00
|
|
|
handleUpdateRequestMimeType: Function,
|
2019-06-03 18:45:22 +00:00
|
|
|
handleUpdateDownloadPath: Function,
|
2020-04-26 20:33:39 +00:00
|
|
|
handleSetActiveActivity: (activity: GlobalActivity) => void,
|
2017-09-25 21:32:58 +00:00
|
|
|
|
|
|
|
// Properties
|
2020-04-26 20:33:39 +00:00
|
|
|
activity: GlobalActivity,
|
|
|
|
apiSpecs: Array<ApiSpec>,
|
2017-09-25 21:32:58 +00:00
|
|
|
loadStartTime: number,
|
|
|
|
isLoading: boolean,
|
|
|
|
paneWidth: number,
|
|
|
|
paneHeight: number,
|
|
|
|
responsePreviewMode: string,
|
|
|
|
responseFilter: string,
|
|
|
|
responseFilterHistory: Array<string>,
|
2019-06-03 18:45:22 +00:00
|
|
|
responseDownloadPath: string | null,
|
2017-09-25 21:32:58 +00:00
|
|
|
sidebarWidth: number,
|
|
|
|
sidebarHidden: boolean,
|
|
|
|
sidebarFilter: string,
|
2019-05-07 14:46:35 +00:00
|
|
|
sidebarChildren: SidebarChildObjects,
|
2017-09-25 21:32:58 +00:00
|
|
|
settings: Settings,
|
|
|
|
workspaces: Array<Workspace>,
|
2019-05-10 01:18:34 +00:00
|
|
|
requestMetas: Array<RequestMeta>,
|
|
|
|
requests: Array<Request>,
|
2019-06-07 15:25:02 +00:00
|
|
|
requestVersions: Array<RequestVersion>,
|
2017-09-25 21:32:58 +00:00
|
|
|
unseenWorkspaces: Array<Workspace>,
|
|
|
|
workspaceChildren: Array<Object>,
|
2020-04-26 20:33:39 +00:00
|
|
|
activeWorkspaceMeta: WorkspaceMeta,
|
2017-09-25 21:32:58 +00:00
|
|
|
environments: Array<Object>,
|
2020-04-26 20:33:39 +00:00
|
|
|
activeApiSpec: ApiSpec,
|
2017-09-25 21:32:58 +00:00
|
|
|
activeRequestResponses: Array<Response>,
|
|
|
|
activeWorkspace: Workspace,
|
|
|
|
activeCookieJar: CookieJar,
|
|
|
|
activeEnvironment: Environment | null,
|
2020-04-26 20:33:39 +00:00
|
|
|
activeGitRepository: GitRepository | null,
|
2020-07-01 21:17:14 +00:00
|
|
|
activeUnitTestResult: UnitTestResult | null,
|
|
|
|
activeUnitTestSuites: Array<UnitTestSuite>,
|
|
|
|
activeUnitTests: Array<UnitTest>,
|
2017-10-31 18:05:35 +00:00
|
|
|
activeWorkspaceClientCertificates: Array<ClientCertificate>,
|
2019-05-08 20:31:54 +00:00
|
|
|
headerEditorKey: string,
|
2020-07-01 21:17:14 +00:00
|
|
|
isVariableUncovered: boolean,
|
2019-04-18 00:50:03 +00:00
|
|
|
vcs: VCS | null,
|
2020-04-26 20:33:39 +00:00
|
|
|
gitVCS: GitVCS | null,
|
|
|
|
gitRepositories: Array<GitRepository>,
|
2019-04-18 00:50:03 +00:00
|
|
|
syncItems: Array<StatusCandidate>,
|
2017-09-25 21:32:58 +00:00
|
|
|
|
|
|
|
// Optional
|
2019-08-02 19:01:01 +00:00
|
|
|
oAuth2Token: OAuth2Token | null,
|
|
|
|
activeRequest: Request | null,
|
|
|
|
activeResponse: Response | null,
|
2017-09-25 21:32:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
type State = {
|
2018-12-12 17:36:11 +00:00
|
|
|
forceRefreshKey: number,
|
2020-06-03 05:32:36 +00:00
|
|
|
activeGitBranch: string,
|
2017-09-25 21:32:58 +00:00
|
|
|
};
|
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
|
2020-04-26 20:33:39 +00:00
|
|
|
class Wrapper extends React.PureComponent<WrapperProps, State> {
|
2018-06-25 17:42:50 +00:00
|
|
|
constructor(props: any) {
|
2017-03-03 01:44:07 +00:00
|
|
|
super(props);
|
|
|
|
this.state = {
|
2018-12-12 17:36:11 +00:00
|
|
|
forceRefreshKey: Date.now(),
|
2020-06-03 05:32:36 +00:00
|
|
|
activeGitBranch: 'no-vcs',
|
2017-03-03 01:44:07 +00:00
|
|
|
};
|
|
|
|
}
|
2016-11-26 00:37:59 +00:00
|
|
|
|
|
|
|
// Request updaters
|
2018-12-14 23:10:57 +00:00
|
|
|
async _handleForceUpdateRequest(r: Request, patch: Object): Promise<Request> {
|
|
|
|
const newRequest = await rUpdate(r, 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.
|
2018-12-14 23:10:57 +00:00
|
|
|
// TODO: Move this refresh key into redux store so we don't need timeout
|
2017-02-28 21:32:23 +00:00
|
|
|
window.setTimeout(this._forceRequestPaneRefresh, 100);
|
|
|
|
|
2017-02-02 18:30:13 +00:00
|
|
|
return newRequest;
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2018-12-14 23:10:57 +00:00
|
|
|
_handleForceUpdateRequestHeaders(r: Request, headers: Array<RequestHeader>): Promise<Request> {
|
|
|
|
return this._handleForceUpdateRequest(r, { headers });
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-28 07:12:17 +00:00
|
|
|
|
2020-06-03 05:32:36 +00:00
|
|
|
async _handleUpdateApiSpec(s: ApiSpec): Promise<void> {
|
2020-04-26 20:33:39 +00:00
|
|
|
await models.apiSpec.update(s);
|
|
|
|
}
|
|
|
|
|
2018-12-14 23:10:57 +00:00
|
|
|
static _handleUpdateRequestBody(r: Request, body: RequestBody): Promise<Request> {
|
|
|
|
return rUpdate(r, { body });
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2018-12-14 23:10:57 +00:00
|
|
|
static _handleUpdateRequestParameters(
|
|
|
|
r: Request,
|
|
|
|
parameters: Array<RequestParameter>,
|
|
|
|
): Promise<Request> {
|
|
|
|
return rUpdate(r, { parameters });
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2018-12-14 23:10:57 +00:00
|
|
|
static _handleUpdateRequestAuthentication(
|
|
|
|
r: Request,
|
|
|
|
authentication: RequestAuthentication,
|
|
|
|
): Promise<Request> {
|
|
|
|
return rUpdate(r, { authentication });
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2018-12-14 23:10:57 +00:00
|
|
|
static _handleUpdateRequestHeaders(r: Request, headers: Array<RequestHeader>): Promise<Request> {
|
|
|
|
return rUpdate(r, { headers });
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2018-12-14 23:10:57 +00:00
|
|
|
static _handleUpdateRequestMethod(r: Request, method: string): Promise<Request> {
|
|
|
|
return rUpdate(r, { method });
|
2017-11-10 15:50:33 +00:00
|
|
|
}
|
|
|
|
|
2018-12-14 23:10:57 +00:00
|
|
|
static _handleUpdateRequestUrl(r: Request, url: string): Promise<Request> {
|
2019-04-18 00:50:03 +00:00
|
|
|
// Don't update if we don't need to
|
|
|
|
if (r.url === url) {
|
|
|
|
return Promise.resolve(r);
|
|
|
|
}
|
|
|
|
|
2018-12-14 23:10:57 +00:00
|
|
|
return rUpdate(r, { url });
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-26 00:37:59 +00:00
|
|
|
|
2018-06-25 17:42:50 +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 {
|
2018-06-25 17:42:50 +00:00
|
|
|
const { data } = await importers.convert(text);
|
|
|
|
const { resources } = data;
|
2016-11-26 00:37:59 +00:00
|
|
|
const r = resources[0];
|
|
|
|
|
2018-12-14 23:10:57 +00:00
|
|
|
if (r && r._type === 'request' && this.props.activeRequest) {
|
2016-11-26 00:37:59 +00:00
|
|
|
// Only pull fields that we want to update
|
2018-12-14 23:10:57 +00:00
|
|
|
return this._handleForceUpdateRequest(this.props.activeRequest, {
|
2016-11-26 00:37:59 +00:00
|
|
|
url: r.url,
|
|
|
|
method: r.method,
|
|
|
|
headers: r.headers,
|
|
|
|
body: r.body,
|
|
|
|
authentication: r.authentication,
|
2018-12-12 17:36:11 +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
|
|
|
|
2020-06-30 23:54:56 +00:00
|
|
|
async _handleWorkspaceActivityChange(workspaceId: string, nextActivity: GlobalActivity) {
|
|
|
|
const { activity, activeApiSpec, handleSetActiveActivity } = this.props;
|
2020-04-26 20:33:39 +00:00
|
|
|
|
2020-06-30 23:54:56 +00:00
|
|
|
// Remember last activity on workspace for later, but only if it isn't HOME
|
|
|
|
if (nextActivity !== ACTIVITY_HOME) {
|
|
|
|
await models.workspaceMeta.updateByParentId(workspaceId, { activeActivity: nextActivity });
|
|
|
|
}
|
|
|
|
|
2020-07-01 21:17:14 +00:00
|
|
|
const notEditingASpec = activity !== ACTIVITY_SPEC;
|
|
|
|
if (notEditingASpec) {
|
2020-06-30 23:54:56 +00:00
|
|
|
handleSetActiveActivity(nextActivity);
|
|
|
|
return;
|
|
|
|
}
|
2020-04-26 20:33:39 +00:00
|
|
|
|
2020-06-30 23:54:56 +00:00
|
|
|
// Handle switching away from the spec design activity. For this, we want to generate
|
|
|
|
// requests that can be accessed from debug or test.
|
2020-04-26 20:33:39 +00:00
|
|
|
|
2020-06-30 23:54:56 +00:00
|
|
|
// If there are errors in the spec, show the user a warning first
|
|
|
|
const results = await spectral.run(activeApiSpec.contents);
|
|
|
|
if (activeApiSpec.contents && results && results.length) {
|
|
|
|
showModal(AlertModal, {
|
|
|
|
title: 'Error Generating Configuration',
|
|
|
|
message:
|
|
|
|
'Some requests may not be available due to errors found in the ' +
|
|
|
|
'specification. We recommend fixing errors before proceeding. 🤗',
|
|
|
|
okLabel: 'Proceed',
|
|
|
|
addCancel: true,
|
|
|
|
onConfirm: () => {
|
|
|
|
handleSetActiveActivity(nextActivity);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delaying generation so design to debug mode is smooth
|
|
|
|
handleSetActiveActivity(nextActivity);
|
2020-04-26 20:33:39 +00:00
|
|
|
setTimeout(() => {
|
2020-06-30 23:54:56 +00:00
|
|
|
importRaw(() => Promise.resolve(workspaceId), activeApiSpec.contents);
|
2020-04-26 20:33:39 +00:00
|
|
|
}, 1000);
|
|
|
|
}
|
|
|
|
|
2016-11-26 00:37:59 +00:00
|
|
|
// Settings updaters
|
2018-10-17 16:42:33 +00:00
|
|
|
_handleUpdateSettingsShowPasswords(showPasswords: boolean): Promise<Settings> {
|
2018-06-25 17:42:50 +00:00
|
|
|
return sUpdate(this.props.settings, { showPasswords });
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2018-10-17 16:42:33 +00:00
|
|
|
_handleUpdateSettingsUseBulkHeaderEditor(useBulkHeaderEditor: boolean): Promise<Settings> {
|
2018-06-25 17:42:50 +00:00
|
|
|
return sUpdate(this.props.settings, { useBulkHeaderEditor });
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-26 00:37:59 +00:00
|
|
|
|
2020-08-03 10:13:08 +00:00
|
|
|
_handleUpdateSettingsUseBulkParametersEditor(
|
|
|
|
useBulkParametersEditor: boolean,
|
|
|
|
): Promise<Settings> {
|
|
|
|
return sUpdate(this.props.settings, { useBulkParametersEditor });
|
|
|
|
}
|
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
_handleImportFile(forceToWorkspace?: ForceToWorkspace): void {
|
|
|
|
this.props.handleImportFileToWorkspace(this.props.activeWorkspace._id, forceToWorkspace);
|
|
|
|
}
|
|
|
|
|
|
|
|
_handleImportUri(uri: string, forceToWorkspace?: ForceToWorkspace): void {
|
|
|
|
this.props.handleImportUriToWorkspace(this.props.activeWorkspace._id, uri, forceToWorkspace);
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
_handleImportClipBoard(forceToWorkspace?: ForceToWorkspace): void {
|
|
|
|
this.props.handleImportClipBoardToWorkspace(this.props.activeWorkspace._id, forceToWorkspace);
|
2017-05-03 17:48:23 +00:00
|
|
|
}
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
_handleSetActiveResponse(responseId: string | null): void {
|
2017-07-19 04:48:28 +00:00
|
|
|
if (!this.props.activeRequest) {
|
|
|
|
console.warn('Tried to set active response when request not active');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-17 16:42:33 +00:00
|
|
|
this.props.handleSetActiveResponse(this.props.activeRequest._id, responseId);
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-12-07 17:57:01 +00:00
|
|
|
|
2018-06-25 17:42:50 +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
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
_handleShowCookiesModal(): void {
|
2017-03-03 01:44:07 +00:00
|
|
|
showModal(CookiesModal, this.props.activeWorkspace);
|
|
|
|
}
|
|
|
|
|
2018-12-14 23:10:57 +00:00
|
|
|
static _handleShowModifyCookieModal(cookie: Object): void {
|
2017-08-22 22:30:57 +00:00
|
|
|
showModal(CookieModifyModal, cookie);
|
2017-08-19 22:34:16 +00:00
|
|
|
}
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
_handleShowRequestSettingsModal(): void {
|
|
|
|
showModal(RequestSettingsModal, { request: this.props.activeRequest });
|
2017-03-29 23:09:28 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 19:23:19 +00:00
|
|
|
async _handleDeleteResponses(requestId: string, environmentId: string | null): Promise<void> {
|
|
|
|
const { handleSetActiveResponse, activeRequest } = this.props;
|
2017-07-19 04:48:28 +00:00
|
|
|
|
2020-01-22 19:23:19 +00:00
|
|
|
await models.response.removeForRequest(requestId, environmentId);
|
|
|
|
|
|
|
|
if (activeRequest && activeRequest._id === requestId) {
|
|
|
|
await handleSetActiveResponse(requestId, null);
|
|
|
|
}
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-27 21:42:38 +00:00
|
|
|
|
2018-06-25 17:42:50 +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
|
2018-10-17 16:42:33 +00:00
|
|
|
if (this.props.activeResponse && this.props.activeResponse._id === response._id) {
|
2017-06-12 21:48:17 +00:00
|
|
|
this._handleSetActiveResponse(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
async _handleRemoveActiveWorkspace(): Promise<void> {
|
|
|
|
const { workspaces, activeWorkspace } = this.props;
|
2016-11-29 20:55:31 +00:00
|
|
|
if (workspaces.length <= 1) {
|
|
|
|
showModal(AlertModal, {
|
|
|
|
title: 'Deleting Last Workspace',
|
2018-12-12 17:36:11 +00:00
|
|
|
message: 'Since you deleted your only workspace, a new one has been created for you.',
|
2020-04-28 22:11:22 +00:00
|
|
|
onConfirm: async () => {
|
2020-12-09 16:39:53 +00:00
|
|
|
await models.stats.incrementDeletedRequestsForDescendents(activeWorkspace);
|
|
|
|
|
2020-04-28 22:11:22 +00:00
|
|
|
await models.workspace.create({ name: getAppName() });
|
|
|
|
await models.workspace.remove(activeWorkspace);
|
|
|
|
},
|
2016-11-29 20:55:31 +00:00
|
|
|
});
|
2020-04-28 22:11:22 +00:00
|
|
|
} else {
|
2020-12-09 16:39:53 +00:00
|
|
|
await models.stats.incrementDeletedRequestsForDescendents(activeWorkspace);
|
|
|
|
|
2020-04-28 22:11:22 +00:00
|
|
|
await models.workspace.remove(activeWorkspace);
|
2016-11-29 20:55:31 +00:00
|
|
|
}
|
2017-06-06 21:21:06 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 16:29:30 +00:00
|
|
|
async _handleActiveWorkspaceClearAllResponses(): Promise<void> {
|
|
|
|
const docs = await db.withDescendants(this.props.activeWorkspace, models.request.type);
|
|
|
|
const requests = docs.filter(doc => doc.type === models.request.type);
|
|
|
|
for (const req of requests) {
|
|
|
|
await models.response.removeForRequest(req._id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
_handleSendRequestWithActiveEnvironment(): void {
|
2018-10-17 16:42:33 +00:00
|
|
|
const { activeRequest, activeEnvironment, handleSendRequestWithEnvironment } = this.props;
|
2016-11-26 00:37:59 +00:00
|
|
|
const activeRequestId = activeRequest ? activeRequest._id : 'n/a';
|
2018-10-17 16:42:33 +00:00
|
|
|
const activeEnvironmentId = activeEnvironment ? activeEnvironment._id : 'n/a';
|
2016-11-26 00:37:59 +00:00
|
|
|
handleSendRequestWithEnvironment(activeRequestId, activeEnvironmentId);
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-25 23:09:17 +00:00
|
|
|
|
2018-12-14 23:10:57 +00:00
|
|
|
async _handleSendAndDownloadRequestWithActiveEnvironment(filename?: string): Promise<void> {
|
2018-06-25 17:42:50 +00:00
|
|
|
const {
|
|
|
|
activeRequest,
|
|
|
|
activeEnvironment,
|
2018-12-12 17:36:11 +00:00
|
|
|
handleSendAndDownloadRequestWithEnvironment,
|
2018-06-25 17:42:50 +00:00
|
|
|
} = this.props;
|
2018-12-14 23:10:57 +00:00
|
|
|
|
2017-02-01 20:21:14 +00:00
|
|
|
const activeRequestId = activeRequest ? activeRequest._id : 'n/a';
|
2018-10-17 16:42:33 +00:00
|
|
|
const activeEnvironmentId = activeEnvironment ? activeEnvironment._id : 'n/a';
|
2019-01-21 16:29:30 +00:00
|
|
|
await handleSendAndDownloadRequestWithEnvironment(
|
|
|
|
activeRequestId,
|
|
|
|
activeEnvironmentId,
|
|
|
|
filename,
|
|
|
|
);
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2017-02-01 20:21:14 +00:00
|
|
|
|
2018-06-25 17:42:50 +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
|
|
|
|
2018-06-25 17:42:50 +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
|
|
|
|
2019-08-02 19:01:01 +00:00
|
|
|
_handleCreateRequestInWorkspace() {
|
|
|
|
const { activeWorkspace, handleCreateRequest } = this.props;
|
|
|
|
handleCreateRequest(activeWorkspace._id);
|
|
|
|
}
|
|
|
|
|
|
|
|
_handleCreateRequestGroupInWorkspace() {
|
|
|
|
const { activeWorkspace, handleCreateRequestGroup } = this.props;
|
|
|
|
handleCreateRequestGroup(activeWorkspace._id);
|
|
|
|
}
|
|
|
|
|
2020-06-08 22:32:49 +00:00
|
|
|
_handleChangeEnvironment(id: string | null) {
|
2019-08-02 19:01:01 +00:00
|
|
|
const { handleSetActiveEnvironment } = this.props;
|
|
|
|
handleSetActiveEnvironment(id);
|
|
|
|
}
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
_forceRequestPaneRefresh(): void {
|
|
|
|
this.setState({ forceRefreshKey: Date.now() });
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-25 23:09:17 +00:00
|
|
|
|
2020-06-03 05:32:36 +00:00
|
|
|
_handleGitBranchChanged(branch) {
|
|
|
|
this.setState({ activeGitBranch: branch || 'no-vcs' });
|
|
|
|
}
|
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
componentDidMount() {
|
|
|
|
const { activity } = this.props;
|
|
|
|
trackPageView(`/${activity || ''}`);
|
|
|
|
}
|
2019-08-02 19:01:01 +00:00
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
componentDidUpdate(prevProps: Props) {
|
|
|
|
// We're using activities as page views so here we monitor
|
|
|
|
// for a change in activity and send it as a pageview.
|
|
|
|
const { activity } = this.props;
|
|
|
|
if (prevProps.activity !== activity) {
|
|
|
|
trackPageView(`/${activity || ''}`);
|
|
|
|
}
|
2019-08-02 19:01:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
activeCookieJar,
|
|
|
|
activeEnvironment,
|
2020-04-26 20:33:39 +00:00
|
|
|
activeGitRepository,
|
2019-08-02 19:01:01 +00:00
|
|
|
activeRequest,
|
|
|
|
activeWorkspace,
|
|
|
|
activeWorkspaceClientCertificates,
|
2020-04-26 20:33:39 +00:00
|
|
|
activity,
|
|
|
|
gitVCS,
|
2019-08-02 19:01:01 +00:00
|
|
|
handleActivateRequest,
|
2019-05-10 01:18:34 +00:00
|
|
|
handleDuplicateWorkspace,
|
2016-11-25 23:09:17 +00:00
|
|
|
handleExportFile,
|
2019-03-05 06:53:45 +00:00
|
|
|
handleExportRequestsToFile,
|
2019-05-10 01:18:34 +00:00
|
|
|
handleGetRenderContext,
|
2020-04-26 20:33:39 +00:00
|
|
|
handleInitializeEntities,
|
2019-05-10 01:18:34 +00:00
|
|
|
handleRender,
|
2016-11-27 21:42:38 +00:00
|
|
|
handleSetActiveWorkspace,
|
2019-05-10 01:18:34 +00:00
|
|
|
handleShowExportRequestsModal,
|
2020-12-01 00:37:57 +00:00
|
|
|
handleSidebarSort,
|
2017-05-17 16:35:44 +00:00
|
|
|
handleToggleMenuBar,
|
2019-05-10 01:18:34 +00:00
|
|
|
isVariableUncovered,
|
|
|
|
requestMetas,
|
2016-11-27 21:42:38 +00:00
|
|
|
settings,
|
2016-11-25 23:09:17 +00:00
|
|
|
sidebarChildren,
|
2019-04-18 00:50:03 +00:00
|
|
|
syncItems,
|
|
|
|
vcs,
|
2019-05-10 01:18:34 +00:00
|
|
|
workspaceChildren,
|
|
|
|
workspaces,
|
2016-11-25 23:09:17 +00:00
|
|
|
} = this.props;
|
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
// Setup git sync dropdown for use in Design/Debug pages
|
|
|
|
let gitSyncDropdown = null;
|
|
|
|
if (gitVCS) {
|
|
|
|
gitSyncDropdown = (
|
|
|
|
<GitSyncDropdown
|
|
|
|
className="margin-left"
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
dropdownButtonClassName="btn--clicky-small btn-sync btn-utility"
|
|
|
|
gitRepository={activeGitRepository}
|
|
|
|
vcs={gitVCS}
|
|
|
|
handleInitializeEntities={handleInitializeEntities}
|
2020-06-03 05:32:36 +00:00
|
|
|
handleGitBranchChanged={this._handleGitBranchChanged}
|
2020-04-26 20:33:39 +00:00
|
|
|
renderDropdownButton={children => (
|
|
|
|
<DropdownButton className="btn--clicky-small btn-sync btn-utility">
|
|
|
|
{children}
|
|
|
|
</DropdownButton>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2017-06-09 21:42:19 +00:00
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
return (
|
|
|
|
<React.Fragment>
|
|
|
|
<div key="modals" className="modals">
|
|
|
|
<ErrorBoundary showAlert>
|
|
|
|
<AlertModal ref={registerModal} />
|
|
|
|
<ErrorModal ref={registerModal} />
|
|
|
|
<PromptModal ref={registerModal} />
|
|
|
|
|
|
|
|
<WrapperModal ref={registerModal} />
|
|
|
|
<LoginModal ref={registerModal} />
|
|
|
|
<AskModal ref={registerModal} />
|
|
|
|
<SelectModal ref={registerModal} />
|
|
|
|
<RequestCreateModal ref={registerModal} />
|
|
|
|
<PaymentNotificationModal ref={registerModal} />
|
|
|
|
<FilterHelpModal ref={registerModal} />
|
|
|
|
<RequestRenderErrorModal ref={registerModal} />
|
|
|
|
<GenerateConfigModal ref={registerModal} settings={settings} />
|
|
|
|
|
|
|
|
<CodePromptModal
|
|
|
|
ref={registerModal}
|
|
|
|
handleRender={handleRender}
|
|
|
|
handleGetRenderContext={handleGetRenderContext}
|
|
|
|
nunjucksPowerUserMode={settings.nunjucksPowerUserMode}
|
|
|
|
editorFontSize={settings.editorFontSize}
|
|
|
|
editorIndentSize={settings.editorIndentSize}
|
|
|
|
editorKeyMap={settings.editorKeyMap}
|
|
|
|
editorLineWrapping={settings.editorLineWrapping}
|
|
|
|
isVariableUncovered={isVariableUncovered}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<RequestSettingsModal
|
|
|
|
ref={registerModal}
|
|
|
|
editorFontSize={settings.editorFontSize}
|
|
|
|
editorIndentSize={settings.editorIndentSize}
|
|
|
|
editorKeyMap={settings.editorKeyMap}
|
|
|
|
editorLineWrapping={settings.editorLineWrapping}
|
|
|
|
handleRender={handleRender}
|
|
|
|
handleGetRenderContext={handleGetRenderContext}
|
|
|
|
nunjucksPowerUserMode={settings.nunjucksPowerUserMode}
|
|
|
|
workspaces={workspaces}
|
|
|
|
isVariableUncovered={isVariableUncovered}
|
|
|
|
/>
|
|
|
|
|
|
|
|
{/* TODO: Figure out why cookieJar is sometimes null */}
|
|
|
|
{activeCookieJar ? (
|
|
|
|
<CookiesModal
|
|
|
|
handleShowModifyCookieModal={Wrapper._handleShowModifyCookieModal}
|
|
|
|
handleRender={handleRender}
|
|
|
|
nunjucksPowerUserMode={settings.nunjucksPowerUserMode}
|
|
|
|
ref={registerModal}
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
cookieJar={activeCookieJar}
|
|
|
|
isVariableUncovered={isVariableUncovered}
|
|
|
|
/>
|
|
|
|
) : null}
|
2017-06-01 22:58:09 +00:00
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
<CookieModifyModal
|
2019-04-18 00:50:03 +00:00
|
|
|
handleRender={handleRender}
|
2020-04-26 20:33:39 +00:00
|
|
|
handleGetRenderContext={handleGetRenderContext}
|
2019-04-18 00:50:03 +00:00
|
|
|
nunjucksPowerUserMode={settings.nunjucksPowerUserMode}
|
|
|
|
ref={registerModal}
|
|
|
|
cookieJar={activeCookieJar}
|
2020-04-26 20:33:39 +00:00
|
|
|
workspace={activeWorkspace}
|
2019-04-18 00:50:03 +00:00
|
|
|
isVariableUncovered={isVariableUncovered}
|
|
|
|
/>
|
2017-08-23 03:33:07 +00:00
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
<NunjucksModal
|
|
|
|
uniqueKey={`key::${this.state.forceRefreshKey}`}
|
|
|
|
ref={registerModal}
|
|
|
|
handleRender={handleRender}
|
|
|
|
handleGetRenderContext={handleGetRenderContext}
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
/>
|
2017-10-13 08:22:13 +00:00
|
|
|
|
2020-11-25 19:17:56 +00:00
|
|
|
<MoveRequestGroupModal
|
|
|
|
ref={registerModal}
|
|
|
|
workspaces={workspaces}
|
|
|
|
activeWorkspace={activeWorkspace}
|
|
|
|
/>
|
2018-03-29 13:57:24 +00:00
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
<WorkspaceSettingsModal
|
|
|
|
ref={registerModal}
|
|
|
|
clientCertificates={activeWorkspaceClientCertificates}
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
editorFontSize={settings.editorFontSize}
|
|
|
|
editorIndentSize={settings.editorIndentSize}
|
|
|
|
editorKeyMap={settings.editorKeyMap}
|
|
|
|
editorLineWrapping={settings.editorLineWrapping}
|
|
|
|
handleRender={handleRender}
|
|
|
|
handleGetRenderContext={handleGetRenderContext}
|
|
|
|
nunjucksPowerUserMode={settings.nunjucksPowerUserMode}
|
|
|
|
handleRemoveWorkspace={this._handleRemoveActiveWorkspace}
|
|
|
|
handleDuplicateWorkspace={handleDuplicateWorkspace}
|
|
|
|
handleClearAllResponses={this._handleActiveWorkspaceClearAllResponses}
|
|
|
|
isVariableUncovered={isVariableUncovered}
|
|
|
|
/>
|
2018-03-29 13:57:24 +00:00
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
<GenerateCodeModal
|
|
|
|
ref={registerModal}
|
|
|
|
environmentId={activeEnvironment ? activeEnvironment._id : 'n/a'}
|
|
|
|
editorFontSize={settings.editorFontSize}
|
|
|
|
editorIndentSize={settings.editorIndentSize}
|
|
|
|
editorKeyMap={settings.editorKeyMap}
|
|
|
|
/>
|
2018-03-29 13:57:24 +00:00
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
<SettingsModal
|
|
|
|
ref={registerModal}
|
|
|
|
handleShowExportRequestsModal={handleShowExportRequestsModal}
|
|
|
|
handleExportAllToFile={handleExportFile}
|
|
|
|
handleImportClipBoard={this._handleImportClipBoard}
|
|
|
|
handleImportFile={this._handleImportFile}
|
|
|
|
handleImportUri={this._handleImportUri}
|
|
|
|
handleToggleMenuBar={handleToggleMenuBar}
|
|
|
|
settings={settings}
|
|
|
|
activity={activity}
|
|
|
|
/>
|
2018-03-29 13:57:24 +00:00
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
<ResponseDebugModal ref={registerModal} settings={settings} />
|
2018-03-29 13:57:24 +00:00
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
<RequestSwitcherModal
|
|
|
|
ref={registerModal}
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
workspaces={workspaces}
|
|
|
|
workspaceChildren={workspaceChildren}
|
|
|
|
activeRequest={activeRequest}
|
|
|
|
activateRequest={handleActivateRequest}
|
|
|
|
requestMetas={requestMetas}
|
|
|
|
handleSetActiveWorkspace={handleSetActiveWorkspace}
|
|
|
|
/>
|
2018-03-29 13:57:24 +00:00
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
<EnvironmentEditModal
|
|
|
|
ref={registerModal}
|
|
|
|
editorFontSize={settings.editorFontSize}
|
|
|
|
editorIndentSize={settings.editorIndentSize}
|
|
|
|
editorKeyMap={settings.editorKeyMap}
|
|
|
|
lineWrapping={settings.editorLineWrapping}
|
|
|
|
onChange={models.requestGroup.update}
|
|
|
|
render={handleRender}
|
|
|
|
getRenderContext={handleGetRenderContext}
|
|
|
|
nunjucksPowerUserMode={settings.nunjucksPowerUserMode}
|
|
|
|
isVariableUncovered={isVariableUncovered}
|
|
|
|
/>
|
2019-04-18 00:50:03 +00:00
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
{gitVCS && (
|
|
|
|
<React.Fragment>
|
|
|
|
<GitStagingModal ref={registerModal} workspace={activeWorkspace} vcs={gitVCS} />
|
|
|
|
<GitLogModal ref={registerModal} vcs={gitVCS} />
|
|
|
|
<GitRepositorySettingsModal ref={registerModal} />
|
|
|
|
{activeGitRepository !== null && (
|
|
|
|
<GitBranchesModal
|
|
|
|
ref={registerModal}
|
|
|
|
vcs={gitVCS}
|
|
|
|
gitRepository={activeGitRepository}
|
|
|
|
handleInitializeEntities={handleInitializeEntities}
|
2020-06-03 05:32:36 +00:00
|
|
|
handleGitBranchChanged={this._handleGitBranchChanged}
|
2020-04-26 20:33:39 +00:00
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</React.Fragment>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{vcs && (
|
|
|
|
<React.Fragment>
|
|
|
|
<SyncStagingModal
|
|
|
|
ref={registerModal}
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
vcs={vcs}
|
|
|
|
syncItems={syncItems}
|
|
|
|
/>
|
|
|
|
<SyncMergeModal
|
|
|
|
ref={registerModal}
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
syncItems={syncItems}
|
|
|
|
vcs={vcs}
|
|
|
|
/>
|
|
|
|
<SyncBranchesModal
|
|
|
|
ref={registerModal}
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
vcs={vcs}
|
|
|
|
syncItems={syncItems}
|
|
|
|
/>
|
2020-11-09 22:56:13 +00:00
|
|
|
<SyncDeleteModal ref={registerModal} workspace={activeWorkspace} vcs={vcs} />
|
2020-04-26 20:33:39 +00:00
|
|
|
<SyncHistoryModal ref={registerModal} workspace={activeWorkspace} vcs={vcs} />
|
|
|
|
<SyncShareModal ref={registerModal} workspace={activeWorkspace} vcs={vcs} />
|
|
|
|
</React.Fragment>
|
|
|
|
)}
|
|
|
|
|
|
|
|
<WorkspaceEnvironmentsEditModal
|
|
|
|
ref={registerModal}
|
2020-06-08 22:32:49 +00:00
|
|
|
handleChangeEnvironment={this._handleChangeEnvironment}
|
2020-04-26 20:33:39 +00:00
|
|
|
lineWrapping={settings.editorLineWrapping}
|
|
|
|
editorFontSize={settings.editorFontSize}
|
|
|
|
editorIndentSize={settings.editorIndentSize}
|
|
|
|
editorKeyMap={settings.editorKeyMap}
|
|
|
|
activeEnvironmentId={activeEnvironment ? activeEnvironment._id : null}
|
|
|
|
render={handleRender}
|
|
|
|
getRenderContext={handleGetRenderContext}
|
|
|
|
nunjucksPowerUserMode={settings.nunjucksPowerUserMode}
|
|
|
|
isVariableUncovered={isVariableUncovered}
|
|
|
|
/>
|
2019-02-08 18:20:24 +00:00
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
<AddKeyCombinationModal ref={registerModal} />
|
|
|
|
<ExportRequestsModal
|
|
|
|
ref={registerModal}
|
|
|
|
childObjects={sidebarChildren.all}
|
|
|
|
handleExportRequestsToFile={handleExportRequestsToFile}
|
|
|
|
/>
|
2020-10-22 19:14:46 +00:00
|
|
|
|
2020-11-16 22:01:50 +00:00
|
|
|
<GrpcDispatchModalWrapper>
|
|
|
|
{dispatch => (
|
|
|
|
<ProtoFilesModal
|
|
|
|
ref={registerModal}
|
|
|
|
grpcDispatch={dispatch}
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</GrpcDispatchModalWrapper>
|
2020-04-26 20:33:39 +00:00
|
|
|
</ErrorBoundary>
|
2017-10-13 13:01:27 +00:00
|
|
|
</div>
|
2020-06-03 05:32:36 +00:00
|
|
|
<React.Fragment key={`views::${this.state.activeGitBranch}`}>
|
|
|
|
{activity === ACTIVITY_HOME && (
|
|
|
|
<WrapperHome
|
|
|
|
wrapperProps={this.props}
|
|
|
|
handleImportFile={this._handleImportFile}
|
|
|
|
handleImportUri={this._handleImportUri}
|
|
|
|
handleImportClipboard={this._handleImportClipBoard}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{activity === ACTIVITY_SPEC && (
|
|
|
|
<WrapperDesign
|
|
|
|
gitSyncDropdown={gitSyncDropdown}
|
2020-06-30 23:54:56 +00:00
|
|
|
handleActivityChange={this._handleWorkspaceActivityChange}
|
2020-06-03 05:32:36 +00:00
|
|
|
handleUpdateApiSpec={this._handleUpdateApiSpec}
|
|
|
|
wrapperProps={this.props}
|
|
|
|
/>
|
|
|
|
)}
|
2017-10-13 13:01:27 +00:00
|
|
|
|
2020-07-01 21:17:14 +00:00
|
|
|
{activity === ACTIVITY_UNIT_TEST && (
|
|
|
|
<WrapperUnitTest
|
|
|
|
gitSyncDropdown={gitSyncDropdown}
|
|
|
|
wrapperProps={this.props}
|
|
|
|
handleActivityChange={this._handleWorkspaceActivityChange}
|
|
|
|
children={sidebarChildren}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
2020-06-03 05:32:36 +00:00
|
|
|
{(activity === ACTIVITY_DEBUG || activity === ACTIVITY_INSOMNIA) && (
|
|
|
|
<WrapperDebug
|
|
|
|
forceRefreshKey={this.state.forceRefreshKey}
|
|
|
|
gitSyncDropdown={gitSyncDropdown}
|
2020-06-30 23:54:56 +00:00
|
|
|
handleActivityChange={this._handleWorkspaceActivityChange}
|
2020-06-03 05:32:36 +00:00
|
|
|
handleChangeEnvironment={this._handleChangeEnvironment}
|
|
|
|
handleDeleteResponse={this._handleDeleteResponse}
|
|
|
|
handleDeleteResponses={this._handleDeleteResponses}
|
|
|
|
handleForceUpdateRequest={this._handleForceUpdateRequest}
|
|
|
|
handleForceUpdateRequestHeaders={this._handleForceUpdateRequestHeaders}
|
|
|
|
handleImport={this._handleImport}
|
|
|
|
handleImportFile={this._handleImportFile}
|
|
|
|
handleRequestCreate={this._handleCreateRequestInWorkspace}
|
|
|
|
handleRequestGroupCreate={this._handleCreateRequestGroupInWorkspace}
|
|
|
|
handleSendAndDownloadRequestWithActiveEnvironment={
|
|
|
|
this._handleSendAndDownloadRequestWithActiveEnvironment
|
|
|
|
}
|
|
|
|
handleSendRequestWithActiveEnvironment={this._handleSendRequestWithActiveEnvironment}
|
|
|
|
handleSetActiveResponse={this._handleSetActiveResponse}
|
|
|
|
handleSetPreviewMode={this._handleSetPreviewMode}
|
|
|
|
handleSetResponseFilter={this._handleSetResponseFilter}
|
|
|
|
handleShowCookiesModal={this._handleShowCookiesModal}
|
|
|
|
handleShowRequestSettingsModal={this._handleShowRequestSettingsModal}
|
2020-12-01 00:37:57 +00:00
|
|
|
handleSidebarSort={handleSidebarSort}
|
2020-06-03 05:32:36 +00:00
|
|
|
handleUpdateRequestAuthentication={Wrapper._handleUpdateRequestAuthentication}
|
|
|
|
handleUpdateRequestBody={Wrapper._handleUpdateRequestBody}
|
|
|
|
handleUpdateRequestHeaders={Wrapper._handleUpdateRequestHeaders}
|
|
|
|
handleUpdateRequestMethod={Wrapper._handleUpdateRequestMethod}
|
|
|
|
handleUpdateRequestParameters={Wrapper._handleUpdateRequestParameters}
|
|
|
|
handleUpdateRequestUrl={Wrapper._handleUpdateRequestUrl}
|
|
|
|
handleUpdateSettingsShowPasswords={this._handleUpdateSettingsShowPasswords}
|
|
|
|
handleUpdateSettingsUseBulkHeaderEditor={
|
|
|
|
this._handleUpdateSettingsUseBulkHeaderEditor
|
|
|
|
}
|
2020-08-03 10:13:08 +00:00
|
|
|
handleUpdateSettingsUseBulkParametersEditor={
|
|
|
|
this._handleUpdateSettingsUseBulkParametersEditor
|
|
|
|
}
|
2020-06-03 05:32:36 +00:00
|
|
|
wrapperProps={this.props}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{activity === null && (
|
|
|
|
<WrapperOnboarding
|
|
|
|
wrapperProps={this.props}
|
|
|
|
handleImportFile={this._handleImportFile}
|
|
|
|
handleImportUri={this._handleImportUri}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</React.Fragment>
|
2020-04-26 20:33:39 +00:00
|
|
|
</React.Fragment>
|
|
|
|
);
|
2016-11-25 23:09:17 +00:00
|
|
|
}
|
|
|
|
}
|
2016-11-16 17:18:39 +00:00
|
|
|
|
|
|
|
export default Wrapper;
|