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

users: use generic destinations for user CM create dialog component #3664

Merged
merged 39 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
851bb92
add user CM create and edit dialogs using destinations
tony-tvu Feb 9, 2024
e8984bd
fix storybook rendering
mastercactapus Feb 9, 2024
3335e57
add missing fields for status updates
mastercactapus Feb 9, 2024
40a9cb8
fix edit dialog stories render
mastercactapus Feb 9, 2024
c0d436c
start adding validation
mastercactapus Feb 9, 2024
21259cc
normalize ValidateDestination errors
mastercactapus Feb 12, 2024
332994d
Merge branch 'master' into dest-error-api
mastercactapus Feb 12, 2024
7c5b4df
revert type change
mastercactapus Feb 12, 2024
78877c7
Merge branch 'dest-error-api' into user-CM-create-edit-dest
mastercactapus Feb 12, 2024
bedf8e5
Merge branch 'master' into user-CM-create-edit-dest
mastercactapus Feb 12, 2024
39aaa04
pass validation errors
mastercactapus Feb 13, 2024
6bdc3fc
cleanup error messages
mastercactapus Feb 13, 2024
54cb6a9
remove conflict query for now
mastercactapus Feb 13, 2024
5da053d
remove exp flag stub
mastercactapus Feb 13, 2024
c3598c3
Merge branch 'master' into user-CM-create-edit-dest
mastercactapus Feb 13, 2024
31ee0e2
update exp flag handler
mastercactapus Feb 13, 2024
8ae4239
fix dest type err
mastercactapus Feb 13, 2024
8505a55
update unit test
mastercactapus Feb 13, 2024
4608530
update create dialog story tests
mastercactapus Feb 13, 2024
e3968db
use full name
mastercactapus Feb 13, 2024
b00a5a8
revert edit dialog changes for this PR
mastercactapus Feb 13, 2024
1ff9a95
Merge branch 'master' into user-CM-create-edit-dest
mastercactapus Feb 20, 2024
9a759f8
standardize error codes
mastercactapus Feb 20, 2024
ef04d14
reorganize
mastercactapus Feb 20, 2024
f653c3c
cleanup errors on other components
mastercactapus Feb 20, 2024
3f38b90
remove special case for dest type err
mastercactapus Feb 20, 2024
80feae2
Merge branch 'dest-err-response-updates' into user-CM-create-edit-dest
mastercactapus Feb 20, 2024
cd19bc6
fix error split
mastercactapus Feb 20, 2024
b0003c3
cleanup imports
mastercactapus Feb 20, 2024
9e5bd28
rename/simplify split helper
mastercactapus Feb 20, 2024
fc9a022
update form
mastercactapus Feb 20, 2024
ad59fc2
update test
mastercactapus Feb 20, 2024
66180fd
fix type issue
mastercactapus Feb 20, 2024
913161d
Merge branch 'dest-err-response-updates' into user-CM-create-edit-dest
mastercactapus Feb 20, 2024
6b7bb82
add pre-check for name when using dest
mastercactapus Feb 20, 2024
7d5bcff
Merge branch 'master' into user-CM-create-edit-dest
mastercactapus Feb 21, 2024
cb25441
fix error rendering and story
mastercactapus Feb 22, 2024
48deb3c
update list stories
mastercactapus Feb 22, 2024
80ccb23
user conflict out of scope for this PR
mastercactapus Feb 22, 2024
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
5 changes: 5 additions & 0 deletions graphql2/graphqlapp/contactmethod.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ func (m *Mutation) CreateUserContactMethod(ctx context.Context, input graphql2.C
cfg := config.FromContext(ctx)

if input.Dest != nil {
err := validate.IDName("input.name", input.Name)
if err != nil {
addInputError(ctx, err)
return nil, nil
}
if ok, err := (*App)(m).ValidateDestination(ctx, "input.dest", input.Dest); !ok {
return nil, err
}
Expand Down
18 changes: 18 additions & 0 deletions graphql2/graphqlapp/destinationvalidation.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ func addDestFieldError(ctx context.Context, parentField, fieldID string, err err
return nil
}

func addInputError(ctx context.Context, err error) {
field := err.(validation.FieldError).Field()

p := graphql.GetPath(ctx)
parentParts := strings.Split(field, ".")
for _, part := range parentParts {
p = append(p, ast.PathName(part))
}

graphql.AddError(ctx, &gqlerror.Error{
Message: errReason(err),
Path: p,
Extensions: map[string]interface{}{
"code": graphql2.ErrorCodeInvalidInputValue,
},
})
}

// ValidateDestination will validate a destination input.
//
// In the future this will be a call to the plugin system.
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@
"@mui/system": "5.15.6",
"@mui/x-data-grid": "6.19.3",
"@playwright/test": "1.41.2",
"@storybook/addon-essentials": "7.6.13",
"@storybook/addon-interactions": "7.6.13",
"@storybook/addon-links": "7.6.13",
"@storybook/addons": "7.6.13",
"@storybook/blocks": "7.6.13",
"@storybook/preview-api": "7.6.13",
"@storybook/react": "7.6.13",
"@storybook/react-vite": "7.6.13",
"@storybook/test": "7.6.13",
"@storybook/addon-essentials": "7.6.17",
"@storybook/addon-interactions": "7.6.17",
"@storybook/addon-links": "7.6.17",
"@storybook/addons": "7.6.17",
"@storybook/blocks": "7.6.17",
"@storybook/preview-api": "7.6.17",
"@storybook/react": "7.6.17",
"@storybook/react-vite": "7.6.17",
"@storybook/test": "7.6.17",
"@storybook/test-runner": "0.16.0",
"@storybook/types": "7.6.13",
"@storybook/types": "7.6.17",
"@types/chance": "1.1.4",
"@types/diff": "5.0.8",
"@types/glob": "8.1.0",
Expand Down Expand Up @@ -133,7 +133,7 @@
"remark-breaks": "4.0.0",
"remark-gfm": "4.0.0",
"semver": "7.6.0",
"storybook": "7.6.13",
"storybook": "7.6.17",
"storybook-addon-mock": "4.3.0",
"stylelint": "16.2.1",
"stylelint-config-standard": "34.0.0",
Expand Down
4 changes: 4 additions & 0 deletions web/src/app/dialogs/FormDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function FormDialog(props) {
onBack,
fullHeight,
disableBackdropClose,
disablePortal,
...dialogProps
} = props

Expand Down Expand Up @@ -178,6 +179,7 @@ function FormDialog(props) {
const fs = fullScreen || (!isWideScreen && !confirm)
return (
<Dialog
disablePortal={disablePortal}
classes={classesProp}
fullScreen={fs}
maxWidth={maxWidth}
Expand Down Expand Up @@ -233,6 +235,8 @@ FormDialog.propTypes = {
confirm: p.bool,
maxWidth: p.string,

disablePortal: p.bool, // disable the portal behavior of the dialog

// overrides any of the main action button titles with this specific text
primaryActionLabel: p.string,

Expand Down
10 changes: 10 additions & 0 deletions web/src/app/forms/FormField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ export function FormField(props) {

return null
}
if (props.select) {
fieldProps.SelectProps = {
...fieldProps.SelectProps,
MenuProps: {
...fieldProps.SelectProps?.MenuProps,
disablePortal: props.disablePortal,
},
}
}

if (render) return render(fieldProps)
return (
Expand Down Expand Up @@ -301,4 +310,5 @@ FormField.propTypes = {
clientSideFilter: p.bool,
disableCloseOnSelect: p.bool,
optionsLimit: p.number,
disablePortal: p.bool,
}
8 changes: 4 additions & 4 deletions web/src/app/storybook/defaultDestTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DestinationTypeInfo } from '../../schema'
export const destTypes: DestinationTypeInfo[] = [
{
type: 'single-field',
name: 'Single Field Destination Type',
name: 'Single Field',
enabled: true,
disabledMessage: 'Single field destination type must be configured.',
userDisclaimer: '',
Expand Down Expand Up @@ -31,7 +31,7 @@ export const destTypes: DestinationTypeInfo[] = [
},
{
type: 'triple-field',
name: 'Multi Field Destination Type',
name: 'Multi Field',
enabled: true,
disabledMessage: 'Multi field destination type must be configured.',
userDisclaimer: '',
Expand Down Expand Up @@ -111,7 +111,7 @@ export const destTypes: DestinationTypeInfo[] = [
},
{
type: 'supports-status',
name: 'Single Field Destination Type',
name: 'Single With Status',
enabled: true,
disabledMessage: 'Single field destination type must be configured.',
userDisclaimer: '',
Expand Down Expand Up @@ -139,7 +139,7 @@ export const destTypes: DestinationTypeInfo[] = [
},
{
type: 'required-status',
name: 'Single Field Destination Type',
name: 'Single With Required Status',
enabled: true,
disabledMessage: 'Single field destination type must be configured.',
userDisclaimer: '',
Expand Down
22 changes: 20 additions & 2 deletions web/src/app/users/UserContactMethodCreateDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { useConfigValue } from '../util/RequireConfig'
import { Dialog, DialogTitle, DialogActions, Button } from '@mui/material'
import DialogContentError from '../dialogs/components/DialogContentError'
import { ContactMethodType } from '../../schema'
import { useExpFlag } from '../util/useExpFlag'
import UserContactMethodCreateDialogDest from './UserContactMethodCreateDialogDest'

type Value = {
name: string
Expand Down Expand Up @@ -36,12 +38,16 @@ const userConflictQuery = gql`

const noSuspense = { suspense: false }

export default function UserContactMethodCreateDialog(props: {
type UserContactMethodCreateDialogProps = {
userID: string
onClose: (contactMethodID?: string) => void
title?: string
subtitle?: string
}): React.ReactNode {
}

function UserContactMethodCreateDialog(
props: UserContactMethodCreateDialogProps,
): React.ReactNode {
const [allowSV, allowE, allowW, allowS] = useConfigValue(
'Twilio.Enable',
'SMTP.Enable',
Expand Down Expand Up @@ -154,3 +160,15 @@ export default function UserContactMethodCreateDialog(props: {
/>
)
}

export default function UserContactMethodCreateDialogSwitch(
props: UserContactMethodCreateDialogProps,
): React.ReactNode {
const isDestTypesSet = useExpFlag('dest-types')

if (isDestTypesSet) {
return <UserContactMethodCreateDialogDest {...props} />
}

return <UserContactMethodCreateDialog {...props} />
}
Loading
Loading