@bigbinary/neeto-rules-frontend 2.3.1 → 2.4.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 +342 -151
- package/app/javascript/src/translations/en.json +15 -2
- package/dist/NeetoRules.js +106 -9161
- package/dist/NeetoRules.js.map +1 -1
- package/dist/NeetoRulesForm.js +86 -559
- package/dist/NeetoRulesForm.js.map +1 -1
- package/dist/RulePreview.js +31 -7
- package/dist/RulePreview.js.map +1 -1
- package/dist/cjs/NeetoRules.js +154 -9225
- package/dist/cjs/NeetoRules.js.map +1 -1
- package/dist/cjs/NeetoRulesForm.js +336 -800
- package/dist/cjs/NeetoRulesForm.js.map +1 -1
- package/dist/cjs/RulePreview.js +42 -15
- package/dist/cjs/RulePreview.js.map +1 -1
- package/dist/cjs/index.js +408 -18
- package/dist/cjs/index.js.map +1 -1
- package/dist/index.js +396 -18
- package/dist/index.js.map +1 -1
- package/dist/useUtilityStore-e4b36ba2.js.map +1 -1
- package/dist/useUtilityStore-ee4f96f8.js.map +1 -1
- package/dist/utils-866e8e3b.js +23 -0
- package/dist/utils-866e8e3b.js.map +1 -0
- package/dist/utils-cd8f199f.js +26 -0
- package/dist/utils-cd8f199f.js.map +1 -0
- package/package.json +103 -83
- package/types.d.ts +39 -0
- package/dist/toConsumableArray-71e2b184.js +0 -58
- package/dist/toConsumableArray-71e2b184.js.map +0 -1
- package/dist/toConsumableArray-ee25f277.js +0 -53
- package/dist/toConsumableArray-ee25f277.js.map +0 -1
- package/dist/utils-249a1c9a.js +0 -119
- package/dist/utils-249a1c9a.js.map +0 -1
- package/dist/utils-ca50bfc9.js +0 -129
- package/dist/utils-ca50bfc9.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
# neeto-rules-nano
|
|
2
2
|
|
|
3
|
-
The `neeto-rules-nano` facilitates the management of automation rules within
|
|
3
|
+
The `neeto-rules-nano` facilitates the management of automation rules within
|
|
4
|
+
neeto applications. The nano exports `@bigbinary/neeto-rules-frontend` NPM
|
|
5
|
+
package and `neeto-rules-engine` Rails engine.
|
|
4
6
|
|
|
5
7
|
## Contents
|
|
6
8
|
|
|
7
9
|
1. [Development with Host Application](#development-with-host-application)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
10
|
+
- [Engine](#engine)
|
|
11
|
+
- [Installation](#installation)
|
|
12
|
+
- [Frontend package](#frontend-package)
|
|
13
|
+
- [Installation](#installation-1)
|
|
14
|
+
- [Instructions for development](#instructions-for-development)
|
|
15
|
+
- [Components](#components)
|
|
16
|
+
- [NeetoRules](#1-neetorules)
|
|
17
|
+
- [NeetoRulesForm](#2-neetorulesform)
|
|
18
|
+
- [Field components for NeetoRulesForm](#3-field-components-for-neetorulesform)
|
|
19
|
+
- [InputField](#31-inputfield)
|
|
20
|
+
- [TextareaField](#32-textareafield)
|
|
21
|
+
- [SelectField](#33-selectfield)
|
|
22
|
+
- [MultiSelectField](#34-multiselectfield)
|
|
23
|
+
- [RadioField](#35-radiofield)
|
|
24
|
+
- [EventConditions](#36-eventconditions)
|
|
25
|
+
- [Conditions](#37-conditions)
|
|
26
|
+
- [Actions](#38-actions)
|
|
27
|
+
- [Custom action component](#39-custom-action-component)
|
|
28
|
+
- [RulePreview](#4-rulepreview)
|
|
29
|
+
- [Constants](#constants)
|
|
30
|
+
- [AUTOMATION_RULES_QUERY_KEY](#1-automation-rules-query-key)
|
|
29
31
|
2. [Instructions for Publishing](#instructions-for-publishing)
|
|
30
32
|
|
|
31
33
|
## Development with Host Application
|
|
@@ -38,37 +40,38 @@ The Engine is used to manage automation rules feature within neeto applications.
|
|
|
38
40
|
|
|
39
41
|
1. Add this line to your application's Gemfile:
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
```ruby
|
|
44
|
+
source "NEETO_GEM_SERVER_URL" do
|
|
45
|
+
# ..existing gems
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
gem "neeto-rules-engine"
|
|
48
|
+
end
|
|
49
|
+
```
|
|
48
50
|
|
|
49
51
|
2. And then execute:
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
```ruby
|
|
54
|
+
bundle install
|
|
55
|
+
```
|
|
54
56
|
|
|
55
57
|
3. Add this line to your application's `config/routes.rb` file:
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
```ruby
|
|
60
|
+
mount NeetoRulesEngine::Engine => "/neeto_rules"
|
|
61
|
+
```
|
|
60
62
|
|
|
61
|
-
4. Run the following command to copy the migrations from the engine to the host
|
|
63
|
+
4. Run the following command to copy the migrations from the engine to the host
|
|
64
|
+
application:
|
|
62
65
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
```ruby
|
|
67
|
+
rails g neeto_rules_engine:install
|
|
68
|
+
```
|
|
66
69
|
|
|
67
70
|
5. Add the migrations to the database:
|
|
68
71
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
```ruby
|
|
73
|
+
bundle exec rails db:migrate
|
|
74
|
+
```
|
|
72
75
|
|
|
73
76
|
### Frontend package
|
|
74
77
|
|
|
@@ -82,7 +85,9 @@ yarn add @bigbinary/neeto-rules-frontend
|
|
|
82
85
|
|
|
83
86
|
### Instructions for development
|
|
84
87
|
|
|
85
|
-
Check the
|
|
88
|
+
Check the
|
|
89
|
+
[Frontend package development guide](https://neeto-engineering.neetokb.com/p/a-d34cb4b0)
|
|
90
|
+
for step-by-step instructions to develop the frontend package.
|
|
86
91
|
|
|
87
92
|
### Components
|
|
88
93
|
|
|
@@ -93,87 +98,100 @@ The `NeetoRules` component is used to add the dashboard for automation rules.
|
|
|
93
98
|

|
|
94
99
|
|
|
95
100
|
#### Props
|
|
101
|
+
|
|
96
102
|
1. `breadcrumbs`: Breadcrumbs for the header of the dashboard.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
2. `allowReordering`: To specify if the user can reorder the automation rules.
|
|
100
|
-
|
|
103
|
+
1. `text`: Text for breadcrumb item
|
|
104
|
+
2. `link`: Link to breadcrumb item
|
|
105
|
+
2. `allowReordering`: To specify if the user can reorder the automation rules.
|
|
106
|
+
(Boolean).
|
|
107
|
+
3. `helpPopoverProps`: To add help popover for the component. Refer
|
|
108
|
+
[HelpPopover component doc](https://neeto-molecules.neeto.com/?path=/docs/helppopover--docs).
|
|
109
|
+
NOTE: `href` from `helpLinkProps` will be used for displaying the link when
|
|
110
|
+
showing `NoData` component.
|
|
101
111
|
4. `rulesTableProps`: Props for the table in the dashboard:
|
|
102
|
-
1. `additionalColumns`: To add additional columns to the table. Refer [Table component doc](https://neeto-ui.neeto.com/?path=/docs/components-table--docs).
|
|
103
|
-
|
|
104
|
-
```jsx
|
|
105
|
-
const additionalColumns = [
|
|
106
|
-
{
|
|
107
|
-
title: "Operated on",
|
|
108
|
-
dataIndex: "recentlyModifiedTickets",
|
|
109
|
-
width: 160,
|
|
110
|
-
description: "Number of tickets the rule has acted upon in the last 7 days",
|
|
111
|
-
render: recentlyModifiedTickets => (
|
|
112
|
-
<div className="text-center">{recentlyModifiedTickets}</div>
|
|
113
|
-
),
|
|
114
|
-
},
|
|
115
|
-
];
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
2. `moreDropdownItems`: Array of dropdown items to be added to the MoreDropdown component in the table. Refer [MoreDropdown in table doc](https://neeto-ui.neeto.com/?path=/docs/components-table--docs).
|
|
119
|
-
|
|
120
|
-
```jsx
|
|
121
|
-
const moreDropdownItems = [
|
|
122
|
-
{
|
|
123
|
-
key: "view-matching-tickets",
|
|
124
|
-
label: "View matching rules",
|
|
125
|
-
// onClick callback receives the selected rule
|
|
126
|
-
onClick: rule => {
|
|
127
|
-
setSelectedRule(rule);
|
|
128
|
-
setShowMatchingTickets(true);
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
];
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
3. `onPreview`: The callback function to call when the preview is clicked.
|
|
135
|
-
```jsx
|
|
136
|
-
const onPreview = id => {
|
|
137
|
-
setRuleId(id);
|
|
138
|
-
};
|
|
139
|
-
```
|
|
140
112
|
|
|
113
|
+
1. `additionalColumns`: To add additional columns to the table. Refer
|
|
114
|
+
[Table component doc](https://neeto-ui.neeto.com/?path=/docs/components-table--docs).
|
|
115
|
+
|
|
116
|
+
```jsx
|
|
117
|
+
const additionalColumns = [
|
|
118
|
+
{
|
|
119
|
+
title: "Operated on",
|
|
120
|
+
dataIndex: "recentlyModifiedTickets",
|
|
121
|
+
width: 160,
|
|
122
|
+
description:
|
|
123
|
+
"Number of tickets the rule has acted upon in the last 7 days",
|
|
124
|
+
render: recentlyModifiedTickets => (
|
|
125
|
+
<div className="text-center">{recentlyModifiedTickets}</div>
|
|
126
|
+
),
|
|
127
|
+
},
|
|
128
|
+
];
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
2. `moreDropdownItems`: Array of dropdown items to be added to the
|
|
132
|
+
MoreDropdown component in the table. Refer
|
|
133
|
+
[MoreDropdown in table doc](https://neeto-ui.neeto.com/?path=/docs/components-table--docs).
|
|
134
|
+
|
|
135
|
+
```jsx
|
|
136
|
+
const moreDropdownItems = [
|
|
137
|
+
{
|
|
138
|
+
key: "view-matching-tickets",
|
|
139
|
+
label: "View matching rules",
|
|
140
|
+
// onClick callback receives the selected rule
|
|
141
|
+
onClick: rule => {
|
|
142
|
+
setSelectedRule(rule);
|
|
143
|
+
setShowMatchingTickets(true);
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
3. `onPreview`: The callback function to call when the preview is clicked.
|
|
150
|
+
|
|
151
|
+
```jsx
|
|
152
|
+
const onPreview = id => {
|
|
153
|
+
setRuleId(id);
|
|
154
|
+
};
|
|
155
|
+
```
|
|
141
156
|
|
|
142
157
|
5. `automationRulesPath`: The path for automation rules dashboard.
|
|
143
158
|
|
|
144
|
-
|
|
159
|
+
Following additional routes are considered by the component:
|
|
145
160
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
161
|
+
| Routes | Description |
|
|
162
|
+
| ---------------------------- | ---------------------------------------- |
|
|
163
|
+
| `{automationRulesPath}/edit` | Route to the rule edit form component. |
|
|
164
|
+
| `{automationRulesPath}/new` | Route to the rule create form component. |
|
|
150
165
|
|
|
151
166
|
6. `automationRulesEndpoint`: The endpoint for automation rules.
|
|
152
167
|
|
|
153
|
-
|
|
168
|
+
Following endpoints will be used by the component:
|
|
154
169
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
170
|
+
| Endpoint | Action | Description |
|
|
171
|
+
| ------------------------------------------- | --------- | ---------------------------------------------------------------------------------- |
|
|
172
|
+
| GET `{automationRulesEndpoint}` | `index` | To fetch the list of automation rules.(Same will be used for pagination/filtering) |
|
|
173
|
+
| POST `{automationRulesEndpoint}/{id}/clone` | `clone` | To create the clone of the automation rule. |
|
|
174
|
+
| PATCH `{automationRulesEndpoint}/{id}` | `update` | To update the status of the automation rule. |
|
|
175
|
+
| DELETE `{automationRulesEndpoint}/{id}` | `destroy` | To delete the automation rule. |
|
|
176
|
+
| PATCH `{automationRulesEndpoint}/reorder` | `reorder` | To reorder the automation rules. |
|
|
162
177
|
|
|
163
|
-
7.
|
|
164
|
-
|
|
165
|
-
|
|
178
|
+
7. `updateRule`: Object that define methods for update rule operation.
|
|
179
|
+
- `onSuccess`: Object for handling update rule success callback.
|
|
180
|
+
- `callback`: Function to be called on success. (Optional)
|
|
166
181
|
8. `deleteRule`: Object that define methods for delete rule operation.
|
|
167
|
-
|
|
168
|
-
|
|
182
|
+
- `onSuccess`: Object for handling delete rule success callback.
|
|
183
|
+
- `callback`: Function to be called on success. (Optional)
|
|
169
184
|
9. `cloneRule`: Object that define methods for clone rule operation.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
185
|
+
- `allowed`: To specify if the clone rule should be allowed, default `true`.
|
|
186
|
+
(Boolean)
|
|
187
|
+
- `onSuccess`: Object for handling clone rule success callback.
|
|
188
|
+
- `callback`: Function to be called on success. (Optional)
|
|
173
189
|
10. `reoderRules`: Function to be called on reorder success.
|
|
174
190
|
- `onSuccess`: Object for handling reorder rule success callback.
|
|
175
|
-
|
|
176
|
-
11. `headerProps`: Props for the header component. Refer
|
|
191
|
+
- `callback`: Function to be called on success. (Optional)
|
|
192
|
+
11. `headerProps`: Props for the header component. Refer
|
|
193
|
+
[Header component doc](https://neeto-molecules.neeto.com/?path=/docs/layouts-header--docs).
|
|
194
|
+
|
|
177
195
|
#### 2. `NeetoRulesForm`
|
|
178
196
|
|
|
179
197
|
<div align="center">
|
|
@@ -184,7 +202,9 @@ The `NeetoRules` component is used to add the dashboard for automation rules.
|
|
|
184
202
|
|
|
185
203
|
The `NeetoRulesForm` component is used to create and edit automation rules.
|
|
186
204
|
|
|
187
|
-
`NeetoRulesForm` accepts the following field types which is specified in the
|
|
205
|
+
`NeetoRulesForm` accepts the following field types which is specified in the
|
|
206
|
+
`initialProps`
|
|
207
|
+
([reference](https://github.com/bigbinary/neeto-desk-web/blob/c7ea475e0963cb4fa0831856c9545e1f697ca472/app/javascript/src/components/Automations/Form/constants.js#L43)):
|
|
188
208
|
|
|
189
209
|
1. text
|
|
190
210
|
2. long-text
|
|
@@ -195,7 +215,8 @@ The `NeetoRulesForm` component is used to create and edit automation rules.
|
|
|
195
215
|
7. condition
|
|
196
216
|
8. actions
|
|
197
217
|
|
|
198
|
-
> **Note:** The `NeetoRulesForm` component includes three fields by default with
|
|
218
|
+
> **Note:** The `NeetoRulesForm` component includes three fields by default with
|
|
219
|
+
> the following names: `name`(required), `description` and `status`.
|
|
199
220
|
|
|
200
221
|
#### Props
|
|
201
222
|
|
|
@@ -204,13 +225,23 @@ The `NeetoRulesForm` component is used to create and edit automation rules.
|
|
|
204
225
|
- `className`: To provide external classes to form.
|
|
205
226
|
- `handleSubmit`: The function to handle the form submission.
|
|
206
227
|
- `handleClose`: The function to handle the form close.
|
|
228
|
+
- `showStatusSwitch`: To specify whether the status switch should be shown or
|
|
229
|
+
not. It is `true` by default.
|
|
207
230
|
|
|
208
231
|
#### Usage
|
|
209
232
|
|
|
210
233
|
```jsx
|
|
211
234
|
import { NeetoRulesForm } from "@bigbinary/neeto-rules-frontend";
|
|
212
235
|
|
|
213
|
-
const {
|
|
236
|
+
const {
|
|
237
|
+
InputField,
|
|
238
|
+
TextareaField,
|
|
239
|
+
SelectField,
|
|
240
|
+
Events,
|
|
241
|
+
Card,
|
|
242
|
+
Conditions,
|
|
243
|
+
Actions,
|
|
244
|
+
} = NeetoRulesForm;
|
|
214
245
|
|
|
215
246
|
<NeetoRulesForm data={initialProps}>
|
|
216
247
|
{({ formattedValues, values, ...formikBag }) => (
|
|
@@ -225,7 +256,7 @@ const { InputField, TextareaField, SelectField, Events, Card, Conditions, Action
|
|
|
225
256
|
<Actions name="actions" data={initialProps} />
|
|
226
257
|
</>
|
|
227
258
|
)}
|
|
228
|
-
</NeetoRulesForm
|
|
259
|
+
</NeetoRulesForm>;
|
|
229
260
|
```
|
|
230
261
|
|
|
231
262
|
#### References
|
|
@@ -270,8 +301,10 @@ const initialProps = {
|
|
|
270
301
|
|
|
271
302
|
#### props
|
|
272
303
|
|
|
273
|
-
1. `name`: Name of the field. The name should be same as that in the
|
|
274
|
-
|
|
304
|
+
1. `name`: Name of the field. The name should be same as that in the
|
|
305
|
+
`initialProps`.
|
|
306
|
+
2. `data`: The same `initialProps` that is passed to data prop in
|
|
307
|
+
`NeetoRulesForm`.
|
|
275
308
|
3. `label`: Label for the field.
|
|
276
309
|
|
|
277
310
|
#### 3.2 `TextareaField`
|
|
@@ -295,11 +328,13 @@ const initialProps = {
|
|
|
295
328
|
|
|
296
329
|
#### props
|
|
297
330
|
|
|
298
|
-
1. `name`: Name of the field. The name should be same as that in the
|
|
299
|
-
|
|
331
|
+
1. `name`: Name of the field. The name should be same as that in the
|
|
332
|
+
`initialProps`.
|
|
333
|
+
2. `data`: The same `initialProps` that is passed as `data` prop in
|
|
334
|
+
`NeetoRulesForm`.
|
|
300
335
|
3. `label`: Label for the field.
|
|
301
336
|
|
|
302
|
-
####
|
|
337
|
+
#### 3.3 `SelectField`
|
|
303
338
|
|
|
304
339
|
```jsx
|
|
305
340
|
import { NeetoRulesForm } from "@bigbinary/neeto-rules-frontend";
|
|
@@ -321,11 +356,15 @@ const initialProps = {
|
|
|
321
356
|
|
|
322
357
|
#### props
|
|
323
358
|
|
|
324
|
-
1. `name`: Name of the field. The name should be same as that in the
|
|
325
|
-
|
|
359
|
+
1. `name`: Name of the field. The name should be same as that in the
|
|
360
|
+
`initialProps`.
|
|
361
|
+
2. `data`: The same `initialProps` that is passed to data prop in
|
|
362
|
+
`NeetoRulesForm`.
|
|
326
363
|
3. `label`: Label for the field.
|
|
327
|
-
4. `options`: Options for the dropdown. The options should be an array of
|
|
328
|
-
|
|
364
|
+
4. `options`: Options for the dropdown. The options should be an array of
|
|
365
|
+
objects with `label` and `value` keys. `[{label, value}]`.
|
|
366
|
+
5. `onChange`: Callback function that is called when the value of the dropdown
|
|
367
|
+
changes. `(value, setValue) => void` `setValue` is to set the new value.
|
|
329
368
|
|
|
330
369
|
#### 3.4 `MultiSelectField`
|
|
331
370
|
|
|
@@ -352,11 +391,15 @@ const initialProps = {
|
|
|
352
391
|
|
|
353
392
|
#### props
|
|
354
393
|
|
|
355
|
-
1. `name`: Name of the field. The name should be same as that in the
|
|
356
|
-
|
|
394
|
+
1. `name`: Name of the field. The name should be same as that in the
|
|
395
|
+
`initialProps`.
|
|
396
|
+
2. `data`: The same `initialProps` that is passed to data prop in
|
|
397
|
+
`NeetoRulesForm`.
|
|
357
398
|
3. `label`: Label for the field.
|
|
358
|
-
4. `options`: Options for the dropdown. The options should be an array of
|
|
359
|
-
|
|
399
|
+
4. `options`: Options for the dropdown. The options should be an array of
|
|
400
|
+
objects with `label` and `value` keys. `[{label, value}]`.
|
|
401
|
+
5. `onChange`: Callback function that is called when the value of the dropdown
|
|
402
|
+
changes. `(value, setValue) => void` `setValue` is to set the new value.
|
|
360
403
|
|
|
361
404
|
#### 3.5 `RadioField`
|
|
362
405
|
|
|
@@ -383,10 +426,13 @@ const initialProps = {
|
|
|
383
426
|
|
|
384
427
|
#### props
|
|
385
428
|
|
|
386
|
-
1. `name`: Name of the field. The name should be same as that in the
|
|
387
|
-
|
|
429
|
+
1. `name`: Name of the field. The name should be same as that in the
|
|
430
|
+
`initialProps`.
|
|
431
|
+
2. `data`: The same `initialProps` that is passed to data prop in
|
|
432
|
+
`NeetoRulesForm`.
|
|
388
433
|
3. `label`: Label for the field.
|
|
389
|
-
4. `options`: Options for the radio buttons. The options should be an array of
|
|
434
|
+
4. `options`: Options for the radio buttons. The options should be an array of
|
|
435
|
+
objects with `label` and `value` keys. `[{label, value}]`.
|
|
390
436
|
|
|
391
437
|
#### 3.6 `EventConditions`
|
|
392
438
|
|
|
@@ -481,14 +527,21 @@ const initialProps = {
|
|
|
481
527
|
|
|
482
528
|
#### props
|
|
483
529
|
|
|
484
|
-
1. `name`: Name of the field. The name should be same as that in the
|
|
485
|
-
|
|
530
|
+
1. `name`: Name of the field. The name should be same as that in the
|
|
531
|
+
`initialProps`.
|
|
532
|
+
2. `data`: The same `initialProps` that is passed to data prop in
|
|
533
|
+
NeetoRulesForm.
|
|
486
534
|
3. `label`: Label for the field.
|
|
487
|
-
4. `performerName`: Name of the performer field. The `performerName` should be
|
|
488
|
-
|
|
489
|
-
|
|
535
|
+
4. `performerName`: Name of the performer field. The `performerName` should be
|
|
536
|
+
same as that in the `initialProps`.
|
|
537
|
+
5. `conditionsName`: Name of the conditions field. The `conditionsName` should
|
|
538
|
+
be same as that in the `initialProps`.
|
|
539
|
+
6. `onSelectEvent`: `(name, selectedOption) => void`. This method will trigger
|
|
540
|
+
when we select an event option. The name is to refer the event in the formik
|
|
541
|
+
context.
|
|
490
542
|
|
|
491
|
-
Refer to the [EventCondition section](./docs/event-conditions.md) for more
|
|
543
|
+
Refer to the [EventCondition section](./docs/event-conditions.md) for more
|
|
544
|
+
information.
|
|
492
545
|
|
|
493
546
|
#### 3.7 `Conditions`
|
|
494
547
|
|
|
@@ -563,13 +616,22 @@ const initialProps = {
|
|
|
563
616
|
|
|
564
617
|
#### props
|
|
565
618
|
|
|
566
|
-
1. `name`: Name of the field. The name should be same as that in the
|
|
567
|
-
|
|
619
|
+
1. `name`: Name of the field. The name should be same as that in the
|
|
620
|
+
`initialProps`.
|
|
621
|
+
2. `data`: The same `initialProps` that is passed to data prop in
|
|
622
|
+
`NeetoRulesForm`.
|
|
568
623
|
3. `label`: Label for the field.
|
|
569
|
-
4. `onSelectCondition`: `(name, selectedOption) => void`. This method will
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
624
|
+
4. `onSelectCondition`: `(name, selectedOption) => void`. This method will
|
|
625
|
+
trigger when we select a condition option. The name is to refer the condition
|
|
626
|
+
in the formik context.
|
|
627
|
+
5. `selectedConditionOptions`: `(selectedCondition)=> [{label, value}]`. To
|
|
628
|
+
provide options for the selected condition if the type of selected condition
|
|
629
|
+
is `dropdown`, `multi-select`, or `multi-select-create`.
|
|
630
|
+
6. `isCallback`: To specify if there is a preview callback function for the
|
|
631
|
+
conditions. (Boolean).
|
|
632
|
+
7. `previewCallback`: `(conditions) => void`. This method will trigger when we
|
|
633
|
+
click on the preview button. The conditions are the selected conditions in
|
|
634
|
+
the formik context.
|
|
573
635
|
|
|
574
636
|
#### 3.8 `Actions`
|
|
575
637
|
|
|
@@ -639,19 +701,28 @@ const initialProps = {
|
|
|
639
701
|
|
|
640
702
|
#### props
|
|
641
703
|
|
|
642
|
-
1. `name`: Name of the field. The name should be same as that in the
|
|
643
|
-
|
|
704
|
+
1. `name`: Name of the field. The name should be same as that in the
|
|
705
|
+
`initialProps`.
|
|
706
|
+
2. `data`: The same `initialProps` that is passed to data prop in
|
|
707
|
+
`NeetoRulesForm`.
|
|
644
708
|
3. `label`: Label for the field.
|
|
645
|
-
4. `onSelectAction`: `(name, selectedOption) => void`. This method will trigger
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
709
|
+
4. `onSelectAction`: `(name, selectedOption) => void`. This method will trigger
|
|
710
|
+
when we select an action option. The name is to refer the action in the
|
|
711
|
+
formik context.
|
|
712
|
+
5. `selectedActionOptions`: `(selectedAction)=> [{label, value}]`. To provide
|
|
713
|
+
options for the selected action if the type of selected action is `dropdown`
|
|
714
|
+
or `multi-select`.
|
|
715
|
+
6. `separator`: Separator to be shown between action sub items. If there is only
|
|
716
|
+
one sub item, provide a string value. If there are multiple sub items,
|
|
717
|
+
provide an array of separators.
|
|
649
718
|
|
|
650
719
|
Refer to the [Actions section](./docs/actions.md) for more information.
|
|
651
720
|
|
|
652
721
|
#### 3.9 Custom action component
|
|
653
722
|
|
|
654
|
-
neetoRulesFrontend allows to pass custom action components from host
|
|
723
|
+
neetoRulesFrontend allows to pass custom action components from host
|
|
724
|
+
application. Below is an example for customize task component which is being
|
|
725
|
+
sent by neeto-crm in action options.
|
|
655
726
|
|
|
656
727
|
```jsx
|
|
657
728
|
{
|
|
@@ -665,7 +736,10 @@ neetoRulesFrontend allows to pass custom action components from host application
|
|
|
665
736
|
|
|
666
737
|
#### 3.10 Custom message templates
|
|
667
738
|
|
|
668
|
-
neetoRulesFrontend allows to pass predefined email, SMS and API templates from
|
|
739
|
+
neetoRulesFrontend allows to pass predefined email, SMS and API templates from
|
|
740
|
+
host application. This enables to use templates created using
|
|
741
|
+
neeto-message-templates-nano. Below is an example for custom message template
|
|
742
|
+
which is being sent by neeto-form in action options.
|
|
669
743
|
|
|
670
744
|
```jsx
|
|
671
745
|
{
|
|
@@ -694,19 +768,136 @@ The `RulePreview` component is used to preview the automation rule.
|
|
|
694
768
|
1. `ruleDetails`: The rule details to be previewed.
|
|
695
769
|
2. `isLoading`: To specify if the preview is loading. (Boolean).
|
|
696
770
|
3. `isOpen`: To specify if the preview is open. (Boolean).
|
|
697
|
-
4. `onClose`: The callback function to call when the preview is closed.
|
|
771
|
+
4. `onClose`: The callback function to call when the preview is closed.
|
|
772
|
+
`() => void`.
|
|
698
773
|
|
|
699
|
-
###
|
|
774
|
+
### Constants
|
|
700
775
|
|
|
701
776
|
#### 1. `AUTOMATION_RULES_QUERY_KEY`
|
|
702
777
|
|
|
703
|
-
The `AUTOMATION_RULES_QUERY_KEY` is the base query key which is being used as
|
|
778
|
+
The `AUTOMATION_RULES_QUERY_KEY` is the base query key which is being used as
|
|
779
|
+
key for query fetching.
|
|
704
780
|
|
|
705
781
|
reference:
|
|
706
782
|
|
|
707
783
|
1. [neeto-desk-web](https://github.com/bigbinary/neeto-desk-web/blob/main/app/javascript/src/components/Automations/index.jsx)
|
|
708
784
|
|
|
785
|
+
<br>
|
|
786
|
+
|
|
787
|
+
#### 5. `CannedResponsesPane`
|
|
788
|
+
|
|
789
|
+
<div align="center">
|
|
790
|
+
<img width="477" alt="Screenshot 2024-09-24 at 5 30 39 PM" src="https://github.com/user-attachments/assets/f223a948-c607-496f-ba7a-f0160a46fd4d" />
|
|
791
|
+
</div>
|
|
792
|
+
|
|
793
|
+
<br>
|
|
794
|
+
|
|
795
|
+
The `CannedResponsesPane` component is used to preview canned responses and
|
|
796
|
+
apply them.
|
|
797
|
+
|
|
798
|
+
#### Props
|
|
799
|
+
|
|
800
|
+
- `actionNameOptions`: An array of actions which any of the canned responses can
|
|
801
|
+
do. Each object in the array can have `label`, `value`, `type`, `placeholder`,
|
|
802
|
+
`dropdownOptions`, `defaultData` and `variables`. Out of these,
|
|
803
|
+
`dropdownOptions`, `defaultData` and `variables` are optional.
|
|
804
|
+
- `areDropdownListsLoading`: To specify if the dropdown lists are loading.
|
|
805
|
+
- `dropdownList`: It is an object of values that are used in the dropdowns. It
|
|
806
|
+
can have the keys `tags`, `teams`, `members`, `fields`, and `status`, with
|
|
807
|
+
their values the respective array of items.
|
|
808
|
+
- `isCannedResponsePaneOpen`: Boolean to specify if the canned response pane is
|
|
809
|
+
open.
|
|
810
|
+
- `isLoadingPreview`: Boolean to specify if the preview is loading.
|
|
811
|
+
- `macros`: An array of possible macros/canned responses that the user can
|
|
812
|
+
choose from.
|
|
813
|
+
- `onApply`: Callback function to apply the canned response.
|
|
814
|
+
- `onCancel`: Callback function to call when the canned response pane is closed.
|
|
815
|
+
- `previewCannedResponses`: Method which will be used to make the API call to
|
|
816
|
+
get the preview of the canned response.
|
|
817
|
+
- `previewParams`: Object that contains the parameters for the preview API call.
|
|
818
|
+
- `variables`: An array of variables that can be used in the canned response.
|
|
819
|
+
This is an optional prop.
|
|
820
|
+
|
|
821
|
+
#### Usage
|
|
822
|
+
|
|
823
|
+
```jsx
|
|
824
|
+
import { useState } from "react";
|
|
825
|
+
|
|
826
|
+
import { CannedResponsesPane } from "@bigbinary/neeto-rules-frontend";
|
|
827
|
+
|
|
828
|
+
import { usePreviewCannedResponses } from "./hooks";
|
|
829
|
+
|
|
830
|
+
const Component = ({ visitorId }) => {
|
|
831
|
+
const [isCannedResponsePaneOpen, setIsCannedResponsePaneOpen] =
|
|
832
|
+
useState(false);
|
|
833
|
+
|
|
834
|
+
const { mutate: previewCannedResponses, isLoading } =
|
|
835
|
+
usePreviewCannedResponses();
|
|
836
|
+
|
|
837
|
+
const dropdownList = {
|
|
838
|
+
status: [
|
|
839
|
+
{ label: "Open", value: "open" },
|
|
840
|
+
{ label: "Closed", value: "closed" },
|
|
841
|
+
],
|
|
842
|
+
tags: [
|
|
843
|
+
{ label: "Tag 1", value: "tag1" },
|
|
844
|
+
{ label: "Tag 2", value: "tag2" },
|
|
845
|
+
],
|
|
846
|
+
teams: [
|
|
847
|
+
{ label: "Team 1", value: "team1" },
|
|
848
|
+
{ label: "Team 2", value: "team2" },
|
|
849
|
+
],
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
const ACTION_NAME_OPTIONS = [
|
|
853
|
+
{
|
|
854
|
+
label: "Add reply",
|
|
855
|
+
value: "add_reply",
|
|
856
|
+
type: "note",
|
|
857
|
+
placeholder: "Reply",
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
label: "Assign member",
|
|
861
|
+
value: "assign_agent",
|
|
862
|
+
type: "dropdown",
|
|
863
|
+
placeholder: "Select member",
|
|
864
|
+
dropdownOptions: [],
|
|
865
|
+
defaultData: { actionable_type: "User" },
|
|
866
|
+
},
|
|
867
|
+
{
|
|
868
|
+
label: "Assign team",
|
|
869
|
+
value: "assign_group",
|
|
870
|
+
type: "dropdown",
|
|
871
|
+
placeholder: "Select team",
|
|
872
|
+
dropdownOptions: [],
|
|
873
|
+
defaultData: { actionable_type: "NeetoTeamMembersEngine::Group" },
|
|
874
|
+
},
|
|
875
|
+
];
|
|
876
|
+
|
|
877
|
+
const handleApply = ({ cannedResponse, setCannedResponse, onSettled }) => {
|
|
878
|
+
// logic to apply canned response
|
|
879
|
+
};
|
|
880
|
+
|
|
881
|
+
return (
|
|
882
|
+
<CannedResponsesPane
|
|
883
|
+
{...{
|
|
884
|
+
dropdownList,
|
|
885
|
+
isCannedResponsePaneOpen,
|
|
886
|
+
isLoadingPreview,
|
|
887
|
+
previewCannedResponses,
|
|
888
|
+
}}
|
|
889
|
+
actionNameOptions={ACTION_NAME_OPTIONS}
|
|
890
|
+
macros={cannedResponses}
|
|
891
|
+
previewParams={{ visitorId }}
|
|
892
|
+
onApply={handleApply}
|
|
893
|
+
onCancel={() => setIsCannedResponsePaneOpen(false)}
|
|
894
|
+
/>
|
|
895
|
+
);
|
|
896
|
+
};
|
|
897
|
+
```
|
|
709
898
|
|
|
710
899
|
## Instructions for Publishing
|
|
711
900
|
|
|
712
|
-
Consult the
|
|
901
|
+
Consult the
|
|
902
|
+
[building and releasing packages](https://neeto-engineering.neetokb.com/articles/building-and-releasing-packages)
|
|
903
|
+
guide for details on how to publish.
|