Skip to content

Commit

Permalink
dest/graphql: normalize schema fields (#3703)
Browse files Browse the repository at this point in the history
* convert comments to description strings

* fix missing text on label

* update label and search select fields

* update UI for schema changes
  • Loading branch information
mastercactapus authored Feb 23, 2024
1 parent 91fc3a7 commit ee523ba
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 186 deletions.
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 @@ -301,8 +301,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 @@ -320,8 +319,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 @@ -338,8 +336,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 @@ -357,8 +354,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 @@ -376,11 +372,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 @@ -394,11 +389,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 @@ -408,19 +402,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

0 comments on commit ee523ba

Please sign in to comment.