@bigbinary/neeto-message-templates-frontend 0.7.1 → 0.7.3

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 CHANGED
@@ -1,97 +1,137 @@
1
1
  # neeto-message-templates-nano
2
- The `neeto-message-templates-nano` manages message templates across the neeto products. As of now, it supports the creation of SMS, Email and Whatsapp templates. The nano exports the `@bigbinary/neeto-message-templates-frontend` NPM package and `neeto-message-templates-engine` Rails engine for development.
2
+
3
+ The `neeto-message-templates-nano` manages message templates across the neeto
4
+ products. As of now, it supports the creation of SMS, Email and Whatsapp
5
+ templates. The nano exports
6
+ the `@bigbinary/neeto-message-templates-frontend` NPM package
7
+ and `neeto-message-templates-engine` Rails engine for development.
3
8
 
4
9
  # Contents
10
+
5
11
  1. [Development with Host Application](#development-with-host-application)
6
- - [Engine](#engine)
7
- - [Installation](#installation)
8
- - [Usage](#usage)
9
- - [Frontend package](#frontend-package)
10
- - [Installation](#installation-1)
11
- - [Components](#components)
12
+ - [Engine](#engine)
13
+ - [Installation](#installation)
14
+ - [Usage](#usage)
15
+ - [Frontend package](#frontend-package)
16
+ - [Installation](#installation-1)
17
+ - [Components](#components)
12
18
  2. [Instructions for Publishing](#instructions-for-publishing)
13
19
 
14
20
  # Development with Host Application
21
+
15
22
  ## Engine
23
+
16
24
  The engine is used to manage message templates across neeto products.
17
25
 
18
26
  ### Installation
27
+
19
28
  1. Add this line to your application's Gemfile:
20
- ```ruby
21
- source "NEETO_GEM_SERVER_URL" do
22
- # ..existing gems
23
29
 
24
- gem 'neeto-message-templates-engine'
25
- end
26
- ```
30
+ ```ruby
31
+ source "NEETO_GEM_SERVER_URL" do
32
+ # ..existing gems
33
+
34
+ gem 'neeto-message-templates-engine'
35
+ end
36
+ ```
37
+
27
38
  2. And then execute:
28
- ```zsh
29
- bundle install
30
- ```
39
+ ```zsh
40
+ bundle install
41
+ ```
31
42
  3. Add this line to your application's `config/routes.rb` file:
32
- ```ruby
33
- mount NeetoMessageTemplatesEngine::Engine => "/neeto_message_templates_engine"
34
- ```
35
- 4. Run the following command to copy the migrations from the engine to the host application:
36
- ```zsh
37
- bundle exec rails neeto_message_templates_engine:install:migrations
38
- ```
43
+ ```ruby
44
+ mount NeetoMessageTemplatesEngine::Engine => "/neeto_message_templates_engine"
45
+ ```
46
+ 4. Run the following command to copy the migrations from the engine to the host
47
+ application:
48
+ ```zsh
49
+ bundle exec rails neeto_message_templates_engine:install:migrations
50
+ ```
39
51
  5. Add the migrations to the database:
40
- ```zsh
41
- bundle exec rails db:migrate
42
- ```
43
- 5. Create file `neeto-message-templates.rb` under `config/initializers` to provide the `owner_class` information
44
- ```ruby
45
- NeetoFormEngine.owner_class = "Organization"
46
- ```
47
- 6. Create file `callbacks.rb` under `app/lib/neeto_message_templates_engine` and provide the permission (If you don't have permissions, then simply return true)
48
- ```ruby
49
- module NeetoMessageTemplatesEngine
50
- class Callbacks
51
- def self.can_manage_message_templates?(user)
52
- user.has_permission?("admin.manage_message_templates")
53
- end
54
- end
55
- end
56
- ```
57
- 7. Configure the owner model in the host application.
58
- ```ruby
59
- has_many :message_templates, as: :owner, class_name: "NeetoMessageTemplatesEngine::MessageTemplate", dependent: :destroy
60
- ```
52
+ ```zsh
53
+ bundle exec rails db:migrate
54
+ ```
55
+ 6. Create file `neeto-message-templates.rb` under `config/initializers` to
56
+ provide the `owner_class` information
57
+ ```ruby
58
+ NeetoFormEngine.owner_class = "Organization"
59
+ ```
60
+ 7. Create file `callbacks.rb` under `app/lib/neeto_message_templates_engine` and
61
+ provide the permission (If you don't have permissions, then simply return
62
+ true)
63
+ ```ruby
64
+ module NeetoMessageTemplatesEngine
65
+ class Callbacks
66
+ def self.can_manage_message_templates?(user)
67
+ user.has_permission?("admin.manage_message_templates")
68
+ end
69
+ end
70
+ end
71
+ ```
72
+ 8. Configure the owner model in the host application.
73
+ ```ruby
74
+ has_many :message_templates, as: :owner, class_name: "NeetoMessageTemplatesEngine::MessageTemplate", dependent: :destroy
75
+ ```
61
76
 
62
77
  ### Usage
78
+
63
79
  You can learn more about usage here:
64
- 1. [Models](/docs/engine/models.md)
80
+
81
+ 1. [Models](/docs/engine/models.md)
65
82
 
66
83
  ## Frontend package
84
+
67
85
  ### Installation
68
- 1. Install the latest `neeto-message-templates-nano` package using the below command:
69
- ```zsh
70
- yarn add @bigbinary/neeto-message-templates-frontend
71
- ```
86
+
87
+ 1. Install the latest `neeto-message-templates-nano` package using the below
88
+ command:
89
+ ```zsh
90
+ yarn add @bigbinary/neeto-message-templates-frontend
91
+ ```
72
92
 
73
93
  ### Instructions for development
74
- Check the [Frontend package development guide](https://neeto-engineering.neetokb.com/p/a-d34cb4b0) for step-by-step instructions to develop the frontend package.
94
+
95
+ Check the
96
+ [Frontend package development guide](https://neeto-engineering.neetokb.com/p/a-d34cb4b0)
97
+ for step-by-step instructions to develop the frontend package.
75
98
 
76
99
  ### Components
100
+
77
101
  #### `MessageTemplates` ([source code](https://github.com/bigbinary/neeto-message-templates-nano/blob/80a73223e8facf21a0135675d4dc837645d0f2b0/app/javascript/src/components/MessageTemplates/index.jsx))
78
- This component is used to manage message templates in your web application. It provides a user-friendly interface for viewing, adding, and editing templates, along with filtering and search capabilities.
102
+
103
+ This component is used to manage message templates in your web application. It
104
+ provides a user-friendly interface for viewing, adding, and editing templates,
105
+ along with filtering and search capabilities.
79
106
 
80
107
  ##### Props
81
- - `shouldIncludeTestTemplate`: A boolean indicating whether the test message template option should be included.
82
- - `handleSubmitTestTemplate`: The function in the host app responsible for submitting values to send test templates for email and SMS.
83
- - `isTestMessageLoading`: A boolean indicating whether the test template handle submit is in a loading state.
84
- - `type`: Represents the type of message, with accepted values of `email`, `sms`, or `whatsapp`.
108
+
109
+ - `shouldIncludeTestTemplate`: A boolean indicating whether the test message
110
+ template option should be included.
111
+ - `handleSubmitTestTemplate`: The function in the host app responsible for
112
+ submitting values to send test templates for email and SMS.
113
+ - `isTestMessageLoading`: A boolean indicating whether the test template handle
114
+ submit is in a loading state.
115
+ - `type`: Represents the type of message, with accepted values of `email`,
116
+ `sms`, or `whatsapp`.
85
117
 
86
118
  ##### Optional Props
119
+
87
120
  - `templateVariables`: (optional) To add dynamic variables to form body field.
88
- - `ownerId`: (optional) To provide the `ID` of the owner if it is not an Organization model. If the owner is an Organization, this prop can be left unspecified.
121
+ - `ownerId`: (optional) To provide the `ID` of the owner if it is not an
122
+ Organization model. If the owner is an Organization, this prop can be left
123
+ unspecified.
89
124
  - `breadcrumbs`: An array of objects that specify breadcrumbs for navigation.
90
- - `isTestingTemplateDisabled`: A boolean indicating whether the test template button should be enabled or not.
91
- - `manageTemplatesPaneCustomFields`: To add custom components to the manage templates pane.
92
- - `onMutationSuccess`: The callback function which is triggered on the success of mutation functions(create, update & delete).
125
+ - `isTestingTemplateDisabled`: A boolean indicating whether the test template
126
+ button should be enabled or not.
127
+ - `manageTemplatesPaneCustomFields`: To add custom components to the manage
128
+ templates pane.
129
+ - `onMutationSuccess`: The callback function which is triggered on the success
130
+ of mutation functions(create, update & delete).
131
+ - `helpDocUrl`: Help article link.
93
132
 
94
133
  ##### Usage
134
+
95
135
  ```jsx
96
136
  import React from "react";
97
137
 
@@ -119,7 +159,8 @@ const App = () => {
119
159
 
120
160
  const manageTemplatesPaneCustomFields = () => (
121
161
  <Callout icon={Warning} style="warning">
122
- Twilio integration is required for sending SMS. Please connect your Twilio account.
162
+ Twilio integration is required for sending SMS. Please connect your Twilio
163
+ account.
123
164
  </Callout>
124
165
  );
125
166
 
@@ -140,22 +181,33 @@ const App = () => {
140
181
  ```
141
182
 
142
183
  #### `SendMessagePane` ([source code](https://github.com/bigbinary/neeto-message-templates-nano/blob/80a73223e8facf21a0135675d4dc837645d0f2b0/app/javascript/src/components/SendMessagePane/index.jsx))
143
- This component provides a pane where users can select a template and add content to compose and send messages.
184
+
185
+ This component provides a pane where users can select a template and add content
186
+ to compose and send messages.
144
187
 
145
188
  ##### Props
189
+
146
190
  - `isOpen`: A boolean determining whether the side pane is open.
147
191
  - `onClose`: The function to execute when closing.
148
192
  - `handleSubmit`: The function within the host app used to send SMS and email.
149
- - `type`: Represents the type of message, with accepted values of `email`, `sms`, or `whatsapp`.
193
+ - `type`: Represents the type of message, with accepted values of `email`,
194
+ `sms`, or `whatsapp`.
195
+ - `addNewTemplateRoute`: A redirect route to the add template page. If there are
196
+ no message templates present, users can be redirected to this route to add new
197
+ message templates.
150
198
 
151
199
  ##### Optional Props
200
+
152
201
  - `customFields`: To add custom field component to the pane.
153
202
  - `customFieldsInitialValues`: To provide initial values for the custom fields.
154
- - `customFieldsValidationSchema`: To provide validation schema for the custom fields.
203
+ - `customFieldsValidationSchema`: To provide validation schema for the custom
204
+ fields.
155
205
  - `templateVariables`: To add dynamic variables to form body field.
156
- - `ownerId`: To provide the `ID` of the owner if it is not an Organization model. If the owner is an Organization, this prop can be left unspecified.
206
+ - `ownerId`: To provide the `ID` of the owner if it is not an Organization
207
+ model. If the owner is an Organization, this prop can be left unspecified.
157
208
 
158
209
  ##### Usage
210
+
159
211
  ```jsx
160
212
  import React, { useState } from "react";
161
213
 
@@ -204,16 +256,25 @@ const App = () => {
204
256
  ```
205
257
 
206
258
  #### ApiTemplates ([source code](https://github.com/bigbinary/neeto-message-templates-nano/blob/main/app/javascript/src/components/Api/ApiTemplates/index.jsx))
207
- This component is used to manage the API templates in your application. It provides the interface to add, delete, and edit API templates, along with filtering and search capabilities.
259
+
260
+ This component is used to manage the API templates in your application. It
261
+ provides the interface to add, delete, and edit API templates, along with
262
+ filtering and search capabilities.
208
263
 
209
264
  ##### Props
210
- - `ownerId`: To provide the `ID` of the owner to which the API templates belongs to.
265
+
266
+ - `ownerId`: To provide the `ID` of the owner to which the API templates belongs
267
+ to.
211
268
 
212
269
  ##### Optional props
270
+
213
271
  - `breadcrumbs`: An array of objects that specify breadcrumbs for navigation.
214
- - `onMutationSuccess`: The callback function which is triggered on the success of mutation functions(create, update & delete).
272
+ - `onMutationSuccess`: The callback function which is triggered on the success
273
+ of mutation functions(create, update & delete).
274
+ - `helpDocUrl`: Help article link.
215
275
 
216
276
  ##### Usage
277
+
217
278
  ```js
218
279
  import React from "react";
219
280
 
@@ -235,15 +296,22 @@ const App = () => {
235
296
  ```
236
297
 
237
298
  #### SendToApiPane ([source code](https://github.com/bigbinary/neeto-message-templates-nano/blob/main/app/javascript/src/components/Api/SendToApiPane/index.jsx))
238
- This component provides a pane where users can select an API template and modify it if needed and send the data to the specified HTTP(S) endpoint.
299
+
300
+ This component provides a pane where users can select an API template and modify
301
+ it if needed and send the data to the specified HTTP(S) endpoint.
239
302
 
240
303
  ##### Props
304
+
241
305
  - `ownerId`: A boolean determining whether the side pane is open.
242
306
  - `onClose`: This function will be executed while closing the pane.
243
307
  - `onSubmit`: This function will be executed while submitting the form.
244
308
  - `isSubmitting`: A boolean to know the form submission status
309
+ - `addNewTemplateRoute`: A redirect route to the API template page. If there are
310
+ no API templates present, users can be redirected to this route to add new API
311
+ templates.
245
312
 
246
313
  ##### Usage
314
+
247
315
  ```js
248
316
  import React, { useState } from "react";
249
317
 
@@ -273,4 +341,7 @@ const App = () => {
273
341
  ```
274
342
 
275
343
  # Instructions for Publishing
276
- Consult the [building and releasing packages](https://neeto-engineering.neetokb.com/articles/building-and-releasing-packages) guide for details on how to publish.
344
+
345
+ Consult the
346
+ [building and releasing packages](https://neeto-engineering.neetokb.com/articles/building-and-releasing-packages)
347
+ guide for details on how to publish.
@@ -24,6 +24,7 @@
24
24
  "subject": "Subject",
25
25
  "title": "Template",
26
26
  "active": "Active",
27
+ "linkToHelpArticle": "Here is how you can use <Link>{{entity}}</Link>.",
27
28
  "templateDeleteConfirmation": "You are deleting the template <strong>{{name}}</strong>. This can't be undone.",
28
29
  "deleteTemplate": "Delete {{label, anyCase}}?",
29
30
  "emailTemplates": "Email templates",
@@ -33,7 +34,7 @@
33
34
  "whatsappTemplates": "Whatsapp Templates",
34
35
  "whatsappTemplate": "Whatsapp Template",
35
36
  "apiTemplates": "API templates",
36
- "emptyState": "There are no {{type, anyCase}} to show.",
37
+ "emptyState": "There are no {{type, anyCase}} to show",
37
38
  "whatsapp": {
38
39
  "helpDocText": "You can create and add new WhatsApp templates by referring to this <Link>help document</Link>."
39
40
  },