2016-11-26 08:29:16 +00:00
|
|
|
import React, {PureComponent, PropTypes} from 'react';
|
2016-08-15 17:04:36 +00:00
|
|
|
import classnames from 'classnames';
|
2016-11-16 17:18:39 +00:00
|
|
|
import EnvironmentsDropdown from '../dropdowns/EnvironmentsDropdown';
|
2016-08-15 17:04:36 +00:00
|
|
|
import SidebarFilter from './SidebarFilter';
|
2016-11-25 23:09:17 +00:00
|
|
|
import SidebarChildren from './SidebarChildren';
|
2016-11-11 23:06:24 +00:00
|
|
|
import SyncButton from '../dropdowns/SyncDropdown';
|
2016-11-16 17:18:39 +00:00
|
|
|
import WorkspaceDropdown from '../dropdowns/WorkspaceDropdown';
|
2016-11-25 23:09:17 +00:00
|
|
|
import {SIDEBAR_SKINNY_REMS, COLLAPSE_SIDEBAR_REMS} from '../../../common/constants';
|
2016-03-18 00:36:00 +00:00
|
|
|
|
2016-07-25 22:27:29 +00:00
|
|
|
|
2016-11-26 08:29:16 +00:00
|
|
|
class Sidebar extends PureComponent {
|
|
|
|
_handleChangeEnvironment = id => {
|
2016-11-25 23:09:17 +00:00
|
|
|
const {workspace, handleSetActiveEnvironment} = this.props;
|
|
|
|
handleSetActiveEnvironment(workspace._id, id);
|
|
|
|
};
|
2016-04-05 05:35:21 +00:00
|
|
|
|
2016-11-25 23:09:17 +00:00
|
|
|
_handleCreateRequestInWorkspace = () => {
|
|
|
|
const {workspace, handleCreateRequest} = this.props;
|
|
|
|
handleCreateRequest(workspace._id);
|
|
|
|
};
|
2016-04-05 05:35:21 +00:00
|
|
|
|
2016-11-25 23:09:17 +00:00
|
|
|
_handleCreateRequestGroupInWorkspace = () => {
|
|
|
|
const {workspace, handleCreateRequestGroup} = this.props;
|
|
|
|
handleCreateRequestGroup(workspace._id);
|
|
|
|
};
|
2016-03-24 10:20:11 +00:00
|
|
|
|
2016-03-23 05:26:27 +00:00
|
|
|
render () {
|
2016-08-15 17:04:36 +00:00
|
|
|
const {
|
|
|
|
showCookiesModal,
|
|
|
|
filter,
|
|
|
|
children,
|
2016-09-12 20:04:15 +00:00
|
|
|
hidden,
|
2016-10-24 23:30:37 +00:00
|
|
|
width,
|
2016-11-16 17:18:39 +00:00
|
|
|
workspace,
|
|
|
|
workspaces,
|
|
|
|
environments,
|
|
|
|
activeEnvironment,
|
|
|
|
handleSetActiveWorkspace,
|
|
|
|
handleImportFile,
|
|
|
|
handleExportFile,
|
|
|
|
handleChangeFilter,
|
|
|
|
isLoading,
|
2016-11-25 23:09:17 +00:00
|
|
|
handleCreateRequest,
|
2016-11-27 21:42:38 +00:00
|
|
|
handleDuplicateRequest,
|
2016-11-28 07:12:17 +00:00
|
|
|
handleDuplicateRequestGroup,
|
|
|
|
handleGenerateCode,
|
2016-11-25 23:09:17 +00:00
|
|
|
handleCreateRequestGroup,
|
|
|
|
handleSetRequestGroupCollapsed,
|
|
|
|
moveRequest,
|
|
|
|
moveRequestGroup,
|
|
|
|
handleActivateRequest,
|
|
|
|
activeRequest,
|
2016-08-15 17:04:36 +00:00
|
|
|
} = this.props;
|
2016-03-23 05:26:27 +00:00
|
|
|
|
|
|
|
return (
|
2016-08-15 17:04:36 +00:00
|
|
|
<aside className={classnames('sidebar', {
|
2016-09-12 20:04:15 +00:00
|
|
|
'sidebar--hidden': hidden,
|
2016-08-15 17:04:36 +00:00
|
|
|
'sidebar--skinny': width < SIDEBAR_SKINNY_REMS,
|
|
|
|
'sidebar--collapsed': width < COLLAPSE_SIDEBAR_REMS
|
|
|
|
})}>
|
|
|
|
<WorkspaceDropdown
|
|
|
|
className="sidebar__header"
|
2016-11-16 17:18:39 +00:00
|
|
|
activeWorkspace={workspace}
|
|
|
|
workspaces={workspaces}
|
|
|
|
handleExportFile={handleExportFile}
|
|
|
|
handleImportFile={handleImportFile}
|
|
|
|
handleSetActiveWorkspace={handleSetActiveWorkspace}
|
|
|
|
isLoading={isLoading}
|
2016-08-15 17:04:36 +00:00
|
|
|
/>
|
|
|
|
|
|
|
|
<div className="sidebar__menu">
|
2016-11-16 17:18:39 +00:00
|
|
|
<EnvironmentsDropdown
|
2016-11-25 23:09:17 +00:00
|
|
|
handleChangeEnvironment={this._handleChangeEnvironment}
|
2016-11-16 17:18:39 +00:00
|
|
|
activeEnvironment={activeEnvironment}
|
|
|
|
environments={environments}
|
|
|
|
workspace={workspace}
|
|
|
|
/>
|
2016-11-25 23:09:17 +00:00
|
|
|
<button className="btn btn--super-compact" onClick={showCookiesModal}>
|
2016-08-15 17:04:36 +00:00
|
|
|
<div className="sidebar__menu__thing">
|
|
|
|
<span>Cookies</span>
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<SidebarFilter
|
2016-11-25 23:09:17 +00:00
|
|
|
onChange={handleChangeFilter}
|
|
|
|
requestCreate={this._handleCreateRequestInWorkspace}
|
|
|
|
requestGroupCreate={this._handleCreateRequestGroupInWorkspace}
|
|
|
|
filter={filter || ''}
|
2016-08-15 17:04:36 +00:00
|
|
|
/>
|
|
|
|
|
2016-11-25 23:09:17 +00:00
|
|
|
<SidebarChildren
|
|
|
|
children={children}
|
|
|
|
handleActivateRequest={handleActivateRequest}
|
|
|
|
handleCreateRequest={handleCreateRequest}
|
|
|
|
handleCreateRequestGroup={handleCreateRequestGroup}
|
|
|
|
handleSetRequestGroupCollapsed={handleSetRequestGroupCollapsed}
|
2016-11-27 21:42:38 +00:00
|
|
|
handleDuplicateRequest={handleDuplicateRequest}
|
2016-11-28 07:12:17 +00:00
|
|
|
handleDuplicateRequestGroup={handleDuplicateRequestGroup}
|
|
|
|
handleGenerateCode={handleGenerateCode}
|
2016-11-25 23:09:17 +00:00
|
|
|
moveRequest={moveRequest}
|
|
|
|
moveRequestGroup={moveRequestGroup}
|
|
|
|
filter={filter}
|
|
|
|
workspace={workspace}
|
|
|
|
activeRequest={activeRequest}
|
|
|
|
/>
|
2016-07-06 20:18:26 +00:00
|
|
|
|
2016-11-16 17:18:39 +00:00
|
|
|
<SyncButton
|
|
|
|
className="sidebar__footer"
|
|
|
|
key={workspace._id}
|
|
|
|
workspace={workspace}
|
|
|
|
/>
|
2016-05-01 19:56:30 +00:00
|
|
|
</aside>
|
2016-03-23 05:26:27 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2016-03-18 00:36:00 +00:00
|
|
|
|
2016-03-20 04:00:40 +00:00
|
|
|
Sidebar.propTypes = {
|
2016-04-26 07:29:24 +00:00
|
|
|
// Functions
|
2016-11-16 17:18:39 +00:00
|
|
|
handleActivateRequest: PropTypes.func.isRequired,
|
|
|
|
handleSetRequestGroupCollapsed: PropTypes.func.isRequired,
|
|
|
|
handleChangeFilter: PropTypes.func.isRequired,
|
|
|
|
handleImportFile: PropTypes.func.isRequired,
|
|
|
|
handleExportFile: PropTypes.func.isRequired,
|
|
|
|
handleSetActiveWorkspace: PropTypes.func.isRequired,
|
|
|
|
handleSetActiveEnvironment: PropTypes.func.isRequired,
|
2016-07-19 16:59:26 +00:00
|
|
|
moveRequest: PropTypes.func.isRequired,
|
|
|
|
moveRequestGroup: PropTypes.func.isRequired,
|
2016-11-16 17:18:39 +00:00
|
|
|
handleCreateRequest: PropTypes.func.isRequired,
|
|
|
|
handleCreateRequestGroup: PropTypes.func.isRequired,
|
2016-11-27 21:42:38 +00:00
|
|
|
handleDuplicateRequest: PropTypes.func.isRequired,
|
2016-11-28 07:12:17 +00:00
|
|
|
handleDuplicateRequestGroup: PropTypes.func.isRequired,
|
|
|
|
handleGenerateCode: PropTypes.func.isRequired,
|
2016-08-15 17:04:36 +00:00
|
|
|
showEnvironmentsModal: PropTypes.func.isRequired,
|
|
|
|
showCookiesModal: PropTypes.func.isRequired,
|
2016-04-26 07:29:24 +00:00
|
|
|
|
|
|
|
// Other
|
2016-11-16 17:18:39 +00:00
|
|
|
hidden: PropTypes.bool.isRequired,
|
|
|
|
width: PropTypes.number.isRequired,
|
|
|
|
isLoading: PropTypes.bool.isRequired,
|
|
|
|
workspace: PropTypes.object.isRequired,
|
2016-11-26 08:29:16 +00:00
|
|
|
children: PropTypes.arrayOf(PropTypes.object).isRequired,
|
2016-11-16 17:18:39 +00:00
|
|
|
workspaces: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
|
|
environments: PropTypes.arrayOf(PropTypes.object).isRequired,
|
2016-04-26 07:29:24 +00:00
|
|
|
|
|
|
|
// Optional
|
|
|
|
filter: PropTypes.string,
|
2016-11-16 17:18:39 +00:00
|
|
|
activeRequest: PropTypes.object,
|
|
|
|
activeEnvironment: PropTypes.object,
|
2016-03-20 04:00:40 +00:00
|
|
|
};
|
2016-03-18 00:36:00 +00:00
|
|
|
|
|
|
|
export default Sidebar;
|