import React, {PureComponent} from 'react'; import PropTypes from 'prop-types'; import autobind from 'autobind-decorator'; import PromptButton from '../base/prompt-button'; import {Dropdown, DropdownButton, DropdownDivider, DropdownHint, DropdownItem} from '../base/dropdown'; import EnvironmentEditModal from '../modals/environment-edit-modal'; import * as models from '../../../models'; import {showModal} from '../modals'; import {trackEvent} from '../../../analytics/index'; import {showPrompt} from '../modals/index'; @autobind class RequestGroupActionsDropdown extends PureComponent { _setDropdownRef (n) { this._dropdown = n; } _handleRename () { const {requestGroup} = this.props; showPrompt({ title: 'Rename Folder', defaultValue: requestGroup.name, onComplete: name => { models.requestGroup.update(requestGroup, {name}); trackEvent('Folder', 'Rename', 'Folder Action'); } }); } async _handleRequestCreate () { this.props.handleCreateRequest(this.props.requestGroup._id); trackEvent('Request', 'Create', 'Folder Action'); } _handleRequestGroupDuplicate () { this.props.handleDuplicateRequestGroup(this.props.requestGroup); trackEvent('Folder', 'Duplicate', 'Folder Action'); } async _handleRequestGroupCreate () { 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, // eslint-disable-line no-unused-vars ...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;