Skip to content

Commit

Permalink
chore: merge with develop to resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
kathleenkhy committed Mar 14, 2024
2 parents 4ba9153 + d68b84a commit 326c746
Show file tree
Hide file tree
Showing 25 changed files with 337 additions and 49 deletions.
1 change: 1 addition & 0 deletions .ebextensions/env-file-creation.config
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ files:
aws ssm get-parameter --name "${ENV_TYPE}-ndi" --with-decryption --region $AWS_REGION | jq -r '.Parameter.Value' >> $TARGET_DIR/.env
aws ssm get-parameter --name "${ENV_TYPE}-verified-fields" --with-decryption --region $AWS_REGION | jq -r '.Parameter.Value' >> $TARGET_DIR/.env
aws ssm get-parameter --name "${ENV_TYPE}-webhook-verified-content" --with-decryption --region $AWS_REGION | jq -r '.Parameter.Value' >> $TARGET_DIR/.env
aws ssm get-parameter --name "${ENV_TYPE}-wogaa" --with-decryption --region $AWS_REGION | jq -r '.Parameter.Value' >> $TARGET_DIR/.env
aws ssm get-parameter --name "${ENV_SITE_NAME}-sgid" --with-decryption --region $AWS_REGION | jq -r '.Parameter.Value' >> $TARGET_DIR/.env
aws ssm get-parameter --name "${ENV_SITE_NAME}-payment" --with-decryption --region $AWS_REGION | jq -r '.Parameter.Value' >> $TARGET_DIR/.env
aws ssm get-parameter --name "${ENV_SITE_NAME}-cron-payment" --with-decryption --region $AWS_REGION | jq -r '.Parameter.Value' >> $TARGET_DIR/.env
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ services:
- GROWTHBOOK_CLIENT_KEY
# env vars for virus scanner
- VIRUS_SCANNER_LAMBDA_FUNCTION_NAME=function
- WOGAA_SECRET_KEY
- WOGAA_START_ENDPOINT
- WOGAA_SUBMIT_ENDPOINT
- WOGAA_FEEDBACK_ENDPOINT


mockpass:
build: https://github.com/opengovsg/mockpass.git#v4.0.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ interface PreviewFormBannerProps {
const textProps: TextProps = {
textStyle: 'body-2',
color: 'white',
ml: '2rem',
mx: '2rem',
mt: '0.5rem',
mb: '0.5rem',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ export const EditEmail = ({ field }: EditEmailProps): JSX.Element => {
}
}, [isPdfResponseEnabled])

// vfn is not supported on MRF
const isToggleVfnDisabled = useMemo(
() => form?.responseMode === FormResponseMode.Multirespondent,
[form],
)

// email confirmation is not supported on MRF
const isToggleEmailConfirmationDisabled = useMemo(
() => form?.responseMode === FormResponseMode.Multirespondent,
[form],
)

return (
<CreatePageDrawerContentContainer>
<FormControl isRequired isReadOnly={isLoading} isInvalid={!!errors.title}>
Expand All @@ -158,7 +170,7 @@ export const EditEmail = ({ field }: EditEmailProps): JSX.Element => {
<FormControl isReadOnly={isLoading}>
<Toggle {...register('required')} label="Required" />
</FormControl>
<FormControl isReadOnly={isLoading}>
<FormControl isReadOnly={isLoading} isDisabled={isToggleVfnDisabled}>
<Toggle
{...register('isVerifiable')}
label="OTP verification"
Expand Down Expand Up @@ -193,7 +205,10 @@ export const EditEmail = ({ field }: EditEmailProps): JSX.Element => {
)}
</Box>
<Box>
<FormControl isReadOnly={isLoading}>
<FormControl
isReadOnly={isLoading}
isDisabled={isToggleEmailConfirmationDisabled}
>
<Toggle
{...register('autoReplyOptions.hasAutoReply')}
description="Customise an email acknowledgement to respondents"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useMemo } from 'react'
import { Box, FormControl, useDisclosure } from '@chakra-ui/react'
import { extend, pick } from 'lodash'

import { FormResponseMode } from '~shared/types'
import { MobileFieldBase } from '~shared/types/field'

