insomnia/app/ui/components/modals/ChangelogModal.js

161 lines
4.0 KiB
JavaScript
Raw Normal View History

import React, {Component} from 'react';
2016-07-20 00:34:47 +00:00
import request from 'request';
import Modal from '../base/Modal';
import ModalBody from '../base/ModalBody';
import ModalHeader from '../base/ModalHeader';
import ModalFooter from '../base/ModalFooter';
import {CHANGELOG_URL} from '../../../backend/constants';
import {getAppVersion} from '../../../backend/appInfo';
2016-07-20 00:34:47 +00:00
class ChangelogModal extends Component {
2016-07-20 00:34:47 +00:00
constructor (props) {
super(props);
this.state = {
2016-07-21 22:26:51 +00:00
startVersion: getAppVersion(),
2016-07-20 00:34:47 +00:00
changelog: null
};
}
2016-07-21 16:33:35 +00:00
show (startVersion = null) {
this.modal.show();
2016-07-20 00:34:47 +00:00
2016-07-21 16:33:35 +00:00
if (startVersion) {
this.setState({startVersion});
}
}
componentDidMount () {
2016-07-20 00:34:47 +00:00
request.get(CHANGELOG_URL, (err, response) => {
if (err) {
console.warn('Failed to load changelog', err);
2016-07-20 00:34:47 +00:00
return;
}
if (response.statusCode !== 200) {
console.warn(
'Failed to fetch changelog',
response.statusCode,
response.body
);
return;
}
2016-07-20 00:34:47 +00:00
let changelog;
try {
changelog = JSON.parse(response.body);
} catch (e) {
console.error('Failed to parse changelog', e);
return;
}
2016-07-21 16:33:35 +00:00
this.setState({changelog});
2016-07-20 00:34:47 +00:00
});
}
shouldComponentUpdate (nextProps, nextState) {
return nextState !== this.state;
}
2016-07-20 00:34:47 +00:00
render () {
const {changelog, startVersion} = this.state;
let html;
if (!changelog) {
html = [
2016-07-20 18:35:08 +00:00
<div key="spinner" className="txt-lg">
2016-07-20 00:34:47 +00:00
<i className="fa fa-refresh fa-spin"></i>
</div>
];
} else {
html = [];
2016-07-21 16:33:35 +00:00
let startIndex = changelog.findIndex(c => c.version === startVersion);
if (startIndex < 0) {
startIndex = 0;
console.warn(`Failed to find changelog version for ${startVersion}`)
2016-07-21 16:33:35 +00:00
}
changelog.slice(startIndex).map((change, i) => {
2016-07-20 00:34:47 +00:00
html = [
...html,
2016-07-21 16:33:35 +00:00
<h1 key={`changes.${i}`}>v{change.version} Changes</h1>
2016-07-20 00:34:47 +00:00
];
if (change.summary) {
if (!Array.isArray(change.summary)) {
html = [
...html,
Sync Proof of Concept (#33) * Maybe working POC * Change to use remote url * Other URL too * Some logic * Got the push part working * Made some updates * Fix * Update * Add status code check * Stuff * Implemented new sync api * A bit more robust * Debounce changes * Change timeout * Some fixes * Remove .less * Better error handling * Fix base url * Support for created vs updated docs * Try silent * Silence removal too * Small fix after merge * Fix test * Stuff * Implement key generation algorithm * Tidy * stuff * A bunch of stuff for the new API * Integrated the session stuff * Stuff * Just started on encryption * Lots of updates to encryption * Finished createResourceGroup function * Full encryption/decryption working (I think) * Encrypt localstorage with sessionID * Some more * Some extra checks * Now uses separate DB. Still needs to be simplified a LOT * Fix deletion bug * Fixed unicode bug with encryption * Simplified and working * A bunch of polish * Some stuff * Removed some workspace meta properties * Migrated a few more meta properties * Small changes * Fix body scrolling and url cursor jumping * Removed duplication of webpack port * Remove workspaces reduces * Some small fixes * Added sync modal and opt-in setting * Good start to sync flow * Refactored modal footer css * Update sync status * Sync logger * A bit better logging * Fixed a bunch of sync-related bugs * Fixed signup form button * Gravatar component * Split sync modal into tabs * Tidying * Some more error handling * start sending 'user agent * Login/signup error handling * Use real UUIDs * Fixed tests * Remove unused function * Some extra checks * Moved cloud sync setting to about page * Some small changes * Some things
2016-10-21 17:20:36 +00:00
<p key={`summary.${i}`}
dangerouslySetInnerHTML={{__html: change.summary}}/>
2016-07-20 00:34:47 +00:00
]
} else {
html = [
...html,
Sync Proof of Concept (#33) * Maybe working POC * Change to use remote url * Other URL too * Some logic * Got the push part working * Made some updates * Fix * Update * Add status code check * Stuff * Implemented new sync api * A bit more robust * Debounce changes * Change timeout * Some fixes * Remove .less * Better error handling * Fix base url * Support for created vs updated docs * Try silent * Silence removal too * Small fix after merge * Fix test * Stuff * Implement key generation algorithm * Tidy * stuff * A bunch of stuff for the new API * Integrated the session stuff * Stuff * Just started on encryption * Lots of updates to encryption * Finished createResourceGroup function * Full encryption/decryption working (I think) * Encrypt localstorage with sessionID * Some more * Some extra checks * Now uses separate DB. Still needs to be simplified a LOT * Fix deletion bug * Fixed unicode bug with encryption * Simplified and working * A bunch of polish * Some stuff * Removed some workspace meta properties * Migrated a few more meta properties * Small changes * Fix body scrolling and url cursor jumping * Removed duplication of webpack port * Remove workspaces reduces * Some small fixes * Added sync modal and opt-in setting * Good start to sync flow * Refactored modal footer css * Update sync status * Sync logger * A bit better logging * Fixed a bunch of sync-related bugs * Fixed signup form button * Gravatar component * Split sync modal into tabs * Tidying * Some more error handling * start sending 'user agent * Login/signup error handling * Use real UUIDs * Fixed tests * Remove unused function * Some extra checks * Moved cloud sync setting to about page * Some small changes * Some things
2016-10-21 17:20:36 +00:00
<p key={`summary.${i}`}><strong
dangerouslySetInnerHTML={{__html: change.summary[0]}}/></p>,
...change.summary.slice(1).map(
Sync Proof of Concept (#33) * Maybe working POC * Change to use remote url * Other URL too * Some logic * Got the push part working * Made some updates * Fix * Update * Add status code check * Stuff * Implemented new sync api * A bit more robust * Debounce changes * Change timeout * Some fixes * Remove .less * Better error handling * Fix base url * Support for created vs updated docs * Try silent * Silence removal too * Small fix after merge * Fix test * Stuff * Implement key generation algorithm * Tidy * stuff * A bunch of stuff for the new API * Integrated the session stuff * Stuff * Just started on encryption * Lots of updates to encryption * Finished createResourceGroup function * Full encryption/decryption working (I think) * Encrypt localstorage with sessionID * Some more * Some extra checks * Now uses separate DB. Still needs to be simplified a LOT * Fix deletion bug * Fixed unicode bug with encryption * Simplified and working * A bunch of polish * Some stuff * Removed some workspace meta properties * Migrated a few more meta properties * Small changes * Fix body scrolling and url cursor jumping * Removed duplication of webpack port * Remove workspaces reduces * Some small fixes * Added sync modal and opt-in setting * Good start to sync flow * Refactored modal footer css * Update sync status * Sync logger * A bit better logging * Fixed a bunch of sync-related bugs * Fixed signup form button * Gravatar component * Split sync modal into tabs * Tidying * Some more error handling * start sending 'user agent * Login/signup error handling * Use real UUIDs * Fixed tests * Remove unused function * Some extra checks * Moved cloud sync setting to about page * Some small changes * Some things
2016-10-21 17:20:36 +00:00
(text, j) => <p key={`summary.${i}[${j}]`}
dangerouslySetInnerHTML={{__html: text}}/>
)
2016-07-20 00:34:47 +00:00
]
}
}
if (change.major && change.major.length) {
html = [
...html,
2016-07-21 16:33:35 +00:00
<h3 key={`major.${i}`}>Noteworthy</h3>,
<ul key={`major.${i}.list`}>
2016-07-20 18:35:08 +00:00
{change.major.map((text, i) => <li key={i}>{text}</li>)}
</ul>
2016-07-20 00:34:47 +00:00
];
}
if (change.fixes && change.fixes.length) {
html = [
...html,
2016-07-21 16:33:35 +00:00
<h3 key={`fixes.${i}`}>Fixes</h3>,
<ul key={`fixes.${i}.list`}>
{change.fixes.map((text, j) => <li key={j}>{text}</li>)}
2016-07-21 16:33:35 +00:00
</ul>
2016-07-20 00:34:47 +00:00
];
}
if (change.minor && change.minor.length) {
html = [
...html,
2016-07-21 16:33:35 +00:00
<h3 key={`minor.${i}`}>Minor Changes</h3>,
<ul key={`minor.${i}.list`}>
2016-07-20 18:35:08 +00:00
{change.minor.map((text, i) => <li key={i}>{text}</li>)}
2016-07-21 16:33:35 +00:00
</ul>
2016-07-20 00:34:47 +00:00
];
}
html = [
...html,
2016-07-21 16:33:35 +00:00
<hr key={`hr.${i}`}/>
2016-07-20 00:34:47 +00:00
]
});
}
return (
<Modal ref={m => this.modal = m} {...this.props}>
2016-07-20 00:34:47 +00:00
<ModalHeader>Insomnia Changelog</ModalHeader>
<ModalBody className="pad changelog">
{html}
</ModalBody>
Sync Proof of Concept (#33) * Maybe working POC * Change to use remote url * Other URL too * Some logic * Got the push part working * Made some updates * Fix * Update * Add status code check * Stuff * Implemented new sync api * A bit more robust * Debounce changes * Change timeout * Some fixes * Remove .less * Better error handling * Fix base url * Support for created vs updated docs * Try silent * Silence removal too * Small fix after merge * Fix test * Stuff * Implement key generation algorithm * Tidy * stuff * A bunch of stuff for the new API * Integrated the session stuff * Stuff * Just started on encryption * Lots of updates to encryption * Finished createResourceGroup function * Full encryption/decryption working (I think) * Encrypt localstorage with sessionID * Some more * Some extra checks * Now uses separate DB. Still needs to be simplified a LOT * Fix deletion bug * Fixed unicode bug with encryption * Simplified and working * A bunch of polish * Some stuff * Removed some workspace meta properties * Migrated a few more meta properties * Small changes * Fix body scrolling and url cursor jumping * Removed duplication of webpack port * Remove workspaces reduces * Some small fixes * Added sync modal and opt-in setting * Good start to sync flow * Refactored modal footer css * Update sync status * Sync logger * A bit better logging * Fixed a bunch of sync-related bugs * Fixed signup form button * Gravatar component * Split sync modal into tabs * Tidying * Some more error handling * start sending 'user agent * Login/signup error handling * Use real UUIDs * Fixed tests * Remove unused function * Some extra checks * Moved cloud sync setting to about page * Some small changes * Some things
2016-10-21 17:20:36 +00:00
<ModalFooter>
<button className="btn" onClick={e => this.modal.hide()}>
Close
</button>
2016-07-20 00:34:47 +00:00
</ModalFooter>
</Modal>
);
}
}
ChangelogModal.propTypes = {};
export default ChangelogModal;