@bigbinary/neeto-message-templates-frontend 0.3.5 → 0.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 CHANGED
@@ -1,51 +1,51 @@
1
- # neeto-message-templates
2
-
3
- To manage message templates across the neeto products. As of now, it supports
4
- the creation of SMS, Email and Whatsapp templates.
5
-
6
- # Engine Installation
7
-
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.
3
+
4
+ # Contents
5
+ 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
+ 2. [Instructions for Publishing](#instructions-for-publishing)
13
+
14
+ # Development with Host Application
15
+ ## Engine
16
+ The engine is used to manage message templates across neeto products.
17
+
18
+ ### Installation
8
19
  1. Add this line to your application's Gemfile:
9
-
10
- ```ruby
20
+ ```ruby
11
21
  source "NEETO_GEM_SERVER_URL" do
12
- # ..existing gems
22
+ # ..existing gems
13
23
 
14
- gem 'neeto-message-templates-engine'
24
+ gem 'neeto-message-templates-engine'
15
25
  end
16
- ```
17
-
26
+ ```
18
27
  2. And then execute:
19
-
20
- ```shell
21
- bundle install
22
- ```
23
-
24
- 3. Configure the owner model in the host application.
25
-
26
- ```ruby
27
- has_many :message_templates, as: :owner, class_name: "NeetoMessageTemplatesEngine::MessageTemplate", dependent: :destroy
28
- ```
29
-
30
- 4. Add this line to your application's `config/routes.rb` file
31
-
32
- ```ruby
33
- mount NeetoMessageTemplatesEngine::Engine => "/neeto_message_templates_engine"
34
- ```
35
-
36
- 5. Copy the migrations from the engine to the host application and run
37
- `db:migrate` in host application
38
-
39
- ```shell
40
- bundle exec rails neeto_message_templates_engine:install:migrations
41
- bundle exec rails db:migrate
42
- ```
43
-
44
- 6. Create a file in the host app under
45
- `app/lib/neeto_message_templates_engine/callbacks.rb` & provide the
46
- permission (If you don't have permissions, then simply return true)
47
-
48
- ```ruby
28
+ ```zsh
29
+ bundle install
30
+ ```
31
+ 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
+ ```
39
+ 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
49
  module NeetoMessageTemplatesEngine
50
50
  class Callbacks
51
51
  def self.can_manage_message_templates?(user)
@@ -53,49 +53,40 @@ the creation of SMS, Email and Whatsapp templates.
53
53
  end
54
54
  end
55
55
  end
56
- ```
57
-
58
- 7. Create an initializer file in the host app under
59
- `configs/initializers/neeto-message-templates.rb` & provide the name of owner
60
- model for the message templates. The message_templates `belongs_to` this
61
- `owner`.
62
-
63
- ```ruby
64
- NeetoMessageTemplatesEngine.owner_class = "Organization"
65
- ```
66
-
67
- # Frontend Package Installation
68
-
69
- Install the latest `neetoMessageTemplates` package using the below command:
70
-
71
- ```shell
72
- yarn add @bigbinary/neeto-message-templates-frontend
73
- ```
74
-
75
- ## MessageTemplates
76
-
77
- ### Props
78
-
79
- - `shouldIncludeTestTemplate`: A boolean value to determines whether test
80
- message template option to be included.
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
+ ```
81
61
 
82
- - `handleSubmitTestTemplate`: The function in the host app that handles
83
- submitting values to send test templates for email and sms.
62
+ ### Usage
63
+ You can learn more about usage here:
64
+ 1. [Models](/docs/engine/models.md)
65
+
66
+ ## Frontend package
67
+ ### 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
+ ```
84
72
 
85
- - `isTestMessageLoading`: A boolean value that determines whether the test
86
- template handle submit is loading or not.
73
+ ### Components
74
+ #### `MessageTemplates` ([source code](https://github.com/bigbinary/neeto-message-templates-nano/blob/80a73223e8facf21a0135675d4dc837645d0f2b0/app/javascript/src/components/MessageTemplates/index.jsx))
75
+ 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.
87
76
 
88
- - `type`: Type can be `email`, `sms` or `whatsapp`.
77
+ ##### Props
78
+ - `shouldIncludeTestTemplate`: A boolean indicating whether the test message template option should be included.
79
+ - `handleSubmitTestTemplate`: The function in the host app responsible for submitting values to send test templates for email and SMS.
80
+ - `isTestMessageLoading`: A boolean indicating whether the test template handle submit is in a loading state.
81
+ - `type`: Represents the type of message, with accepted values of `email`, `sms`, or `whatsapp`.
89
82
 
83
+ ##### Optional Props
90
84
  - `templateVariables`: (optional) To add dynamic variables to form body field.
85
+ - `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.
86
+ - `breadcrumbs`: An array of objects that specify breadcrumbs for navigation.
91
87
 
92
- - `ownerId`: (optional) To provide the `id` of the owner if it is not an
93
- Organization model. If the owner is an Organization, this prop can be left
94
- unspecified.
95
-
96
- ### Usage
97
-
98
- ```javascript
88
+ ##### Usage
89
+ ```jsx
99
90
  import React from "react";
100
91
 
101
92
  import { MessageTemplates } from "@bigbinary/neeto-message-templates-frontend";
@@ -131,36 +122,24 @@ const App = () => {
131
122
  };
132
123
  ```
133
124
 
134
- ## SendMessagePane
135
-
136
- ### Props
137
-
138
- - `isOpen`: To open the side pane.
139
-
140
- - `onClose`: To close the side pane.
125
+ #### `SendMessagePane` ([source code](https://github.com/bigbinary/neeto-message-templates-nano/blob/80a73223e8facf21a0135675d4dc837645d0f2b0/app/javascript/src/components/SendMessagePane/index.jsx))
126
+ This component provides a pane where users can select a template and add content to compose and send messages.
141
127
 
142
- * `handleSubmit`: The function in the host app which is used to send sms and
143
- email.
128
+ ##### Props
129
+ - `isOpen`: A boolean determining whether the side pane is open.
130
+ - `onClose`: The function to execute when closing.
131
+ - `handleSubmit`: The function within the host app used to send SMS and email.
132
+ - `type`: Represents the type of message, with accepted values of `email`, `sms`, or `whatsapp`.
144
133
 
145
- * `type`: Type can be `email`, `sms` or `whatsapp`.
134
+ ##### Optional Props
135
+ - `customFields`: To add custom field component to the pane.
136
+ - `customFieldsInitialValues`: To provide initial values for the custom fields.
137
+ - `customFieldsValidationSchema`: To provide validation schema for the custom fields.
138
+ - `templateVariables`: To add dynamic variables to form body field.
139
+ - `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.
146
140
 
147
- - `customFields`: (optional) To add custom field component to the pane.
148
-
149
- - `customFieldsInitialValues`: (optional) To provide initial values for the
150
- custom fields.
151
-
152
- - `customFieldsValidationSchema`: (optional) To provide validation schema for
153
- the custom fields.
154
-
155
- - `templateVariables`: (optional) To add dynamic variables to form body field.
156
-
157
- - `ownerId`: (optional) To provide the `id` of the owner if it is not an
158
- Organization model. If the owner is an Organization, this prop can be left
159
- unspecified.
160
-
161
- ### Usage
162
-
163
- ```js
141
+ ##### Usage
142
+ ```jsx
164
143
  import React, { useState } from "react";
165
144
 
166
145
  import { SendMessagePane } from "@bigbinary/neeto-message-templates-frontend";
@@ -207,54 +186,5 @@ const App = () => {
207
186
  };
208
187
  ```
209
188
 
210
- # Development
211
-
212
- ### Engine
213
-
214
- 1. Add this line to your application's Gemfile (replace the path to the local
215
- copy of neeto-message-templates-engine):
216
-
217
- ```ruby
218
- gem 'neeto-message-templates-engine', path: '../neeto-message-templates-engine'
219
- ```
220
-
221
- 2. And then execute:
222
-
223
- ```shell
224
- bundle install
225
- ```
226
-
227
- 3. Refer [engine installation](#engine-installation) steps 3, 4, 5 and 6.
228
-
229
- ### Frontend Package
230
-
231
- The usage of `yalc` is explained in this video:
232
- https://www.youtube.com/watch?v=QBiYGP0Rhe0
233
-
234
- 1. See the changes in the host app by executing the following command \
235
- <br/> Use this command if releasing package for the first time.
236
-
237
- ```shell
238
- yarn build && yalc publish
239
- ```
240
-
241
- Use this command to see changes after the initial publish.
242
-
243
- ```shell
244
- yarn release
245
- ```
246
-
247
- # Setup dummy host app
248
-
249
- Setup
250
- [Instructions](https://github.com/bigbinary/neeto-engineering/tree/main/Local-Development-Setup).
251
-
252
- Visit http://spinkart.lvh.me:9014 and login with email `oliver@example.com` and
253
- password `welcome`.
254
-
255
- ### Additional Instructions
256
-
257
- - Run `yarn build` to bundle the app.
258
-
259
- - Note: Run the following command before running rails test
260
- `RAILS_ENV=test rails db:migrate`
189
+ # Instructions for Publishing
190
+ Consult the [building and releasing packages](https://neeto-engineering.neetokb.com/articles/building-and-releasing-packages) guide for details on how to publish.
@@ -0,0 +1,65 @@
1
+ {
2
+ "neetoMessageTemplate": {
3
+ "template": {
4
+ "addEmailTemplate": "Add new email template",
5
+ "addSmsTemplate": "Add new SMS template",
6
+ "addWhatsappTemplate": "Add new whatsapp template",
7
+ "editEmailTemplate": "Edit email template",
8
+ "editSmsTemplate": "Edit SMS template",
9
+ "editWhatsappTemplate": "Edit whatsapp template",
10
+ "search": "Search {{what}}",
11
+ "markAsActive": "Mark as active",
12
+ "markAsInactive": "Mark as inactive",
13
+ "close": "Close",
14
+ "delete": "Delete",
15
+ "edit": "Edit",
16
+ "saveChanges": "Save changes",
17
+ "send": "Send",
18
+ "cancel": "Cancel",
19
+ "emailAddress": "Email address",
20
+ "phoneNumber": "Phone number",
21
+ "name": "Name",
22
+ "body": "Body",
23
+ "subject": "Subject",
24
+ "title": "Template",
25
+ "active": "Active",
26
+ "templateDeleteConfirmation": "Are you sure want to delete <strong>{{name}}</strong>. This action cannot be undone.",
27
+ "deleteTemplate": "Delete {{label, anyCase}}",
28
+ "emailTemplates": "Email templates",
29
+ "emailTemplate": "Email template",
30
+ "smsTemplates": "SMS templates",
31
+ "smsTemplate": "SMS template",
32
+ "whatsappTemplates": "Whatsapp Templates",
33
+ "whatsappTemplate": "Whatsapp Template",
34
+ "emptyState": "There are no {{type, anyCase}} to show.",
35
+ "sendTestEmail": "Send test email",
36
+ "sendTestSms": "Send test SMS",
37
+ "filtersEmptyState": "There are no {{type, anyCase}} to show for applied filters.",
38
+ "preview": "Template Preview",
39
+ "resolveVariable": "Resolve {{type}} variables",
40
+ "validation": {
41
+ "namePresence": "Name is required",
42
+ "subjectPresence": "Subject is required",
43
+ "bodyPresence": "Body is required",
44
+ "emailAddressPresence": "Email address is required",
45
+ "emailAddressFormatValidation": "Invalid email address",
46
+ "validPhoneNumber": "Enter valid phone number",
47
+ "variablePresence": "Variable should not be empty"
48
+ }
49
+ },
50
+ "sendMessage": {
51
+ "email": "Send email",
52
+ "sms": "Send SMS",
53
+ "selectTemplate": "Select a template",
54
+ "testSmsNote": "Note: Variable values will be empty for test SMS."
55
+ },
56
+ "common": {
57
+ "send": "Send"
58
+ }
59
+ },
60
+ "messageType": {
61
+ "sms": "SMS",
62
+ "email": "email",
63
+ "whatsapp": "whatsapp"
64
+ }
65
+ }
@@ -0,0 +1,3 @@
1
+ import en from "./en.json";
2
+
3
+ export { en };