2021-02-02 23:19:22 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import { ACTIVITY_HOME } from '../../common/constants';
|
|
|
|
import coreLogo from '../images/insomnia-core-logo.png';
|
|
|
|
import strings from '../../common/strings';
|
|
|
|
import WorkspaceDropdown from './dropdowns/workspace-dropdown';
|
|
|
|
import ActivityToggle from './activity-toggle';
|
|
|
|
import type { WrapperProps } from './wrapper';
|
|
|
|
import { Header, Breadcrumb } from 'insomnia-components';
|
2021-02-12 02:20:35 +00:00
|
|
|
import AccountDropdown from './dropdowns/account-dropdown';
|
|
|
|
import SettingsButton from './buttons/settings-button';
|
2021-02-02 23:19:22 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
wrapperProps: WrapperProps,
|
|
|
|
handleActivityChange: (workspaceId: string, activity: GlobalActivity) => Promise<void>,
|
|
|
|
gridRight: React.Node,
|
|
|
|
};
|
|
|
|
|
|
|
|
const WorkspacePageHeader = ({
|
|
|
|
gridRight,
|
|
|
|
handleActivityChange,
|
|
|
|
wrapperProps: {
|
|
|
|
activeApiSpec,
|
|
|
|
activeWorkspace,
|
|
|
|
activeEnvironment,
|
|
|
|
settings,
|
|
|
|
activity,
|
|
|
|
unseenWorkspaces,
|
|
|
|
vcs,
|
|
|
|
workspaces,
|
|
|
|
isLoading,
|
|
|
|
handleSetActiveWorkspace,
|
|
|
|
},
|
|
|
|
}: Props) => {
|
|
|
|
const collection = activeWorkspace.scope === 'collection';
|
|
|
|
const designer = !collection;
|
|
|
|
|
|
|
|
const homeCallback = React.useCallback(
|
|
|
|
() => handleActivityChange(activeWorkspace._id, ACTIVITY_HOME),
|
|
|
|
[activeWorkspace._id, handleActivityChange],
|
|
|
|
);
|
|
|
|
|
|
|
|
const workspace = (
|
|
|
|
<WorkspaceDropdown
|
|
|
|
displayName={collection ? activeWorkspace.name : activeApiSpec.fileName}
|
|
|
|
activeEnvironment={activeEnvironment}
|
|
|
|
activeWorkspace={activeWorkspace}
|
|
|
|
workspaces={workspaces}
|
|
|
|
unseenWorkspaces={unseenWorkspaces}
|
|
|
|
hotKeyRegistry={settings.hotKeyRegistry}
|
|
|
|
handleSetActiveWorkspace={handleSetActiveWorkspace}
|
|
|
|
isLoading={isLoading}
|
|
|
|
vcs={vcs}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Header
|
|
|
|
className="app-header"
|
|
|
|
gridLeft={
|
|
|
|
<React.Fragment>
|
2021-02-10 23:37:10 +00:00
|
|
|
<img src={coreLogo} alt="Insomnia" width="24" height="24" />
|
2021-02-02 23:19:22 +00:00
|
|
|
<Breadcrumb
|
|
|
|
className="breadcrumb"
|
|
|
|
crumbs={[strings.home, <React.Fragment key="workspace-dd">{workspace}</React.Fragment>]}
|
|
|
|
onClick={homeCallback}
|
|
|
|
/>
|
|
|
|
</React.Fragment>
|
|
|
|
}
|
|
|
|
gridCenter={
|
|
|
|
designer && (
|
|
|
|
<ActivityToggle
|
|
|
|
activity={activity}
|
|
|
|
handleActivityChange={handleActivityChange}
|
|
|
|
workspace={activeWorkspace}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
2021-02-12 02:20:35 +00:00
|
|
|
gridRight={
|
|
|
|
<>
|
|
|
|
{gridRight}
|
|
|
|
<SettingsButton className="margin-left" />
|
|
|
|
<AccountDropdown className="margin-left" />
|
|
|
|
</>
|
|
|
|
}
|
2021-02-02 23:19:22 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default WorkspacePageHeader;
|