From e752f81ec7a4ecb013987c48358f0787aa3073db Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Wed, 30 Nov 2016 16:02:35 -0800 Subject: [PATCH] Some cleanup --- app/common/constants.js | 2 +- app/common/import.js | 13 ++++-- app/package.json | 2 +- app/ui/components/modals/ChangelogModal.js | 10 ++++ .../components/modals/ImportSummaryModal.js | 43 ----------------- .../settings/SettingsImportExport.js | 46 +++++++++++-------- app/ui/css/layout/base.less | 3 +- app/ui/redux/modules/global.js | 6 +-- package.json | 2 +- 9 files changed, 53 insertions(+), 74 deletions(-) delete mode 100644 app/ui/components/modals/ImportSummaryModal.js diff --git a/app/common/constants.js b/app/common/constants.js index 9b5eaa2c6..f7e82d9d9 100644 --- a/app/common/constants.js +++ b/app/common/constants.js @@ -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; diff --git a/app/common/import.js b/app/common/import.js index 7664318fc..9cb67a234 100644 --- a/app/common/import.js +++ b/app/common/import.js @@ -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) { diff --git a/app/package.json b/app/package.json index 33f2c2810..896718591 100644 --- a/app/package.json +++ b/app/package.json @@ -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", diff --git a/app/ui/components/modals/ChangelogModal.js b/app/ui/components/modals/ChangelogModal.js index 2800826d9..17920f4e8 100644 --- a/app/ui/components/modals/ChangelogModal.js +++ b/app/ui/components/modals/ChangelogModal.js @@ -55,6 +55,7 @@ class ChangelogModal extends Component { ...html,

v{change.version} Changes

]; + if (change.summary) { if (!Array.isArray(change.summary)) { html = [ @@ -72,6 +73,15 @@ class ChangelogModal extends Component { } } + if (change.link) { + html = [ + ...html, + + Read More + + ] + } + if (change.major && change.major.length) { html = [ ...html, diff --git a/app/ui/components/modals/ImportSummaryModal.js b/app/ui/components/modals/ImportSummaryModal.js deleted file mode 100644 index 3ba83e93e..000000000 --- a/app/ui/components/modals/ImportSummaryModal.js +++ /dev/null @@ -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 ( - this.modal = m}> - Import Summary - - - -
{hint ? `* ${hint}` : ''}
-
- - -
-
-
- ) - } -} - -ImportSummaryModal.propTypes = {}; - -export default ImportSummaryModal; diff --git a/app/ui/components/settings/SettingsImportExport.js b/app/ui/components/settings/SettingsImportExport.js index 469972a66..f34121e8a 100644 --- a/app/ui/components/settings/SettingsImportExport.js +++ b/app/ui/components/settings/SettingsImportExport.js @@ -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 = ({

Import format will be automatically detected (Insomnia, Postman v2, HAR, Curl)

- - - Export Data - - - handleExportWorkspace()}> - - Current Workspace - - handleExportAll()}> - - All Workspaces - - -    - -

+

+ Don't see your format here? + {" "} + Add Your Own. +

+
+ + + Export Data + + + handleExportWorkspace()}> + + Current Workspace + + handleExportAll()}> + + All Workspaces + + +    + +
+

* Tip: You can also paste Curl commands into the URL bar

diff --git a/app/ui/css/layout/base.less b/app/ui/css/layout/base.less index d9d99c59e..e41a26833 100644 --- a/app/ui/css/layout/base.less +++ b/app/ui/css/layout/base.less @@ -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; } diff --git a/app/ui/redux/modules/global.js b/app/ui/redux/modules/global.js index a0d4496de..bfa5516f6 100644 --- a/app/ui/redux/modules/global.js +++ b/app/ui/redux/modules/global.js @@ -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'); } } }); diff --git a/package.json b/package.json index df88585de..251c70567 100644 --- a/package.json +++ b/package.json @@ -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",