Skip to content

Commit 71cbc49

Browse files
feat: update notebook slack alert with dropdown color selector (#3823)
* chore: update clockface version * feat: replace ColorPicker with CreatableTypeAheadDropdown for slack message color * chore: fix clockface classname in cypress test
1 parent a1a3951 commit 71cbc49

File tree

5 files changed

+35
-14
lines changed

5 files changed

+35
-14
lines changed

cypress/e2e/shared/labels.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe('labels', () => {
9090
cy.getByTestID('color-picker--input')
9191
.parent()
9292
.parent()
93-
.children('div.cf-color-picker--selected')
93+
.children('div.cf-color-preview')
9494
.invoke('attr', 'style')
9595
.should('equal', 'background-color: rgb(255, 210, 85);')
9696

@@ -116,7 +116,7 @@ describe('labels', () => {
116116
cy.getByTestID('color-picker--input')
117117
.parent()
118118
.parent()
119-
.children('div.cf-color-picker--selected')
119+
.children('div.cf-color-preview')
120120
.invoke('attr', 'style')
121121
.should('equal', hex2BgColor(hex))
122122
})
@@ -127,7 +127,7 @@ describe('labels', () => {
127127
cy.getByTestID('color-picker--input')
128128
.parent()
129129
.parent()
130-
.children('div.cf-color-picker--selected')
130+
.children('div.cf-color-preview')
131131
.invoke('attr', 'style')
132132
.should('equal', hex2BgColor(newLabelColor))
133133

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
},
157157
"dependencies": {
158158
"@docsearch/react": "^3.0.0-alpha.37",
159-
"@influxdata/clockface": "^3.1.14",
159+
"@influxdata/clockface": "^3.2.1",
160160
"@influxdata/flux-lsp-browser": "^0.8.0",
161161
"@influxdata/giraffe": "^2.24.1",
162162
"@influxdata/influxdb-templates": "0.9.0",

src/flows/pipes/Notification/endpoints/Slack/view.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React, {FC, useContext} from 'react'
22
import {
3-
ColorPicker,
3+
ColorPreview,
4+
CreatableTypeAheadDropdown,
5+
FlexBox,
46
Form,
57
Input,
68
InputType,
@@ -10,6 +12,11 @@ import {
1012
import {PipeContext} from 'src/flows/context/pipe'
1113
import {EndpointProps} from 'src/types'
1214

15+
/** The hex colors are suggested from here
16+
* https://github.com/influxdata/ui/issues/2572
17+
*/
18+
const suggestedColors = ['#DC4E58', '#FFB94A', '#2FA74D', '#0098F0', '#8E1FC3']
19+
1320
const View: FC<EndpointProps> = () => {
1421
const {data, update} = useContext(PipeContext)
1522

@@ -64,7 +71,21 @@ const View: FC<EndpointProps> = () => {
6471
/>
6572
</Form.Element>
6673
<Form.Element label="Message Color">
67-
<ColorPicker color={data.endpointData.color} onChange={updateColor} />
74+
<CreatableTypeAheadDropdown
75+
selectedOption={data.endpointData.color}
76+
onSelect={updateColor}
77+
options={suggestedColors}
78+
placeholder="#000000"
79+
inputColorPreviewOn={true}
80+
customizedDropdownItem={displayText => (
81+
<FlexBox>
82+
<ColorPreview color={displayText} />
83+
<div className="slack-message-color--dropdown-item">
84+
{displayText}
85+
</div>
86+
</FlexBox>
87+
)}
88+
/>
6889
</Form.Element>
6990
</div>
7091
)

src/flows/pipes/Notification/styles.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
margin-right: 0px;
2222
}
2323

24-
.cf-color-picker--selected {
25-
top: 19px;
26-
}
27-
2824
.cf-color-picker--form .cf-input-field {
2925
height: 38px;
3026
font-size: 14px;
@@ -55,3 +51,7 @@
5551
flex: 1;
5652
max-width: 14%;
5753
}
54+
55+
.slack-message-color--dropdown-item {
56+
padding-left: 26px;
57+
}

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,10 +1187,10 @@
11871187
gud "^1.0.0"
11881188
warning "^4.0.3"
11891189

1190-
"@influxdata/clockface@^3.1.14":
1191-
version "3.1.14"
1192-
resolved "https://registry.yarnpkg.com/@influxdata/clockface/-/clockface-3.1.14.tgz#835ed0f66a97c10c7b1977abc3adc292c26a502e"
1193-
integrity sha512-ESpTIZh87r3zVy5kb4aST0CQHjiZBZX1JlrsDjbOk6FGJwGyZz+n74KqnPQmMt+EKKDO70vOH3OJf1I8qE9X5Q==
1190+
"@influxdata/clockface@^3.2.1":
1191+
version "3.2.1"
1192+
resolved "https://registry.yarnpkg.com/@influxdata/clockface/-/clockface-3.2.1.tgz#e31ef829a910564e1108ef6e92a1255ab3b41513"
1193+
integrity sha512-RGqwnfTa2QDu9dEDJcKLsH8RaYtJtzFqy+FaAziQ5IcYZk+j8+BjKowrLfwxfwsp3DjhMnn8fCQgWaiCoK/RrQ==
11941194

11951195
"@influxdata/flux-lsp-browser@^0.8.0":
11961196
version "0.8.0"

0 commit comments

Comments
 (0)