@bigbinary/neeto-slack-frontend 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,452 @@
1
+ @bigbinary/neeto-slack-frontend
2
+
3
+ UI for slack integration for all neeto products.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ yarn add @bigbinary/neeto-slack-frontend
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Available components:
14
+
15
+ - [Connect](#connect)
16
+ - [Configure](#configure)
17
+ - [Finish](#finish)
18
+
19
+ View the [example app](./example/src/App.jsx) to see usage.
20
+
21
+ ### Connect
22
+
23
+ ```js
24
+ const handleRedirect = () => {
25
+ window.location.assign(slackAuthorizationUrl);
26
+ };
27
+
28
+ return(
29
+ <Connect handleRedirectToSlack={handleRedirect} />;
30
+ );
31
+ ```
32
+
33
+ <table>
34
+ <thead>
35
+ <tr>
36
+ <th>
37
+
38
+ Prop
39
+
40
+ </th>
41
+ <th>
42
+
43
+ Type
44
+
45
+ </th>
46
+ <th>
47
+
48
+ Description
49
+
50
+ </th>
51
+ </tr>
52
+ </thead>
53
+ <tbody>
54
+
55
+ <tr>
56
+ <td style="vertical-align: top;">
57
+
58
+ handleRedirectToSlack
59
+
60
+ </td>
61
+ <td style="vertical-align: top;">
62
+
63
+ Function
64
+
65
+ </td>
66
+ <td style="vertical-align: top;">
67
+
68
+ Handles the redirect to the slack OAuth url
69
+
70
+ </td>
71
+ </tr>
72
+ <tr></tr>
73
+ </tbody>
74
+ </table>
75
+
76
+ ### Configure
77
+
78
+ ```js
79
+ const CONFIGURE_FORM_INITIAL_VALUES = {
80
+ channels: [
81
+ { label: "general", value: "K87KJHKS987" },
82
+ { label: "hq", value: "IJHKJ76889H" },
83
+ ],
84
+ selectedChannel: { label: "general", value: "K87KJHKS987" },
85
+ name: "",
86
+ };
87
+
88
+ const { slack, handleSubmit, isSubmitting } = useSlackApi();
89
+ const CONFIGURE_FORM_VALIDATION_SCHEMA = {
90
+ name: yup.string().required(),
91
+ };
92
+
93
+ return (
94
+ <Configure
95
+ teamName={slack.teamName}
96
+ initialFormValues={CONFIGURE_FORM_INITIAL_VALUES}
97
+ handleSubmit={handleSubmit}
98
+ isSubmitting={isSubmitting}
99
+ className="neeto-ui-my-2"
100
+ validationSchema={CONFIGURE_FORM_VALIDATION_SCHEMA}
101
+ >
102
+ <Input name="name" className="neeto-ui-my-2" />
103
+ </Configure>;
104
+ );
105
+ ```
106
+
107
+ <table>
108
+ <thead>
109
+ <tr>
110
+ <th>
111
+
112
+ Prop
113
+
114
+ </th>
115
+ <th>
116
+
117
+ Type
118
+
119
+ </th>
120
+ <th>
121
+
122
+ Description
123
+
124
+ </th>
125
+ </tr>
126
+ </thead>
127
+ <tbody>
128
+
129
+ <tr>
130
+ <td style="vertical-align: top;">
131
+
132
+ children
133
+
134
+ </td>
135
+ <td style="vertical-align: top;">
136
+
137
+ Function | JSX.Element
138
+
139
+ </td>
140
+ <td style="vertical-align: top;">
141
+
142
+ Extra form fields to be included in the `Configure` page
143
+
144
+ </td>
145
+ </tr>
146
+ <tr></tr>
147
+ <tr>
148
+ <td style="vertical-align: top;">
149
+
150
+ teamName
151
+
152
+ </td>
153
+ <td style="vertical-align: top;">
154
+
155
+ String
156
+
157
+ </td>
158
+ <td style="vertical-align: top;">
159
+
160
+ Slack team name to be displayed.
161
+
162
+ </td>
163
+ </tr>
164
+ <tr></tr>
165
+ <tr>
166
+ <td style="vertical-align: top;">
167
+
168
+ initialFormValues
169
+
170
+ </td>
171
+ <td style="vertical-align: top;">
172
+
173
+ Object
174
+
175
+ </td>
176
+ <td style="vertical-align: top;">
177
+
178
+ Initial form values for formik. <br/> (Note: Include channels array &
179
+ selectedChannel value) <br/> [Example](./example/src/constants.js)
180
+
181
+ </td>
182
+ </tr>
183
+ <tr></tr>
184
+ <tr>
185
+ <td style="vertical-align: top;">
186
+
187
+ handleSubmit
188
+
189
+ </td>
190
+ <td style="vertical-align: top;">
191
+
192
+ Function
193
+
194
+ </td>
195
+ <td style="vertical-align: top;">
196
+
197
+ Handle formik submit.
198
+
199
+ </td>
200
+ </tr>
201
+ <tr></tr>
202
+ <tr>
203
+ <td style="vertical-align: top;">
204
+
205
+ isSubmitting
206
+
207
+ </td>
208
+ <td style="vertical-align: top;">
209
+
210
+ bool
211
+
212
+ </td>
213
+ <td style="vertical-align: top;">
214
+
215
+ Boolean which is set when submitting the form.
216
+
217
+ </td>
218
+ </tr>
219
+ <tr></tr>
220
+ <tr>
221
+ <td style="vertical-align: top;">
222
+
223
+ className?
224
+
225
+ </td>
226
+ <td style="vertical-align: top;">
227
+
228
+ String
229
+
230
+ </td>
231
+ <td style="vertical-align: top;">
232
+
233
+ Custom classnames to be applied to Configure component
234
+
235
+ </td>
236
+ </tr>
237
+ <tr></tr>
238
+ <tr>
239
+ <td style="vertical-align: top;">
240
+
241
+ validationSchema
242
+
243
+ </td>
244
+ <td style="vertical-align: top;">
245
+
246
+ Object
247
+
248
+ </td>
249
+ <td style="vertical-align: top;">
250
+
251
+ Validation schema for fields using yup.<br/> (Note: No need to include
252
+ selectedChannel validation. Also no need to wrap validationSchema in
253
+ yup.object().shape({..}))<br/> [Example](./example/src/constants.js)
254
+
255
+ </td>
256
+ </tr>
257
+ <tr></tr>
258
+ </tbody>
259
+ </table>
260
+
261
+ ### Finish
262
+
263
+ ```js
264
+ const selectedChannel = "General";
265
+ const { configuration } = useSlackApi();
266
+
267
+ return (
268
+ <Finish
269
+ selectedChannel={selectedChannel}
270
+ teamName={configuration.teamName}
271
+ otherFields={[
272
+ {
273
+ name: "Update type",
274
+ value: configuration.notificationKind,
275
+ },
276
+ ]}
277
+ onBack={() => setActiveTab("configure")}
278
+ onClose={onClose}
279
+ />
280
+ );
281
+ ```
282
+
283
+ <table>
284
+ <thead>
285
+ <tr>
286
+ <th>
287
+
288
+ Prop
289
+
290
+ </th>
291
+ <th>
292
+
293
+ Type
294
+
295
+ </th>
296
+ <th>
297
+
298
+ Description
299
+
300
+ </th>
301
+ </tr>
302
+ </thead>
303
+ <tbody>
304
+
305
+ <tr>
306
+ <td style="vertical-align: top;">
307
+
308
+ children
309
+
310
+ </td>
311
+ <td style="vertical-align: top;">
312
+
313
+ JSX.Element
314
+
315
+ </td>
316
+ <td style="vertical-align: top;">
317
+
318
+ Extra form fields to be included in the Finish page
319
+
320
+ </td>
321
+ </tr>
322
+ <tr></tr>
323
+ <tr>
324
+ <td style="vertical-align: top;">
325
+
326
+ onBack
327
+
328
+ </td>
329
+ <td style="vertical-align: top;">
330
+
331
+ Function
332
+
333
+ </td>
334
+ <td style="vertical-align: top;">
335
+
336
+ Function that handles redirect to Configure page
337
+
338
+ </td>
339
+ </tr>
340
+ <tr></tr>
341
+ <tr>
342
+ <td style="vertical-align: top;">
343
+
344
+ onClose
345
+
346
+ </td>
347
+ <td style="vertical-align: top;">
348
+
349
+ Function
350
+
351
+ </td>
352
+ <td style="vertical-align: top;">
353
+
354
+ Function that handles closing of the modal
355
+
356
+ </td>
357
+ </tr>
358
+ <tr></tr>
359
+ <tr>
360
+ <td style="vertical-align: top;">
361
+
362
+ selectedChannel
363
+
364
+ </td>
365
+ <td style="vertical-align: top;">
366
+
367
+ String
368
+
369
+ </td>
370
+ <td style="vertical-align: top;">
371
+
372
+ Selected slack channel name
373
+
374
+ </td>
375
+ </tr>
376
+ <tr></tr>
377
+ <tr>
378
+ <td style="vertical-align: top;">
379
+
380
+ teamName
381
+
382
+ </td>
383
+ <td style="vertical-align: top;">
384
+
385
+ String
386
+
387
+ </td>
388
+ <td style="vertical-align: top;">
389
+
390
+ Slack team name to be displayed
391
+
392
+ </td>
393
+ </tr>
394
+ <tr></tr>
395
+ <tr>
396
+ <td style="vertical-align: top;">
397
+
398
+ otherFields
399
+
400
+ </td>
401
+ <td style="vertical-align: top;">
402
+
403
+ Array
404
+
405
+ </td>
406
+ <td style="vertical-align: top;">
407
+
408
+ Extra fields that need to be displayed in the finish page.
409
+ [Example](./example/src/App.js)
410
+
411
+ </td>
412
+ </tr>
413
+ <tr></tr>
414
+ </tbody>
415
+ </table>
416
+
417
+ ## Development
418
+
419
+ Install all the dependencies by executing the following command
420
+
421
+ ```bash
422
+ yarn install
423
+ ```
424
+
425
+ ### Using example app
426
+
427
+ Start the development server using the `yarn start` command. Development server
428
+ will run the example app using webpack.
429
+
430
+ ### Using host application
431
+
432
+ 1. Clone this repository.
433
+ 2. Run `yarn install` to download the dependencies and setup the development
434
+ environment.
435
+ 3. Have a host application ready.
436
+ 4. Run `yarn build --watch` to automatically transpile code as you save the
437
+ file. You can omit the `--watch` flag if you want to run the build only once.
438
+ 5. In a different terminal, run `yalc publish` to publish the
439
+ neeto-slack-frontend to the local yalc store.
440
+ 6. Run `yalc add @bigbinary/neeto-slack-frontend` to install the
441
+ neeto-slack-frontend to the host application.
442
+ 7. After making necessary changes to `neeto-slack-frontend`, run `yalc push` to
443
+ push the changes to the host application (assuming that you are in watch mode
444
+ and the changes are bundled automatically). Restart webpack-dev-server in
445
+ host if changes are not applied.
446
+ 8. Video explanation on how to use yalc: https://vimeo.com/722958162/9e931b640c
447
+
448
+ ## Building
449
+
450
+ The neetoSlack package gets auto-published to npm for every new merge to the
451
+ main branch. You can checkout the publish workflow in git actions to get a live
452
+ update.