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

dest/graphql: normalize schema fields #3703

Merged
merged 5 commits into from
Feb 23, 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
115 changes: 28 additions & 87 deletions graphql2/generated.go

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

11 changes: 3 additions & 8 deletions graphql2/graph/destinations.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,9 @@ type DestinationFieldConfig {
fieldID: ID!

"""
user-friendly label
user-friendly label (should be singular)
"""
labelSingular: String!

"""
user-friendly plural label
"""
labelPlural: String!
label: String!

"""
user-friendly helper text for input fields (i.e., "Enter a phone number")
Expand Down Expand Up @@ -256,7 +251,7 @@ type DestinationFieldConfig {
"""
if true, the destination can be selected via search
"""
isSearchSelectable: Boolean!
supportsSearch: Boolean!

"""
if true, the destination type supports validation
Expand Down
48 changes: 20 additions & 28 deletions graphql2/graphqlapp/destinationtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ func (q *Query) DestinationTypes(ctx context.Context) ([]graphql2.DestinationTyp
IsContactMethod: true,
RequiredFields: []graphql2.DestinationFieldConfig{{
FieldID: fieldPhoneNumber,
LabelSingular: "Phone Number",
LabelPlural: "Phone Numbers",
Label: "Phone Number",
Hint: "Include country code e.g. +1 (USA), +91 (India), +44 (UK)",
PlaceholderText: "11235550123",
Prefix: "+",
Expand All @@ -220,8 +219,7 @@ func (q *Query) DestinationTypes(ctx context.Context) ([]graphql2.DestinationTyp
SupportsStatusUpdates: true,
RequiredFields: []graphql2.DestinationFieldConfig{{
FieldID: fieldPhoneNumber,
LabelSingular: "Phone Number",
LabelPlural: "Phone Numbers",
Label: "Phone Number",
Hint: "Include country code e.g. +1 (USA), +91 (India), +44 (UK)",
PlaceholderText: "11235550123",
Prefix: "+",
Expand All @@ -238,8 +236,7 @@ func (q *Query) DestinationTypes(ctx context.Context) ([]graphql2.DestinationTyp
DisabledMessage: "SMTP must be configured by an administrator",
RequiredFields: []graphql2.DestinationFieldConfig{{
FieldID: fieldEmailAddress,
LabelSingular: "Email Address",
LabelPlural: "Email Addresses",
Label: "Email Address",
PlaceholderText: "foobar@example.com",
InputType: "email",
SupportsValidation: true,
Expand All @@ -257,8 +254,7 @@ func (q *Query) DestinationTypes(ctx context.Context) ([]graphql2.DestinationTyp
DisabledMessage: "Webhooks must be enabled by an administrator",
RequiredFields: []graphql2.DestinationFieldConfig{{
FieldID: fieldWebhookURL,
LabelSingular: "Webhook URL",
LabelPlural: "Webhook URLs",
Label: "Webhook URL",
PlaceholderText: "https://example.com",
InputType: "url",
Hint: "Webhook Documentation",
Expand All @@ -276,11 +272,10 @@ func (q *Query) DestinationTypes(ctx context.Context) ([]graphql2.DestinationTyp
DisabledMessage: "Slack must be enabled by an administrator",
RequiredFields: []graphql2.DestinationFieldConfig{{
FieldID: fieldSlackUserID,
LabelSingular: "Slack User",
LabelPlural: "Slack Users",
Label: "Slack User",
PlaceholderText: "member ID",
InputType: "text",
// IsSearchSelectable: true, // TODO: implement search select functionality for users
// supportsSearch: true, // TODO: implement search select functionality for users
Hint: `Go to your Slack profile, click the three dots, and select "Copy member ID".`,
}},
},
Expand All @@ -294,11 +289,10 @@ func (q *Query) DestinationTypes(ctx context.Context) ([]graphql2.DestinationTyp
StatusUpdatesRequired: true,
DisabledMessage: "Slack must be enabled by an administrator",
RequiredFields: []graphql2.DestinationFieldConfig{{
FieldID: fieldSlackChanID,
LabelSingular: "Slack Channel",
LabelPlural: "Slack Channels",
InputType: "text",
IsSearchSelectable: true,
FieldID: fieldSlackChanID,
Label: "Slack Channel",
InputType: "text",
SupportsSearch: true,
}},
},
{
Expand All @@ -308,19 +302,17 @@ func (q *Query) DestinationTypes(ctx context.Context) ([]graphql2.DestinationTyp
IsSchedOnCallNotify: true,
DisabledMessage: "Slack must be enabled by an administrator",
RequiredFields: []graphql2.DestinationFieldConfig{{
FieldID: fieldSlackUGID,
LabelSingular: "User Group",
LabelPlural: "User Groups",
InputType: "text",
IsSearchSelectable: true,
Hint: "The selected group's membership will be replaced/set to the schedule's on-call user(s).",
FieldID: fieldSlackUGID,
Label: "User Group",
InputType: "text",
SupportsSearch: true,
Hint: "The selected group's membership will be replaced/set to the schedule's on-call user(s).",
}, {
FieldID: fieldSlackChanID,
LabelSingular: "Slack Channel (for errors)",
LabelPlural: "Slack Channels (for errors)",
InputType: "text",
IsSearchSelectable: true,
Hint: "If the user group update fails, an error will be posted to this channel.",
FieldID: fieldSlackChanID,
Label: "Slack Channel (for errors)",
InputType: "text",
SupportsSearch: true,
Hint: "If the user group update fails, an error will be posted to this channel.",
}},
},
}
Expand Down
8 changes: 3 additions & 5 deletions graphql2/models_gen.go

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

2 changes: 1 addition & 1 deletion web/src/app/selection/DestinationField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function DestinationField(
)?.message || '',
)

if (field.isSearchSelectable)
if (field.supportsSearch)
return (
<Grid key={field.fieldID} item xs={12} sm={12} md={12}>
<DestinationSearchSelect
Expand Down
Loading
Loading