mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
7b8d26c292
* Added import from URI ability * Add protocol handlers * Fix for keymap setting on read-only mode * Refactored some main components out * Protocols shoudl work now
85 lines
2.7 KiB
JavaScript
85 lines
2.7 KiB
JavaScript
import React, {PureComponent, PropTypes} from 'react';
|
|
import autobind from 'autobind-decorator';
|
|
import {Dropdown, DropdownButton, DropdownItem, DropdownDivider} from '../base/dropdown';
|
|
import PromptModal from '../modals/prompt-modal';
|
|
import Link from '../base/link';
|
|
import {showModal} from '../modals/index';
|
|
|
|
@autobind
|
|
class ImportExport extends PureComponent {
|
|
async _handleImportUri () {
|
|
const uri = await showModal(PromptModal, {
|
|
headerName: 'Import Data from URL',
|
|
submitName: 'Fetch and Import',
|
|
label: 'URL',
|
|
placeholder: 'https://website.com/insomnia-import.json'
|
|
});
|
|
this.props.handleImportUri(uri);
|
|
}
|
|
|
|
render () {
|
|
const {
|
|
handleImportFile,
|
|
handleExportAll,
|
|
handleExportWorkspace
|
|
} = this.props;
|
|
|
|
return (
|
|
<div>
|
|
<p className="no-margin-top">
|
|
Import format will be automatically detected (<strong>Insomnia, Postman v2, HAR,
|
|
Curl</strong>)
|
|
</p>
|
|
<p>
|
|
Don't see your format here?
|
|
{' '}
|
|
<Link href="https://insomnia.rest/documentation/import-export">Add Your Own</Link>.
|
|
</p>
|
|
<div className="pad-top">
|
|
<Dropdown outline>
|
|
<DropdownButton className="btn btn--clicky">
|
|
Export Data <i className="fa fa-caret-down"></i>
|
|
</DropdownButton>
|
|
<DropdownDivider>Choose Export Type</DropdownDivider>
|
|
<DropdownItem onClick={handleExportWorkspace}>
|
|
<i className="fa fa-home"/>
|
|
Current Workspace
|
|
</DropdownItem>
|
|
<DropdownItem onClick={handleExportAll}>
|
|
<i className="fa fa-empty"/>
|
|
All Workspaces
|
|
</DropdownItem>
|
|
</Dropdown>
|
|
|
|
<Dropdown outline>
|
|
<DropdownButton className="btn btn--clicky">
|
|
Import Data <i className="fa fa-caret-down"></i>
|
|
</DropdownButton>
|
|
<DropdownDivider>Choose Import Type</DropdownDivider>
|
|
<DropdownItem onClick={handleImportFile}>
|
|
<i className="fa fa-file-o"/>
|
|
From File
|
|
</DropdownItem>
|
|
<DropdownItem onClick={this._handleImportUri}>
|
|
<i className="fa fa-link"/>
|
|
From URL
|
|
</DropdownItem>
|
|
</Dropdown>
|
|
</div>
|
|
<p className="italic faint">
|
|
* Tip: You can also paste Curl commands into the URL bar
|
|
</p>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
ImportExport.propTypes = {
|
|
handleImportFile: PropTypes.func.isRequired,
|
|
handleImportUri: PropTypes.func.isRequired,
|
|
handleExportAll: PropTypes.func.isRequired,
|
|
handleExportWorkspace: PropTypes.func.isRequired
|
|
};
|
|
|
|
export default ImportExport;
|