Use activateWorkspace action to activate a workspace (#3856)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>
This commit is contained in:
Opender Singh 2021-07-29 16:55:31 +12:00 committed by GitHub
parent 21b02cc61a
commit 7397370f4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 103 additions and 129 deletions

View File

@ -1,4 +1,4 @@
import { ACTIVITY_DEBUG } from '../common/constants';
import { ACTIVITY_HOME } from '../common/constants';
import { BASE_SPACE_ID } from '../models/space';
import { RootState } from '../ui/redux/modules';
import * as entities from '../ui/redux/modules/entities';
@ -8,7 +8,7 @@ export const reduxStateForTest = async (global: Partial<GlobalState> = {}): Prom
entities: entities.reducer(entities.initialEntitiesState, entities.initializeWith(await entities.allDocs())),
global: {
activeWorkspaceId: null,
activeActivity: ACTIVITY_DEBUG,
activeActivity: ACTIVITY_HOME,
activeSpaceId: BASE_SPACE_ID,
isLoading: false,
isLoggedIn: false,

View File

@ -7,22 +7,22 @@ import { AUTOBIND_CFG } from '../../../common/constants';
import { GrpcRequestEventEnum } from '../../../common/grpc-events';
import type { ProtoDirectory } from '../../../models/proto-directory';
import type { ProtoFile } from '../../../models/proto-file';
import type { Workspace } from '../../../models/workspace';
import * as protoManager from '../../../network/grpc/proto-manager';
import type { GrpcDispatch } from '../../context/grpc';
import { grpcActions, sendGrpcIpcMultiple } from '../../context/grpc';
import type { ExpandedProtoDirectory } from '../../redux/proto-selectors';
import { RootState } from '../../redux/modules';
import { selectExpandedActiveProtoDirectories } from '../../redux/proto-selectors';
import { selectActiveWorkspace } from '../../redux/selectors';
import Modal from '../base/modal';
import ModalBody from '../base/modal-body';
import ModalFooter from '../base/modal-footer';
import ModalHeader from '../base/modal-header';
import ProtoFileList from '../proto-file/proto-file-list';
interface Props {
type ReduxProps = ReturnType<typeof mapStateToProps>;
interface Props extends ReduxProps {
grpcDispatch: GrpcDispatch;
workspace: Workspace;
protoDirectories: ExpandedProtoDirectory[];
}
interface State {
@ -105,7 +105,13 @@ class ProtoFilesModal extends PureComponent<Props, State> {
}
_handleAdd() {
return protoManager.addFile(this.props.workspace._id, createdId => {
const { workspace } = this.props;
if (!workspace) {
return;
}
return protoManager.addFile(workspace._id, createdId => {
this.setState({
selectedProtoFileId: createdId,
});
@ -122,7 +128,13 @@ class ProtoFilesModal extends PureComponent<Props, State> {
}
_handleAddDirectory() {
return protoManager.addDirectory(this.props.workspace._id);
const { workspace } = this.props;
if (!workspace) {
return;
}
return protoManager.addDirectory(workspace._id);
}
_handleRename(protoFile: ProtoFile, name: string) {
@ -172,13 +184,10 @@ class ProtoFilesModal extends PureComponent<Props, State> {
}
}
const mapStateToProps = (state, props) => {
// @ts-expect-error -- TSCONVERSION
const protoDirectories = selectExpandedActiveProtoDirectories(state, props);
return {
protoDirectories,
};
};
const mapStateToProps = (state: RootState) => ({
protoDirectories: selectExpandedActiveProtoDirectories(state),
workspace: selectActiveWorkspace(state),
});
export default connect(mapStateToProps, null, null, {
forwardRef: true,

View File

@ -2,8 +2,10 @@ import { autoBindMethodsForReact } from 'class-autobind-decorator';
import classnames from 'classnames';
import { buildQueryStringFromParams, joinUrlAndQueryString } from 'insomnia-url';
import React, { Fragment, PureComponent } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { ACTIVITY_DEBUG, ACTIVITY_SPEC, AUTOBIND_CFG, GlobalActivity, isWorkspaceActivity } from '../../../common/constants';
import { AUTOBIND_CFG } from '../../../common/constants';
import { hotKeyRefs } from '../../../common/hotkeys';
import { executeHotKey } from '../../../common/hotkeys-listener';
import { keyboardKeys } from '../../../common/keyboard-keys';
@ -11,10 +13,11 @@ import { fuzzyMatchAll } from '../../../common/misc';
import type { BaseModel } from '../../../models';
import * as models from '../../../models';
import { isRequest, Request } from '../../../models/request';
import { isRequestGroup, RequestGroup } from '../../../models/request-group';
import type { RequestMeta } from '../../../models/request-meta';
import { isDesign, Workspace } from '../../../models/workspace';
import { setActiveActivity, setActiveWorkspace } from '../../redux/modules/global';
import { isRequestGroup } from '../../../models/request-group';
import { Workspace } from '../../../models/workspace';
import { RootState } from '../../redux/modules';
import { activateWorkspace } from '../../redux/modules/workspace';
import { selectActiveRequest, selectActiveWorkspace, selectRequestMetas, selectWorkspaceRequestsAndRequestGroups, selectWorkspacesForActiveSpace } from '../../redux/selectors';
import Button from '../base/button';
import Highlight from '../base/highlight';
import Modal from '../base/modal';
@ -23,15 +26,31 @@ import ModalHeader from '../base/modal-header';
import KeydownBinder from '../keydown-binder';
import MethodTag from '../tags/method-tag';
interface Props {
handleSetActiveWorkspace: typeof setActiveWorkspace;
handleSetActiveActivity: typeof setActiveActivity;
type ReduxProps = ReturnType<typeof mapStateToProps> & ReturnType<typeof mapDispatchToProps>;
const mapStateToProps = (state: RootState) => {
const activeRequest = selectActiveRequest(state);
// the request switcher modal does not know about grpc requests yet
const normalizedRequest = activeRequest && isRequest(activeRequest) ? activeRequest : undefined;
return {
activeRequest: normalizedRequest,
workspace: selectActiveWorkspace(state),
workspaces: selectWorkspacesForActiveSpace(state),
requestMetas: selectRequestMetas(state),
workspaceChildren: selectWorkspaceRequestsAndRequestGroups(state),
};
};
const mapDispatchToProps = (dispatch) => {
const bound = bindActionCreators({ activateWorkspace }, dispatch);
return {
handleActivateWorkspace: bound.activateWorkspace,
};
};
interface Props extends ReduxProps {
activateRequest: (id: string) => void;
activeRequest?: Request;
workspaceChildren: (Request | RequestGroup)[];
workspace?: Workspace;
workspaces: Workspace[];
requestMetas: RequestMeta[];
}
interface State {
@ -155,18 +174,7 @@ class RequestSwitcherModal extends PureComponent<Props, State> {
}
async _activateWorkspace(workspace: Workspace) {
const { activeActivity } = await models.workspaceMeta.getOrCreateByParentId(workspace._id);
let goToActivity: GlobalActivity;
if (activeActivity && isWorkspaceActivity(activeActivity)) {
goToActivity = activeActivity;
} else {
goToActivity = isDesign(workspace) ? ACTIVITY_SPEC : ACTIVITY_DEBUG;
}
this.props.handleSetActiveActivity(goToActivity);
this.props.handleSetActiveWorkspace(workspace._id);
await this.props.handleActivateWorkspace(workspace);
this.modal && this.modal.hide();
}
@ -509,4 +517,11 @@ class RequestSwitcherModal extends PureComponent<Props, State> {
}
}
export default RequestSwitcherModal;
export default connect(
mapStateToProps,
mapDispatchToProps,
null,
{ forwardRef: true }
)(RequestSwitcherModal);

View File

@ -41,7 +41,6 @@ class PageLayout extends PureComponent<Props> {
handleInitializeEntities,
handleResetDragSidebar,
handleSetActiveEnvironment,
handleSetActiveWorkspace,
handleSetSidebarRef,
handleSetRequestPaneRef,
handleSetResponsePaneRef,
@ -114,7 +113,6 @@ class PageLayout extends PureComponent<Props> {
environmentHighlightColorStyle={settings.environmentHighlightColorStyle}
handleInitializeEntities={handleInitializeEntities}
handleSetActiveEnvironment={handleSetActiveEnvironment}
handleSetActiveWorkspace={handleSetActiveWorkspace}
hidden={sidebarHidden || false}
hotKeyRegistry={settings.hotKeyRegistry}
isLoading={isLoading}

View File

@ -16,7 +16,6 @@ interface Props {
children: ReactNode;
environmentHighlightColorStyle: string;
handleSetActiveEnvironment: (...args: any[]) => any;
handleSetActiveWorkspace: (...args: any[]) => any;
hidden: boolean;
hotKeyRegistry: HotKeyRegistry;
isLoading: boolean;

View File

@ -17,18 +17,13 @@ import { bindActionCreators } from 'redux';
import { parseApiSpec, ParsedApiSpec } from '../../common/api-specs';
import {
ACTIVITY_DEBUG,
ACTIVITY_SPEC,
AUTOBIND_CFG,
GlobalActivity,
isWorkspaceActivity,
} from '../../common/constants';
import { hotKeyRefs } from '../../common/hotkeys';
import { executeHotKey } from '../../common/hotkeys-listener';
import { fuzzyMatchAll, isNotNullOrUndefined } from '../../common/misc';
import { descendingNumberSort } from '../../common/sorting';
import { strings } from '../../common/strings';
import * as models from '../../models';
import { isRemoteSpace } from '../../models/space';
import { isDesign, Workspace, WorkspaceScopeKeys } from '../../models/workspace';
import { MemClient } from '../../sync/git/mem-client';
@ -37,7 +32,7 @@ import coreLogo from '../images/insomnia-core-logo.png';
import { cloneGitRepository } from '../redux/modules/git';
import { ForceToWorkspace } from '../redux/modules/helpers';
import { importClipBoard, importFile, importUri } from '../redux/modules/import';
import { createWorkspace } from '../redux/modules/workspace';
import { activateWorkspace, createWorkspace } from '../redux/modules/workspace';
import Highlight from './base/highlight';
import SettingsButton from './buttons/settings-button';
import AccountDropdown from './dropdowns/account-dropdown';
@ -144,19 +139,6 @@ class WrapperHome extends PureComponent<Props, State> {
});
}
async _handleClickCard(id: string, defaultActivity: GlobalActivity) {
const { handleSetActiveWorkspace, handleSetActiveActivity } = this.props.wrapperProps;
const { activeActivity } = await models.workspaceMeta.getOrCreateByParentId(id);
if (!activeActivity || !isWorkspaceActivity(activeActivity)) {
handleSetActiveActivity(defaultActivity);
} else {
handleSetActiveActivity(activeActivity);
}
handleSetActiveWorkspace(id);
}
renderCard(workspace: Workspace) {
const {
activeSpace,
@ -237,7 +219,6 @@ class WrapperHome extends PureComponent<Props, State> {
let label: string = strings.collection.singular;
let format = '';
let labelIcon = <i className="fa fa-bars" />;
let defaultActivity = ACTIVITY_DEBUG;
let title = workspace.name;
if (isDesign(workspace)) {
@ -251,7 +232,6 @@ class WrapperHome extends PureComponent<Props, State> {
format = `OpenAPI ${specFormatVersion}`;
}
defaultActivity = ACTIVITY_SPEC;
title = apiSpec.fileName || title;
}
@ -283,7 +263,7 @@ class WrapperHome extends PureComponent<Props, State> {
docLog={log}
docMenu={docMenu}
docFormat={format}
onClick={() => this._handleClickCard(workspace._id, defaultActivity)}
onClick={() => this.props.handleActivateWorkspace(workspace)}
/>
);
const renderedCard: RenderedCard = {
@ -419,6 +399,7 @@ const mapDispatchToProps = (dispatch) => {
importFile,
importClipBoard,
importUri,
activateWorkspace,
}, dispatch);
return ({
@ -427,6 +408,7 @@ const mapDispatchToProps = (dispatch) => {
handleImportFile: bound.importFile,
handleImportUri: bound.importUri,
handleImportClipboard: bound.importClipBoard,
handleActivateWorkspace: bound.activateWorkspace,
});
};

View File

@ -471,7 +471,6 @@ class Wrapper extends PureComponent<WrapperProps, State> {
activeCookieJar,
activeEnvironment,
activeGitRepository,
activeRequest,
activeWorkspace,
activeSpace,
activeApiSpec,
@ -483,16 +482,12 @@ class Wrapper extends PureComponent<WrapperProps, State> {
handleGetRenderContext,
handleInitializeEntities,
handleRender,
handleSetActiveWorkspace,
handleSetActiveActivity,
handleSidebarSort,
isVariableUncovered,
requestMetas,
settings,
sidebarChildren,
syncItems,
vcs,
workspaceChildren,
workspaces,
} = this.props;
@ -641,15 +636,7 @@ class Wrapper extends PureComponent<WrapperProps, State> {
<RequestSwitcherModal
ref={registerModal}
workspace={activeWorkspace}
workspaces={workspaces}
workspaceChildren={workspaceChildren}
// the request switcher modal does not know about grpc requests yet
activeRequest={activeRequest && isRequest(activeRequest) ? activeRequest : undefined}
activateRequest={handleActivateRequest}
requestMetas={requestMetas}
handleSetActiveWorkspace={handleSetActiveWorkspace}
handleSetActiveActivity={handleSetActiveActivity}
/>
<EnvironmentEditModal
@ -735,7 +722,6 @@ class Wrapper extends PureComponent<WrapperProps, State> {
<ProtoFilesModal
ref={registerModal}
grpcDispatch={dispatch}
workspace={activeWorkspace}
/>
)}
</GrpcDispatchModalWrapper>

View File

@ -95,7 +95,6 @@ import {
loadRequestStop,
newCommand,
setActiveActivity,
setActiveWorkspace,
} from '../redux/modules/global';
import { importUri } from '../redux/modules/import';
import {
@ -1783,7 +1782,6 @@ const mapDispatchToProps = (dispatch: Dispatch<Action<any>>) => {
importUri: handleImportUri,
loadRequestStart: handleStartLoading,
loadRequestStop: handleStopLoading,
setActiveWorkspace: handleSetActiveWorkspace,
newCommand: handleCommand,
setActiveActivity: handleSetActiveActivity,
goToNextActivity: handleGoToNextActivity,
@ -1794,7 +1792,6 @@ const mapDispatchToProps = (dispatch: Dispatch<Action<any>>) => {
loadRequestStart,
loadRequestStop,
newCommand,
setActiveWorkspace,
setActiveActivity,
goToNextActivity,
exportRequestsToFile,
@ -1803,7 +1800,6 @@ const mapDispatchToProps = (dispatch: Dispatch<Action<any>>) => {
return {
handleCommand,
handleImportUri,
handleSetActiveWorkspace,
handleSetActiveActivity,
handleStartLoading,
handleStopLoading,

View File

@ -1,5 +1,6 @@
import { globalBeforeEach } from '../../../__jest__/before-each';
import { reduxStateForTest } from '../../../__jest__/redux-state-for-test';
import { ACTIVITY_DEBUG } from '../../../common/constants';
import * as models from '../../../models';
import { selectExpandedActiveProtoDirectories } from '../proto-selectors';
@ -10,7 +11,7 @@ describe('selectExpandedActiveProtoDirectories', () => {
// Arrange
const w = await models.workspace.create();
// Act
const state = await reduxStateForTest({ activeWorkspaceId: w._id });
const state = await reduxStateForTest({ activeWorkspaceId: w._id, activeActivity: ACTIVITY_DEBUG });
const expandedDirs = selectExpandedActiveProtoDirectories(state);
// Assert
expect(expandedDirs).toHaveLength(0);
@ -36,7 +37,7 @@ describe('selectExpandedActiveProtoDirectories', () => {
});
const w2 = await models.workspace.create();
// Act
const state = await reduxStateForTest({ activeWorkspaceId: w2._id });
const state = await reduxStateForTest({ activeWorkspaceId: w2._id, activeActivity: ACTIVITY_DEBUG });
const expandedDirs = selectExpandedActiveProtoDirectories(state);
// Assert
expect(expandedDirs).toHaveLength(0);
@ -52,7 +53,7 @@ describe('selectExpandedActiveProtoDirectories', () => {
parentId: pd1._id,
});
// Act
const state = await reduxStateForTest({ activeWorkspaceId: w._id });
const state = await reduxStateForTest({ activeWorkspaceId: w._id, activeActivity: ACTIVITY_DEBUG });
const expandedDirs = selectExpandedActiveProtoDirectories(state);
// Assert
expect(expandedDirs).toHaveLength(1);
@ -81,7 +82,7 @@ describe('selectExpandedActiveProtoDirectories', () => {
parentId: w._id,
});
// Act
const state = await reduxStateForTest({ activeWorkspaceId: w._id });
const state = await reduxStateForTest({ activeWorkspaceId: w._id, activeActivity: ACTIVITY_DEBUG });
const expandedDirs = selectExpandedActiveProtoDirectories(state);
// Assert
expect(expandedDirs).toHaveLength(1);
@ -110,7 +111,7 @@ describe('selectExpandedActiveProtoDirectories', () => {
parentId: pd2._id,
});
// Act
const state = await reduxStateForTest({ activeWorkspaceId: w._id });
const state = await reduxStateForTest({ activeWorkspaceId: w._id, activeActivity: ACTIVITY_DEBUG });
const expandedDirs = selectExpandedActiveProtoDirectories(state);
// Assert
expect(expandedDirs).toHaveLength(2);
@ -146,7 +147,7 @@ describe('selectExpandedActiveProtoDirectories', () => {
parentId: pd2._id,
});
// Act
const state = await reduxStateForTest({ activeWorkspaceId: w._id });
const state = await reduxStateForTest({ activeWorkspaceId: w._id, activeActivity: ACTIVITY_DEBUG });
const expandedDirs = selectExpandedActiveProtoDirectories(state);
// Assert
expect(expandedDirs).toHaveLength(1);
@ -184,7 +185,7 @@ describe('selectExpandedActiveProtoDirectories', () => {
parentId: w._id,
});
// Act
const state = await reduxStateForTest({ activeWorkspaceId: w._id });
const state = await reduxStateForTest({ activeWorkspaceId: w._id, activeActivity: ACTIVITY_DEBUG });
const expandedDirs = selectExpandedActiveProtoDirectories(state);
// Assert
expect(expandedDirs).toHaveLength(2);

View File

@ -12,6 +12,7 @@ import { trackEvent, trackSegmentEvent } from '../../../../common/analytics';
import { ACTIVITY_SPEC } from '../../../../common/constants';
import * as models from '../../../../models';
import { gitRepositorySchema } from '../../../../models/__schemas__/model-schemas';
import { BASE_SPACE_ID } from '../../../../models/space';
import { Workspace, WorkspaceScopeKeys } from '../../../../models/workspace';
import { GIT_INSOMNIA_DIR } from '../../../../sync/git/git-vcs';
import { MemClient } from '../../../../sync/git/mem-client';
@ -23,7 +24,7 @@ import {
getAndClearShowPromptMockArgs,
} from '../../../../test-utils';
import { cloneGitRepository, setupGitRepository } from '../git';
import { LOAD_START, LOAD_STOP, SET_ACTIVE_ACTIVITY, SET_ACTIVE_WORKSPACE } from '../global';
import { LOAD_START, LOAD_STOP, SET_ACTIVE_ACTIVITY, SET_ACTIVE_SPACE, SET_ACTIVE_WORKSPACE } from '../global';
jest.mock('../../../components/modals');
jest.mock('../../../../sync/git/shallow-clone');
@ -119,6 +120,10 @@ describe('git', () => {
{
type: LOAD_STOP,
},
{
type: SET_ACTIVE_SPACE,
spaceId: BASE_SPACE_ID,
},
{
type: SET_ACTIVE_WORKSPACE,
workspaceId: workspace._id,

View File

@ -4,7 +4,7 @@ import thunk from 'redux-thunk';
import { globalBeforeEach } from '../../../../__jest__/before-each';
import { reduxStateForTest } from '../../../../__jest__/redux-state-for-test';
import { trackEvent, trackSegmentEvent } from '../../../../common/analytics';
import { ACTIVITY_DEBUG, ACTIVITY_HOME, ACTIVITY_SPEC, ACTIVITY_UNIT_TEST } from '../../../../common/constants';
import { ACTIVITY_DEBUG, ACTIVITY_SPEC, ACTIVITY_UNIT_TEST } from '../../../../common/constants';
import { database } from '../../../../common/database';
import * as models from '../../../../models';
import { ApiSpec } from '../../../../models/api-spec';
@ -64,6 +64,10 @@ describe('workspace', () => {
expect(trackSegmentEvent).toHaveBeenCalledWith('Document Created');
expect(trackEvent).toHaveBeenCalledWith('Workspace', 'Create');
expect(store.getActions()).toEqual([
{
type: SET_ACTIVE_SPACE,
spaceId: BASE_SPACE_ID,
},
{
type: SET_ACTIVE_WORKSPACE,
workspaceId: workspaceId,
@ -95,34 +99,9 @@ describe('workspace', () => {
expect(trackEvent).toHaveBeenCalledWith('Workspace', 'Create');
expect(store.getActions()).toEqual([
{
type: SET_ACTIVE_WORKSPACE,
workspaceId: workspaceId,
type: SET_ACTIVE_SPACE,
spaceId: BASE_SPACE_ID,
},
{
type: SET_ACTIVE_ACTIVITY,
activity: ACTIVITY_DEBUG,
},
]);
});
it('should create with no space', async () => {
const store = mockStore(await reduxStateForTest());
// @ts-expect-error redux-thunk types
store.dispatch(createWorkspace({ scope: WorkspaceScopeKeys.collection }));
const { title, submitName, defaultValue, onComplete } = getAndClearShowPromptMockArgs();
expect(title).toBe('Create New Request Collection');
expect(submitName).toBe('Create');
expect(defaultValue).toBe('My Collection');
const workspaceName = 'name';
await onComplete?.(workspaceName);
const workspaceId = await expectedModelsCreated(workspaceName, WorkspaceScopeKeys.collection, BASE_SPACE_ID);
expect(trackSegmentEvent).toHaveBeenCalledWith('Collection Created');
expect(trackEvent).toHaveBeenCalledWith('Workspace', 'Create');
expect(store.getActions()).toEqual([
{
type: SET_ACTIVE_WORKSPACE,
workspaceId: workspaceId,
@ -139,7 +118,7 @@ describe('workspace', () => {
it('should activate space and workspace and activity from home', async () => {
const space = await models.space.create();
const workspace = await models.workspace.create({ scope: 'design', parentId: space._id });
const store = mockStore(await reduxStateForTest({ activeSpaceId: 'abc', activeWorkspaceId: 'def', activeActivity: ACTIVITY_HOME }));
const store = mockStore(await reduxStateForTest({ activeSpaceId: 'abc', activeWorkspaceId: 'def' }));
await store.dispatch(activateWorkspace(workspace));
@ -162,7 +141,7 @@ describe('workspace', () => {
it('should switch to the default design activity', async () => {
const space = await models.space.create();
const workspace = await models.workspace.create({ scope: 'design', parentId: space._id });
const store = mockStore(await reduxStateForTest({ activeSpaceId: space._id, activeWorkspaceId: workspace._id, activeActivity: ACTIVITY_HOME }));
const store = mockStore(await reduxStateForTest({ activeSpaceId: space._id, activeWorkspaceId: workspace._id }));
await store.dispatch(activateWorkspace(workspace));
@ -223,7 +202,7 @@ describe('workspace', () => {
it('should switch to the default collection activity', async () => {
const space = await models.space.create();
const workspace = await models.workspace.create({ scope: 'collection', parentId: space._id });
const store = mockStore(await reduxStateForTest({ activeSpaceId: space._id, activeWorkspaceId: workspace._id, activeActivity: ACTIVITY_HOME }));
const store = mockStore(await reduxStateForTest({ activeSpaceId: space._id, activeWorkspaceId: workspace._id }));
await store.dispatch(activateWorkspace(workspace));
@ -248,7 +227,7 @@ describe('workspace', () => {
const workspace = await models.workspace.create({ scope: 'design', parentId: space._id });
await models.workspace.ensureChildren(workspace);
await models.workspaceMeta.updateByParentId(workspace._id, { activeActivity: ACTIVITY_UNIT_TEST });
const store = mockStore(await reduxStateForTest({ activeSpaceId: space._id, activeWorkspaceId: workspace._id, activeActivity: ACTIVITY_HOME }));
const store = mockStore(await reduxStateForTest({ activeSpaceId: space._id, activeWorkspaceId: workspace._id }));
await store.dispatch(activateWorkspace(workspace));

View File

@ -23,7 +23,7 @@ const createWorkspaceAndChildren = async (patch: Partial<Workspace>) => {
};
const actuallyCreate = (patch: Partial<Workspace>, onCreate?: OnWorkspaceCreateCallback) => {
return async (dispatch: Dispatch) => {
return async (dispatch) => {
const workspace = await createWorkspaceAndChildren(patch);
if (onCreate) {
@ -31,8 +31,7 @@ const actuallyCreate = (patch: Partial<Workspace>, onCreate?: OnWorkspaceCreateC
}
trackEvent('Workspace', 'Create');
dispatch(setActiveWorkspace(workspace._id));
dispatch(setActiveActivity(isDesign(workspace) ? ACTIVITY_SPEC : ACTIVITY_DEBUG));
await dispatch(activateWorkspace(workspace));
};
};

View File

@ -66,6 +66,11 @@ export const selectSettings = createSelector(
selectEntitiesLists,
entities => entities.settings[0] || models.settings.init());
export const selectRequestMetas = createSelector(
selectEntitiesLists,
entities => entities.requestMetas,
);
export const selectSpaces = createSelector(
selectEntitiesLists,
entities => entities.spaces,

View File

@ -14,7 +14,7 @@ function isPromise(obj: unknown) {
}
export interface AsyncButtonProps<T> extends ButtonProps {
onClick: (e: React.MouseEvent<HTMLButtonElement>) => Promise<T>;
onClick: (e: React.MouseEvent<HTMLButtonElement>) => Promise<T> | undefined;
loadingNode?: ReactNode;
}