import React, {Component, PropTypes} from 'react'; import PromptButton from '../base/PromptButton'; import {Dropdown, DropdownButton, DropdownItem, DropdownDivider, DropdownHint} from '../base/dropdown'; import EnvironmentEditModal from '../modals/EnvironmentEditModal'; import PromptModal from '../modals/PromptModal'; import * as models from '../../../models'; import {showModal} from '../modals'; import {trackEvent} from '../../../analytics/index'; class RequestGroupActionsDropdown extends Component { async _promptUpdateName () { const {requestGroup} = this.props; const name = await showModal(PromptModal, { headerName: 'Rename Folder', defaultValue: requestGroup.name }); models.requestGroup.update(requestGroup, {name}); trackEvent('Folder', 'Rename', 'Folder Action'); } async _requestCreate () { this.props.handleCreateRequest(); trackEvent('Request', 'Create', 'Folder Action'); } _requestGroupDuplicate () { const {requestGroup} = this.props; models.requestGroup.duplicate(requestGroup); trackEvent('Folder', 'Duplicate', 'Folder Action'); } async _requestGroupCreate () { this.props.handleCreateRequestGroup(); trackEvent('Folder', 'Create', 'Folder Action'); } render () { const {requestGroup, ...other} = this.props; return ( this._requestCreate()}> New Request this._requestGroupCreate()}> New Folder this._requestGroupDuplicate()}> Duplicate this._promptUpdateName()}> Rename showModal(EnvironmentEditModal, requestGroup)}> Environment { models.requestGroup.remove(requestGroup); trackEvent('Folder', 'Delete', 'Folder Action'); }}> Delete ) } } RequestGroupActionsDropdown.propTypes = { workspace: PropTypes.object.isRequired, handleCreateRequest: PropTypes.func.isRequired, handleCreateRequestGroup: PropTypes.func.isRequired, // Optional requestGroup: PropTypes.object }; export default RequestGroupActionsDropdown;