import React, {PureComponent, 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 PureComponent { _setDropdownRef = n => this._dropdown = n; _handleRename = async () => { 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'); }; _handleRequestCreate = async () => { this.props.handleCreateRequest(this.props.requestGroup._id); trackEvent('Request', 'Create', 'Folder Action'); }; _handleRequestGroupDuplicate = () => { this.props.handleDuplicateRequestGroup(this.props.requestGroup); trackEvent('Folder', 'Duplicate', 'Folder Action'); }; _handleRequestGroupCreate = async () => { this.props.handleCreateRequestGroup(this.props.requestGroup._id); trackEvent('Folder', 'Create', 'Folder Action'); }; _handleDeleteFolder = () => { models.requestGroup.remove(this.props.requestGroup); trackEvent('Folder', 'Delete', 'Folder Action'); }; _handleEditEnvironment = () => { showModal(EnvironmentEditModal, this.props.requestGroup); }; show () { this._dropdown.show(); } render () { const {requestGroup, ...other} = this.props; return ( New Request New Folder Duplicate Rename Environment Delete ) } } RequestGroupActionsDropdown.propTypes = { workspace: PropTypes.object.isRequired, handleCreateRequest: PropTypes.func.isRequired, handleCreateRequestGroup: PropTypes.func.isRequired, handleDuplicateRequestGroup: PropTypes.func.isRequired, // Optional requestGroup: PropTypes.object }; export default RequestGroupActionsDropdown;