Skip to content

Commit

Permalink
V0.4.0 (#30)
Browse files Browse the repository at this point in the history
* disable version update dialog on dev

* allow setting different expected msg for failing (300 <=) requests [#22]

* drag and drop to reorder requests within the collection #23

* bump to 0.4.0, with minor lint fixes

* update README.md

Co-authored-by: Inchan Hwang <ih33@duke.edu>
  • Loading branch information
spluxx and Inchan Hwang committed Jul 27, 2020
1 parent 2876a99 commit 19854f0
Show file tree
Hide file tree
Showing 15 changed files with 240 additions and 40 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,25 @@ A [Postman](https://www.postman.com/)-like API client for [protobuf](https://dev
4. **As of version 0.3.0, you can also import / export collections as JSON**

- When importing a collection, all the proto definitions / path to .proto files are also imported. Hence, it's recommended to fix the paths to keep the proto definitions up-to-date.
- Note that it's not compatible with Postman collections.

5. **That's it for the current version. Enjoy and leave a star if you like it !**
5. **As of version 0.4.0, you can also reorder requests / set different expected messages for success(2XX) and failures(others)**

6. **That's it for the current version. Enjoy and leave a star if you like it !**

## Installation

### Mac

[Protoman-0.3.4.dmg](https://github.com/spluxx/Protoman/releases/download/v0.3.4/Protoman-0.3.4.dmg)
[Protoman-0.4.0.dmg](https://github.com/spluxx/Protoman/releases/download/v0.4.0/Protoman-0.4.0.dmg)

### Windows

[Protoman Setup 0.3.4.exe](https://github.com/spluxx/Protoman/releases/download/v0.3.4/Protoman.Setup.0.3.4.exe) - Unlike mac, I don't currently own a license to sign the app. So it might give you some security warnings!
[Protoman Setup 0.4.0.exe](https://github.com/spluxx/Protoman/releases/download/v0.4.0/Protoman.Setup.0.4.0.exe) - Unlike mac, I don't currently own a license to sign the app. So it might give you some security warnings!

### Linux

[Protoman-0.3.4.AppImage](https://github.com/spluxx/Protoman/releases/download/v0.3.4/Protoman-0.3.4.AppImage)
[Protoman-0.4.0.AppImage](https://github.com/spluxx/Protoman/releases/download/v0.4.0/Protoman-0.4.0.AppImage)

As a fallback, you can clone the repo and run npm install && npm run build to build, and npm run start to launch the app. Or, you can actually find configurations on [electron builder](https://www.electron.build/) to get the right distribution version yourself!

Expand Down
53 changes: 52 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Protoman",
"version": "0.3.4",
"version": "0.4.0",
"description": "Basic Postman clone with protobuf functionalities",
"author": "Inchan Hwang, Louis Lee",
"license": "MIT",
Expand Down Expand Up @@ -67,6 +67,7 @@
"node-fetch": "^2.6.0",
"protobufjs": "^6.8.8",
"react": "^16.12.0",
"react-beautiful-dnd": "^13.0.0",
"react-dom": "^16.12.0",
"react-redux": "^7.1.3",
"react-tooltip": "^4.1.0",
Expand All @@ -80,6 +81,7 @@
"@types/jest": "^25.1.4",
"@types/node-fetch": "^2.5.5",
"@types/react": "^16.9.19",
"@types/react-beautiful-dnd": "^13.0.0",
"@types/react-dom": "^16.9.5",
"@types/react-redux": "^7.1.7",
"@types/react-tooltip": "^3.11.0",
Expand Down
9 changes: 7 additions & 2 deletions src/core/http_client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function translateResponse(
const responseHeaders = unconvertHeaders(response.headers);
const saidContentType = responseHeaders.find(([name]) => name === 'content-type')?.[1];

const { expectedProtobufMsg } = request;
const { expectedProtobufMsg, expectedProtobufMsgOnError } = request;

let responseBodyType: ResponseBodyType = 'unknown';
let responseBodyValue: ResponseBodyValue = undefined;
Expand All @@ -50,7 +50,12 @@ async function translateResponse(
responseBodyType = 'html';
responseBodyValue = toStr(buf);
} else if (expectedProtobufMsg) {
const res = await deserializeProtobuf(buf, expectedProtobufMsg, protoCtx);
let msgToUse = expectedProtobufMsg;
if (!response.ok && expectedProtobufMsgOnError) {
msgToUse = expectedProtobufMsgOnError;
}

const res = await deserializeProtobuf(buf, msgToUse, protoCtx);
switch (res.tag) {
case 'invalid':
if (res.value) {
Expand Down
1 change: 1 addition & 0 deletions src/core/http_client/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export interface RequestDescriptor {
readonly headers: ReadonlyArray<[string, string]>;
readonly body: Uint8Array | undefined;
readonly expectedProtobufMsg: string | undefined;
readonly expectedProtobufMsgOnError: string | undefined;
}
2 changes: 2 additions & 0 deletions src/main/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const ICON_URL = 'https://raw.githubusercontent.com/spluxx/Protoman/master/asset

// couldn't get https://github.com/pd4d10/electron-update-notification to work... :/
export async function checkUpdateAndNotify(window: BrowserWindow): Promise<void> {
if (process.env.NODE_ENV === 'development') return;

try {
const res = await fetch(RELEASE_URL);
const json = await res.json();
Expand Down
23 changes: 22 additions & 1 deletion src/renderer/components/Collection/CollectionActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ type CloseFM = {

const CLOSE_FM = 'CLOSE_FM';

type ReorderFlow = {
type: 'REORDER_FLOW';
collectionName: string;
src: number;
dst: number;
};

const REORDER_FLOW = 'REORDER_FLOW';

export const CollectionActionTypes = [
CREATE_COLLECTION,
CHANGE_COLLECTION_NAME,
Expand All @@ -74,7 +83,9 @@ export const CollectionActionTypes = [
DELETE_FLOW,
OPEN_FM,
CLOSE_FM,
REORDER_FLOW,
];

export type CollectionAction =
| CreateCollection
| ChangeCollectionName
Expand All @@ -84,7 +95,8 @@ export type CollectionAction =
| SelectFlow
| DeleteFlow
| OpenFM
| CloseFM;
| CloseFM
| ReorderFlow;

export function createCollection(collectionName: string): CreateCollection {
return {
Expand Down Expand Up @@ -151,3 +163,12 @@ export function closeFM(): CloseFM {
type: CLOSE_FM,
};
}

export function reorderFlow(collectionName: string, src: number, dst: number): ReorderFlow {
return {
type: REORDER_FLOW,
collectionName,
src,
dst,
};
}
8 changes: 8 additions & 0 deletions src/renderer/components/Collection/CollectionReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ export default function CollectionReducer(s: AppState, action: AnyAction): AppSt
return produce(s, draft => {
draft.fmOpenCollection = undefined;
});
case 'REORDER_FLOW':
return produce(s, draft => {
const flows = getByKey(draft.collections, a.collectionName)?.flows;
if (!flows) return draft;

const [rm] = flows.splice(a.src, 1);
flows.splice(a.dst, 0, rm);
});
default:
return s;
}
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/Collection/CollectionSider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Layout, Collapse, Modal, Button, Row } from 'antd';
import { Layout, Collapse, Modal, Button } from 'antd';
import styled from 'styled-components';
import CollectionCell from './CollectionCell';
import { useSelector, useDispatch } from 'react-redux';
Expand Down Expand Up @@ -94,7 +94,7 @@ const CollectionSider: React.FunctionComponent<{}> = ({}) => {
{collections.map(([name]) => {
const header = <CollectionCell collectionName={name} />;
return (
<Panel key={name} header={header} style={{ paddingBottom: 4 }}>
<Panel key={name} header={header}>
<FlowList collectionName={name} />
</Panel>
);
Expand Down
Loading

0 comments on commit 19854f0

Please sign in to comment.