mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
9e84bc4387
* Start on workspace dropdown and upgrade fontawesome * WorkspaceDropdown start and Elm components! * Lots of CSS shit * Refactor some db stuff and move filter out of sidebar * Adjust dropdown css * Handle duplicate header names, and stuff * Shitty cookies tab * fixed cookie table a bit * Modal refactor * Starteed cookie modal design * Better cookie storage and filter cookie modal * Cookie editor round 1 * Fix kve cursor jumping and form encoding templating * New cookies now show up in filter * Checkpoint * Stuff and fix environments css * Added manage cookies button to cookie pane * Fix accidental sidebar item drag on sidebar resize * Environments modal is looking pretty good now * Pretty much done environments nad cookies * Some changes * Fixed codemirror in modals * Fixed some things * Add basic proxy support * Updated shortcuts * Code snippet generation * Some style * bug fix * Code export now gets cookies for correct domain
116 lines
3.1 KiB
JavaScript
116 lines
3.1 KiB
JavaScript
import React, {Component, PropTypes} from 'react';
|
|
import {connect} from 'react-redux'
|
|
import Dropdown from '../components/base/Dropdown';
|
|
import DropdownHint from '../components/base/DropdownHint';
|
|
import EnvironmentEditModal from '../components/modals/EnvironmentEditModal';
|
|
import PromptModal from '../components/modals/PromptModal';
|
|
import * as db from '../database';
|
|
import {getModal} from '../components/modals/index';
|
|
|
|
class RequestGroupActionsDropdown extends Component {
|
|
_promptUpdateName () {
|
|
const {requestGroup} = this.props;
|
|
|
|
getModal(PromptModal).show({
|
|
headerName: 'Rename Folder',
|
|
defaultValue: requestGroup.name
|
|
}).then(name => {
|
|
db.requestGroupUpdate(requestGroup, {name});
|
|
})
|
|
}
|
|
|
|
_requestCreate () {
|
|
getModal(PromptModal).show({
|
|
headerName: 'Create New Request',
|
|
defaultValue: 'My Request',
|
|
selectText: true
|
|
}).then(name => {
|
|
const workspace = this._getActiveWorkspace();
|
|
const {requestGroup} = this.props;
|
|
const parentId = requestGroup._id;
|
|
db.requestCreateAndActivate(workspace, {parentId, name})
|
|
});
|
|
}
|
|
|
|
_getActiveWorkspace (props) {
|
|
// TODO: Factor this out into a selector
|
|
|
|
const {entities, workspaces} = props || this.props;
|
|
let workspace = entities.workspaces[workspaces.activeId];
|
|
if (!workspace) {
|
|
workspace = entities.workspaces[Object.keys(entities.workspaces)[0]];
|
|
}
|
|
|
|
return workspace;
|
|
}
|
|
|
|
render () {
|
|
const {requestGroup, ...other} = this.props;
|
|
|
|
return (
|
|
<Dropdown {...other}>
|
|
<button>
|
|
<i className="fa fa-caret-down"></i>
|
|
</button>
|
|
<ul>
|
|
<li>
|
|
<button onClick={e => this._requestCreate()}>
|
|
<i className="fa fa-plus-circle"></i> New Request
|
|
<DropdownHint char="N"></DropdownHint>
|
|
</button>
|
|
</li>
|
|
<li>
|
|
<button onClick={e => this._promptUpdateName()}>
|
|
<i className="fa fa-edit"></i> Rename
|
|
</button>
|
|
</li>
|
|
<li>
|
|
<button onClick={e => getModal(EnvironmentEditModal).show(requestGroup)}>
|
|
<i className="fa fa-code"></i> Environment
|
|
</button>
|
|
</li>
|
|
{/*<li>*/}
|
|
{/*<button onClick={e => db.requestGroupCreate({parentId: requestGroup._id})}>*/}
|
|
{/*<i className="fa fa-folder"></i> New Folder*/}
|
|
{/*</button>*/}
|
|
{/*</li>*/}
|
|
<li>
|
|
<button onClick={e => db.requestGroupRemove(requestGroup)}>
|
|
<i className="fa fa-trash-o"></i> Delete
|
|
</button>
|
|
</li>
|
|
</ul>
|
|
</Dropdown>
|
|
)
|
|
}
|
|
}
|
|
|
|
RequestGroupActionsDropdown.propTypes = {
|
|
// Required
|
|
entities: PropTypes.shape({
|
|
workspaces: PropTypes.object.isRequired
|
|
}).isRequired,
|
|
workspaces: PropTypes.shape({
|
|
activeId: PropTypes.string
|
|
}),
|
|
|
|
// Optional
|
|
requestGroup: PropTypes.object
|
|
};
|
|
|
|
function mapStateToProps (state) {
|
|
return {
|
|
workspaces: state.workspaces,
|
|
entities: state.entities
|
|
};
|
|
}
|
|
|
|
function mapDispatchToProps (dispatch) {
|
|
return {}
|
|
}
|
|
|
|
export default connect(
|
|
mapStateToProps,
|
|
mapDispatchToProps
|
|
)(RequestGroupActionsDropdown);
|