Skip to content

Commit 962e876

Browse files
committed
update flow config upon onClose or onSubmit
1 parent b1e4f6b commit 962e876

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/backend/src/graphql/mutations/update-flow-config.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type Params = {
1111
id: string
1212
notificationFrequency: IFlowErrorConfig['notificationFrequency']
1313
hasLoadedOnce: IFlowDemoConfig['hasLoadedOnce']
14+
showSurvey: boolean
1415
}
1516
}
1617

@@ -38,11 +39,15 @@ const updateFlowConfig = async (
3839
}
3940

4041
// TODO (mal): remove demo config
41-
if (params.input.hasLoadedOnce !== undefined) {
42-
newConfig.demoConfig = {
43-
...newConfig.demoConfig, // If ever undefined (should never be), it gets set to an empty object first
44-
hasLoadedOnce: params.input.hasLoadedOnce,
45-
}
42+
// if (params.input.hasLoadedOnce !== undefined) {
43+
// newConfig.demoConfig = {
44+
// ...newConfig.demoConfig, // If ever undefined (should never be), it gets set to an empty object first
45+
// hasLoadedOnce: params.input.hasLoadedOnce,
46+
// }
47+
// }
48+
49+
if (params.input.showSurvey !== undefined) {
50+
newConfig.showSurvey = params.input.showSurvey
4651
}
4752

4853
return await flow.$query().patchAndFetch({

packages/backend/src/graphql/schema.graphql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type Query {
4343
getTableConnections(tableIds: [String!]!): JSONObject
4444
getTables(limit: Int!, offset: Int!, name: String): PaginatedTables!
4545
# Tiles rows
46-
getAllRows(tableId: String!, stringifiedCursor: String): GetTableRowsResult!
46+
getAllRows(tableId: String!, stringifiedCursor: String): GetTableRowsResult!
4747
getCurrentUser: User
4848
healthcheck: AppHealth
4949
getPlumberStats: Stats
@@ -450,6 +450,7 @@ input UpdateFlowConfigInput {
450450
id: String!
451451
notificationFrequency: NotificationFrequency
452452
hasLoadedOnce: Boolean
453+
showSurvey: Boolean
453454
}
454455

455456
input ExecuteFlowInput {

packages/frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"dedent": "1.5.1",
4242
"escape-html": "1.0.3",
4343
"file-saver": "2.0.5",
44-
"lens-widget": "1.35.0",
44+
"lens-widget": "1.36.0",
4545
"lodash": "^4.17.21",
4646
"lodash.get": "4.4.2",
4747
"lottie-web": "5.12.2",

packages/frontend/src/components/Editor/index.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
StepExecutionsToIncludeProvider,
2424
} from '@/contexts/StepExecutionsToInclude'
2525
import { CREATE_STEP } from '@/graphql/mutations/create-step'
26+
import { UPDATE_FLOW_CONFIG } from '@/graphql/mutations/update-flow-config'
2627
import { UPDATE_STEP } from '@/graphql/mutations/update-step'
2728
import { GET_APPS } from '@/graphql/queries/get-apps'
2829
import { GET_FLOW } from '@/graphql/queries/get-flow'
@@ -103,6 +104,13 @@ export default function Editor(props: EditorProps): React.ReactElement {
103104
const showSurvey = flow.active && flow.config?.showSurvey
104105
const { currentUser } = useAuthentication()
105106

107+
const [updateFlowConfig] = useMutation(UPDATE_FLOW_CONFIG)
108+
const onFlowConfigUpdate = useCallback(async () => {
109+
await updateFlowConfig({
110+
variables: { input: { id: flow.id, showSurvey: false } },
111+
})
112+
}, [updateFlowConfig, flow.id])
113+
106114
const steps = useMemo(
107115
// Populate each step's flowId so that IStep isn't LYING about flowId being
108116
// non-undefined. We do it here instead of fetching in GraphQL since all
@@ -310,6 +318,8 @@ export default function Editor(props: EditorProps): React.ReactElement {
310318
`UserEmail: ${currentUser?.email}`,
311319
...(appConfig.env !== 'prod' ? [`Env: ${appConfig.env}`] : []),
312320
]}
321+
onSubmit={onFlowConfigUpdate}
322+
onClose={onFlowConfigUpdate}
313323
/>
314324
)}
315325
</Flex>

0 commit comments

Comments
 (0)