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.118.0 #7293

Merged
merged 12 commits into from
Apr 30, 2024
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
23 changes: 21 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,26 @@ 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.117.0](https://github.com/opengovsg/FormSG/compare/v6.117.0...v6.117.0)
#### [v6.118.0](https://github.com/opengovsg/FormSG/compare/v6.118.0...v6.118.0)

- fix(btn): use different growthbook api [`#7299`](https://github.com/opengovsg/FormSG/pull/7299)

#### [v6.118.0](https://github.com/opengovsg/FormSG/compare/v6.117.0...v6.118.0)

> 30 April 2024

- fix(payments): allow 0 cents [`#7298`](https://github.com/opengovsg/FormSG/pull/7298)
- fix(deps): bump type-fest from 4.17.0 to 4.18.0 in /shared [`#7297`](https://github.com/opengovsg/FormSG/pull/7297)
- fix: update chromium version [`#7294`](https://github.com/opengovsg/FormSG/pull/7294)
- feat(btn): phase 2 - add growthbook toggle to control adding twilio creds [`#7290`](https://github.com/opengovsg/FormSG/pull/7290)
- feat(payments): add min global payment limit override [`#7291`](https://github.com/opengovsg/FormSG/pull/7291)
- fix: add localhost domain into cors, used by attachment uploads [`#7280`](https://github.com/opengovsg/FormSG/pull/7280)
- fix(deps): bump type-fest from 4.16.0 to 4.17.0 in /shared [`#7287`](https://github.com/opengovsg/FormSG/pull/7287)
- chore: reduce output, check gh login auth status only if not logged in [`#7282`](https://github.com/opengovsg/FormSG/pull/7282)
- build: merge release v6.117.0 into develop [`#7284`](https://github.com/opengovsg/FormSG/pull/7284)
- build: release v6.117.0 [`#7266`](https://github.com/opengovsg/FormSG/pull/7266)
- fix(deps): bump zod from 3.23.0 to 3.23.4 in /shared [`#7283`](https://github.com/opengovsg/FormSG/pull/7283)
- chore: bump version to v6.118.0 [`9bcc6a0`](https://github.com/opengovsg/FormSG/commit/9bcc6a0140e3f10d6b8df4c1333fcf701ca24d10)

#### [v6.117.0](https://github.com/opengovsg/FormSG/compare/v6.116.0...v6.117.0)

Expand All @@ -30,7 +49,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- chore: refactor to move endpage block to generic folder [`#7248`](https://github.com/opengovsg/FormSG/pull/7248)
- build: release v6.116.0 [`#7251`](https://github.com/opengovsg/FormSG/pull/7251)
- chore: reverting package-lock changes [`040b962`](https://github.com/opengovsg/FormSG/commit/040b96284ea317de22d9de6cf872fd4116f24c51)
- chore: bump version to v6.117.0 [`b355f4a`](https://github.com/opengovsg/FormSG/commit/b355f4a686445a7863e06a0da2ec136e878d50fd)
- chore: bump version to v6.117.0 [`6eb4aca`](https://github.com/opengovsg/FormSG/commit/6eb4aca28514e3286c23c0834f9962de291a7fbc)

#### [v6.116.0](https://github.com/opengovsg/FormSG/compare/v6.115.1...v6.116.0)

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.development
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RUN apk update && apk upgrade && \
# https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md#running-on-alpine
# https://www.npmjs.com/package/puppeteer-core?activeTab=versions for corresponding versions
# Compatible chromium versions can be found here https://pkgs.alpinelinux.org/packages?name=chromium&branch=v3.19&repo=&arch=&maintainer=
chromium=124.0.6367.60-r0 \
chromium=124.0.6367.78-r0 \
nss \
freetype \
freetype-dev \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.production
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ RUN mv /opt/formsg/dist/backend/shared /opt/formsg/

RUN apk add --no-cache \
# Compatible chromium versions can be found here https://pkgs.alpinelinux.org/packages?name=chromium&branch=v3.19&repo=&arch=&maintainer=
chromium=124.0.6367.60-r0 \
chromium=124.0.6367.78-r0 \
nss \
freetype \
freetype-dev \
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ services:
environment:
- SERVICES=s3,sqs,secretsmanager
- DNS_ADDRESS=0
- EXTRA_CORS_ALLOWED_ORIGINS=http://localhost:3000
volumes:
- ./.localstack/volume:/var/lib/localstack
- /var/run/docker.sock:/var/run/docker.sock
Expand Down
4 changes: 2 additions & 2 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.117.0",
"version": "6.118.0",
"homepage": ".",
"private": true,
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,21 @@ export const VariablePaymentAmountField = ({
}) => {
const {
data: {
maxPaymentAmountCents = Number.MAX_SAFE_INTEGER,
minPaymentAmountCents = Number.MIN_SAFE_INTEGER,
maxPaymentAmountCents: envMaxPaymentAmountCents = Number.MAX_SAFE_INTEGER,
minPaymentAmountCents: envMinPaymentAmountCents = Number.MIN_SAFE_INTEGER,
} = {},
} = useEnv()

const minAmountCents =
input.global_min_amount_override || envMinPaymentAmountCents

const maxAmountCents = envMaxPaymentAmountCents

const minAmountInDollars = `S${formatCurrency(
Number(centsToDollars(minPaymentAmountCents)),
Number(centsToDollars(minAmountCents)),
)}`
const maxAmountInDollars = `S${formatCurrency(
Number(centsToDollars(maxPaymentAmountCents)),
Number(centsToDollars(maxAmountCents)),
)}`

const minAmountValidation: RegisterOptions<
Expand All @@ -51,6 +56,7 @@ export const VariablePaymentAmountField = ({
> = usePaymentFieldValidation<FormPaymentsInput, typeof MIN_FIELD_KEY>({
lesserThanCents: dollarsToCents(input[MAX_FIELD_KEY] || ''),
msgWhenEmpty: `The minimum amount is ${minAmountInDollars}`,
overrideMinAmount: input.global_min_amount_override,
})
const maxAmountValidation: RegisterOptions<
FormPaymentsInput,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import {
Stack,
useDisclosure,
} from '@chakra-ui/react'
import { useFeatureValue } from '@growthbook/growthbook-react'
import { useToggle } from 'rooks'

import { featureFlags } from '~shared/constants'
import { TwilioCredentials } from '~shared/types/twilio'

import { trimStringsInObject } from '~utils/trimStringsInObject'
Expand Down Expand Up @@ -61,12 +63,16 @@ const TWILIO_INPUT_RULES: Record<keyof TwilioCredentials, RegisterOptions> = {
},
},
}

export const TwilioDetailsInputs = (): JSX.Element => {
const { data: form, isLoading } = useAdminForm()

const [isApiSecretShown, toggleIsApiSecretShown] = useToggle(false)

const isAddingTwilioDisabled = useFeatureValue(
featureFlags.addingTwilioDisabled,
false,
)

const hasExistingTwilioCreds = useMemo(
() => !!form?.msgSrvcName,
[form?.msgSrvcName],
Expand All @@ -93,6 +99,7 @@ export const TwilioDetailsInputs = (): JSX.Element => {

const handleUpdateTwilioDetails = handleSubmit((credentials) => {
if (!form) return
if (isAddingTwilioDisabled) return
return mutateFormTwilioDetails.mutate(trimStringsInObject(credentials), {
onSuccess: () => reset(),
})
Expand Down Expand Up @@ -129,6 +136,7 @@ export const TwilioDetailsInputs = (): JSX.Element => {
<FormControl
isReadOnly={mutateFormTwilioDetails.isLoading}
isInvalid={!!errors.accountSid}
isDisabled={isAddingTwilioDisabled}
>
<FormLabel isRequired>Account SID</FormLabel>
<Skeleton isLoaded={!isLoading}>
Expand All @@ -139,6 +147,7 @@ export const TwilioDetailsInputs = (): JSX.Element => {
<FormControl
isReadOnly={mutateFormTwilioDetails.isLoading}
isInvalid={!!errors.apiKey}
isDisabled={isAddingTwilioDisabled}
>
<FormLabel isRequired>API Key SID</FormLabel>
<Skeleton isLoaded={!isLoading}>
Expand All @@ -149,6 +158,7 @@ export const TwilioDetailsInputs = (): JSX.Element => {
<FormControl
isReadOnly={mutateFormTwilioDetails.isLoading}
isInvalid={!!errors.apiSecret}
isDisabled={isAddingTwilioDisabled}
>
<FormLabel isRequired>API key secret</FormLabel>
<Skeleton isLoaded={!isLoading}>
Expand Down Expand Up @@ -179,6 +189,7 @@ export const TwilioDetailsInputs = (): JSX.Element => {
<FormControl
isReadOnly={mutateFormTwilioDetails.isLoading}
isInvalid={!!errors.messagingServiceSid}
isDisabled={isAddingTwilioDisabled}
>
<FormLabel isRequired>Messaging service SID</FormLabel>
<Skeleton isLoaded={!isLoading}>
Expand All @@ -198,6 +209,7 @@ export const TwilioDetailsInputs = (): JSX.Element => {
<Button
isLoading={mutateFormTwilioDetails.isLoading}
onClick={handleUpdateTwilioDetails}
isDisabled={isAddingTwilioDisabled}
>
Save credentials
</Button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import { ListItem, Text, UnorderedList } from '@chakra-ui/react'
import { useFeatureValue } from '@growthbook/growthbook-react'

import { featureFlags } from '~shared/constants'

import InlineMessage from '~components/InlineMessage'

import { TwilioDetailsInputs } from './TwilioDetailsInputs'

export const TwilioSettingsSection = (): JSX.Element => {
const isAddingTwilioDisabled = useFeatureValue(
featureFlags.addingTwilioDisabled,
false,
)

const verbTense = isAddingTwilioDisabled ? 'has been' : 'will be'

return (
<>
<InlineMessage mb="1rem" variant="warning">
Expand All @@ -15,8 +25,8 @@ export const TwilioSettingsSection = (): JSX.Element => {
<UnorderedList spacing="0.5rem" mt="1rem">
<ListItem>
There is no longer a limit of 10,000 SMSes per form admin. Given
this change, the capability of adding new Twilio credentials will
be disabled from 30 April.
this change, the capability of adding new Twilio credentials{' '}
{verbTense} disabled from 30 April.
</ListItem>

<ListItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const VariablePaymentItemDetailsBlock = ({
paymentItemName,
paymentMin: _paymentMin,
paymentMax: _paymentMax,
globalMinAmountOverride,
}: VariableItemDetailProps): JSX.Element => {
const {
control,
Expand All @@ -39,7 +40,11 @@ export const VariablePaymentItemDetailsBlock = ({
[PAYMENT_VARIABLE_INPUT_AMOUNT_FIELD_ID]: string
},
typeof PAYMENT_VARIABLE_INPUT_AMOUNT_FIELD_ID
>({ lesserThanCents: paymentMax, greaterThanCents: paymentMin })
>({
lesserThanCents: paymentMax,
greaterThanCents: paymentMin,
overrideMinAmount: globalMinAmountOverride,
})

const amountHint = `Enter an amount between ${centsToDollarString(
paymentMin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type PaymentItemDetailsProps = PaymentItemNameDescriptionProps
export interface VariableItemDetailProps extends PaymentItemDetailsProps {
paymentMin: number
paymentMax: number
globalMinAmountOverride: number | undefined
}

export interface FixedItemDetailProps extends PaymentItemDetailsProps {
Expand Down
20 changes: 16 additions & 4 deletions frontend/src/hooks/usePaymentFieldValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,40 @@ import {

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

/**
*
* @param options.greaterThanCents The minimum amount in cents
* @param options.lesserThanCents The maximum amount in cents
* @param options.overrideMinAmount The minimum amount in cents that overrides the global minimum amount
* @param options.msgWhenEmpty The message to display when the field is empty
* @returns
*/
export const usePaymentFieldValidation = <
T extends FieldValues,
V extends FieldPath<T>,
>(options?: {
greaterThanCents?: number
lesserThanCents?: number
overrideMinAmount?: number
msgWhenEmpty?: string
}) => {
const {
data: {
maxPaymentAmountCents = Number.MAX_SAFE_INTEGER,
minPaymentAmountCents = Number.MIN_SAFE_INTEGER,
maxPaymentAmountCents: envMaxPaymentAmountCents = Number.MAX_SAFE_INTEGER,
minPaymentAmountCents: envMinPaymentAmountCents = Number.MIN_SAFE_INTEGER,
} = {},
} = useEnv()

const maxAmountCents = envMaxPaymentAmountCents
const minAmountCents = options?.overrideMinAmount || envMinPaymentAmountCents

const {
lesserThanCents: maxCents = Number.MAX_SAFE_INTEGER,
greaterThanCents: minCents = Number.MIN_SAFE_INTEGER,
msgWhenEmpty = '',
} = options || {}
const maxCentsLimit = Math.min(maxCents, maxPaymentAmountCents)
const minCentsLimit = Math.max(minCents, minPaymentAmountCents)
const maxCentsLimit = Math.min(maxCents, maxAmountCents)
const minCentsLimit = Math.max(minCents, minAmountCents)

const amountValidation: RegisterOptions<T, V> = {
validate: (val) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const PaymentItemDetailsElement = ({
paymentDescription={paymentDetails.description}
paymentMin={paymentDetails.min_amount}
paymentMax={paymentDetails.max_amount}
globalMinAmountOverride={paymentDetails.global_min_amount_override}
/>
)
}
Expand Down
4 changes: 2 additions & 2 deletions 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 package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "FormSG",
"description": "Form Manager for Government",
"version": "6.117.0",
"version": "6.118.0",
"homepage": "https://form.gov.sg",
"authors": [
"FormSG <formsg@data.gov.sg>"
Expand Down
14 changes: 11 additions & 3 deletions scripts/release_prep.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
#!/bin/bash
set +x

set -x

# pre-requisites: install github CLI
# - github documentation: https://github.com/cli/cli#installation
# - github is remote 'origin'
# - PRs use test section LAST with heading "## Tests"
# - ALL build and release PRs start with "build: "

if ! command -v gh >/dev/null 2>&1; then
echo "Install gh first"
exit 1
fi

if ! gh auth status >/dev/null 2>&1; then
echo "You need to login: gh auth login"
exit 1
fi

has_local_changes=$(git status --porcelain --untracked-files=no --ignored=no)
if [[ ${has_local_changes} ]]; then
set +x
Expand Down Expand Up @@ -70,8 +80,6 @@ echo "## Dev-Dependencies" >> ${pr_body_file_groupped}
echo "" >> ${pr_body_file_groupped}
grep -E -- '- [a-z]+\(deps-dev\)' ${pr_body_file} >> ${pr_body_file_groupped}

gh auth login

## Extract test procedures for feature PRs
echo "" >> ${pr_body_file_groupped}
echo "## Tests" >> ${pr_body_file_groupped}
Expand Down
1 change: 1 addition & 0 deletions shared/constants/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export const featureFlags = {
validateStripeEmailDomain: 'validateStripeEmailDomain' as const,
myinfoSgid: 'myinfo-sgid' as const,
chartsMaxResponseCount: 'charts-max-response-count' as const,
addingTwilioDisabled: 'adding-twilio-disabled' as const,
}
Loading
Loading