import { createBaseValidationRules } from '~utils/fieldValidation'
Expand Down Expand Up @@ -62,13 +63,20 @@ export const EditMobile = ({ field }: EditMobileProps): JSX.Element => {

const { data: freeSmsCount } = useFreeSmsQuota()
const isToggleVfnDisabled = useMemo(() => {
// vfn is not supported on MRF
if (form?.responseMode === FormResponseMode.Multirespondent) return true
if (!freeSmsCount) return true
return (
!field.isVerifiable &&
!hasTwilioCredentials &&
freeSmsCount.freeSmsCounts >= freeSmsCount.quota
)
}, [field.isVerifiable, freeSmsCount, hasTwilioCredentials])
}, [
field.isVerifiable,
freeSmsCount,
hasTwilioCredentials,
form?.responseMode,
])

const smsCountsDisclosure = useDisclosure()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Droppable } from 'react-beautiful-dnd'
import { Box } from '@chakra-ui/react'

import { BasicField, FormResponseMode } from '~shared/types'

import { useAdminForm } from '~features/admin-form/common/queries'
import {
BASIC_FIELDS_ORDERED,
CREATE_FIELD_DROP_ID,
Expand All @@ -13,20 +16,33 @@ import { FieldSection } from './FieldSection'

export const BasicFieldPanel = () => {
const { isLoading } = useCreateTabForm()
const { data: form } = useAdminForm()

return (
<Droppable isDropDisabled droppableId={CREATE_FIELD_DROP_ID}>
{(provided) => (
<Box ref={provided.innerRef} {...provided.droppableProps}>
<FieldSection>
{BASIC_FIELDS_ORDERED.map((fieldType, index) => (
<DraggableBasicFieldListOption
index={index}
isDisabled={isLoading}
key={index}
fieldType={fieldType}
/>
))}
{BASIC_FIELDS_ORDERED.map((fieldType, index) => {
let shouldDisableField = isLoading

// Attachment is not supported on MRF
if (
fieldType === BasicField.Attachment &&
form?.responseMode === FormResponseMode.Multirespondent
) {
shouldDisableField = true
}

return (
<DraggableBasicFieldListOption
index={index}
isDisabled={shouldDisableField}
key={index}
fieldType={fieldType}
/>
)
})}
<Box display="none">{provided.placeholder}</Box>
</FieldSection>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Default.args = {
title:
'Thank you for your submission with some super long backstory about how important the submission is to them',
paragraph: 'We will get back to you shortly.\n\nOnce again,\r\nthank you.',
paymentTitle: '',
paymentParagraph: '',
},
submissionData: {
id: 'mockSubmissionId',
Expand Down Expand Up @@ -84,7 +86,7 @@ ColorThemeOrange.args = {
export const FeedbackSubmitted = Template.bind({})
FeedbackSubmitted.args = {
...Default.args,
isFeedbackSubmitted: true,
isFeedbackSectionHidden: true,
}

export const Mobile = Template.bind({})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ export interface FormEndPageProps {
endPage: FormDto['endPage']
submissionData: SubmissionData
handleSubmitFeedback: (inputs: FeedbackFormInput) => void
isFeedbackSubmitted: boolean
isFeedbackSectionHidden: boolean
colorTheme: FormColorTheme
}

export const FormEndPage = ({
handleSubmitFeedback,
isFeedbackSubmitted,
isFeedbackSectionHidden,
colorTheme,
...endPageProps
}: FormEndPageProps): JSX.Element => {
Expand All @@ -40,7 +40,7 @@ export const FormEndPage = ({
{...endPageProps}
colorTheme={colorTheme}
/>
{isFeedbackSubmitted ? null : (
{isFeedbackSectionHidden ? null : (
<FeedbackBlock
colorTheme={colorTheme}
onSubmit={handleSubmitFeedback}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,20 @@ export const FormEndPageContainer = (): JSX.Element | null => {
/>
)
}

const isFeedbackHidden =
// Feedback is not supported on MRF
form.responseMode === FormResponseMode.Multirespondent ||
isFeedbackSubmitted

return (
<Box py={{ base: '1.5rem', md: '2.5rem' }} w="100%">
<FormEndPage
colorTheme={form.startPage.colorTheme}
submissionData={submissionData}
formTitle={form.title}
endPage={form.endPage}
isFeedbackSubmitted={isFeedbackSubmitted}
isFeedbackSectionHidden={isFeedbackHidden}
handleSubmitFeedback={handleSubmitFeedback}
/>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ export const PaymentEndPagePreview = ({
</Box>
<Stack
pt={{ base: '1rem', md: '1.5rem' }}
mx={{ base: '1rem', md: '2rem' }}
px={{ base: '1rem', md: '4rem' }}
bg="transparent"
w="100%"
>
<PaymentEndPageBlock focusOnMount {...endPageProps} />
{isFeedbackSubmitted ? null : (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo, useState } from 'react'
import { useParams } from 'react-router-dom'
import { Box, Center, Container } from '@chakra-ui/react'
import { Box, Center, Container, Flex, Stack, Text } from '@chakra-ui/react'
import { Elements, useStripe } from '@stripe/react-stripe-js'
import { loadStripe } from '@stripe/stripe-js'

Expand All @@ -11,6 +11,7 @@ import {
} from '~shared/types'

import InlineMessage from '~components/InlineMessage'
import { CopyButton } from '~templates/CopyButton'

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

Expand Down Expand Up @@ -155,9 +156,22 @@ const StripePaymentContainer = ({
<PaymentFormWrapper>
{secretEnv === 'production' ? null : (
<InlineMessage variant="warning" mb="1rem">
Use '4242 4242 4242 4242' as your card number to test payments
on this form. Payments made on this form will only show in
test mode in Stripe.
<Stack>
<Text>
Make a test payment with the card number below! Payments
made on this form will only show in test mode in Stripe.
</Text>
<Flex align="center">
<Text mr="0.25rem">4242 4242 4242 4242</Text>
<Flex boxSize="1.5rem" align="center" justify="center">
<CopyButton
colorScheme="secondary"
stringToCopy={`4242424242424242`}
aria-label="Copy test card number"
/>
</Flex>
</Flex>
</Stack>
</InlineMessage>
)}
<PaymentStack>
Expand Down
6 changes: 3 additions & 3 deletions serverless/virus-scanner/src/__tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('handler', () => {
expect(mockLoggerWarn).toHaveBeenCalledWith(
expect.objectContaining({
message: 'File not found',
error: new Error('File not found'),
err: new Error('File not found'),
quarantineFileKey: mockUUID,
}),
)
Expand Down Expand Up @@ -175,7 +175,7 @@ describe('handler', () => {
expect(mockLoggerError).toHaveBeenCalledWith(
expect.objectContaining({
message: 'Failed to scan file',
error: new Error('Failed to scan file'),
err: new Error('Failed to scan file'),
quarantineFileKey: mockUUID,
}),
)
Expand Down Expand Up @@ -248,7 +248,7 @@ describe('handler', () => {
expect(mockLoggerError).toHaveBeenCalledWith(
expect.objectContaining({
message: 'Failed to move file to clean bucket',
error: new Error('Failed to move file'),
err: new Error('Failed to move file'),
bucket: 'local-virus-scanner-quarantine-bucket',
key: mockUUID,
}),
Expand Down
4 changes: 2 additions & 2 deletions serverless/virus-scanner/src/__tests/s3.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe('S3Service', () => {
expect.objectContaining({
bucketName: 'bucketName',
objectKey: 'objectKey',
error: new Error('Body is empty'),
err: new Error('Body is empty'),
}),
'Failed to get object from s3',
)
Expand All @@ -172,7 +172,7 @@ describe('S3Service', () => {
expect.objectContaining({
bucketName: 'bucketName',
objectKey: 'objectKey',
error: new Error('VersionId is empty'),
err: new Error('VersionId is empty'),
}),
'Failed to get object from s3',
)
Expand Down
16 changes: 8 additions & 8 deletions serverless/virus-scanner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ export const handler = async (
bucketName: quarantineBucket,
objectKey: quarantineFileKey,
})
} catch (error) {
} catch (err) {
logger.warn({
message: 'File not found',
error,
err,
quarantineFileKey,
})
return {
Expand All @@ -88,10 +88,10 @@ export const handler = async (
let scanResult
try {
scanResult = await scanFileStream(body)
} catch (error) {
} catch (err) {
logger.error({
message: 'Failed to scan file',
error,
err,
quarantineFileKey,
})
return {
Expand Down Expand Up @@ -122,11 +122,11 @@ export const handler = async (
objectKey: quarantineFileKey,
versionId,
})
} catch (error) {
} catch (err) {
// Log but do not halt execution as we still want to return 400 for malicious file
logger.error({
message: 'Failed to delete file from quarantine bucket',
error,
err,
key: quarantineFileKey,
})
}
Expand Down Expand Up @@ -158,10 +158,10 @@ export const handler = async (
destinationBucketName: cleanBucket,
destinationObjectKey: cleanFileKey,
})
} catch (error) {
} catch (err) {
logger.error({
message: 'Failed to move file to clean bucket',
error,
err,
bucket: quarantineBucket,
key: quarantineFileKey,
})
Expand Down
Loading

0 comments on commit 326c746

Please sign in to comment.