diff --git a/packages/insomnia-app/.storybook/preview-head.html b/packages/insomnia-app/.storybook/preview-head.html index 97d7de2f75..5e689b1c97 100644 --- a/packages/insomnia-app/.storybook/preview-head.html +++ b/packages/insomnia-app/.storybook/preview-head.html @@ -306,33 +306,6 @@ --hl-xl-rgb: 130, 130, 130, 0.8; } - [theme='studio-light'] .theme--activity-bar, - [subtheme='studio-light'] .theme--activity-bar--sub { - /* Background */ - --color-bg: rgb(0, 48, 82); - --color-bg-rgb: 0, 48, 82; - - /* Foreground */ - --color-font: rgb(255, 255, 255); - --color-font-rgb: 255, 255, 255; - - /* Highlight */ - --hl: rgb(23, 130, 207); - --hl-rgb: 23, 130, 207; - --hl-xxs: rgba(23, 130, 207, 0.05); - --hl-xxs-rgb: 23, 130, 207, 0.05; - --hl-xs: rgba(23, 130, 207, 0.1); - --hl-xs-rgb: 23, 130, 207, 0.1; - --hl-sm: rgba(23, 130, 207, 0.2); - --hl-sm-rgb: 23, 130, 207, 0.2; - --hl-md: rgba(23, 130, 207, 0.3); - --hl-md-rgb: 23, 130, 207, 0.3; - --hl-lg: rgba(23, 130, 207, 0.5); - --hl-lg-rgb: 23, 130, 207, 0.5; - --hl-xl: rgba(23, 130, 207, 0.8); - --hl-xl-rgb: 23, 130, 207, 0.8; - } - [theme='studio-light'] .theme--dropdown__menu, [subtheme='studio-light'] .theme--dropdown__menu--sub { /* Background */ @@ -413,33 +386,6 @@ --color-info-rgb: 0, 91, 158; } - [theme='studio-light'] .theme--activity-bar, - [subtheme='studio-light'] .theme--activity-bar--sub { - /* Background */ - --color-bg: rgb(0, 48, 82); - --color-bg-rgb: 0, 48, 82; - - /* Foreground */ - --color-font: rgb(255, 255, 255); - --color-font-rgb: 255, 255, 255; - - /* Highlight */ - --hl: rgb(23, 130, 207); - --hl-rgb: 23, 130, 207; - --hl-xxs: rgba(23, 130, 207, 0.05); - --hl-xxs-rgb: 23, 130, 207, 0.05; - --hl-xs: rgba(23, 130, 207, 0.1); - --hl-xs-rgb: 23, 130, 207, 0.1; - --hl-sm: rgba(23, 130, 207, 0.2); - --hl-sm-rgb: 23, 130, 207, 0.2; - --hl-md: rgba(23, 130, 207, 0.3); - --hl-md-rgb: 23, 130, 207, 0.3; - --hl-lg: rgba(23, 130, 207, 0.5); - --hl-lg-rgb: 23, 130, 207, 0.5; - --hl-xl: rgba(23, 130, 207, 0.8); - --hl-xl-rgb: 23, 130, 207, 0.8; - } - [theme='studio-light'] .theme--dropdown__menu, [subtheme='studio-light'] .theme--dropdown__menu--sub { /* Background */ @@ -571,33 +517,6 @@ --hl-xl-rgb: 133, 157, 176, 0.8; } - [theme='studio-colorful'] .theme--activity-bar, - [subtheme='studio-colorful'] .theme--activity-bar--sub { - /* Background */ - --color-bg: rgb(0, 69, 114); - --color-bg-rgb: 0, 69, 114; - - /* Foreground */ - --color-font: rgb(255, 255, 255); - --color-font-rgb: 255, 255, 255; - - /* Highlight */ - --hl: rgb(23, 130, 207); - --hl-rgb: 23, 130, 207; - --hl-xxs: rgba(23, 130, 207, 0.05); - --hl-xxs-rgb: 23, 130, 207, 0.05; - --hl-xs: rgba(23, 130, 207, 0.1); - --hl-xs-rgb: 23, 130, 207, 0.1; - --hl-sm: rgba(23, 130, 207, 0.2); - --hl-sm-rgb: 23, 130, 207, 0.2; - --hl-md: rgba(23, 130, 207, 0.3); - --hl-md-rgb: 23, 130, 207, 0.3; - --hl-lg: rgba(23, 130, 207, 0.5); - --hl-lg-rgb: 23, 130, 207, 0.5; - --hl-xl: rgba(23, 130, 207, 0.8); - --hl-xl-rgb: 23, 130, 207, 0.8; - } - [theme='studio-colorful'] .theme--dropdown__menu, [subtheme='studio-colorful'] .theme--dropdown__menu--sub { /* Background */ diff --git a/packages/insomnia-app/app/common/constants.js b/packages/insomnia-app/app/common/constants.js index 0e604843c7..ad31b09d3b 100644 --- a/packages/insomnia-app/app/common/constants.js +++ b/packages/insomnia-app/app/common/constants.js @@ -4,8 +4,6 @@ import * as electron from 'electron'; import path from 'path'; import mkdirp from 'mkdirp'; import { getDataDirectory } from './misc'; -import type { GlobalActivity } from '../ui/components/activity-bar/activity-bar'; -import { ACTIVITY_INSOMNIA } from '../ui/components/activity-bar/activity-bar'; // App Stuff @@ -153,6 +151,14 @@ export const DEFAULT_PANE_WIDTH = 0.5; export const DEFAULT_PANE_HEIGHT = 0.5; export const DEFAULT_SIDEBAR_WIDTH = 19; +// Activities +export type GlobalActivity = 'spec' | 'debug' | 'monitor' | 'home'; +export const ACTIVITY_SPEC: GlobalActivity = 'spec'; +export const ACTIVITY_DEBUG: GlobalActivity = 'debug'; +export const ACTIVITY_UNIT_TEST: GlobalActivity = 'unittest'; +export const ACTIVITY_HOME: GlobalActivity = 'home'; +export const ACTIVITY_INSOMNIA: GlobalActivity = 'insomnia'; + // HTTP Methods export const METHOD_GET = 'GET'; export const METHOD_POST = 'POST'; diff --git a/packages/insomnia-app/app/common/misc.js b/packages/insomnia-app/app/common/misc.js index 69c4ce1515..bf2b564b09 100644 --- a/packages/insomnia-app/app/common/misc.js +++ b/packages/insomnia-app/app/common/misc.js @@ -6,7 +6,7 @@ import * as uuid from 'uuid'; import zlib from 'zlib'; import { join as pathJoin } from 'path'; import { METHOD_OPTIONS, METHOD_DELETE, DEBOUNCE_MILLIS } from './constants'; -import type { GlobalActivity } from '../ui/components/activity-bar/activity-bar'; +import type { GlobalActivity } from './constants'; const ESCAPE_REGEX_MATCH = /[-[\]/{}()*+?.\\^$|]/g; diff --git a/packages/insomnia-app/app/plugins/misc.js b/packages/insomnia-app/app/plugins/misc.js index 6eaeb3a9f6..b316d4af30 100644 --- a/packages/insomnia-app/app/plugins/misc.js +++ b/packages/insomnia-app/app/plugins/misc.js @@ -39,7 +39,6 @@ type ThemeInner = { ...ThemeBlock, rawCss?: string, styles: ?{ - activityBar?: ThemeBlock, dialog?: ThemeBlock, dialogFooter?: ThemeBlock, dialogHeader?: ThemeBlock, diff --git a/packages/insomnia-app/app/ui/components/activity-bar/activity-bar-button.js b/packages/insomnia-app/app/ui/components/activity-bar/activity-bar-button.js deleted file mode 100644 index 1ea7162efb..0000000000 --- a/packages/insomnia-app/app/ui/components/activity-bar/activity-bar-button.js +++ /dev/null @@ -1,69 +0,0 @@ -// @flow -import * as React from 'react'; -import autobind from 'autobind-decorator'; -import classnames from 'classnames'; -import type { GlobalActivity } from './activity-bar'; -import type { HotKeyDefinition, HotKeyRegistry } from '../../../common/hotkeys'; -import { getHotKeyDisplay } from '../../../common/hotkeys'; -import KeydownBinder from '../keydown-binder'; -import { executeHotKey } from '../../../common/hotkeys-listener'; - -type Props = {| - activity: { - key: GlobalActivity, - name: string, - hotKey: HotKeyDefinition, - }, - hotKeyRegistry: HotKeyRegistry, - activeActivity: GlobalActivity, - setActivity: GlobalActivity => void, -|}; - -const ACTIVITY_MAP_ICONS: { [GlobalActivity]: string } = { - home: 'fa fa-home', - spec: 'ico-edit-spec', - debug: 'ico-debug', -}; - -@autobind -class ActivityBarButton extends React.PureComponent { - _handleSetActivity() { - const { setActivity, activity } = this.props; - - setActivity(activity.key); - } - - async _handleKeyDown(e: KeyboardEvent) { - const { activity, setActivity } = this.props; - - await executeHotKey(e, activity.hotKey, () => { - setActivity(activity.key); - }); - } - - render() { - const { activeActivity, activity, hotKeyRegistry } = this.props; - - const classes = { - 'activity-bar__item': true, - 'activity-bar__item--active': activity.key === activeActivity, - }; - - const icon = ACTIVITY_MAP_ICONS[activity.key]; - - return ( - -
  • - -
  • -
    - ); - } -} - -export default ActivityBarButton; diff --git a/packages/insomnia-app/app/ui/components/activity-bar/activity-bar.js b/packages/insomnia-app/app/ui/components/activity-bar/activity-bar.js deleted file mode 100644 index 7cd4f1c390..0000000000 --- a/packages/insomnia-app/app/ui/components/activity-bar/activity-bar.js +++ /dev/null @@ -1,74 +0,0 @@ -// @flow -import * as React from 'react'; -import autobind from 'autobind-decorator'; -import ActivityBarButton from './activity-bar-button'; -import { getHotKeyDisplay, hotKeyRefs } from '../../../common/hotkeys'; -import type { HotKeyDefinition, HotKeyRegistry } from '../../../common/hotkeys'; - -export type GlobalActivity = 'spec' | 'debug' | 'monitor' | 'home'; - -export const ACTIVITY_SPEC: GlobalActivity = 'spec'; -export const ACTIVITY_DEBUG: GlobalActivity = 'debug'; -export const ACTIVITY_MONITOR: GlobalActivity = 'monitor'; -export const ACTIVITY_HOME: GlobalActivity = 'home'; -export const ACTIVITY_INSOMNIA: GlobalActivity = 'insomnia'; - -type Props = {| - activity: GlobalActivity, - setActivity: GlobalActivity => void, - showSettings: () => void, - hotKeyRegistry: HotKeyRegistry, -|}; - -const ACTIVITIES: Array<{ key: GlobalActivity, name: string, hotKey: HotKeyDefinition }> = [ - { - key: ACTIVITY_HOME, - name: 'Home', - hotKey: hotKeyRefs.SHOW_HOME, - }, - { - key: ACTIVITY_SPEC, - name: 'API Specification', - hotKey: hotKeyRefs.SHOW_SPEC_EDITOR, - }, - { - key: ACTIVITY_DEBUG, - name: 'Debug API', - hotKey: hotKeyRefs.SHOW_TEST, - }, -]; - -@autobind -class ActivityBar extends React.PureComponent { - render() { - const { activity, showSettings, setActivity, hotKeyRegistry } = this.props; - return ( -
      - {ACTIVITIES.map(a => ( - - ))} - -
    • - -
    • -
    - ); - } -} - -export default ActivityBar; diff --git a/packages/insomnia-app/app/ui/components/activity-toggle.js b/packages/insomnia-app/app/ui/components/activity-toggle.js new file mode 100644 index 0000000000..bf58ec7647 --- /dev/null +++ b/packages/insomnia-app/app/ui/components/activity-toggle.js @@ -0,0 +1,40 @@ +// @flow + +import React from 'react'; +import { MultiSwitch } from 'insomnia-components'; +import type { GlobalActivity } from '../../common/constants'; +import { ACTIVITY_DEBUG, ACTIVITY_SPEC, ACTIVITY_UNIT_TEST } from '../../common/constants'; +import type { Settings } from '../../models/settings'; +import type { Workspace } from '../../models/workspace'; + +type Props = { + activity: GlobalActivity, + handleActivityChange: (workspaceId: string, activity: GlobalActivity) => Promise, + settings: Settings, + workspace: Workspace, +}; + +export default function ActivityToggle({ + activity, + handleActivityChange, + settings, + workspace, +}: Props) { + const choices = [ + { label: 'Design', value: ACTIVITY_SPEC }, + { label: 'Debug', value: ACTIVITY_DEBUG }, + ]; + + if (settings.enableUnitTestingBeta || activity === ACTIVITY_UNIT_TEST) { + choices.push({ label: 'Test', value: ACTIVITY_UNIT_TEST }); + } + + return ( + handleActivityChange(workspace._id, a)} + choices={choices} + /> + ); +} diff --git a/packages/insomnia-app/app/ui/components/wrapper-debug.js b/packages/insomnia-app/app/ui/components/wrapper-debug.js index 12859a445d..68e560a950 100644 --- a/packages/insomnia-app/app/ui/components/wrapper-debug.js +++ b/packages/insomnia-app/app/ui/components/wrapper-debug.js @@ -1,10 +1,9 @@ // @flow import * as React from 'react'; import autobind from 'autobind-decorator'; -import { Breadcrumb, Switch, Header } from 'insomnia-components'; +import { Breadcrumb, Header } from 'insomnia-components'; import PageLayout from './page-layout'; import type { WrapperProps } from './wrapper'; -import { ACTIVITY_HOME } from './activity-bar/activity-bar'; import RequestPane from './request-pane'; import ErrorBoundary from './error-boundary'; import ResponsePane from './response-pane'; @@ -13,11 +12,13 @@ import SidebarFilter from './sidebar/sidebar-filter'; import EnvironmentsDropdown from './dropdowns/environments-dropdown'; import designerLogo from '../images/insomnia-designer-logo.svg'; import WorkspaceDropdown from './dropdowns/workspace-dropdown'; -import { isInsomnia } from '../../common/constants'; +import { ACTIVITY_HOME, isInsomnia } from '../../common/constants'; +import ActivityToggle from './activity-toggle'; type Props = { forceRefreshKey: string, gitSyncDropdown: React.Node, + handleActivityChange: (workspaceId: string, activity: GlobalActivity) => Promise, handleChangeEnvironment: Function, handleDeleteResponse: Function, handleDeleteResponses: Function, @@ -42,7 +43,6 @@ type Props = { handleUpdateRequestUrl: Function, handleUpdateSettingsShowPasswords: Function, handleUpdateSettingsUseBulkHeaderEditor: Function, - handleSetDesignActivity: (workspaceId: string) => Promise, wrapperProps: WrapperProps, }; @@ -52,18 +52,11 @@ class WrapperDebug extends React.PureComponent { this.props.wrapperProps.handleSetActiveActivity(ACTIVITY_HOME); } - async _handleDesign(): Promise { - const { - handleSetDesignActivity, - wrapperProps: { activeWorkspace }, - } = this.props; - await handleSetDesignActivity(activeWorkspace._id); - } - _renderPageHeader() { const { gitSyncDropdown, - wrapperProps: { activeApiSpec }, + handleActivityChange, + wrapperProps: { activeApiSpec, activeWorkspace, settings, activity }, } = this.props; return ( @@ -80,12 +73,11 @@ class WrapperDebug extends React.PureComponent { } gridCenter={ - } gridRight={gitSyncDropdown} diff --git a/packages/insomnia-app/app/ui/components/wrapper-design.js b/packages/insomnia-app/app/ui/components/wrapper-design.js index c195c673b7..d681e9ed4a 100644 --- a/packages/insomnia-app/app/ui/components/wrapper-design.js +++ b/packages/insomnia-app/app/ui/components/wrapper-design.js @@ -3,7 +3,7 @@ import * as React from 'react'; import autobind from 'autobind-decorator'; import type { WrapperProps } from './wrapper'; import PageLayout from './page-layout'; -import { Breadcrumb, Button, Header, NoticeTable, Switch } from 'insomnia-components'; +import { Breadcrumb, Button, Header, NoticeTable } from 'insomnia-components'; import ErrorBoundary from './error-boundary'; import SpecEditorSidebar from './spec-editor/spec-editor-sidebar'; import CodeEditor from './codemirror/code-editor'; @@ -12,7 +12,6 @@ import { showModal } from './modals'; import GenerateConfigModal from './modals/generate-config-modal'; import classnames from 'classnames'; import SwaggerUI from 'swagger-ui-react'; -import { ACTIVITY_HOME } from './activity-bar/activity-bar'; import type { ApiSpec } from '../../models/api-spec'; import designerLogo from '../images/insomnia-designer-logo.svg'; import previewIcon from '../images/icn-eye.svg'; @@ -21,14 +20,17 @@ import * as models from '../../models/index'; import { parseApiSpec } from '../../common/api-specs'; import { getConfigGenerators } from '../../plugins'; import AlertModal from './modals/alert-modal'; +import { ACTIVITY_HOME } from '../../common/constants'; +import type { GlobalActivity } from '../../common/constants'; +import ActivityToggle from './activity-toggle'; const spectral = new Spectral(); type Props = {| gitSyncDropdown: React.Node, - wrapperProps: WrapperProps, + handleActivityChange: (workspaceId: string, activity: GlobalActivity) => Promise, handleUpdateApiSpec: (s: ApiSpec) => Promise, - handleSetDebugActivity: (s: ApiSpec) => Promise, + wrapperProps: WrapperProps, |}; type State = {| @@ -181,22 +183,21 @@ class WrapperDesign extends React.PureComponent { } render() { - const { gitSyncDropdown, wrapperProps } = this.props; + const { gitSyncDropdown, wrapperProps, handleActivityChange } = this.props; - const { activeApiSpec, settings } = wrapperProps; + const { activeApiSpec, settings, activity, activeWorkspace } = wrapperProps; const { lintMessages, previewHidden, hasConfigPlugins } = this.state; let swaggerUiSpec; try { - const { contents } = parseApiSpec(activeApiSpec.contents); - swaggerUiSpec = contents; - } catch (err) { + swaggerUiSpec = parseApiSpec(activeApiSpec.contents).contents; + } catch (err) {} + + if (!swaggerUiSpec) { swaggerUiSpec = {}; } - const lintErrorsExist = !!lintMessages.find(c => c.type === 'error'); - return ( { } gridCenter={ - } gridRight={ diff --git a/packages/insomnia-app/app/ui/components/wrapper-home.js b/packages/insomnia-app/app/ui/components/wrapper-home.js index 4c1e3da91e..562b7c16c9 100644 --- a/packages/insomnia-app/app/ui/components/wrapper-home.js +++ b/packages/insomnia-app/app/ui/components/wrapper-home.js @@ -27,8 +27,8 @@ import { trackEvent } from '../../common/analytics'; import YAML from 'yaml'; import TimeFromNow from './time-from-now'; import Highlight from './base/highlight'; -import type { GlobalActivity } from './activity-bar/activity-bar'; -import { ACTIVITY_DEBUG, ACTIVITY_SPEC } from './activity-bar/activity-bar'; +import type { GlobalActivity } from '../../common/constants'; +import { ACTIVITY_DEBUG, ACTIVITY_HOME, ACTIVITY_SPEC } from '../../common/constants'; import { fuzzyMatchAll } from '../../common/misc'; import type { WrapperProps } from './wrapper'; import Notice from './notice'; @@ -273,8 +273,13 @@ class WrapperHome extends React.PureComponent { async _handleSetActiveWorkspace(id: string, defaultActivity: GlobalActivity) { const { handleSetActiveWorkspace, handleSetActiveActivity } = this.props.wrapperProps; - const selectedWorkspaceMeta = await models.workspaceMeta.getOrCreateByParentId(id); - handleSetActiveActivity(selectedWorkspaceMeta.activeActivity || defaultActivity); + const { activeActivity } = await models.workspaceMeta.getOrCreateByParentId(id); + + if (!activeActivity || activeActivity === ACTIVITY_HOME) { + handleSetActiveActivity(defaultActivity); + } else { + handleSetActiveActivity(activeActivity); + } handleSetActiveWorkspace(id); } diff --git a/packages/insomnia-app/app/ui/components/wrapper-onboarding.js b/packages/insomnia-app/app/ui/components/wrapper-onboarding.js index 96091f85f9..cf75fe5c54 100644 --- a/packages/insomnia-app/app/ui/components/wrapper-onboarding.js +++ b/packages/insomnia-app/app/ui/components/wrapper-onboarding.js @@ -5,7 +5,7 @@ import 'swagger-ui-react/swagger-ui.css'; import { showPrompt } from './modals'; import type { BaseModel } from '../../models'; import * as models from '../../models'; -import { ACTIVITY_HOME } from './activity-bar/activity-bar'; +import { ACTIVITY_HOME, getAppLongName, getAppName, getAppSynopsis } from '../../common/constants'; import type { WrapperProps } from './wrapper'; import PageLayout from './page-layout'; import * as db from '../../common/database'; @@ -13,7 +13,6 @@ import chartSrc from '../images/chart.svg'; import imgSrc from '../images/logo.png'; import type { ForceToWorkspace } from '../redux/modules/helpers'; import { ForceToWorkspaceKeys } from '../redux/modules/helpers'; -import { getAppLongName, getAppName, getAppSynopsis } from '../../common/constants'; type Props = {| wrapperProps: WrapperProps, diff --git a/packages/insomnia-app/app/ui/components/wrapper.js b/packages/insomnia-app/app/ui/components/wrapper.js index a19f6a2af8..04583d1d85 100644 --- a/packages/insomnia-app/app/ui/components/wrapper.js +++ b/packages/insomnia-app/app/ui/components/wrapper.js @@ -65,13 +65,6 @@ import VCS from '../../sync/vcs'; import type { StatusCandidate } from '../../sync/types'; import type { RequestMeta } from '../../models/request-meta'; import type { RequestVersion } from '../../models/request-version'; -import type { GlobalActivity } from './activity-bar/activity-bar'; -import { - ACTIVITY_DEBUG, - ACTIVITY_HOME, - ACTIVITY_INSOMNIA, - ACTIVITY_SPEC, -} from './activity-bar/activity-bar'; import type { ApiSpec } from '../../models/api-spec'; import GitVCS from '../../sync/git/git-vcs'; import { trackPageView } from '../../common/analytics'; @@ -84,7 +77,17 @@ import { importRaw } from '../../common/import'; import GitSyncDropdown from './dropdowns/git-sync-dropdown'; import { DropdownButton } from './base/dropdown'; import type { ForceToWorkspace } from '../redux/modules/helpers'; -import { getAppName } from '../../common/constants'; +import { + ACTIVITY_DEBUG, + ACTIVITY_HOME, + ACTIVITY_INSOMNIA, + ACTIVITY_SPEC, + getAppName, +} from '../../common/constants'; +import { Spectral } from '@stoplight/spectral'; +import type { GlobalActivity } from '../../common/constants'; + +const spectral = new Spectral(); export type WrapperProps = { // Helper Functions @@ -294,32 +297,46 @@ class Wrapper extends React.PureComponent { return null; } - async _handleWorkspaceActivityChange(workspaceId: string, activeActivity: GlobalActivity) { - const { activity: updatedActivity } = this.props.handleSetActiveActivity(activeActivity); - await models.workspaceMeta.updateByParentId(workspaceId, { activeActivity: updatedActivity }); - } + async _handleWorkspaceActivityChange(workspaceId: string, nextActivity: GlobalActivity) { + const { activity, activeApiSpec, handleSetActiveActivity } = this.props; - async _handleSetDesignActivity(workspaceId: string): Promise { - await this._handleWorkspaceActivityChange(workspaceId, ACTIVITY_SPEC); - } + // 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 }); + } - async _handleSetDebugActivity(apiSpec: ApiSpec): Promise { - const workspaceId = apiSpec.parentId; - await this._handleWorkspaceActivityChange(workspaceId, ACTIVITY_DEBUG); + if (activity !== ACTIVITY_SPEC) { + handleSetActiveActivity(nextActivity); + return; + } + // 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 + 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); setTimeout(() => { - // Delaying generation so design to debug mode is smooth - importRaw( - () => Promise.resolve(workspaceId), // Always import into current workspace - apiSpec.contents, - ); + importRaw(() => Promise.resolve(workspaceId), activeApiSpec.contents); }, 1000); } - _handleSetHomeActivity(): void { - this.props.handleSetActiveActivity(ACTIVITY_HOME); - } - // Settings updaters _handleUpdateSettingsShowPasswords(showPasswords: boolean): Promise { return sUpdate(this.props.settings, { showPasswords }); @@ -760,7 +777,7 @@ class Wrapper extends React.PureComponent { {activity === ACTIVITY_SPEC && ( @@ -770,7 +787,7 @@ class Wrapper extends React.PureComponent { { it('should return null if forcing to a new workspace', () => { const func = askToImportIntoWorkspace('id', ForceToWorkspaceKeys.new); diff --git a/packages/insomnia-app/app/ui/redux/modules/global.js b/packages/insomnia-app/app/ui/redux/modules/global.js index 211e61fa32..5d73cb66ea 100644 --- a/packages/insomnia-app/app/ui/redux/modules/global.js +++ b/packages/insomnia-app/app/ui/redux/modules/global.js @@ -24,13 +24,13 @@ import SettingsModal, { import install from '../../../plugins/install'; import type { ForceToWorkspace } from './helpers'; import { askToImportIntoWorkspace, ensureActivityIsForApp } from './helpers'; -import type { GlobalActivity } from '../../components/activity-bar/activity-bar'; import { createPlugin } from '../../../plugins/create'; import { reloadPlugins } from '../../../plugins'; import { setTheme } from '../../../plugins/misc'; import { setActivityAttribute } from '../../../common/misc'; import { isDevelopment } from '../../../common/constants'; import type { Workspace } from '../../../models/workspace'; +import type { GlobalActivity } from '../../../common/constants'; const LOCALSTORAGE_PREFIX = 'insomnia::meta'; diff --git a/packages/insomnia-app/app/ui/redux/modules/helpers.js b/packages/insomnia-app/app/ui/redux/modules/helpers.js index beef616cb5..26b37bab8b 100644 --- a/packages/insomnia-app/app/ui/redux/modules/helpers.js +++ b/packages/insomnia-app/app/ui/redux/modules/helpers.js @@ -1,9 +1,8 @@ // @flow import { showModal } from '../../components/modals'; import AskModal from '../../components/modals/ask-modal'; -import type { GlobalActivity } from '../../components/activity-bar/activity-bar'; -import { ACTIVITY_HOME, ACTIVITY_INSOMNIA } from '../../components/activity-bar/activity-bar'; -import { getDefaultAppId } from '../../../common/constants'; +import type { GlobalActivity } from '../../../common/constants'; +import { ACTIVITY_HOME, ACTIVITY_INSOMNIA, getDefaultAppId } from '../../../common/constants'; import { APP_ID_INSOMNIA } from '../../../../config'; export const ForceToWorkspaceKeys = { diff --git a/packages/insomnia-components/index.js b/packages/insomnia-components/index.js index c9d053ccc4..346cee34c8 100644 --- a/packages/insomnia-components/index.js +++ b/packages/insomnia-components/index.js @@ -7,9 +7,11 @@ import _DropdownDivider from './components/dropdown/dropdown-divider'; import _DropdownItem from './components/dropdown/dropdown-item'; import _GravatarImg from './components/gravatar-img'; import _Header from './components/header'; +import _MultiSwitch from './components/multi-switch'; import _NoticeTable from './components/notice-table'; -import _SvgIcon from './components/svg-icon'; +import _RadioButtonGroup from './components/radio-button-group'; import _Sidebar from './components/sidebar'; +import _SvgIcon from './components/svg-icon'; import _Switch from './components/switch'; import _ToggleSwitch from './components/toggle-switch'; import * as table from './components/table'; @@ -23,7 +25,9 @@ export const DropdownDivider = _DropdownDivider; export const DropdownItem = _DropdownItem; export const GravatarImg = _GravatarImg; export const Header = _Header; +export const MultiSwitch = _MultiSwitch; export const NoticeTable = _NoticeTable; +export const RadioButtonGroup = _RadioButtonGroup; export const SvgIcon = _SvgIcon; export const Switch = _Switch; export const Sidebar = _Sidebar;