-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: describe altered nodes and prompt for summary message before publishing #683
Changes from 16 commits
ef84b40
779ff3c
e2257c3
1c7bed7
1d039d0
5165b3f
c60dc0b
9ac1acd
7ba1731
7b158f0
8bc097e
6c6006b
91bcb18
3beb9d3
0d341e8
5500099
d505c75
e435886
a1c87ac
1127565
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ import axios from "axios"; | |
import { getCookie } from "lib/cookie"; | ||
import { client } from "lib/graphql"; | ||
import debounce from "lodash/debounce"; | ||
import isEmpty from "lodash/isEmpty"; | ||
import omitBy from "lodash/omitBy"; | ||
import type { FlowSettings, TextContent } from "types"; | ||
import type { GetState, SetState } from "zustand/vanilla"; | ||
|
||
|
@@ -56,6 +58,7 @@ export interface EditorStore extends Store.Store { | |
copyNode: (id: Store.nodeId) => void; | ||
createFlow: (teamId: any, newSlug: any) => Promise<string>; | ||
deleteFlow: (teamId: number, flowSlug: string) => Promise<object>; | ||
diffFlow: (flowId: string) => Promise<any>; | ||
getFlows: (teamId: number) => Promise<any>; | ||
isClone: (id: Store.nodeId) => boolean; | ||
lastPublished: (flowId: string) => Promise<string>; | ||
|
@@ -68,7 +71,7 @@ export interface EditorStore extends Store.Store { | |
toParent?: Store.nodeId | ||
) => void; | ||
pasteNode: (toParent: Store.nodeId, toBefore: Store.nodeId) => void; | ||
publishFlow: (flowId: string) => Promise<any>; | ||
publishFlow: (flowId: string, summary?: string) => Promise<any>; | ||
removeNode: (id: Store.nodeId, parent: Store.nodeId) => void; | ||
updateFlowSettings: ( | ||
teamSlug: string, | ||
|
@@ -211,6 +214,18 @@ export const editorStore = ( | |
return response; | ||
}, | ||
|
||
diffFlow(flowId: string) { | ||
const token = getCookie("jwt"); | ||
|
||
return axios({ | ||
url: `${process.env.REACT_APP_API_URL}/flows/${flowId}/diff`, | ||
method: "POST", | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}); | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tiny nit and maybe a nit but idk -
I must admit I can sometimes get a bit lost in considering implications of async stuff though. I was considering adding something like https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-floating-promises.md to catch little edge cases like this. I think maybe the quickest fix here would be to (a) ignore this for now 😅 (b) handle the catch in the caller. I'll be very happy to go along with whatever you think makes sense! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah good thinking, this stuff is indeed tedious & tricky - i picked option b and added a try/catch to the caller to log any errors! |
||
|
||
getFlows: async (teamId) => { | ||
client.cache.reset(); | ||
const { data } = await client.query({ | ||
|
@@ -322,11 +337,19 @@ export const editorStore = ( | |
} | ||
}, | ||
|
||
publishFlow(flowId: string) { | ||
publishFlow(flowId: string, summary?: string) { | ||
const token = getCookie("jwt"); | ||
|
||
const urlWithParams = (url: string, params: any) => | ||
[url, new URLSearchParams(omitBy(params, isEmpty))] | ||
.filter(Boolean) | ||
.join("?"); | ||
|
||
return axios({ | ||
url: `${process.env.REACT_APP_API_URL}/flows/${flowId}/publish`, | ||
url: urlWithParams( | ||
`${process.env.REACT_APP_API_URL}/flows/${flowId}/publish`, | ||
{ summary } | ||
), | ||
method: "POST", | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE "public"."published_flows" DROP COLUMN "summary"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE "public"."published_flows" ADD COLUMN "summary" text NULL; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. while I'm looking at sql, maybe we need an index on published_flows.flow_id? 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added a hash index as I think we'll always do equality checks against flow_id ! also motivation to upgrade hasura: getting to create/manage indexes in the console rather than via manual sql command migrations!! hasura/graphql-engine#2219 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah nice, I think we'll be able to upgrade this week! According to them, the upgrade should just involve changing the version number in the dockerfile. We'll see... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, could this be changed to use the next() callback please
planx-new/api.planx.uk/server.js
Lines 36 to 39 in 7d80145
I'm still not exactly completely happy with the api error handling but if everything goes to the same function in the chain it'll be easier to refactor in future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep thanks for spotting these lingering cases - all updated to use next() now!