Some cleanup

This commit is contained in:
Gregory Schier 2016-11-30 16:02:35 -08:00
parent 361c2ff77d
commit e752f81ec7
9 changed files with 53 additions and 74 deletions

View File

@ -53,7 +53,7 @@ export const SEGMENT_WRITE_KEY = isDevelopment() ?
'DlRubvWRIqAyzhLAQ5Lea1nXdIAsEoD2';
// UI Stuff
export const MAX_SIDEBAR_REMS = 35;
export const MAX_SIDEBAR_REMS = 45;
export const MIN_SIDEBAR_REMS = 0.75;
export const COLLAPSE_SIDEBAR_REMS = 4;
export const SIDEBAR_SKINNY_REMS = 10;

View File

@ -1,4 +1,4 @@
import * as importers from 'insomnia-importers';
import {convert} from 'insomnia-importers';
import * as db from './database';
import * as models from '../models';
import {getAppVersion} from './constants';
@ -24,14 +24,16 @@ const MODELS = {
};
export async function importRaw (workspace, rawContent, generateNewIds = false) {
let data;
let results;
try {
data = importers.import(rawContent);
results = convert(rawContent);
} catch (e) {
console.error('Failed to import data', e);
return;
}
const {data} = results;
// Generate all the ids we may need
const generatedIds = {};
for (const r of data.resources) {
@ -86,7 +88,10 @@ export async function importRaw (workspace, rawContent, generateNewIds = false)
db.flushChanges();
return importedDocs;
return {
source: results.type.id,
summary: importedDocs
};
}
export async function exportJSON (parentDoc = null) {

View File

@ -16,7 +16,7 @@
"electron-squirrel-startup": "^1.0.0",
"hkdf": "0.0.2",
"httpsnippet": "git@github.com:getinsomnia/httpsnippet.git#a3a2c0a0167fa844bf92df52a1442fa1d68a9053",
"insomnia-importers": "^0.4.0",
"insomnia-importers": "^1.0.0",
"json-lint": "^0.1.0",
"jsonpath-plus": "^0.15.0",
"mime-types": "^2.1.12",

View File

@ -55,6 +55,7 @@ class ChangelogModal extends Component {
...html,
<h1 key={`changes.${i}`}>v{change.version} Changes</h1>
];
if (change.summary) {
if (!Array.isArray(change.summary)) {
html = [
@ -72,6 +73,15 @@ class ChangelogModal extends Component {
}
}
if (change.link) {
html = [
...html,
<Link href={change.link} className="btn btn--clicky" button={true} key="link">
Read More
</Link>
]
}
if (change.major && change.major.length) {
html = [
...html,

View File

@ -1,43 +0,0 @@
import React, {Component} from 'react';
import Modal from '../base/Modal';
import ModalBody from '../base/ModalBody';
import ModalHeader from '../base/ModalHeader';
import ModalFooter from '../base/ModalFooter';
class ImportSummaryModal extends Component {
state = {
summary: {}
};
show ({summary}) {
this.modal.show();
this.setState({summary});
}
render () {
const {summary} = this.state;
return (
<Modal ref={m => this.modal = m}>
<ModalHeader>Import Summary</ModalHeader>
<ModalBody className="wide">
</ModalBody>
<ModalFooter>
<div className="margin-left faint italic txt-sm tall">{hint ? `* ${hint}` : ''}</div>
<div>
<button className="btn" onClick={() => this.modal.hide()}>
Cancel
</button>
<button className="btn" onClick={this._onSubmit.bind(this)}>
{submitName || 'Save'}
</button>
</div>
</ModalFooter>
</Modal>
)
}
}
ImportSummaryModal.propTypes = {};
export default ImportSummaryModal;

View File

@ -1,5 +1,6 @@
import React, {PropTypes} from 'react';
import {Dropdown, DropdownButton, DropdownItem, DropdownDivider} from '../base/dropdown';
import Link from '../base/Link';
const SettingsImportExport = ({
handleImport,
@ -11,25 +12,32 @@ const SettingsImportExport = ({
<p>
Import format will be automatically detected (<strong>Insomnia, Postman v2, HAR, Curl</strong>)
</p>
<Dropdown outline={true}>
<DropdownButton className="btn btn--clicky">
Export Data <i className="fa fa-caret-down"></i>
</DropdownButton>
<DropdownDivider name="Choose Export Type"/>
<DropdownItem onClick={e => handleExportWorkspace()}>
<i className="fa fa-home"></i>
Current Workspace
</DropdownItem>
<DropdownItem onClick={e => handleExportAll()}>
<i className="fa fa-empty"></i>
All Workspaces
</DropdownItem>
</Dropdown>
&nbsp;&nbsp;
<button className="btn btn--clicky" onClick={e => handleImport()}>
Import Data
</button>
<p className="italic faint pad-top">
<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={true}>
<DropdownButton className="btn btn--clicky">
Export Data <i className="fa fa-caret-down"></i>
</DropdownButton>
<DropdownDivider name="Choose Export Type"/>
<DropdownItem onClick={e => handleExportWorkspace()}>
<i className="fa fa-home"></i>
Current Workspace
</DropdownItem>
<DropdownItem onClick={e => handleExportAll()}>
<i className="fa fa-empty"></i>
All Workspaces
</DropdownItem>
</Dropdown>
&nbsp;&nbsp;
<button className="btn btn--clicky" onClick={e => handleImport()}>
Import Data
</button>
</div>
<p className="italic faint">
* Tip: You can also paste Curl commands into the URL bar
</p>
</div>

View File

@ -33,7 +33,7 @@ h3 {
font-size: @font-size-lg;
}
h1, h2, h3 {
p, h1, h2, h3 {
margin-bottom: @padding-sm;
margin-top: @padding-md;
}
@ -60,7 +60,6 @@ label {
}
p {
margin-bottom: 1.5em;
line-height: 1.7em;
}

View File

@ -122,7 +122,7 @@ export function importFile (workspaceId) {
const data = fs.readFileSync(path, 'utf8');
dispatch(loadStop());
const summary = await importRaw(workspace, data);
const {summary, source} = await importRaw(workspace, data);
let statements = Object.keys(summary).map(type => {
const count = summary[type].length;
@ -137,10 +137,10 @@ export function importFile (workspaceId) {
message = `You imported ${statements.join(', ')}!`;
}
showModal(AlertModal, {title: 'Import Succeeded', message});
trackEvent('Import', 'Success');
trackEvent('Import', source, 'Success');
} catch (e) {
showModal(AlertModal, {title: 'Import Failed', message: e + ''});
trackEvent('Import', 'Failure', e);
trackEvent('Import', source, 'Failure');
}
}
});

View File

@ -106,7 +106,7 @@
"electron-squirrel-startup": "^1.0.0",
"hkdf": "0.0.2",
"httpsnippet": "git@github.com:getinsomnia/httpsnippet.git#a3a2c0a0167fa844bf92df52a1442fa1d68a9053",
"insomnia-importers": "^0.4.0",
"insomnia-importers": "^1.0.0",
"json-lint": "^0.1.0",
"jsonpath-plus": "^0.15.0",
"mime-types": "^2.1.12",