Skip to content

Commit

Permalink
Merge pull request #6688 from opengovsg/release_v6.75.0
Browse files Browse the repository at this point in the history
* feat: % rollout of new storage submission endpoint (#6665)

* feat: use new endpoint for storage submissions

* fix: answerArray fields hidden error

- response.answerArray did not return visibility true

* feat: growthbook on frontend

* feat: script to set encryptionBoundaryShift to true

* feat: default `encryptionBoundaryShift` to true

* fix: form server model backend tests

- set encryptionBoundaryShift flag for encrypted forms

* refactor: setBody -> additionalBodyFields naming

* refactor: rename ...FormV2Args -> ...FormClearArgs

* fix: tighter typing for answerArray

* refactor: create FormDataArgs types

* feat: fetch fallback for new storage submission

- refactor: use 'clear' instead of 'V2'

* fix: add missing dependencies to handleSubmitForm

* feat: use db env feature flags for BE

* fix: missing args with env feature flags

* fix: admin-form.controller tests

* fix: IncomingEncryptSubmission tests

* feat: script to unset encryptionBoundaryShift flag

* feat: rm form-level encryptionBoundaryShift flags

* fix: use docker images from edge/main instead

* fix: use dl-cdn rather than nl

- nl.alpinelinux.org mirror is outdated

* fix: typo for dl-cdn

* fix: testing instead of main url

- font-wqy-zenhei@edge only available on edge/testing (ref: https://repology.org/project/fonts:wqy-zenhei/versions)

* fix: update alpinelinux mirror for dev docker

* fix: add growthbook to connect src CSP

* fix: add more growthbook paths to csp

* fix: helmet tests

* feat: growthbook reverse proxy api host

* feat: use appropriate domains for proxy

* revert: changes to add growthbook to CSP

* docs: ENCRYPTION_BOUNDARY_SHIFT_ENCRYPTION_VERSION

* refactor: isDev for clarity of apiHost

* refactor: use constants for link and path

- refactor: rm unused formsgSdkMode

* feat: unset encryptionBoundaryShift only if present

* refactor: mv feature loading to AppRouter

* feat: payment security account email check (#6604)

* test: add cases for failed whitelisting domain

* feat: add agency domain check when connecting stripe account

* feat: add feature flag to allow release in dark

* test: add cases to test for disabled fetaure flag

* chore: update comments for clarity

* chore: remove unused imports

* refactor: use guard clause for flag checks

* refcator: rename defaultvalue to fallback as its is applied during errors

* feat: add be to redirect with query params when domain check fails

* feat: add fe to show alert when non-whitelisted domain error is returned

* chore: fix typo on whitelisting

* Update src/app/modules/payments/__tests__/stripe.service.spec.ts

Co-authored-by: Lin Huiqing <[email protected]>

---------

Co-authored-by: Lin Huiqing <[email protected]>

* fix: Find latest successful payment query to sort by completed payment date and constraint query to last 30 days (#6615)

* fix: change query sort and add date constraint

* test: add cases to test for query sort and date constraint

* fix: standardise to use moment

* chore: bump version to v6.75.0

* fix: payments params in new storage submission endpoint (#6689)

* fix: joi validation for new storage endpoint

* fix: pass payments params for new endpoint

* chore: bump version to 6.75.1

---------

Co-authored-by: Ken Lee Shu Ming <[email protected]>
Co-authored-by: Bryce Goh <[email protected]>
  • Loading branch information
3 people authored Sep 4, 2023
2 parents bcd292f + af06ba3 commit 34d6bba
Show file tree
Hide file tree
Showing 47 changed files with 926 additions and 116 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,27 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v6.75.1](https://github.com/opengovsg/FormSG/compare/v6.75.0...v6.75.1)

- fix: payments params in new storage submission endpoint [`#6689`](https://github.com/opengovsg/FormSG/pull/6689)

#### [v6.75.0](https://github.com/opengovsg/FormSG/compare/v6.74.1...v6.75.0)

> 4 September 2023

- fix: Find latest successful payment query to sort by completed payment date and constraint query to last 30 days [`#6615`](https://github.com/opengovsg/FormSG/pull/6615)
- feat: payment security account email check [`#6604`](https://github.com/opengovsg/FormSG/pull/6604)
- feat: % rollout of new storage submission endpoint [`#6665`](https://github.com/opengovsg/FormSG/pull/6665)
- build: merge v6.74.1 into develop [`#6683`](https://github.com/opengovsg/FormSG/pull/6683)
- build: release v6.74.1 [`#6682`](https://github.com/opengovsg/FormSG/pull/6682)
- chore: bump version to v6.75.0 [`6ba6155`](https://github.com/opengovsg/FormSG/commit/6ba61554e3f9c83b27eb1aea8df5ddd241afe852)

#### [v6.74.1](https://github.com/opengovsg/FormSG/compare/v6.74.0...v6.74.1)

> 31 August 2023

- fix: payment quantity modal input inconsistencies [`#6681`](https://github.com/opengovsg/FormSG/pull/6681)
- chore: bump version to 6.74.1 [`1c96e9e`](https://github.com/opengovsg/FormSG/commit/1c96e9ea74c772e8cd45bc6877dfc8b1e41e4832)

#### [v6.74.0](https://github.com/opengovsg/FormSG/compare/v6.73.0...v6.74.0)

Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ services:
- GOGOV_API_KEY
# Bearer token API key format
- API_KEY_VERSION=v1
# env vars for growthbook
- GROWTHBOOK_CLIENT_KEY

mockpass:
build: https://github.com/opengovsg/mockpass.git#v4.0.4
Expand Down
59 changes: 57 additions & 2 deletions frontend/package-lock.json

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

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "form-frontend",
"version": "6.74.0",
"version": "6.75.0",
"homepage": ".",
"private": true,
"dependencies": {
Expand All @@ -10,6 +10,7 @@
"@emotion/react": "^11.7.0",
"@emotion/styled": "^11.6.0",
"@floating-ui/react-dom-interactions": "^0.9.3",
"@growthbook/growthbook-react": "^0.17.0",
"@opengovsg/formsg-sdk": "^0.10.0",
"@stablelib/base64": "^1.0.1",
"@stripe/react-stripe-js": "^1.15.0",
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { datadogLogs } from '@datadog/browser-logs'

import { theme } from '~theme/index'
import { AuthProvider } from '~contexts/AuthContext'
import { GrowthBookProvider } from '~contexts/GrowthbookContext'
import { HttpError } from '~services/ApiService'

import { AppHelmet } from './AppHelmet'
Expand Down Expand Up @@ -70,7 +71,9 @@ export const App = (): JSX.Element => {
<BrowserRouter>
<ChakraProvider theme={theme} resetCSS>
<AuthProvider>
<AppRouter />
<GrowthBookProvider>
<AppRouter />
</GrowthBookProvider>
</AuthProvider>
</ChakraProvider>
</BrowserRouter>
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/app/AppRouter.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { lazy, Suspense } from 'react'
import { lazy, Suspense, useEffect } from 'react'
import { Route, Routes } from 'react-router-dom'
import { Box } from '@chakra-ui/react'
import { useGrowthBook } from '@growthbook/growthbook-react'

import {
ADMINFORM_PREVIEW_ROUTE,
Expand Down Expand Up @@ -72,6 +73,14 @@ const WithSuspense = ({ children }: { children: React.ReactNode }) => (
)

export const AppRouter = (): JSX.Element => {
const growthbook = useGrowthBook()
useEffect(() => {
if (growthbook) {
// Load features from the GrowthBook API
growthbook.loadFeatures({ autoRefresh: true })
}
}, [growthbook])

return (
<WithSuspense>
<Routes>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/constants/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,6 @@ export const OGP_SGID = 'https://go.gov.sg/sgid-formsg'
export const OGP_FORMSG_REPO = 'https://github.com/opengovsg/formsg'

export const FORMSG_UAT = 'https://uat.form.gov.sg'

export const GROWTHBOOK_DEV_PROXY =
'https://proxy-growthbook-stg.formsg.workers.dev'
3 changes: 3 additions & 0 deletions frontend/src/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ export const ACTIVE_ADMINFORM_RESULTS_ROUTE_REGEX = new RegExp(
'i',
)
export const PAYMENT_PAGE_SUBROUTE = 'payment/:paymentId'

// Path for growthbook api proxy, set up on cloudflare workers. Worker script: https://github.com/opengovsg/formsg-private/pull/171.
export const GROWTHBOOK_API_HOST_PATH = '/api/v1/proxy/growthbook'
26 changes: 26 additions & 0 deletions frontend/src/contexts/GrowthbookContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { ReactNode } from 'react'
import { GrowthBookProvider as BaseGrowthBookProvider } from '@growthbook/growthbook-react'

import { createGrowthbookInstance } from '~/growthbook'

import { useEnv } from '~features/env/queries'

/**
* Provider component that wraps your app and makes auth object available to any
* child component that calls `useAuth()`.
*/
export const GrowthBookProvider = ({ children }: { children: ReactNode }) => {
const { data: { growthbookClientKey } = {} } = useEnv()

return (
<BaseGrowthBookProvider
growthbook={
growthbookClientKey
? createGrowthbookInstance(growthbookClientKey)
: undefined
}
>
{children}
</BaseGrowthBookProvider>
)
}
12 changes: 9 additions & 3 deletions frontend/src/features/admin-form/common/AdminViewFormService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
SubmitStorageFormArgs,
} from '~features/public-form/PublicFormService'
import {
createEmailSubmissionFormData,
createClearSubmissionFormData,
createEncryptedSubmissionData,
filterHiddenInputs,
} from '~features/public-form/utils'
Expand Down Expand Up @@ -166,7 +166,10 @@ export const submitEmailModeFormPreview = async ({
formInputs,
formLogics,
})
const formData = createEmailSubmissionFormData(formFields, filteredInputs)
const formData = createClearSubmissionFormData({
formFields,
formInputs: filteredInputs,
})

return ApiService.post<SubmissionResponseDto>(
`${ADMIN_FORM_ENDPOINT}/${formId}/preview/submissions/email`,
Expand Down Expand Up @@ -216,7 +219,10 @@ export const submitEmailModeFormPreviewWithFetch = async ({
formInputs,
formLogics,
})
const formData = createEmailSubmissionFormData(formFields, filteredInputs)
const formData = createClearSubmissionFormData({
formFields,
formInputs: filteredInputs,
})

const response = await fetch(
`${API_BASE_URL}${ADMIN_FORM_ENDPOINT}/${formId}/preview/submissions/email`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState } from 'react'
import { useSearchParams } from 'react-router-dom'
import {
As,
Divider,
Expand All @@ -10,6 +11,10 @@ import {
VStack,
} from '@chakra-ui/react'

import {
DISALLOW_CONNECT_NON_WHITELIST_STRIPE_ACCOUNT,
ERROR_QUERY_PARAM_KEY,
} from '~shared/constants'
import { FormResponseMode, PaymentChannel } from '~shared/types'

import { BxsCheckCircle, BxsError, BxsInfoCircle } from '~assets/icons'
Expand Down Expand Up @@ -39,6 +44,27 @@ const BeforeConnectionInstructions = ({
}): JSX.Element => {
const [allowConnect, setAllowConnect] = useState(false)
const { data: paymentGuideLink } = usePaymentGuideLink()
const [searchParams] = useSearchParams()

const queryParams = Object.fromEntries([...searchParams])
const isInvalidDomain =
queryParams[ERROR_QUERY_PARAM_KEY] ===
DISALLOW_CONNECT_NON_WHITELIST_STRIPE_ACCOUNT

if (isInvalidDomain) {
return (
<>
<InlineMessage variant="error" my="2rem">
<Text>
Your Stripe account could not be connected because it was created
with a non-whitelisted email domain. Try reconnecting an account
that was created with a whitelisted email domain.
</Text>
</InlineMessage>
<StripeConnectButton connectState={StripeConnectButtonStates.ENABLED} />
</>
)
}
if (isProductionEnv) {
return (
<VStack spacing="2.5rem" alignItems="start">
Expand Down Expand Up @@ -84,19 +110,19 @@ const BeforeConnectionInstructions = ({
/>
</VStack>
)
} else {
return (
<>
<InlineMessage variant="info" my="2rem">
<Text>
You are currently in test mode. You can choose to skip connecting a
Stripe account after clicking the button below.
</Text>
</InlineMessage>
<StripeConnectButton connectState={StripeConnectButtonStates.ENABLED} />
</>
)
}

return (
<>
<InlineMessage variant="info" my="2rem">
<Text>
You are currently in test mode. You can choose to skip connecting a
Stripe account after clicking the button below.
</Text>
</InlineMessage>
<StripeConnectButton connectState={StripeConnectButtonStates.ENABLED} />
</>
)
}

const ConnectionStatusText = ({
Expand Down
Loading

0 comments on commit 34d6bba

Please sign in to comment.