import React, { Fragment, PureComponent, ReactNode } from 'react'; import { autoBindMethodsForReact } from 'class-autobind-decorator'; import PageLayout from './page-layout'; import type { HandleImportFileCallback, WrapperProps } from './wrapper'; import RequestPane from './panes/request-pane'; import ErrorBoundary from './error-boundary'; import ResponsePane from './panes/response-pane'; import SidebarChildren from './sidebar/sidebar-children'; import SidebarFilter from './sidebar/sidebar-filter'; import EnvironmentsDropdown from './dropdowns/environments-dropdown'; import { AUTOBIND_CFG, GlobalActivity, SortOrder } from '../../common/constants'; import GrpcRequestPane from './panes/grpc-request-pane'; import GrpcResponsePane from './panes/grpc-response-pane'; import WorkspacePageHeader from './workspace-page-header'; import SyncDropdown from './dropdowns/sync-dropdown'; import { Button } from 'insomnia-components'; import { showSyncShareModal } from './modals/sync-share-modal'; import { Settings } from '../../models/settings'; import { Request, RequestAuthentication, RequestBody, RequestHeader, RequestParameter } from '../../models/request'; import { isGrpcRequest } from '../../models/grpc-request'; import { isCollection, isDesign } from '../../models/workspace'; interface Props { forceRefreshKey: number; gitSyncDropdown: ReactNode; handleActivityChange: (workspaceId: string, activity: GlobalActivity) => Promise; handleChangeEnvironment: Function; handleDeleteResponse: Function; handleDeleteResponses: Function; handleForceUpdateRequest: (r: Request, patch: Partial) => Promise; handleForceUpdateRequestHeaders: (r: Request, headers: RequestHeader[]) => Promise; handleImport: Function; handleImportFile: HandleImportFileCallback; handleRequestCreate: () => void; handleRequestGroupCreate: () => void; handleSendAndDownloadRequestWithActiveEnvironment: (filepath?: string) => Promise; handleSendRequestWithActiveEnvironment: () => void; handleSetActiveResponse: Function; handleSetPreviewMode: Function; handleSetResponseFilter: (filter: string) => void; handleShowCookiesModal: Function; handleShowRequestSettingsModal: Function; handleSidebarSort: (sortOrder: SortOrder) => void; handleUpdateRequestAuthentication: (r: Request, auth: RequestAuthentication) => Promise; handleUpdateRequestBody: (r: Request, body: RequestBody) => Promise; handleUpdateRequestHeaders: (r: Request, headers: RequestHeader[]) => Promise; handleUpdateRequestMethod: (r: Request, method: string) => Promise; handleUpdateRequestParameters: (r: Request, params: RequestParameter[]) => Promise; handleUpdateRequestUrl: (r: Request, url: string) => Promise; handleUpdateSettingsShowPasswords: (showPasswords: boolean) => Promise; handleUpdateSettingsUseBulkHeaderEditor: Function; handleUpdateSettingsUseBulkParametersEditor: (useBulkParametersEditor: boolean) => Promise; wrapperProps: WrapperProps; } @autoBindMethodsForReact(AUTOBIND_CFG) class WrapperDebug extends PureComponent { _renderPageHeader() { const { wrapperProps, gitSyncDropdown, handleActivityChange } = this.props; const { vcs, activeWorkspace, activeWorkspaceMeta, activeSpace, syncItems, isLoggedIn } = this.props.wrapperProps; const collection = isCollection(activeWorkspace); const design = isDesign(activeWorkspace); let share: ReactNode = null; let insomniaSync: ReactNode = null; if (isLoggedIn && collection && activeSpace?.remoteId && vcs) { share = ; insomniaSync = ; } const gitSync = design && gitSyncDropdown; const sync = insomniaSync || gitSync; return ( {share} {sync && {sync}} } /> ); } _renderPageSidebar() { const { handleChangeEnvironment, handleRequestCreate, handleRequestGroupCreate, handleShowCookiesModal, handleSidebarSort, } = this.props; const { activeEnvironment, activeRequest, activeWorkspace, environments, handleActivateRequest, handleCopyAsCurl, handleCreateRequest, handleCreateRequestGroup, handleDuplicateRequest, handleDuplicateRequestGroup, handleGenerateCode, handleMoveDoc, handleMoveRequestGroup, handleRender, handleSetRequestGroupCollapsed, handleSetRequestPinned, handleSetSidebarFilter, settings, sidebarChildren, sidebarFilter, sidebarHidden, sidebarWidth, } = this.props.wrapperProps; return (
{/* @ts-expect-error -- TSCONVERSION onClick event doesn't matter */}
); } _renderRequestPane() { const { forceRefreshKey, handleForceUpdateRequest, handleForceUpdateRequestHeaders, handleImport, handleImportFile, handleSendAndDownloadRequestWithActiveEnvironment, handleSendRequestWithActiveEnvironment, handleUpdateRequestAuthentication, handleUpdateRequestBody, handleUpdateRequestHeaders, handleUpdateRequestMethod, handleUpdateRequestParameters, handleUpdateRequestUrl, handleUpdateSettingsShowPasswords, handleUpdateSettingsUseBulkHeaderEditor, handleUpdateSettingsUseBulkParametersEditor, } = this.props; const { activeEnvironment, activeRequest, activeWorkspace, handleCreateRequestForWorkspace, handleGenerateCodeForActiveRequest, handleGetRenderContext, handleRender, handleUpdateDownloadPath, handleUpdateRequestMimeType, headerEditorKey, isVariableUncovered, oAuth2Token, responseDownloadPath, 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 ( ); } return ( ); } _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 ( ); } return ( ); } render() { return ( ); } } export default WrapperDebug;