Skip to content

Commit 2d6626d

Browse files
authored
PLU-477: fix slack bot display name should be optional (#1042)
1 parent f5697a1 commit 2d6626d

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

gql-codegen.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ const config: CodegenConfig = {
3737
output: 'type-fest#JsonObject',
3838
},
3939
},
40-
JSON: {
40+
JSONPrimitive: {
4141
type: {
42-
input: 'type-fest#JsonValue',
43-
output: 'type-fest#JsonValue',
42+
input: 'type-fest#JsonPrimitive',
43+
output: 'type-fest#JsonPrimitive',
4444
},
4545
},
4646
Any: {
@@ -117,7 +117,7 @@ const config: CodegenConfig = {
117117
scalars: {
118118
// Use type-fest's JSON types in generated code, as they're nice.
119119
JSONObject: 'type-fest#JsonObject',
120-
JSON: 'type-fest#JsonValue',
120+
JSONPrimitive: 'type-fest#JsonPrimitive',
121121
Any: 'any',
122122
},
123123
},

packages/backend/src/apps/slack/actions/send-a-message-to-channel/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const action: IRawAction = {
3838
label: 'Send as a bot?',
3939
key: 'sendAsBot',
4040
type: 'boolean-radio' as const,
41-
required: false,
41+
required: true,
4242
value: false,
4343
description:
4444
'If you choose no, this message will appear to come from you. Direct messages are always sent by bots.',
@@ -47,11 +47,16 @@ const action: IRawAction = {
4747
label: 'Bot name',
4848
key: 'botName',
4949
type: 'string' as const,
50-
required: true,
50+
required: false,
5151
value: 'Plumber',
5252
description:
5353
'Specify the bot name which appears as a bold username above the message inside Slack. Defaults to Plumber.',
5454
variables: true,
55+
hiddenIf: {
56+
fieldKey: 'sendAsBot',
57+
op: 'equals',
58+
fieldValue: false,
59+
},
5560
},
5661
{
5762
label: 'Bot icon',
@@ -61,6 +66,11 @@ const action: IRawAction = {
6166
description:
6267
'Either an image url or an emoji available to your team (surrounded by :). For example, https://example.com/icon_256.png or :robot_face:',
6368
variables: true,
69+
hiddenIf: {
70+
fieldKey: 'sendAsBot',
71+
op: 'equals',
72+
fieldValue: false,
73+
},
6474
},
6575
],
6676

packages/backend/src/apps/slack/actions/send-a-message-to-channel/post-message.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const postMessage = async ($: IGlobalVariable) => {
2424
}
2525

2626
if (sendAsBot) {
27-
data.username = botName
27+
// somehow slack doesn't recognise '0' as a valid username
28+
data.username = !botName || botName === '0' ? 'Plumber' : botName
2829
try {
2930
// challenging the input to check if it is a URL!
3031
new URL(botIcon)

packages/backend/src/graphql/schema.graphql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ enum FieldVisibilityOp {
137137
type FieldVisibilityCondition {
138138
op: FieldVisibilityOp!
139139
fieldKey: String
140-
fieldValue: String
140+
fieldValue: JSONPrimitive
141141
}
142142

143143
enum SetupMessageVariant {
@@ -559,6 +559,7 @@ input BulkRetryExecutionsInput {
559559
The `JSONObject` scalar type represents JSON objects as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).
560560
"""
561561
scalar JSONObject
562+
scalar JSONPrimitive
562563
scalar Any
563564

564565
input PreviousStepInput {

packages/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ interface IFieldComparativeVisibilityCondition {
247247
op: Extract<FieldVisibilityOp, 'equals' | 'not_equals'>
248248

249249
fieldKey: string
250-
fieldValue: string
250+
fieldValue?: IJSONPrimitive
251251
}
252252

253253
export type IFieldVisibilityCondition =

0 commit comments

Comments
 (0)