Skip to content
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

build: release v6.174.0 #8039

Merged
merged 8 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ 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.173.1](https://github.com/opengovsg/FormSG/compare/v6.174.0...v6.173.1)
#### [v6.174.0](https://github.com/opengovsg/FormSG/compare/v6.174.0...v6.174.0)

- fix: set limit to 250kb for whitelist [`#8043`](https://github.com/opengovsg/FormSG/pull/8043)
- build: merge release v6.173.1 to develop [`#8044`](https://github.com/opengovsg/FormSG/pull/8044)
- build: release v6.173.1 [`#8042`](https://github.com/opengovsg/FormSG/pull/8042)
- fix: remove multer [`#8041`](https://github.com/opengovsg/FormSG/pull/8041)
- chore: bump version to v6.173.1 [`70fd33a`](https://github.com/opengovsg/FormSG/commit/70fd33aa01b398f98f2b2dfee6880cd043889cc1)

#### [v6.174.0](https://github.com/opengovsg/FormSG/compare/v6.173.0...v6.174.0)
#### [v6.174.0](https://github.com/opengovsg/FormSG/compare/v6.173.1...v6.174.0)

> 13 January 2025

Expand All @@ -17,20 +21,26 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- chore: mongoose, nanoid packages update [`#8000`](https://github.com/opengovsg/FormSG/pull/8000)
- build: merge release v6.173.0 to develop [`#8034`](https://github.com/opengovsg/FormSG/pull/8034)
- fix(deps): bump libphonenumber-js from 1.11.16 to 1.11.17 in /shared [`#8021`](https://github.com/opengovsg/FormSG/pull/8021)
- * fix(deps): bump fp-ts from 2.16.8 to 2.16.9 (#8017) [`#8027`](https://github.com/opengovsg/FormSG/pull/8027)
- fix: update mongodb binary version to 6 [`#8032`](https://github.com/opengovsg/FormSG/pull/8032)
- chore: bump version to v6.173.0 [`54e544d`](https://github.com/opengovsg/FormSG/commit/54e544d9835af07fbcd2b0218ed522c26b18fa5e)
- chore: bump version to v6.174.0 [`22b1122`](https://github.com/opengovsg/FormSG/commit/22b1122e8e15dbb8ca4c69c1d6c026a865d3b67c)

#### [v6.173.1](https://github.com/opengovsg/FormSG/compare/v6.173.0...v6.173.1)

> 13 January 2025

- fix: remove multer [`#8041`](https://github.com/opengovsg/FormSG/pull/8041)
- * fix(deps): bump fp-ts from 2.16.8 to 2.16.9 (#8017) [`#8027`](https://github.com/opengovsg/FormSG/pull/8027)
- chore: bump version to v6.173.1 [`70fd33a`](https://github.com/opengovsg/FormSG/commit/70fd33aa01b398f98f2b2dfee6880cd043889cc1)

#### [v6.173.0](https://github.com/opengovsg/FormSG/compare/v6.172.0...v6.173.0)

> 7 January 2025

- fix: update mongodb binary version to 6 [`#8032`](https://github.com/opengovsg/FormSG/pull/8032)
- feat: multi lang feature [`#8022`](https://github.com/opengovsg/FormSG/pull/8022)
- fix(deps): bump fp-ts from 2.16.8 to 2.16.9 [`#8017`](https://github.com/opengovsg/FormSG/pull/8017)
- build: merge release v6.172.0 to develop [`#8016`](https://github.com/opengovsg/FormSG/pull/8016)
- build: release v6.172.0 [`#8015`](https://github.com/opengovsg/FormSG/pull/8015)
- chore: bump version to v6.173.0 [`1cb7772`](https://github.com/opengovsg/FormSG/commit/1cb7772374249830091d1fb3278a035957d23bcb)
- chore: bump version to v6.173.0 [`54e544d`](https://github.com/opengovsg/FormSG/commit/54e544d9835af07fbcd2b0218ed522c26b18fa5e)

#### [v6.172.0](https://github.com/opengovsg/FormSG/compare/v6.171.0...v6.172.0)

Expand All @@ -53,7 +63,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- build: release v6.170.0 [`#7998`](https://github.com/opengovsg/FormSG/pull/7998)
- chore: bump version to v6.171.0 [`089a155`](https://github.com/opengovsg/FormSG/commit/089a155a51691f98f7c06ff218da3a263d22086c)

#### [v6.170.0](https://github.com/opengovsg/FormSG/compare/v6.169.0...v6.170.0)
#### [v6.170.0](https://github.com/opengovsg/FormSG/compare/v6.169.1...v6.170.0)

> 16 December 2024

Expand All @@ -65,9 +75,15 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- build: merge release 6.169.0 to develop [`#7987`](https://github.com/opengovsg/FormSG/pull/7987)
- fix(i18n): replace title,desc missed earlier [`#7940`](https://github.com/opengovsg/FormSG/pull/7940)
- feat(i18n): replace hardcoded text in FeedbackBlock for i18n [`#7941`](https://github.com/opengovsg/FormSG/pull/7941)
- build: release v6.169.0 [`#7986`](https://github.com/opengovsg/FormSG/pull/7986)
- chore: bump version to v6.170.0 [`91bdef3`](https://github.com/opengovsg/FormSG/commit/91bdef34cd54b347c6ea9a1526b8811e8a6d2c1c)

#### [v6.169.1](https://github.com/opengovsg/FormSG/compare/v6.169.0...v6.169.1)

> 13 December 2024

- feat: add formurl to otp email [`#7993`](https://github.com/opengovsg/FormSG/pull/7993)
- build: release v6.169.0 [`#7986`](https://github.com/opengovsg/FormSG/pull/7986)

#### [v6.169.0](https://github.com/opengovsg/FormSG/compare/v6.168.0...v6.169.0)

> 11 December 2024
Expand Down
16 changes: 8 additions & 8 deletions frontend/package-lock.json

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

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "form-frontend",
"version": "6.173.1",
"version": "6.174.0",
"homepage": ".",
"type": "module",
"private": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useEffect, useMemo, useState } from 'react'
import { useCallback, useEffect, useState } from 'react'
import {
Controller,
ControllerRenderProps,
Expand All @@ -8,14 +8,13 @@ import {
import { useParams } from 'react-router'
import { Box, Skeleton } from '@chakra-ui/react'

import { MB } from '~shared/constants'
import { AttachmentSize, BasicField, StorageFormSettings } from '~shared/types'
import { KB } from '~shared/constants'
import { StorageFormSettings } from '~shared/types'
import { VALID_WHITELIST_FILE_EXTENSIONS } from '~shared/utils/file-validation'

import { parseCsvFileToCsvString } from '~utils/parseCsvFileToCsvString'
import Attachment from '~components/Field/Attachment'
import { AttachmentFieldSchema } from '~templates/Field'
import { FieldContainer } from '~templates/Field/FieldContainer'
import { BaseFieldProps, FieldContainer } from '~templates/Field/FieldContainer'

import { useMutateFormSettings } from '../../mutations'

Expand All @@ -26,6 +25,7 @@ interface FormWhitelistAttachmentFieldProps {
isDisabled: boolean
}

const MAX_SIZE_IN_BYTES = 250 * KB
const FormWhitelistAttachmentFieldContainerName =
'whitelist-csv-attachment-field-container'
const FormWhitelistAttachmentFieldName = 'whitelist-csv-attachment-field'
Expand All @@ -45,16 +45,14 @@ export const FormWhitelistAttachmentField = ({

const standardCsvDownloadFileName = `whitelist_${formId}.csv`

const fieldContainerSchema: AttachmentFieldSchema = {
const fieldContainerSchema: BaseFieldProps['schema'] = {
_id: FormWhitelistAttachmentFieldContainerName,
title: 'Restrict form to eligible NRIC/FIN/UENs only',
description:
'Only NRIC/FIN/UENs in this list are allowed to submit a response. CSV file should include all whitelisted NRIC/FIN/UENs in a single column with the "Respondent" header. ' +
'[Download a sample .csv file](https://go.gov.sg/formsg-whitelist-respondents-sample-csv)',
required: true,
disabled: isDisabled,
fieldType: BasicField.Attachment,
attachmentSize: AttachmentSize.TwentyMb,
}

const { publicKey, whitelistedSubmitterIds } = settings
Expand All @@ -73,13 +71,6 @@ export const FormWhitelistAttachmentField = ({
}
}, [isWhitelistEnabled, setValue, standardCsvDownloadFileName])

const maxSizeInBytes = useMemo(() => {
if (!fieldContainerSchema.attachmentSize) {
return
}
return parseInt(fieldContainerSchema.attachmentSize) * MB
}, [fieldContainerSchema.attachmentSize])

const setWhitelistAttachmentFieldError = useCallback(
(errMsg: string) => {
setError(FormWhitelistAttachmentFieldContainerName, {
Expand Down Expand Up @@ -168,7 +159,7 @@ export const FormWhitelistAttachmentField = ({
handleDownloadFileOverride={triggerSecretKeyInputTransition}
handleRemoveFileOverride={removeWhitelist}
showFileSize
maxSize={maxSizeInBytes}
maxSize={MAX_SIZE_IN_BYTES}
showDownload
showRemove
isDownloadDisabled={false}
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/features/public-form/PublicFormProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import {

import { FormNotFound } from './components/FormNotFound'
import { decryptAttachment, decryptSubmission } from './utils/decryptSubmission'
import { postIFrameMessage } from './utils/iframeMessaging'
import { usePublicAuthMutations, usePublicFormMutations } from './mutations'
import { PublicFormContext, SubmissionData } from './PublicFormContext'
import { useEncryptedSubmission, usePublicFormView } from './queries'
Expand Down Expand Up @@ -629,6 +630,8 @@ export const PublicFormProvider = ({
}
}

postIFrameMessage({ state: 'submitting' })

switch (form.responseMode) {
case FormResponseMode.Email: {
// Using mutateAsync so react-hook-form goes into loading state.
Expand Down Expand Up @@ -762,6 +765,7 @@ export const PublicFormProvider = ({
paymentData,
}) => {
trackSubmitForm(form)
postIFrameMessage({ state: 'submitted', submissionId })

if (paymentData) {
navigate(getPaymentPageUrl(formId, paymentData.paymentId))
Expand All @@ -784,6 +788,7 @@ export const PublicFormProvider = ({
},
)
.catch(async (error) => {
postIFrameMessage({ state: 'submitError' })
datadogLogs.logger.warn(`handleSubmitForm: ${error.message}`, {
meta: {
...logMeta,
Expand Down Expand Up @@ -826,6 +831,7 @@ export const PublicFormProvider = ({
paymentData,
}) => {
trackSubmitForm(form)
postIFrameMessage({ state: 'submitted', submissionId })
if (paymentData) {
navigate(getPaymentPageUrl(formId, paymentData.paymentId))
storePaymentMemory(paymentData.paymentId)
Expand All @@ -847,6 +853,7 @@ export const PublicFormProvider = ({
},
)
.catch(async (error) => {
postIFrameMessage({ state: 'submitError' })
// TODO(#5826): Remove when we have resolved the Network Error
datadogLogs.logger.warn(
`handleSubmitForm: submit with virus scan`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { useTranslation } from 'react-i18next'
import useScrollSpy from 'react-use-scrollspy'

import { BasicField, FormFieldDto } from '~shared/types'
import { BasicField, FormFieldDto, Language } from '~shared/types'

import { FieldIdSet } from '~features/logic/types'
import { usePublicFormContext } from '~features/public-form/PublicFormContext'
Expand Down Expand Up @@ -43,9 +43,17 @@ interface FormSectionsProviderProps {
export const FormSectionsProvider = ({
children,
}: FormSectionsProviderProps): JSX.Element => {
const { t } = useTranslation()
const { t, i18n } = useTranslation()
const { form, isAuthRequired } = usePublicFormContext()

useEffect(() => {
// On page load render, if the form does not support multi-langugage
// set the language preference to be English.
if (!form?.hasMultiLang) {
i18n.changeLanguage(Language.ENGLISH)
}
}, [form?.hasMultiLang, i18n])

const [visibleFieldIds, setVisibleFieldIds] = useState<FieldIdSet>()

const sectionScrollData = useMemo(() => {
Expand Down
21 changes: 21 additions & 0 deletions frontend/src/features/public-form/utils/iframeMessaging.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export type PublicFormIFrameMessage =
| { state: 'submitting' | 'submitError' }
| { state: 'submitted'; submissionId: string }

const TRUSTED_TARGET_ORIGINS = [
'https://pay.gov.sg',
'https://exp.pay.gov.sg',
'https://staging.pay.gov.sg',
]

export const postIFrameMessage = (message: PublicFormIFrameMessage): void => {
// De-risk by wrapping in try-catch even though this is synchronous. This should
// never block form submission.
try {
TRUSTED_TARGET_ORIGINS.forEach((origin) => {
window.parent.postMessage(message, origin)
})
} catch (error) {
console.warn('Error while posting form state to iframe parent', error)
}
}
2 changes: 1 addition & 1 deletion frontend/src/i18n/locales/features/login/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './en-sg'
export * from './zh-sg'
export * from './zh-sg.example'

export interface Login {
components: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const enSG: Fields = {
fileEmpty:
'You have uploaded an empty file, please upload a valid attachment',
fileTooLarge:
'You have exceeded the limit, please upload a file below {readableMaxSize}',
'You have exceeded the file size limit, please upload a file below {readableMaxSize}',
fileInvalidType:
"Your file's extension ending in *{fileExt} is not allowed",
tooManyFiles: 'You can only upload a single file in this input',
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/i18n/locales/zh-sg.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { PartialDeep } from 'type-fest'

import { zhSG as login } from './features/login'
import { zhSG as publicForm } from './features/public-form'
import Translation from './types'

export const zhSG: PartialDeep<Translation> = {
translation: {
features: {
publicForm,
login,
},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ describe('attachment validation', () => {
// Assert
// Should show error message.
const error = screen.getByText(
/You have exceeded the limit, please upload a file below 1 MB/i,
/You have exceeded the file size limit, please upload a file below 1 MB/i,
)
expect(error).not.toBeNull()
})
Expand Down
Loading
Loading