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

feat: gate mrf form creation on frontend and backend by beta-flags #6962

Merged
merged 1 commit into from
Dec 19, 2023
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
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { FormResponseMode } from '~shared/types/form/form'
import Badge from '~components/Badge' import Badge from '~components/Badge'
import Tile from '~components/Tile' import Tile from '~components/Tile'


import { useUser } from '~features/user/queries'

export interface FormResponseOptionsProps { export interface FormResponseOptionsProps {
onChange: (option: FormResponseMode) => void onChange: (option: FormResponseMode) => void
value: FormResponseMode value: FormResponseMode
Expand All @@ -29,6 +31,7 @@ export const FormResponseOptions = forwardRef<
FormResponseOptionsProps, FormResponseOptionsProps,
'button' 'button'
>(({ value, onChange }, ref) => { >(({ value, onChange }, ref) => {
const { user } = useUser()
return ( return (
<Stack spacing="1rem" w="100%" direction={{ base: 'column', md: 'row' }}> <Stack spacing="1rem" w="100%" direction={{ base: 'column', md: 'row' }}>
<Tile <Tile
Expand Down Expand Up @@ -69,6 +72,7 @@ export const FormResponseOptions = forwardRef<
]} ]}
/> />
</Tile> </Tile>
{user?.betaFlags?.mrf && (
<Tile <Tile
ref={ref} ref={ref}
variant="complex" variant="complex"
Expand All @@ -91,6 +95,7 @@ export const FormResponseOptions = forwardRef<
]} ]}
/> />
</Tile> </Tile>
)}
</Stack> </Stack>
) )
}) })
1 change: 1 addition & 0 deletions shared/types/user.ts
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const UserBase = z.object({
.object({ .object({
payment: z.boolean().optional(), payment: z.boolean().optional(),
children: z.boolean().optional(), children: z.boolean().optional(),
mrf: z.boolean().optional(),
}) })
.optional(), .optional(),
flags: z flags: z
Expand Down
1 change: 1 addition & 0 deletions src/app/models/user.server.model.ts
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const compileUserModel = (db: Mongoose) => {
betaFlags: { betaFlags: {
payment: Boolean, payment: Boolean,
children: Boolean, children: Boolean,
mrf: Boolean,
}, },
flags: { flags: {
lastSeenFeatureUpdateVersion: Number, lastSeenFeatureUpdateVersion: Number,
Expand Down
8 changes: 7 additions & 1 deletion src/app/modules/form/admin-form/admin-form.controller.ts
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { celebrate, Joi as BaseJoi, Segments } from 'celebrate'
import { AuthedSessionData } from 'express-session' import { AuthedSessionData } from 'express-session'
import { StatusCodes } from 'http-status-codes' import { StatusCodes } from 'http-status-codes'
import JSONStream from 'JSONStream' import JSONStream from 'JSONStream'
import { ResultAsync } from 'neverthrow' import { okAsync, ResultAsync } from 'neverthrow'


import { import {
MAX_UPLOAD_FILE_SIZE, MAX_UPLOAD_FILE_SIZE,
Expand Down Expand Up @@ -105,6 +105,7 @@ import { PermissionLevel } from './admin-form.types'
import { import {
mapGoGovErrors, mapGoGovErrors,
mapRouteError, mapRouteError,
verifyUserBetaflag,
verifyValidUnicodeString, verifyValidUnicodeString,
} from './admin-form.utils' } from './admin-form.utils'


Expand Down Expand Up @@ -1183,6 +1184,11 @@ export const createForm: ControllerHandler<
return ( return (
// Step 1: Retrieve currently logged in user. // Step 1: Retrieve currently logged in user.
UserService.findUserById(sessionUserId) UserService.findUserById(sessionUserId)
.andThen((user) =>
formParams.responseMode === FormResponseMode.Multirespondent
? verifyUserBetaflag(user, 'mrf')
: okAsync(user),
)
// Step 2: Create form with given params and set admin to logged in user. // Step 2: Create form with given params and set admin to logged in user.
.andThen((user) => .andThen((user) =>
AdminFormService.createForm( AdminFormService.createForm(
Expand Down
Loading