2021-02-02 22:23:42 +00:00
|
|
|
import { autoBindMethodsForReact } from 'class-autobind-decorator';
|
2021-07-22 23:04:56 +00:00
|
|
|
import * as importers from 'insomnia-importers';
|
2021-09-29 07:44:28 +00:00
|
|
|
import React, { Fragment, PureComponent, Ref } from 'react';
|
2021-07-22 23:04:56 +00:00
|
|
|
|
|
|
|
import { trackPageView } from '../../common/analytics';
|
|
|
|
import type { GlobalActivity } from '../../common/constants';
|
2021-02-02 22:23:42 +00:00
|
|
|
import {
|
|
|
|
ACTIVITY_DEBUG,
|
|
|
|
ACTIVITY_HOME,
|
2021-07-22 23:04:56 +00:00
|
|
|
ACTIVITY_MIGRATION,
|
2021-02-02 22:23:42 +00:00
|
|
|
ACTIVITY_SPEC,
|
|
|
|
ACTIVITY_UNIT_TEST,
|
2021-07-22 23:04:56 +00:00
|
|
|
AUTOBIND_CFG,
|
2021-02-02 22:23:42 +00:00
|
|
|
SortOrder,
|
|
|
|
} from '../../common/constants';
|
2021-07-22 23:04:56 +00:00
|
|
|
import { database as db } from '../../common/database';
|
|
|
|
import { importRaw } from '../../common/import';
|
|
|
|
import { initializeSpectral, isLintError } from '../../common/spectral';
|
|
|
|
import type { ApiSpec } from '../../models/api-spec';
|
|
|
|
import type { Cookie } from '../../models/cookie-jar';
|
|
|
|
import * as models from '../../models/index';
|
|
|
|
import {
|
|
|
|
isRequest,
|
|
|
|
Request,
|
|
|
|
RequestAuthentication,
|
|
|
|
RequestBody,
|
|
|
|
RequestHeader,
|
|
|
|
RequestParameter,
|
|
|
|
} from '../../models/request';
|
|
|
|
import { RequestGroup } from '../../models/request-group';
|
|
|
|
import type { Response } from '../../models/response';
|
|
|
|
import { GitVCS } from '../../sync/git/git-vcs';
|
|
|
|
import { VCS } from '../../sync/vcs/vcs';
|
2021-09-27 13:47:22 +00:00
|
|
|
import { CookieModifyModal } from '../components/modals/cookie-modify-modal';
|
2021-07-22 23:04:56 +00:00
|
|
|
import { AppProps } from '../containers/app';
|
|
|
|
import { GrpcDispatchModalWrapper } from '../context/grpc';
|
2021-09-15 20:16:04 +00:00
|
|
|
import { DropdownButton } from './base/dropdown/dropdown-button';
|
2021-07-22 23:04:56 +00:00
|
|
|
import GitSyncDropdown from './dropdowns/git-sync-dropdown';
|
2021-09-27 13:47:22 +00:00
|
|
|
import { ErrorBoundary } from './error-boundary';
|
|
|
|
import { AddKeyCombinationModal } from './modals/add-key-combination-modal';
|
|
|
|
import { AlertModal } from './modals/alert-modal';
|
2021-12-16 04:58:00 +00:00
|
|
|
import { AnalyticsModal } from './modals/analytics-modal';
|
2021-09-27 13:47:22 +00:00
|
|
|
import { AskModal } from './modals/ask-modal';
|
|
|
|
import { CodePromptModal } from './modals/code-prompt-modal';
|
2021-12-08 03:11:04 +00:00
|
|
|
import { CookiesModalFC } from './modals/cookies-modal';
|
2021-09-27 13:47:22 +00:00
|
|
|
import { EnvironmentEditModal } from './modals/environment-edit-modal';
|
|
|
|
import { ErrorModal } from './modals/error-modal';
|
|
|
|
import { ExportRequestsModal } from './modals/export-requests-modal';
|
|
|
|
import { FilterHelpModal } from './modals/filter-help-modal';
|
|
|
|
import { GenerateCodeModal } from './modals/generate-code-modal';
|
|
|
|
import { GenerateConfigModal } from './modals/generate-config-modal';
|
|
|
|
import { GitBranchesModal } from './modals/git-branches-modal';
|
|
|
|
import { GitLogModal } from './modals/git-log-modal';
|
|
|
|
import { GitRepositorySettingsModal } from './modals/git-repository-settings-modal';
|
|
|
|
import { GitStagingModal } from './modals/git-staging-modal';
|
2021-07-22 23:04:56 +00:00
|
|
|
import { registerModal, showModal } from './modals/index';
|
2021-09-27 13:47:22 +00:00
|
|
|
import { LoginModal } from './modals/login-modal';
|
|
|
|
import { NunjucksModal } from './modals/nunjucks-modal';
|
|
|
|
import { PaymentNotificationModal } from './modals/payment-notification-modal';
|
2021-08-20 15:12:36 +00:00
|
|
|
import ProjectSettingsModal from './modals/project-settings-modal';
|
2021-09-27 13:47:22 +00:00
|
|
|
import { PromptModal } from './modals/prompt-modal';
|
2021-07-22 23:04:56 +00:00
|
|
|
import ProtoFilesModal from './modals/proto-files-modal';
|
2021-09-27 13:47:22 +00:00
|
|
|
import { RequestCreateModal } from './modals/request-create-modal';
|
|
|
|
import { RequestGroupSettingsModal } from './modals/request-group-settings-modal';
|
|
|
|
import { RequestRenderErrorModal } from './modals/request-render-error-modal';
|
|
|
|
import { RequestSettingsModal } from './modals/request-settings-modal';
|
2017-03-08 05:52:17 +00:00
|
|
|
import RequestSwitcherModal from './modals/request-switcher-modal';
|
2021-09-27 13:47:22 +00:00
|
|
|
import { ResponseDebugModal } from './modals/response-debug-modal';
|
2021-07-22 23:04:56 +00:00
|
|
|
import { SelectModal } from './modals/select-modal';
|
2021-09-27 13:47:22 +00:00
|
|
|
import { SettingsModal } from './modals/settings-modal';
|
|
|
|
import { SyncBranchesModal } from './modals/sync-branches-modal';
|
|
|
|
import { SyncDeleteModal } from './modals/sync-delete-modal';
|
|
|
|
import { SyncHistoryModal } from './modals/sync-history-modal';
|
|
|
|
import { SyncMergeModal } from './modals/sync-merge-modal';
|
|
|
|
import { SyncStagingModal } from './modals/sync-staging-modal';
|
2021-07-28 21:49:02 +00:00
|
|
|
import { WorkspaceDuplicateModal } from './modals/workspace-duplicate-modal';
|
2021-09-27 13:47:22 +00:00
|
|
|
import { WorkspaceEnvironmentsEditModal } from './modals/workspace-environments-edit-modal';
|
|
|
|
import { WorkspaceSettingsModal } from './modals/workspace-settings-modal';
|
|
|
|
import { WrapperModal } from './modals/wrapper-modal';
|
|
|
|
import { WrapperDebug } from './wrapper-debug';
|
|
|
|
import { WrapperDesign } from './wrapper-design';
|
2021-07-22 23:04:56 +00:00
|
|
|
import WrapperHome from './wrapper-home';
|
2021-09-27 13:47:22 +00:00
|
|
|
import { WrapperMigration } from './wrapper-migration';
|
|
|
|
import { WrapperUnitTest } from './wrapper-unit-test';
|
2020-06-30 23:54:56 +00:00
|
|
|
|
2021-06-30 15:11:20 +00:00
|
|
|
const spectral = initializeSpectral();
|
2020-04-26 20:33:39 +00:00
|
|
|
|
2021-06-30 07:47:17 +00:00
|
|
|
export type WrapperProps = AppProps & {
|
2021-05-12 06:35:00 +00:00
|
|
|
handleActivateRequest: (activeRequestId: string) => void;
|
|
|
|
handleSetSidebarFilter: (value: string) => Promise<void>;
|
|
|
|
handleShowSettingsModal: Function;
|
|
|
|
handleSetActiveEnvironment: (environmentId: string | null) => Promise<void>;
|
2021-06-30 07:47:17 +00:00
|
|
|
handleCreateRequest: (id: string) => void;
|
2021-05-12 06:35:00 +00:00
|
|
|
handleDuplicateRequest: Function;
|
|
|
|
handleDuplicateRequestGroup: (requestGroup: RequestGroup) => void;
|
|
|
|
handleCreateRequestGroup: (parentId: string) => void;
|
|
|
|
handleGenerateCodeForActiveRequest: Function;
|
|
|
|
handleGenerateCode: Function;
|
|
|
|
handleCopyAsCurl: Function;
|
|
|
|
handleCreateRequestForWorkspace: () => void;
|
2021-09-29 07:44:28 +00:00
|
|
|
requestPaneRef: Ref<HTMLElement>;
|
|
|
|
responsePaneRef: Ref<HTMLElement>;
|
2021-05-12 06:35:00 +00:00
|
|
|
handleSetResponsePreviewMode: Function;
|
|
|
|
handleSetResponseFilter: Function;
|
|
|
|
handleSetActiveResponse: Function;
|
2021-09-29 07:44:28 +00:00
|
|
|
sidebarRef: Ref<HTMLElement>;
|
2021-05-12 06:35:00 +00:00
|
|
|
handleSidebarSort: (sortOrder: SortOrder) => void;
|
|
|
|
handleStartDragSidebar: React.MouseEventHandler;
|
|
|
|
handleResetDragSidebar: React.MouseEventHandler;
|
|
|
|
handleStartDragPaneHorizontal: React.MouseEventHandler;
|
|
|
|
handleStartDragPaneVertical: React.MouseEventHandler;
|
|
|
|
handleResetDragPaneHorizontal: React.MouseEventHandler;
|
|
|
|
handleResetDragPaneVertical: React.MouseEventHandler;
|
|
|
|
handleSetRequestGroupCollapsed: Function;
|
|
|
|
handleSetRequestPinned: Function;
|
|
|
|
handleSendRequestWithEnvironment: Function;
|
|
|
|
handleSendAndDownloadRequestWithEnvironment: Function;
|
|
|
|
handleUpdateRequestMimeType: (mimeType: string) => Promise<Request | null>;
|
|
|
|
handleUpdateDownloadPath: Function;
|
2021-06-30 07:47:17 +00:00
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
paneWidth: number;
|
|
|
|
paneHeight: number;
|
|
|
|
sidebarWidth: number;
|
|
|
|
headerEditorKey: string;
|
|
|
|
vcs: VCS | null;
|
|
|
|
gitVCS: GitVCS | null;
|
2021-09-01 14:50:26 +00:00
|
|
|
};
|
2017-09-25 21:32:58 +00:00
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
interface State {
|
|
|
|
forceRefreshKey: number;
|
|
|
|
activeGitBranch: string;
|
|
|
|
}
|
2016-11-16 17:18:39 +00:00
|
|
|
|
fixes 'previewHidden' of undefined error (#3409)
* readability improvements and reduced indirection
* adds type for handleShowModifyCookieModal
* correctly types wrapperProps property, thereby fixing bug.
if you add `console.log({ previewHidden, propsOne: this.props.wrapperProps.activeWorkspaceMeta });` to the third line of `_renderPreview()` you'll see that `activeWorkspaceMeta` is indeed, sometimes, `undefined.
Also, there's no reason to use `await` on `this.setState`. I didn't find any more of these in the codebase, I just found this one.
* adds type for swaggerUiSpec
* undoes lifting props to state
almost always, this is done for performance reasons, but I removed it the app is working pretty quick-and-snappy for me without needing to introduced duplicated application state and keep track of it.
I went ahead and measured it before and after this commit (using performance.now):
before = [
1.93500000750646,
1.149999996414408,
0.9499999869149178,
0.9950000094249845,
0.8650000090710819,
1.560000004246831,
1.5699999930802733,
0.8450000023003668,
1.4550000196322799,
1.3299999991431832,
1.3050000125076622,
1.4099999971222132,
1.3099999923724681,
1.3100000214762986,
1.1999999987892807,
1.0099999781232327,
0.830000004498288,
1.2449999921955168,
1.2500000011641532,
1.4349999837577343,
]
after = [
2.9400000057648867,
2.449999999953434,
2.33499999740161,
2.2849999950267375,
1.7700000025797635,
1.8149999959859997,
2.1249999990686774,
1.9150000007357448,
2.074999996693805,
1.9899999897461385,
2.0200000144541264,
2.869999996619299,
2.1450000058393925,
2.33499999740161,
2.130000008037314,
2.119999990100041,
2.144999976735562,
2.130000008037314,
2.380000009201467,
2.8999999922234565,
]
> R.mean(before)
> 1.2480000004870817
> R.mean(after)
> 2.243749999080319
> R.median(before)
> 1.2775000068359077
> R.median(after)
> 2.137499992386438
So basically, considering a 16ms render rate (i.e. 60hz), 1ms saved by lifting props to state makes no difference in application performance.
This is committed separately so that if there's any reason we want to keep the prior implementation, we can just still do so.
2021-05-24 14:14:00 +00:00
|
|
|
const requestUpdate = (request: Request, patch: Partial<Request>) => {
|
2017-07-19 04:48:28 +00:00
|
|
|
if (!request) {
|
|
|
|
throw new Error('Tried to update null request');
|
|
|
|
}
|
|
|
|
|
fixes 'previewHidden' of undefined error (#3409)
* readability improvements and reduced indirection
* adds type for handleShowModifyCookieModal
* correctly types wrapperProps property, thereby fixing bug.
if you add `console.log({ previewHidden, propsOne: this.props.wrapperProps.activeWorkspaceMeta });` to the third line of `_renderPreview()` you'll see that `activeWorkspaceMeta` is indeed, sometimes, `undefined.
Also, there's no reason to use `await` on `this.setState`. I didn't find any more of these in the codebase, I just found this one.
* adds type for swaggerUiSpec
* undoes lifting props to state
almost always, this is done for performance reasons, but I removed it the app is working pretty quick-and-snappy for me without needing to introduced duplicated application state and keep track of it.
I went ahead and measured it before and after this commit (using performance.now):
before = [
1.93500000750646,
1.149999996414408,
0.9499999869149178,
0.9950000094249845,
0.8650000090710819,
1.560000004246831,
1.5699999930802733,
0.8450000023003668,
1.4550000196322799,
1.3299999991431832,
1.3050000125076622,
1.4099999971222132,
1.3099999923724681,
1.3100000214762986,
1.1999999987892807,
1.0099999781232327,
0.830000004498288,
1.2449999921955168,
1.2500000011641532,
1.4349999837577343,
]
after = [
2.9400000057648867,
2.449999999953434,
2.33499999740161,
2.2849999950267375,
1.7700000025797635,
1.8149999959859997,
2.1249999990686774,
1.9150000007357448,
2.074999996693805,
1.9899999897461385,
2.0200000144541264,
2.869999996619299,
2.1450000058393925,
2.33499999740161,
2.130000008037314,
2.119999990100041,
2.144999976735562,
2.130000008037314,
2.380000009201467,
2.8999999922234565,
]
> R.mean(before)
> 1.2480000004870817
> R.mean(after)
> 2.243749999080319
> R.median(before)
> 1.2775000068359077
> R.median(after)
> 2.137499992386438
So basically, considering a 16ms render rate (i.e. 60hz), 1ms saved by lifting props to state makes no difference in application performance.
This is committed separately so that if there's any reason we want to keep the prior implementation, we can just still do so.
2021-05-24 14:14:00 +00:00
|
|
|
return models.request.update(request, patch);
|
2017-07-19 04:48:28 +00:00
|
|
|
};
|
|
|
|
|
2021-02-02 22:23:42 +00:00
|
|
|
@autoBindMethodsForReact(AUTOBIND_CFG)
|
2021-09-27 13:47:22 +00:00
|
|
|
export class Wrapper extends PureComponent<WrapperProps, State> {
|
2021-05-12 06:35:00 +00:00
|
|
|
state: State = {
|
|
|
|
forceRefreshKey: Date.now(),
|
|
|
|
activeGitBranch: 'no-vcs',
|
2021-09-01 14:50:26 +00:00
|
|
|
};
|
2016-11-26 00:37:59 +00:00
|
|
|
|
|
|
|
// Request updaters
|
2021-05-12 06:35:00 +00:00
|
|
|
async _handleForceUpdateRequest(r: Request, patch: Partial<Request>) {
|
fixes 'previewHidden' of undefined error (#3409)
* readability improvements and reduced indirection
* adds type for handleShowModifyCookieModal
* correctly types wrapperProps property, thereby fixing bug.
if you add `console.log({ previewHidden, propsOne: this.props.wrapperProps.activeWorkspaceMeta });` to the third line of `_renderPreview()` you'll see that `activeWorkspaceMeta` is indeed, sometimes, `undefined.
Also, there's no reason to use `await` on `this.setState`. I didn't find any more of these in the codebase, I just found this one.
* adds type for swaggerUiSpec
* undoes lifting props to state
almost always, this is done for performance reasons, but I removed it the app is working pretty quick-and-snappy for me without needing to introduced duplicated application state and keep track of it.
I went ahead and measured it before and after this commit (using performance.now):
before = [
1.93500000750646,
1.149999996414408,
0.9499999869149178,
0.9950000094249845,
0.8650000090710819,
1.560000004246831,
1.5699999930802733,
0.8450000023003668,
1.4550000196322799,
1.3299999991431832,
1.3050000125076622,
1.4099999971222132,
1.3099999923724681,
1.3100000214762986,
1.1999999987892807,
1.0099999781232327,
0.830000004498288,
1.2449999921955168,
1.2500000011641532,
1.4349999837577343,
]
after = [
2.9400000057648867,
2.449999999953434,
2.33499999740161,
2.2849999950267375,
1.7700000025797635,
1.8149999959859997,
2.1249999990686774,
1.9150000007357448,
2.074999996693805,
1.9899999897461385,
2.0200000144541264,
2.869999996619299,
2.1450000058393925,
2.33499999740161,
2.130000008037314,
2.119999990100041,
2.144999976735562,
2.130000008037314,
2.380000009201467,
2.8999999922234565,
]
> R.mean(before)
> 1.2480000004870817
> R.mean(after)
> 2.243749999080319
> R.median(before)
> 1.2775000068359077
> R.median(after)
> 2.137499992386438
So basically, considering a 16ms render rate (i.e. 60hz), 1ms saved by lifting props to state makes no difference in application performance.
This is committed separately so that if there's any reason we want to keep the prior implementation, we can just still do so.
2021-05-24 14:14:00 +00:00
|
|
|
const newRequest = await requestUpdate(r, patch);
|
2021-09-15 13:01:35 +00:00
|
|
|
this._forceRequestPaneRefreshAfterDelay();
|
|
|
|
|
2017-02-02 18:30:13 +00:00
|
|
|
return newRequest;
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2021-05-18 20:32:18 +00:00
|
|
|
_handleForceUpdateRequestHeaders(r: Request, headers: RequestHeader[]) {
|
fixes 'previewHidden' of undefined error (#3409)
* readability improvements and reduced indirection
* adds type for handleShowModifyCookieModal
* correctly types wrapperProps property, thereby fixing bug.
if you add `console.log({ previewHidden, propsOne: this.props.wrapperProps.activeWorkspaceMeta });` to the third line of `_renderPreview()` you'll see that `activeWorkspaceMeta` is indeed, sometimes, `undefined.
Also, there's no reason to use `await` on `this.setState`. I didn't find any more of these in the codebase, I just found this one.
* adds type for swaggerUiSpec
* undoes lifting props to state
almost always, this is done for performance reasons, but I removed it the app is working pretty quick-and-snappy for me without needing to introduced duplicated application state and keep track of it.
I went ahead and measured it before and after this commit (using performance.now):
before = [
1.93500000750646,
1.149999996414408,
0.9499999869149178,
0.9950000094249845,
0.8650000090710819,
1.560000004246831,
1.5699999930802733,
0.8450000023003668,
1.4550000196322799,
1.3299999991431832,
1.3050000125076622,
1.4099999971222132,
1.3099999923724681,
1.3100000214762986,
1.1999999987892807,
1.0099999781232327,
0.830000004498288,
1.2449999921955168,
1.2500000011641532,
1.4349999837577343,
]
after = [
2.9400000057648867,
2.449999999953434,
2.33499999740161,
2.2849999950267375,
1.7700000025797635,
1.8149999959859997,
2.1249999990686774,
1.9150000007357448,
2.074999996693805,
1.9899999897461385,
2.0200000144541264,
2.869999996619299,
2.1450000058393925,
2.33499999740161,
2.130000008037314,
2.119999990100041,
2.144999976735562,
2.130000008037314,
2.380000009201467,
2.8999999922234565,
]
> R.mean(before)
> 1.2480000004870817
> R.mean(after)
> 2.243749999080319
> R.median(before)
> 1.2775000068359077
> R.median(after)
> 2.137499992386438
So basically, considering a 16ms render rate (i.e. 60hz), 1ms saved by lifting props to state makes no difference in application performance.
This is committed separately so that if there's any reason we want to keep the prior implementation, we can just still do so.
2021-05-24 14:14:00 +00:00
|
|
|
return this._handleForceUpdateRequest(r, { headers });
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-28 07:12:17 +00:00
|
|
|
|
fixes 'previewHidden' of undefined error (#3409)
* readability improvements and reduced indirection
* adds type for handleShowModifyCookieModal
* correctly types wrapperProps property, thereby fixing bug.
if you add `console.log({ previewHidden, propsOne: this.props.wrapperProps.activeWorkspaceMeta });` to the third line of `_renderPreview()` you'll see that `activeWorkspaceMeta` is indeed, sometimes, `undefined.
Also, there's no reason to use `await` on `this.setState`. I didn't find any more of these in the codebase, I just found this one.
* adds type for swaggerUiSpec
* undoes lifting props to state
almost always, this is done for performance reasons, but I removed it the app is working pretty quick-and-snappy for me without needing to introduced duplicated application state and keep track of it.
I went ahead and measured it before and after this commit (using performance.now):
before = [
1.93500000750646,
1.149999996414408,
0.9499999869149178,
0.9950000094249845,
0.8650000090710819,
1.560000004246831,
1.5699999930802733,
0.8450000023003668,
1.4550000196322799,
1.3299999991431832,
1.3050000125076622,
1.4099999971222132,
1.3099999923724681,
1.3100000214762986,
1.1999999987892807,
1.0099999781232327,
0.830000004498288,
1.2449999921955168,
1.2500000011641532,
1.4349999837577343,
]
after = [
2.9400000057648867,
2.449999999953434,
2.33499999740161,
2.2849999950267375,
1.7700000025797635,
1.8149999959859997,
2.1249999990686774,
1.9150000007357448,
2.074999996693805,
1.9899999897461385,
2.0200000144541264,
2.869999996619299,
2.1450000058393925,
2.33499999740161,
2.130000008037314,
2.119999990100041,
2.144999976735562,
2.130000008037314,
2.380000009201467,
2.8999999922234565,
]
> R.mean(before)
> 1.2480000004870817
> R.mean(after)
> 2.243749999080319
> R.median(before)
> 1.2775000068359077
> R.median(after)
> 2.137499992386438
So basically, considering a 16ms render rate (i.e. 60hz), 1ms saved by lifting props to state makes no difference in application performance.
This is committed separately so that if there's any reason we want to keep the prior implementation, we can just still do so.
2021-05-24 14:14:00 +00:00
|
|
|
async _handleUpdateApiSpec(apiSpec: ApiSpec) {
|
|
|
|
await models.apiSpec.update(apiSpec);
|
2020-04-26 20:33:39 +00:00
|
|
|
}
|
|
|
|
|
fixes 'previewHidden' of undefined error (#3409)
* readability improvements and reduced indirection
* adds type for handleShowModifyCookieModal
* correctly types wrapperProps property, thereby fixing bug.
if you add `console.log({ previewHidden, propsOne: this.props.wrapperProps.activeWorkspaceMeta });` to the third line of `_renderPreview()` you'll see that `activeWorkspaceMeta` is indeed, sometimes, `undefined.
Also, there's no reason to use `await` on `this.setState`. I didn't find any more of these in the codebase, I just found this one.
* adds type for swaggerUiSpec
* undoes lifting props to state
almost always, this is done for performance reasons, but I removed it the app is working pretty quick-and-snappy for me without needing to introduced duplicated application state and keep track of it.
I went ahead and measured it before and after this commit (using performance.now):
before = [
1.93500000750646,
1.149999996414408,
0.9499999869149178,
0.9950000094249845,
0.8650000090710819,
1.560000004246831,
1.5699999930802733,
0.8450000023003668,
1.4550000196322799,
1.3299999991431832,
1.3050000125076622,
1.4099999971222132,
1.3099999923724681,
1.3100000214762986,
1.1999999987892807,
1.0099999781232327,
0.830000004498288,
1.2449999921955168,
1.2500000011641532,
1.4349999837577343,
]
after = [
2.9400000057648867,
2.449999999953434,
2.33499999740161,
2.2849999950267375,
1.7700000025797635,
1.8149999959859997,
2.1249999990686774,
1.9150000007357448,
2.074999996693805,
1.9899999897461385,
2.0200000144541264,
2.869999996619299,
2.1450000058393925,
2.33499999740161,
2.130000008037314,
2.119999990100041,
2.144999976735562,
2.130000008037314,
2.380000009201467,
2.8999999922234565,
]
> R.mean(before)
> 1.2480000004870817
> R.mean(after)
> 2.243749999080319
> R.median(before)
> 1.2775000068359077
> R.median(after)
> 2.137499992386438
So basically, considering a 16ms render rate (i.e. 60hz), 1ms saved by lifting props to state makes no difference in application performance.
This is committed separately so that if there's any reason we want to keep the prior implementation, we can just still do so.
2021-05-24 14:14:00 +00:00
|
|
|
static _handleUpdateRequestBody(request: Request, body: RequestBody) {
|
|
|
|
return requestUpdate(request, { body });
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
fixes 'previewHidden' of undefined error (#3409)
* readability improvements and reduced indirection
* adds type for handleShowModifyCookieModal
* correctly types wrapperProps property, thereby fixing bug.
if you add `console.log({ previewHidden, propsOne: this.props.wrapperProps.activeWorkspaceMeta });` to the third line of `_renderPreview()` you'll see that `activeWorkspaceMeta` is indeed, sometimes, `undefined.
Also, there's no reason to use `await` on `this.setState`. I didn't find any more of these in the codebase, I just found this one.
* adds type for swaggerUiSpec
* undoes lifting props to state
almost always, this is done for performance reasons, but I removed it the app is working pretty quick-and-snappy for me without needing to introduced duplicated application state and keep track of it.
I went ahead and measured it before and after this commit (using performance.now):
before = [
1.93500000750646,
1.149999996414408,
0.9499999869149178,
0.9950000094249845,
0.8650000090710819,
1.560000004246831,
1.5699999930802733,
0.8450000023003668,
1.4550000196322799,
1.3299999991431832,
1.3050000125076622,
1.4099999971222132,
1.3099999923724681,
1.3100000214762986,
1.1999999987892807,
1.0099999781232327,
0.830000004498288,
1.2449999921955168,
1.2500000011641532,
1.4349999837577343,
]
after = [
2.9400000057648867,
2.449999999953434,
2.33499999740161,
2.2849999950267375,
1.7700000025797635,
1.8149999959859997,
2.1249999990686774,
1.9150000007357448,
2.074999996693805,
1.9899999897461385,
2.0200000144541264,
2.869999996619299,
2.1450000058393925,
2.33499999740161,
2.130000008037314,
2.119999990100041,
2.144999976735562,
2.130000008037314,
2.380000009201467,
2.8999999922234565,
]
> R.mean(before)
> 1.2480000004870817
> R.mean(after)
> 2.243749999080319
> R.median(before)
> 1.2775000068359077
> R.median(after)
> 2.137499992386438
So basically, considering a 16ms render rate (i.e. 60hz), 1ms saved by lifting props to state makes no difference in application performance.
This is committed separately so that if there's any reason we want to keep the prior implementation, we can just still do so.
2021-05-24 14:14:00 +00:00
|
|
|
static _handleUpdateRequestParameters(request: Request, parameters: RequestParameter[]) {
|
|
|
|
return requestUpdate(request, { parameters });
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
fixes 'previewHidden' of undefined error (#3409)
* readability improvements and reduced indirection
* adds type for handleShowModifyCookieModal
* correctly types wrapperProps property, thereby fixing bug.
if you add `console.log({ previewHidden, propsOne: this.props.wrapperProps.activeWorkspaceMeta });` to the third line of `_renderPreview()` you'll see that `activeWorkspaceMeta` is indeed, sometimes, `undefined.
Also, there's no reason to use `await` on `this.setState`. I didn't find any more of these in the codebase, I just found this one.
* adds type for swaggerUiSpec
* undoes lifting props to state
almost always, this is done for performance reasons, but I removed it the app is working pretty quick-and-snappy for me without needing to introduced duplicated application state and keep track of it.
I went ahead and measured it before and after this commit (using performance.now):
before = [
1.93500000750646,
1.149999996414408,
0.9499999869149178,
0.9950000094249845,
0.8650000090710819,
1.560000004246831,
1.5699999930802733,
0.8450000023003668,
1.4550000196322799,
1.3299999991431832,
1.3050000125076622,
1.4099999971222132,
1.3099999923724681,
1.3100000214762986,
1.1999999987892807,
1.0099999781232327,
0.830000004498288,
1.2449999921955168,
1.2500000011641532,
1.4349999837577343,
]
after = [
2.9400000057648867,
2.449999999953434,
2.33499999740161,
2.2849999950267375,
1.7700000025797635,
1.8149999959859997,
2.1249999990686774,
1.9150000007357448,
2.074999996693805,
1.9899999897461385,
2.0200000144541264,
2.869999996619299,
2.1450000058393925,
2.33499999740161,
2.130000008037314,
2.119999990100041,
2.144999976735562,
2.130000008037314,
2.380000009201467,
2.8999999922234565,
]
> R.mean(before)
> 1.2480000004870817
> R.mean(after)
> 2.243749999080319
> R.median(before)
> 1.2775000068359077
> R.median(after)
> 2.137499992386438
So basically, considering a 16ms render rate (i.e. 60hz), 1ms saved by lifting props to state makes no difference in application performance.
This is committed separately so that if there's any reason we want to keep the prior implementation, we can just still do so.
2021-05-24 14:14:00 +00:00
|
|
|
static _handleUpdateRequestAuthentication(request: Request, authentication: RequestAuthentication) {
|
|
|
|
return requestUpdate(request, { authentication });
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
fixes 'previewHidden' of undefined error (#3409)
* readability improvements and reduced indirection
* adds type for handleShowModifyCookieModal
* correctly types wrapperProps property, thereby fixing bug.
if you add `console.log({ previewHidden, propsOne: this.props.wrapperProps.activeWorkspaceMeta });` to the third line of `_renderPreview()` you'll see that `activeWorkspaceMeta` is indeed, sometimes, `undefined.
Also, there's no reason to use `await` on `this.setState`. I didn't find any more of these in the codebase, I just found this one.
* adds type for swaggerUiSpec
* undoes lifting props to state
almost always, this is done for performance reasons, but I removed it the app is working pretty quick-and-snappy for me without needing to introduced duplicated application state and keep track of it.
I went ahead and measured it before and after this commit (using performance.now):
before = [
1.93500000750646,
1.149999996414408,
0.9499999869149178,
0.9950000094249845,
0.8650000090710819,
1.560000004246831,
1.5699999930802733,
0.8450000023003668,
1.4550000196322799,
1.3299999991431832,
1.3050000125076622,
1.4099999971222132,
1.3099999923724681,
1.3100000214762986,
1.1999999987892807,
1.0099999781232327,
0.830000004498288,
1.2449999921955168,
1.2500000011641532,
1.4349999837577343,
]
after = [
2.9400000057648867,
2.449999999953434,
2.33499999740161,
2.2849999950267375,
1.7700000025797635,
1.8149999959859997,
2.1249999990686774,
1.9150000007357448,
2.074999996693805,
1.9899999897461385,
2.0200000144541264,
2.869999996619299,
2.1450000058393925,
2.33499999740161,
2.130000008037314,
2.119999990100041,
2.144999976735562,
2.130000008037314,
2.380000009201467,
2.8999999922234565,
]
> R.mean(before)
> 1.2480000004870817
> R.mean(after)
> 2.243749999080319
> R.median(before)
> 1.2775000068359077
> R.median(after)
> 2.137499992386438
So basically, considering a 16ms render rate (i.e. 60hz), 1ms saved by lifting props to state makes no difference in application performance.
This is committed separately so that if there's any reason we want to keep the prior implementation, we can just still do so.
2021-05-24 14:14:00 +00:00
|
|
|
static _handleUpdateRequestHeaders(request: Request, headers: RequestHeader[]) {
|
|
|
|
return requestUpdate(request, { headers });
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
fixes 'previewHidden' of undefined error (#3409)
* readability improvements and reduced indirection
* adds type for handleShowModifyCookieModal
* correctly types wrapperProps property, thereby fixing bug.
if you add `console.log({ previewHidden, propsOne: this.props.wrapperProps.activeWorkspaceMeta });` to the third line of `_renderPreview()` you'll see that `activeWorkspaceMeta` is indeed, sometimes, `undefined.
Also, there's no reason to use `await` on `this.setState`. I didn't find any more of these in the codebase, I just found this one.
* adds type for swaggerUiSpec
* undoes lifting props to state
almost always, this is done for performance reasons, but I removed it the app is working pretty quick-and-snappy for me without needing to introduced duplicated application state and keep track of it.
I went ahead and measured it before and after this commit (using performance.now):
before = [
1.93500000750646,
1.149999996414408,
0.9499999869149178,
0.9950000094249845,
0.8650000090710819,
1.560000004246831,
1.5699999930802733,
0.8450000023003668,
1.4550000196322799,
1.3299999991431832,
1.3050000125076622,
1.4099999971222132,
1.3099999923724681,
1.3100000214762986,
1.1999999987892807,
1.0099999781232327,
0.830000004498288,
1.2449999921955168,
1.2500000011641532,
1.4349999837577343,
]
after = [
2.9400000057648867,
2.449999999953434,
2.33499999740161,
2.2849999950267375,
1.7700000025797635,
1.8149999959859997,
2.1249999990686774,
1.9150000007357448,
2.074999996693805,
1.9899999897461385,
2.0200000144541264,
2.869999996619299,
2.1450000058393925,
2.33499999740161,
2.130000008037314,
2.119999990100041,
2.144999976735562,
2.130000008037314,
2.380000009201467,
2.8999999922234565,
]
> R.mean(before)
> 1.2480000004870817
> R.mean(after)
> 2.243749999080319
> R.median(before)
> 1.2775000068359077
> R.median(after)
> 2.137499992386438
So basically, considering a 16ms render rate (i.e. 60hz), 1ms saved by lifting props to state makes no difference in application performance.
This is committed separately so that if there's any reason we want to keep the prior implementation, we can just still do so.
2021-05-24 14:14:00 +00:00
|
|
|
static _handleUpdateRequestMethod(request: Request, method: string) {
|
|
|
|
return requestUpdate(request, { method });
|
2017-11-10 15:50:33 +00:00
|
|
|
}
|
|
|
|
|
fixes 'previewHidden' of undefined error (#3409)
* readability improvements and reduced indirection
* adds type for handleShowModifyCookieModal
* correctly types wrapperProps property, thereby fixing bug.
if you add `console.log({ previewHidden, propsOne: this.props.wrapperProps.activeWorkspaceMeta });` to the third line of `_renderPreview()` you'll see that `activeWorkspaceMeta` is indeed, sometimes, `undefined.
Also, there's no reason to use `await` on `this.setState`. I didn't find any more of these in the codebase, I just found this one.
* adds type for swaggerUiSpec
* undoes lifting props to state
almost always, this is done for performance reasons, but I removed it the app is working pretty quick-and-snappy for me without needing to introduced duplicated application state and keep track of it.
I went ahead and measured it before and after this commit (using performance.now):
before = [
1.93500000750646,
1.149999996414408,
0.9499999869149178,
0.9950000094249845,
0.8650000090710819,
1.560000004246831,
1.5699999930802733,
0.8450000023003668,
1.4550000196322799,
1.3299999991431832,
1.3050000125076622,
1.4099999971222132,
1.3099999923724681,
1.3100000214762986,
1.1999999987892807,
1.0099999781232327,
0.830000004498288,
1.2449999921955168,
1.2500000011641532,
1.4349999837577343,
]
after = [
2.9400000057648867,
2.449999999953434,
2.33499999740161,
2.2849999950267375,
1.7700000025797635,
1.8149999959859997,
2.1249999990686774,
1.9150000007357448,
2.074999996693805,
1.9899999897461385,
2.0200000144541264,
2.869999996619299,
2.1450000058393925,
2.33499999740161,
2.130000008037314,
2.119999990100041,
2.144999976735562,
2.130000008037314,
2.380000009201467,
2.8999999922234565,
]
> R.mean(before)
> 1.2480000004870817
> R.mean(after)
> 2.243749999080319
> R.median(before)
> 1.2775000068359077
> R.median(after)
> 2.137499992386438
So basically, considering a 16ms render rate (i.e. 60hz), 1ms saved by lifting props to state makes no difference in application performance.
This is committed separately so that if there's any reason we want to keep the prior implementation, we can just still do so.
2021-05-24 14:14:00 +00:00
|
|
|
static _handleUpdateRequestUrl(request: Request, url: string) {
|
2019-04-18 00:50:03 +00:00
|
|
|
// Don't update if we don't need to
|
fixes 'previewHidden' of undefined error (#3409)
* readability improvements and reduced indirection
* adds type for handleShowModifyCookieModal
* correctly types wrapperProps property, thereby fixing bug.
if you add `console.log({ previewHidden, propsOne: this.props.wrapperProps.activeWorkspaceMeta });` to the third line of `_renderPreview()` you'll see that `activeWorkspaceMeta` is indeed, sometimes, `undefined.
Also, there's no reason to use `await` on `this.setState`. I didn't find any more of these in the codebase, I just found this one.
* adds type for swaggerUiSpec
* undoes lifting props to state
almost always, this is done for performance reasons, but I removed it the app is working pretty quick-and-snappy for me without needing to introduced duplicated application state and keep track of it.
I went ahead and measured it before and after this commit (using performance.now):
before = [
1.93500000750646,
1.149999996414408,
0.9499999869149178,
0.9950000094249845,
0.8650000090710819,
1.560000004246831,
1.5699999930802733,
0.8450000023003668,
1.4550000196322799,
1.3299999991431832,
1.3050000125076622,
1.4099999971222132,
1.3099999923724681,
1.3100000214762986,
1.1999999987892807,
1.0099999781232327,
0.830000004498288,
1.2449999921955168,
1.2500000011641532,
1.4349999837577343,
]
after = [
2.9400000057648867,
2.449999999953434,
2.33499999740161,
2.2849999950267375,
1.7700000025797635,
1.8149999959859997,
2.1249999990686774,
1.9150000007357448,
2.074999996693805,
1.9899999897461385,
2.0200000144541264,
2.869999996619299,
2.1450000058393925,
2.33499999740161,
2.130000008037314,
2.119999990100041,
2.144999976735562,
2.130000008037314,
2.380000009201467,
2.8999999922234565,
]
> R.mean(before)
> 1.2480000004870817
> R.mean(after)
> 2.243749999080319
> R.median(before)
> 1.2775000068359077
> R.median(after)
> 2.137499992386438
So basically, considering a 16ms render rate (i.e. 60hz), 1ms saved by lifting props to state makes no difference in application performance.
This is committed separately so that if there's any reason we want to keep the prior implementation, we can just still do so.
2021-05-24 14:14:00 +00:00
|
|
|
if (request.url === url) {
|
|
|
|
return Promise.resolve(request);
|
2019-04-18 00:50:03 +00:00
|
|
|
}
|
|
|
|
|
fixes 'previewHidden' of undefined error (#3409)
* readability improvements and reduced indirection
* adds type for handleShowModifyCookieModal
* correctly types wrapperProps property, thereby fixing bug.
if you add `console.log({ previewHidden, propsOne: this.props.wrapperProps.activeWorkspaceMeta });` to the third line of `_renderPreview()` you'll see that `activeWorkspaceMeta` is indeed, sometimes, `undefined.
Also, there's no reason to use `await` on `this.setState`. I didn't find any more of these in the codebase, I just found this one.
* adds type for swaggerUiSpec
* undoes lifting props to state
almost always, this is done for performance reasons, but I removed it the app is working pretty quick-and-snappy for me without needing to introduced duplicated application state and keep track of it.
I went ahead and measured it before and after this commit (using performance.now):
before = [
1.93500000750646,
1.149999996414408,
0.9499999869149178,
0.9950000094249845,
0.8650000090710819,
1.560000004246831,
1.5699999930802733,
0.8450000023003668,
1.4550000196322799,
1.3299999991431832,
1.3050000125076622,
1.4099999971222132,
1.3099999923724681,
1.3100000214762986,
1.1999999987892807,
1.0099999781232327,
0.830000004498288,
1.2449999921955168,
1.2500000011641532,
1.4349999837577343,
]
after = [
2.9400000057648867,
2.449999999953434,
2.33499999740161,
2.2849999950267375,
1.7700000025797635,
1.8149999959859997,
2.1249999990686774,
1.9150000007357448,
2.074999996693805,
1.9899999897461385,
2.0200000144541264,
2.869999996619299,
2.1450000058393925,
2.33499999740161,
2.130000008037314,
2.119999990100041,
2.144999976735562,
2.130000008037314,
2.380000009201467,
2.8999999922234565,
]
> R.mean(before)
> 1.2480000004870817
> R.mean(after)
> 2.243749999080319
> R.median(before)
> 1.2775000068359077
> R.median(after)
> 2.137499992386438
So basically, considering a 16ms render rate (i.e. 60hz), 1ms saved by lifting props to state makes no difference in application performance.
This is committed separately so that if there's any reason we want to keep the prior implementation, we can just still do so.
2021-05-24 14:14:00 +00:00
|
|
|
return requestUpdate(request, { url });
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-26 00:37:59 +00:00
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
async _handleImport(text: string) {
|
2021-06-30 07:47:17 +00:00
|
|
|
const { activeRequest } = this.props;
|
|
|
|
|
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];
|
|
|
|
|
2021-06-30 07:47:17 +00:00
|
|
|
if (r && r._type === 'request' && activeRequest && isRequest(activeRequest)) {
|
2016-11-26 00:37:59 +00:00
|
|
|
// Only pull fields that we want to update
|
2021-06-30 07:47:17 +00:00
|
|
|
return this._handleForceUpdateRequest(activeRequest, {
|
2016-11-26 00:37:59 +00:00
|
|
|
url: r.url,
|
|
|
|
method: r.method,
|
|
|
|
headers: r.headers,
|
2021-05-12 06:35:00 +00:00
|
|
|
// @ts-expect-error -- TSCONVERSION
|
2016-11-26 00:37:59 +00:00
|
|
|
body: r.body,
|
|
|
|
authentication: r.authentication,
|
2021-05-12 06:35:00 +00:00
|
|
|
// @ts-expect-error -- TSCONVERSION
|
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
|
|
|
|
2021-09-01 14:50:26 +00:00
|
|
|
async _handleWorkspaceActivityChange({ workspaceId, nextActivity }: {workspaceId?: string; nextActivity: GlobalActivity}) {
|
2020-06-30 23:54:56 +00:00
|
|
|
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
|
2021-06-30 07:47:17 +00:00
|
|
|
if (workspaceId && nextActivity !== ACTIVITY_HOME) {
|
2021-05-12 06:35:00 +00:00
|
|
|
await models.workspaceMeta.updateByParentId(workspaceId, {
|
|
|
|
activeActivity: nextActivity,
|
|
|
|
});
|
2020-06-30 23:54:56 +00:00
|
|
|
}
|
|
|
|
|
2021-07-20 01:05:08 +00:00
|
|
|
const editingASpec = activity === ACTIVITY_SPEC;
|
2021-05-12 06:35:00 +00:00
|
|
|
|
2021-07-20 01:05:08 +00:00
|
|
|
if (!editingASpec) {
|
2020-06-30 23:54:56 +00:00
|
|
|
handleSetActiveActivity(nextActivity);
|
|
|
|
return;
|
|
|
|
}
|
2020-04-26 20:33:39 +00:00
|
|
|
|
2021-06-30 07:47:17 +00:00
|
|
|
if (!activeApiSpec || !workspaceId) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-20 01:05:08 +00:00
|
|
|
const goingToDebugOrTest = nextActivity === ACTIVITY_DEBUG || nextActivity === ACTIVITY_UNIT_TEST;
|
|
|
|
|
|
|
|
// If editing a spec and not going to debug or test, don't regenerate anything
|
|
|
|
if (editingASpec && !goingToDebugOrTest) {
|
|
|
|
handleSetActiveActivity(nextActivity);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
// If there are errors in the spec, show the user a warning first
|
2021-06-30 15:11:20 +00:00
|
|
|
const results = (await spectral.run(activeApiSpec.contents)).filter(isLintError);
|
2020-06-30 23:54:56 +00:00
|
|
|
if (activeApiSpec.contents && results && results.length) {
|
|
|
|
showModal(AlertModal, {
|
|
|
|
title: 'Error Generating Configuration',
|
2022-01-07 22:32:09 +00:00
|
|
|
message: 'Some requests may not be available due to errors found in the specification. We recommend fixing errors before proceeding.',
|
2020-06-30 23:54:56 +00:00
|
|
|
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(() => {
|
2021-03-02 21:16:48 +00:00
|
|
|
importRaw(activeApiSpec.contents, {
|
|
|
|
getWorkspaceId: () => Promise.resolve(workspaceId),
|
Differential (Additive/Removal) patching when switching between design / debug (#3124)
* fix(import) do differential patching for design activity imports
This patch adds differential patching for imports that occur during the switching between
design and debug tabs inside of Designer. As reported through #2971, and others, this patch
favors existing data over imported data, values that exist already on the document will remain
unchanged, only new values (including array based values) will be added / removed.
This also includes a bypass feature for urls, currently these options are not exposed through
the interface but could be. This feature is an object to allow for future properties for
preference-based patching.
- Adds `options.enableDiffBasedPatching` and `options.enableDiffDeep` to `importRaw` for backwards compat.
- Adds `options.bypassDiffProps.url` for url bypassing and use an object for future items.
- Adds `diffPatchObj` based on differential patching for objects (works with arrays as well).
Future ideas:
- `hasBeenModifiedByUser` property map object to allow changing properties that haven't been touched by the user with options.
fixes: #2971, #2882, #3038, #2442
* adds some basic tests
- also adds jest (which was (mistakenly) not there before)
- does not call `.hasOwnProperty` directly, per https://eslint.org/docs/rules/no-prototype-builtins (which, we will add more formally at a later date)
* don't special-case workspaces
this ensures the behavior of the initial PR is more preserved
Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>
2021-03-03 17:57:09 +00:00
|
|
|
enableDiffBasedPatching: true,
|
|
|
|
enableDiffDeep: true,
|
|
|
|
bypassDiffProps: {
|
|
|
|
url: true,
|
|
|
|
},
|
2021-03-02 21:16:48 +00:00
|
|
|
});
|
2020-04-26 20:33:39 +00:00
|
|
|
}, 1000);
|
|
|
|
}
|
|
|
|
|
2016-11-26 00:37:59 +00:00
|
|
|
// Settings updaters
|
2021-05-12 06:35:00 +00:00
|
|
|
_handleUpdateSettingsShowPasswords(showPasswords: boolean) {
|
fixes 'previewHidden' of undefined error (#3409)
* readability improvements and reduced indirection
* adds type for handleShowModifyCookieModal
* correctly types wrapperProps property, thereby fixing bug.
if you add `console.log({ previewHidden, propsOne: this.props.wrapperProps.activeWorkspaceMeta });` to the third line of `_renderPreview()` you'll see that `activeWorkspaceMeta` is indeed, sometimes, `undefined.
Also, there's no reason to use `await` on `this.setState`. I didn't find any more of these in the codebase, I just found this one.
* adds type for swaggerUiSpec
* undoes lifting props to state
almost always, this is done for performance reasons, but I removed it the app is working pretty quick-and-snappy for me without needing to introduced duplicated application state and keep track of it.
I went ahead and measured it before and after this commit (using performance.now):
before = [
1.93500000750646,
1.149999996414408,
0.9499999869149178,
0.9950000094249845,
0.8650000090710819,
1.560000004246831,
1.5699999930802733,
0.8450000023003668,
1.4550000196322799,
1.3299999991431832,
1.3050000125076622,
1.4099999971222132,
1.3099999923724681,
1.3100000214762986,
1.1999999987892807,
1.0099999781232327,
0.830000004498288,
1.2449999921955168,
1.2500000011641532,
1.4349999837577343,
]
after = [
2.9400000057648867,
2.449999999953434,
2.33499999740161,
2.2849999950267375,
1.7700000025797635,
1.8149999959859997,
2.1249999990686774,
1.9150000007357448,
2.074999996693805,
1.9899999897461385,
2.0200000144541264,
2.869999996619299,
2.1450000058393925,
2.33499999740161,
2.130000008037314,
2.119999990100041,
2.144999976735562,
2.130000008037314,
2.380000009201467,
2.8999999922234565,
]
> R.mean(before)
> 1.2480000004870817
> R.mean(after)
> 2.243749999080319
> R.median(before)
> 1.2775000068359077
> R.median(after)
> 2.137499992386438
So basically, considering a 16ms render rate (i.e. 60hz), 1ms saved by lifting props to state makes no difference in application performance.
This is committed separately so that if there's any reason we want to keep the prior implementation, we can just still do so.
2021-05-24 14:14:00 +00:00
|
|
|
return models.settings.update(this.props.settings, { showPasswords });
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
_handleUpdateSettingsUseBulkHeaderEditor(useBulkHeaderEditor: boolean) {
|
fixes 'previewHidden' of undefined error (#3409)
* readability improvements and reduced indirection
* adds type for handleShowModifyCookieModal
* correctly types wrapperProps property, thereby fixing bug.
if you add `console.log({ previewHidden, propsOne: this.props.wrapperProps.activeWorkspaceMeta });` to the third line of `_renderPreview()` you'll see that `activeWorkspaceMeta` is indeed, sometimes, `undefined.
Also, there's no reason to use `await` on `this.setState`. I didn't find any more of these in the codebase, I just found this one.
* adds type for swaggerUiSpec
* undoes lifting props to state
almost always, this is done for performance reasons, but I removed it the app is working pretty quick-and-snappy for me without needing to introduced duplicated application state and keep track of it.
I went ahead and measured it before and after this commit (using performance.now):
before = [
1.93500000750646,
1.149999996414408,
0.9499999869149178,
0.9950000094249845,
0.8650000090710819,
1.560000004246831,
1.5699999930802733,
0.8450000023003668,
1.4550000196322799,
1.3299999991431832,
1.3050000125076622,
1.4099999971222132,
1.3099999923724681,
1.3100000214762986,
1.1999999987892807,
1.0099999781232327,
0.830000004498288,
1.2449999921955168,
1.2500000011641532,
1.4349999837577343,
]
after = [
2.9400000057648867,
2.449999999953434,
2.33499999740161,
2.2849999950267375,
1.7700000025797635,
1.8149999959859997,
2.1249999990686774,
1.9150000007357448,
2.074999996693805,
1.9899999897461385,
2.0200000144541264,
2.869999996619299,
2.1450000058393925,
2.33499999740161,
2.130000008037314,
2.119999990100041,
2.144999976735562,
2.130000008037314,
2.380000009201467,
2.8999999922234565,
]
> R.mean(before)
> 1.2480000004870817
> R.mean(after)
> 2.243749999080319
> R.median(before)
> 1.2775000068359077
> R.median(after)
> 2.137499992386438
So basically, considering a 16ms render rate (i.e. 60hz), 1ms saved by lifting props to state makes no difference in application performance.
This is committed separately so that if there's any reason we want to keep the prior implementation, we can just still do so.
2021-05-24 14:14:00 +00:00
|
|
|
return models.settings.update(this.props.settings, { useBulkHeaderEditor });
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-26 00:37:59 +00:00
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
_handleUpdateSettingsUseBulkParametersEditor(useBulkParametersEditor: boolean) {
|
fixes 'previewHidden' of undefined error (#3409)
* readability improvements and reduced indirection
* adds type for handleShowModifyCookieModal
* correctly types wrapperProps property, thereby fixing bug.
if you add `console.log({ previewHidden, propsOne: this.props.wrapperProps.activeWorkspaceMeta });` to the third line of `_renderPreview()` you'll see that `activeWorkspaceMeta` is indeed, sometimes, `undefined.
Also, there's no reason to use `await` on `this.setState`. I didn't find any more of these in the codebase, I just found this one.
* adds type for swaggerUiSpec
* undoes lifting props to state
almost always, this is done for performance reasons, but I removed it the app is working pretty quick-and-snappy for me without needing to introduced duplicated application state and keep track of it.
I went ahead and measured it before and after this commit (using performance.now):
before = [
1.93500000750646,
1.149999996414408,
0.9499999869149178,
0.9950000094249845,
0.8650000090710819,
1.560000004246831,
1.5699999930802733,
0.8450000023003668,
1.4550000196322799,
1.3299999991431832,
1.3050000125076622,
1.4099999971222132,
1.3099999923724681,
1.3100000214762986,
1.1999999987892807,
1.0099999781232327,
0.830000004498288,
1.2449999921955168,
1.2500000011641532,
1.4349999837577343,
]
after = [
2.9400000057648867,
2.449999999953434,
2.33499999740161,
2.2849999950267375,
1.7700000025797635,
1.8149999959859997,
2.1249999990686774,
1.9150000007357448,
2.074999996693805,
1.9899999897461385,
2.0200000144541264,
2.869999996619299,
2.1450000058393925,
2.33499999740161,
2.130000008037314,
2.119999990100041,
2.144999976735562,
2.130000008037314,
2.380000009201467,
2.8999999922234565,
]
> R.mean(before)
> 1.2480000004870817
> R.mean(after)
> 2.243749999080319
> R.median(before)
> 1.2775000068359077
> R.median(after)
> 2.137499992386438
So basically, considering a 16ms render rate (i.e. 60hz), 1ms saved by lifting props to state makes no difference in application performance.
This is committed separately so that if there's any reason we want to keep the prior implementation, we can just still do so.
2021-05-24 14:14:00 +00:00
|
|
|
return models.settings.update(this.props.settings, { useBulkParametersEditor });
|
2020-08-03 10:13:08 +00:00
|
|
|
}
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
_handleSetActiveResponse(responseId: string | null) {
|
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
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
_handleShowEnvironmentsModal() {
|
2017-03-03 01:44:07 +00:00
|
|
|
showModal(WorkspaceEnvironmentsEditModal, this.props.activeWorkspace);
|
|
|
|
}
|
2016-11-26 00:37:59 +00:00
|
|
|
|
fixes 'previewHidden' of undefined error (#3409)
* readability improvements and reduced indirection
* adds type for handleShowModifyCookieModal
* correctly types wrapperProps property, thereby fixing bug.
if you add `console.log({ previewHidden, propsOne: this.props.wrapperProps.activeWorkspaceMeta });` to the third line of `_renderPreview()` you'll see that `activeWorkspaceMeta` is indeed, sometimes, `undefined.
Also, there's no reason to use `await` on `this.setState`. I didn't find any more of these in the codebase, I just found this one.
* adds type for swaggerUiSpec
* undoes lifting props to state
almost always, this is done for performance reasons, but I removed it the app is working pretty quick-and-snappy for me without needing to introduced duplicated application state and keep track of it.
I went ahead and measured it before and after this commit (using performance.now):
before = [
1.93500000750646,
1.149999996414408,
0.9499999869149178,
0.9950000094249845,
0.8650000090710819,
1.560000004246831,
1.5699999930802733,
0.8450000023003668,
1.4550000196322799,
1.3299999991431832,
1.3050000125076622,
1.4099999971222132,
1.3099999923724681,
1.3100000214762986,
1.1999999987892807,
1.0099999781232327,
0.830000004498288,
1.2449999921955168,
1.2500000011641532,
1.4349999837577343,
]
after = [
2.9400000057648867,
2.449999999953434,
2.33499999740161,
2.2849999950267375,
1.7700000025797635,
1.8149999959859997,
2.1249999990686774,
1.9150000007357448,
2.074999996693805,
1.9899999897461385,
2.0200000144541264,
2.869999996619299,
2.1450000058393925,
2.33499999740161,
2.130000008037314,
2.119999990100041,
2.144999976735562,
2.130000008037314,
2.380000009201467,
2.8999999922234565,
]
> R.mean(before)
> 1.2480000004870817
> R.mean(after)
> 2.243749999080319
> R.median(before)
> 1.2775000068359077
> R.median(after)
> 2.137499992386438
So basically, considering a 16ms render rate (i.e. 60hz), 1ms saved by lifting props to state makes no difference in application performance.
This is committed separately so that if there's any reason we want to keep the prior implementation, we can just still do so.
2021-05-24 14:14:00 +00:00
|
|
|
static _handleShowModifyCookieModal(cookie: Cookie) {
|
2017-08-22 22:30:57 +00:00
|
|
|
showModal(CookieModifyModal, cookie);
|
2017-08-19 22:34:16 +00:00
|
|
|
}
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
_handleShowRequestSettingsModal() {
|
fixes 'previewHidden' of undefined error (#3409)
* readability improvements and reduced indirection
* adds type for handleShowModifyCookieModal
* correctly types wrapperProps property, thereby fixing bug.
if you add `console.log({ previewHidden, propsOne: this.props.wrapperProps.activeWorkspaceMeta });` to the third line of `_renderPreview()` you'll see that `activeWorkspaceMeta` is indeed, sometimes, `undefined.
Also, there's no reason to use `await` on `this.setState`. I didn't find any more of these in the codebase, I just found this one.
* adds type for swaggerUiSpec
* undoes lifting props to state
almost always, this is done for performance reasons, but I removed it the app is working pretty quick-and-snappy for me without needing to introduced duplicated application state and keep track of it.
I went ahead and measured it before and after this commit (using performance.now):
before = [
1.93500000750646,
1.149999996414408,
0.9499999869149178,
0.9950000094249845,
0.8650000090710819,
1.560000004246831,
1.5699999930802733,
0.8450000023003668,
1.4550000196322799,
1.3299999991431832,
1.3050000125076622,
1.4099999971222132,
1.3099999923724681,
1.3100000214762986,
1.1999999987892807,
1.0099999781232327,
0.830000004498288,
1.2449999921955168,
1.2500000011641532,
1.4349999837577343,
]
after = [
2.9400000057648867,
2.449999999953434,
2.33499999740161,
2.2849999950267375,
1.7700000025797635,
1.8149999959859997,
2.1249999990686774,
1.9150000007357448,
2.074999996693805,
1.9899999897461385,
2.0200000144541264,
2.869999996619299,
2.1450000058393925,
2.33499999740161,
2.130000008037314,
2.119999990100041,
2.144999976735562,
2.130000008037314,
2.380000009201467,
2.8999999922234565,
]
> R.mean(before)
> 1.2480000004870817
> R.mean(after)
> 2.243749999080319
> R.median(before)
> 1.2775000068359077
> R.median(after)
> 2.137499992386438
So basically, considering a 16ms render rate (i.e. 60hz), 1ms saved by lifting props to state makes no difference in application performance.
This is committed separately so that if there's any reason we want to keep the prior implementation, we can just still do so.
2021-05-24 14:14:00 +00:00
|
|
|
showModal(RequestSettingsModal, { request: this.props.activeRequest });
|
2017-03-29 23:09:28 +00:00
|
|
|
}
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
async _handleDeleteResponses(requestId: string, environmentId: string | null) {
|
2020-01-22 19:23:19 +00:00
|
|
|
const { handleSetActiveResponse, activeRequest } = this.props;
|
|
|
|
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
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
async _handleDeleteResponse(response: Response) {
|
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
|
2021-07-30 03:32:08 +00:00
|
|
|
if (this.props.activeResponse?._id === response._id) {
|
2017-06-12 21:48:17 +00:00
|
|
|
this._handleSetActiveResponse(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
async _handleRemoveActiveWorkspace() {
|
2021-06-30 07:47:17 +00:00
|
|
|
const { workspaces, activeWorkspace, handleSetActiveActivity } = this.props;
|
|
|
|
|
|
|
|
if (!activeWorkspace) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
await models.stats.incrementDeletedRequestsForDescendents(activeWorkspace);
|
|
|
|
await models.workspace.remove(activeWorkspace);
|
2021-05-12 06:35:00 +00:00
|
|
|
|
2016-11-29 20:55:31 +00:00
|
|
|
if (workspaces.length <= 1) {
|
2021-06-30 07:47:17 +00:00
|
|
|
handleSetActiveActivity(ACTIVITY_HOME);
|
2016-11-29 20:55:31 +00:00
|
|
|
}
|
2017-06-06 21:21:06 +00:00
|
|
|
}
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
async _handleActiveWorkspaceClearAllResponses() {
|
2021-06-30 07:47:17 +00:00
|
|
|
const { activeWorkspace } = this.props;
|
|
|
|
|
|
|
|
if (!activeWorkspace) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const docs = await db.withDescendants(activeWorkspace, models.request.type);
|
2021-06-16 19:19:00 +00:00
|
|
|
const requests = docs.filter(isRequest);
|
2021-05-12 06:35:00 +00:00
|
|
|
|
2019-01-21 16:29:30 +00:00
|
|
|
for (const req of requests) {
|
|
|
|
await models.response.removeForRequest(req._id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
_handleSendRequestWithActiveEnvironment() {
|
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
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
async _handleSendAndDownloadRequestWithActiveEnvironment(filename?: string) {
|
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;
|
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
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
_handleSetPreviewMode(previewMode: string) {
|
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
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
_handleSetResponseFilter(filter: string) {
|
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;
|
2021-06-30 07:47:17 +00:00
|
|
|
|
|
|
|
if (!activeWorkspace) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-02 19:01:01 +00:00
|
|
|
handleCreateRequest(activeWorkspace._id);
|
|
|
|
}
|
|
|
|
|
|
|
|
_handleCreateRequestGroupInWorkspace() {
|
|
|
|
const { activeWorkspace, handleCreateRequestGroup } = this.props;
|
2021-06-30 07:47:17 +00:00
|
|
|
|
|
|
|
if (!activeWorkspace) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-02 19:01:01 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2021-09-15 13:01:35 +00:00
|
|
|
_forceRequestPaneRefreshAfterDelay(): void {
|
|
|
|
// 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.
|
|
|
|
// TODO: Move this refresh key into redux store so we don't need timeout
|
|
|
|
window.setTimeout(this._forceRequestPaneRefresh, 100);
|
|
|
|
}
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
_forceRequestPaneRefresh() {
|
|
|
|
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) {
|
2021-05-12 06:35:00 +00:00
|
|
|
this.setState({
|
|
|
|
activeGitBranch: branch || 'no-vcs',
|
|
|
|
});
|
2020-06-03 05:32:36 +00:00
|
|
|
}
|
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
componentDidMount() {
|
|
|
|
const { activity } = this.props;
|
|
|
|
trackPageView(`/${activity || ''}`);
|
|
|
|
}
|
2019-08-02 19:01:01 +00:00
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
componentDidUpdate(prevProps: WrapperProps) {
|
2020-04-26 20:33:39 +00:00
|
|
|
// 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;
|
2021-05-12 06:35:00 +00:00
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
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
|
|
|
activeWorkspace,
|
2021-08-20 15:12:36 +00:00
|
|
|
activeProject,
|
2021-03-01 21:32:32 +00:00
|
|
|
activeApiSpec,
|
2019-08-02 19:01:01 +00:00
|
|
|
activeWorkspaceClientCertificates,
|
2020-04-26 20:33:39 +00:00
|
|
|
activity,
|
|
|
|
gitVCS,
|
2019-08-02 19:01:01 +00:00
|
|
|
handleActivateRequest,
|
2019-03-05 06:53:45 +00:00
|
|
|
handleExportRequestsToFile,
|
2020-04-26 20:33:39 +00:00
|
|
|
handleInitializeEntities,
|
2020-12-01 00:37:57 +00:00
|
|
|
handleSidebarSort,
|
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
|
|
|
workspaces,
|
2016-11-25 23:09:17 +00:00
|
|
|
} = this.props;
|
2021-06-30 07:47:17 +00:00
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
// Setup git sync dropdown for use in Design/Debug pages
|
2021-05-12 06:35:00 +00:00
|
|
|
let gitSyncDropdown: JSX.Element | null = null;
|
|
|
|
|
2021-06-30 07:47:17 +00:00
|
|
|
if (activeWorkspace && gitVCS) {
|
2020-04-26 20:33:39 +00:00
|
|
|
gitSyncDropdown = (
|
|
|
|
<GitSyncDropdown
|
|
|
|
className="margin-left"
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
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 => (
|
2021-10-04 09:35:53 +00:00
|
|
|
<DropdownButton className="btn--clicky-small btn-sync">
|
2020-04-26 20:33:39 +00:00
|
|
|
{children}
|
|
|
|
</DropdownButton>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2017-06-09 21:42:19 +00:00
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
return (
|
2021-05-12 06:35:00 +00:00
|
|
|
<Fragment>
|
2020-04-26 20:33:39 +00:00
|
|
|
<div key="modals" className="modals">
|
|
|
|
<ErrorBoundary showAlert>
|
2021-12-16 04:58:00 +00:00
|
|
|
<AnalyticsModal />
|
2020-04-26 20:33:39 +00:00
|
|
|
<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} />
|
2021-11-25 04:26:08 +00:00
|
|
|
<GenerateConfigModal ref={registerModal} />
|
2021-08-20 15:12:36 +00:00
|
|
|
<ProjectSettingsModal ref={registerModal} />
|
2021-07-28 21:49:02 +00:00
|
|
|
<WorkspaceDuplicateModal ref={registerModal} vcs={vcs || undefined} />
|
2020-04-26 20:33:39 +00:00
|
|
|
|
|
|
|
<CodePromptModal
|
|
|
|
ref={registerModal}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<RequestSettingsModal
|
|
|
|
ref={registerModal}
|
|
|
|
workspaces={workspaces}
|
|
|
|
/>
|
|
|
|
|
2021-06-25 14:21:07 +00:00
|
|
|
<RequestGroupSettingsModal
|
|
|
|
ref={registerModal}
|
|
|
|
workspaces={workspaces}
|
|
|
|
/>
|
|
|
|
|
2021-06-30 07:47:17 +00:00
|
|
|
{activeWorkspace ? <>
|
|
|
|
{/* TODO: Figure out why cookieJar is sometimes null */}
|
|
|
|
{activeCookieJar ? <>
|
2021-12-08 03:11:04 +00:00
|
|
|
<CookiesModalFC
|
2021-06-30 07:47:17 +00:00
|
|
|
ref={registerModal}
|
2021-12-03 20:08:28 +00:00
|
|
|
handleShowModifyCookieModal={Wrapper._handleShowModifyCookieModal}
|
2021-06-30 07:47:17 +00:00
|
|
|
workspace={activeWorkspace}
|
|
|
|
cookieJar={activeCookieJar}
|
|
|
|
/>
|
|
|
|
<CookieModifyModal
|
|
|
|
ref={registerModal}
|
|
|
|
cookieJar={activeCookieJar}
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
/>
|
|
|
|
</> : null}
|
|
|
|
|
|
|
|
<NunjucksModal
|
|
|
|
uniqueKey={`key::${this.state.forceRefreshKey}`}
|
2020-04-26 20:33:39 +00:00
|
|
|
ref={registerModal}
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
/>
|
2017-06-01 22:58:09 +00:00
|
|
|
|
2021-06-30 07:47:17 +00:00
|
|
|
{activeApiSpec ? <WorkspaceSettingsModal
|
|
|
|
ref={registerModal}
|
|
|
|
clientCertificates={activeWorkspaceClientCertificates}
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
apiSpec={activeApiSpec}
|
|
|
|
handleRemoveWorkspace={this._handleRemoveActiveWorkspace}
|
|
|
|
handleClearAllResponses={this._handleActiveWorkspaceClearAllResponses}
|
|
|
|
/> : null}
|
|
|
|
</> : null}
|
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'}
|
|
|
|
/>
|
2018-03-29 13:57:24 +00:00
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
<SettingsModal
|
|
|
|
ref={registerModal}
|
|
|
|
settings={settings}
|
|
|
|
/>
|
2018-03-29 13:57:24 +00:00
|
|
|
|
2021-11-25 04:26:08 +00:00
|
|
|
<ResponseDebugModal ref={registerModal} />
|
2018-03-29 13:57:24 +00:00
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
<RequestSwitcherModal
|
|
|
|
ref={registerModal}
|
|
|
|
activateRequest={handleActivateRequest}
|
|
|
|
/>
|
2018-03-29 13:57:24 +00:00
|
|
|
|
2020-04-26 20:33:39 +00:00
|
|
|
<EnvironmentEditModal
|
|
|
|
ref={registerModal}
|
|
|
|
onChange={models.requestGroup.update}
|
|
|
|
/>
|
2019-04-18 00:50:03 +00:00
|
|
|
|
2021-06-30 07:47:17 +00:00
|
|
|
<GitRepositorySettingsModal ref={registerModal} />
|
|
|
|
|
|
|
|
{activeWorkspace && gitVCS ? (
|
2021-05-12 06:35:00 +00:00
|
|
|
<Fragment>
|
2020-04-26 20:33:39 +00:00
|
|
|
<GitStagingModal ref={registerModal} workspace={activeWorkspace} vcs={gitVCS} />
|
|
|
|
<GitLogModal ref={registerModal} vcs={gitVCS} />
|
|
|
|
{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
|
|
|
/>
|
|
|
|
)}
|
2021-05-12 06:35:00 +00:00
|
|
|
</Fragment>
|
2021-06-30 07:47:17 +00:00
|
|
|
) : null}
|
2020-04-26 20:33:39 +00:00
|
|
|
|
2021-06-30 07:47:17 +00:00
|
|
|
{activeWorkspace && vcs ? (
|
2021-05-12 06:35:00 +00:00
|
|
|
<Fragment>
|
2020-04-26 20:33:39 +00:00
|
|
|
<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}
|
2021-08-20 15:12:36 +00:00
|
|
|
project={activeProject}
|
2020-04-26 20:33:39 +00:00
|
|
|
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} />
|
2021-05-12 06:35:00 +00:00
|
|
|
</Fragment>
|
2021-06-30 07:47:17 +00:00
|
|
|
) : null}
|
2020-04-26 20:33:39 +00:00
|
|
|
|
|
|
|
<WorkspaceEnvironmentsEditModal
|
|
|
|
ref={registerModal}
|
2020-06-08 22:32:49 +00:00
|
|
|
handleChangeEnvironment={this._handleChangeEnvironment}
|
2020-04-26 20:33:39 +00:00
|
|
|
activeEnvironmentId={activeEnvironment ? activeEnvironment._id : null}
|
|
|
|
/>
|
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}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</GrpcDispatchModalWrapper>
|
2020-04-26 20:33:39 +00:00
|
|
|
</ErrorBoundary>
|
2017-10-13 13:01:27 +00:00
|
|
|
</div>
|
2021-05-12 06:35:00 +00:00
|
|
|
<Fragment key={`views::${this.state.activeGitBranch}`}>
|
2021-06-30 07:47:17 +00:00
|
|
|
{(activity === ACTIVITY_HOME || !activeWorkspace) && (
|
2020-06-03 05:32:36 +00:00
|
|
|
<WrapperHome
|
|
|
|
wrapperProps={this.props}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{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}
|
2021-05-27 18:00:32 +00:00
|
|
|
>
|
|
|
|
{sidebarChildren}
|
|
|
|
</WrapperUnitTest>
|
2020-07-01 21:17:14 +00:00
|
|
|
)}
|
|
|
|
|
2021-02-02 23:19:22 +00:00
|
|
|
{activity === ACTIVITY_DEBUG && (
|
2020-06-03 05:32:36 +00:00
|
|
|
<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}
|
|
|
|
handleRequestCreate={this._handleCreateRequestInWorkspace}
|
|
|
|
handleRequestGroupCreate={this._handleCreateRequestGroupInWorkspace}
|
|
|
|
handleSendAndDownloadRequestWithActiveEnvironment={
|
|
|
|
this._handleSendAndDownloadRequestWithActiveEnvironment
|
|
|
|
}
|
|
|
|
handleSendRequestWithActiveEnvironment={this._handleSendRequestWithActiveEnvironment}
|
|
|
|
handleSetActiveResponse={this._handleSetActiveResponse}
|
|
|
|
handleSetPreviewMode={this._handleSetPreviewMode}
|
|
|
|
handleSetResponseFilter={this._handleSetResponseFilter}
|
|
|
|
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}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
2021-02-09 19:55:30 +00:00
|
|
|
{activity === ACTIVITY_MIGRATION && <WrapperMigration wrapperProps={this.props} />}
|
2021-05-12 06:35:00 +00:00
|
|
|
</Fragment>
|
|
|
|
</Fragment>
|
2020-04-26 20:33:39 +00:00
|
|
|
);
|
2016-11-25 23:09:17 +00:00
|
|
|
}
|
|
|
|
}
|