Upgrade flow

This commit is contained in:
Gregory Schier 2018-03-29 13:59:32 -04:00
parent 2cc5c541f2
commit c9402c58d0
17 changed files with 1256 additions and 157 deletions

View File

@ -278,6 +278,6 @@ async function getDocWithDescendants (
const docs = await db.withDescendants(parentDoc);
return docs.filter(d => (
// Don't include if private, except if we want to
!d.isPrivate || includePrivateDocs
!(d: any).isPrivate || includePrivateDocs
));
}

View File

@ -118,7 +118,7 @@ export function removeVowels (str: string): string {
}
export function keyedDebounce (callback: Function, millis: number = DEBOUNCE_MILLIS): Function {
let timeout = null;
let timeout;
let results = {};
return function (key, ...args) {
@ -289,11 +289,11 @@ export function getUserLanguage (): string {
export async function waitForStreamToFinish (s: Readable | Writable): Promise<void> {
return new Promise(resolve => {
if (s._readableState && s._readableState.finished) {
if ((s: any)._readableState && (s: any)._readableState.finished) {
return resolve();
}
if (s._writableState && s._writableState.finished) {
if ((s: any)._writableState && (s: any)._writableState.finished) {
return resolve();
}

View File

@ -37,8 +37,9 @@ export async function buildRenderContext (
}
for (const doc of (ancestors || []).reverse()) {
if (typeof doc.environment === 'object' && doc.environment !== null) {
envObjects.push(doc.environment);
const environment = (doc: any).environment;
if (typeof environment === 'object' && environment !== null) {
envObjects.push(environment);
}
}

View File

@ -5,7 +5,12 @@ export type NunjucksParsedTagArg = {
value: string | number | boolean,
defaultValue?: string | number | boolean,
forceVariable?: boolean,
quotedBy?: '"' | "'"
placeholder?: string,
help?: string,
displayName?: string,
quotedBy?: '"' | "'",
validate?: (value: any) => string,
hide?: (Array<NunjucksParsedTagArg>) => boolean
};
export type NunjucksParsedTag = {

View File

@ -71,6 +71,7 @@ class AuthWrapper extends PureComponent {
handleRender={handleRender}
handleGetRenderContext={handleGetRenderContext}
nunjucksPowerUserMode={nunjucksPowerUserMode}
showPasswords={showPasswords}
onChange={onChange}
/>
);

View File

@ -15,6 +15,7 @@ type Props = {
handleRender: Function,
handleGetRenderContext: Function,
nunjucksPowerUserMode: boolean,
showPasswords: boolean,
onChange: Function,
request: Request
};

View File

@ -32,8 +32,8 @@ type State = {
@autobind
class CookieModifyModal extends React.PureComponent<Props, State> {
modal: Modal | null;
_rawTimeout: number | null;
_cookieUpdateTimeout: number | null;
_rawTimeout: TimeoutID;
_cookieUpdateTimeout: TimeoutID;
constructor (props: any) {
super(props);
@ -42,9 +42,6 @@ class CookieModifyModal extends React.PureComponent<Props, State> {
cookie: null,
rawValue: ''
};
this._rawTimeout = null;
this._cookieUpdateTimeout = null;
}
_setModalRef (n: Modal | null) {

View File

@ -7,6 +7,7 @@ import Modal from '../base/modal';
import ModalHeader from '../base/modal-header';
import ModalBody from '../base/modal-body';
import MethodTag from '../tags/method-tag';
import type {BaseModel} from '../../../models';
import * as models from '../../../models';
import {fuzzyMatchAll} from '../../../common/misc';
import type {RequestGroup} from '../../../models/request-group';
@ -146,12 +147,12 @@ class RequestSwitcherModal extends React.PureComponent<Props, State> {
}
/** Return array of path segments for given request or folder */
_groupOf (requestOrRequestGroup: Request | RequestGroup): Array<string> {
_groupOf (requestOrRequestGroup: BaseModel): Array<string> {
const {workspaceChildren} = this.props;
const requestGroups = workspaceChildren.filter(d => d.type === models.requestGroup.type);
const matchedGroups = requestGroups.filter(g => g._id === requestOrRequestGroup.parentId);
const currentGroupName = requestOrRequestGroup.type === models.requestGroup.type
? `${requestOrRequestGroup.name}`
? `${(requestOrRequestGroup: any).name}`
: '';
// It's the final parent
@ -235,8 +236,10 @@ class RequestSwitcherModal extends React.PureComponent<Props, State> {
this.setState({
activeIndex,
searchString,
matchedRequests,
matchedWorkspaces
matchedWorkspaces,
// Ugh. Force cast to make Flow happy
matchedRequests: ((matchedRequests: any): Array<Request>)
});
}
@ -316,8 +319,8 @@ class RequestSwitcherModal extends React.PureComponent<Props, State> {
<i className="fa fa-folder-o"/>
</div>
)}
<MethodTag method={r.method}/>
<strong>{r.name}</strong>
<MethodTag method={(r: any).method}/>
<strong>{(r: any).name}</strong>
</Button>
</li>
);
@ -340,7 +343,7 @@ class RequestSwitcherModal extends React.PureComponent<Props, State> {
<Button onClick={this._activateWorkspace} value={w} className={buttonClasses}>
<i className="fa fa-random"/>
&nbsp;&nbsp;&nbsp;
Switch to <strong>{w.name}</strong>
Switch to <strong>{(w: any).name}</strong>
</Button>
</li>
);

View File

@ -62,7 +62,7 @@ type Props = {
@autobind
class RequestPane extends React.PureComponent<Props> {
_handleUpdateRequestUrlTimeout: number;
_handleUpdateRequestUrlTimeout: TimeoutID;
_handleEditDescriptionAdd () {
this._handleEditDescription(true);

View File

@ -19,7 +19,7 @@ class General extends React.PureComponent<Props> {
const el = e.currentTarget;
let value = el.type === 'checkbox' ? el.checked : el.value;
if (e.target.type === 'number') {
if (e.currentTarget.type === 'number') {
value = parseInt(value, 10);
}

View File

@ -10,7 +10,8 @@ import type {Request} from '../../../models/request';
type Child = {
doc: Request | RequestGroup,
children: Array<Child>,
collapsed: boolean
collapsed: boolean,
hidden: boolean
};
type Props = {

View File

@ -421,17 +421,17 @@ class TagEditor extends React.PureComponent<Props, State> {
return (
<select value={id} onChange={this._handleChange}>
<option value="n/a">-- Select Item --</option>
{docs.map(doc => {
{docs.map((doc: any) => {
let namePrefix = null;
// Show paren't folder with name if it's a request
if (doc.type === models.request.type) {
const requests = allDocs[models.request.type] || [];
const request = requests.find(r => r._id === doc._id);
const request: any = requests.find(r => r._id === doc._id);
const method = request && typeof request.method === 'string' ? request.method : 'GET';
const parentId = request ? request.parentId : 'n/a';
const requestGroups = allDocs[models.requestGroup.type] || [];
const requestGroup = requestGroups.find(rg => rg._id === parentId);
const requestGroup: any = requestGroups.find(rg => rg._id === parentId);
const requestGroupName = requestGroup && typeof requestGroup.name === 'string'
? requestGroup.name
: '';

View File

@ -20,7 +20,7 @@ type State = {
@autobind
class Tooltip extends React.PureComponent<Props, State> {
_showTimeout: number;
_showTimeout: TimeoutID;
// TODO: Figure out what type these should be
_tooltip: ?HTMLDivElement;

View File

@ -1,9 +1,14 @@
declare module 'insomnia-importers' {
declare module.exports: {
convert: (data: string) => {
convert: (data: string) => Promise<{
type: {
id: string,
name: string,
description: string
},
data: {
resources: Array<Object>
}
}
}>
}
}

View File

@ -72,6 +72,9 @@ declare class Curl {
debug: {
SSL_DATA_IN: string,
SSL_DATA_OUT: string,
DATA_OUT: string,
DATA_IN: string,
TEXT: string
}
};

File diff suppressed because it is too large Load Diff

View File

@ -184,8 +184,7 @@
"eslint-plugin-react": "^7.4.0",
"eslint-plugin-standard": "^2.3.1",
"file-loader": "^1.1.5",
"flow": "^0.2.3",
"flow-bin": "^0.58.0",
"flow-bin": "^0.69.0",
"less": "^2.7.2",
"less-loader": "^4.0.5",
"ncp": "^2.0.0",