@bigbinary/neeto-approvals-frontend 0.2.12 → 0.2.13
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 +131 -75
- package/{src → app/javascript/src}/translations/en.json +3 -6
- package/dist/index.cjs.js +93 -185
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +76 -165
- package/dist/index.js.map +1 -1
- package/package.json +132 -118
- /package/{src → app/javascript/src}/translations/fr.json +0 -0
- /package/{src → app/javascript/src}/translations/index.js +0 -0
package/README.md
CHANGED
|
@@ -1,34 +1,92 @@
|
|
|
1
|
-
#
|
|
1
|
+
# neeto-approvals-nano
|
|
2
|
+
The `neeto-approvals-nano` manages approvals within neeto applications. The nano exports the `@bigbinary/neeto-approvals-frontend` NPM package and `neeto-approvals-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 approval requests and approval templates for an organization.
|
|
17
|
+
|
|
18
|
+
### Installation
|
|
19
|
+
1. Add this line to your application's Gemfile:
|
|
20
|
+
```ruby
|
|
21
|
+
source "NEETO_GEM_SERVER_URL" do
|
|
22
|
+
# ..existing gems
|
|
23
|
+
|
|
24
|
+
gem 'neeto-approvals-engine'
|
|
25
|
+
end
|
|
26
|
+
```
|
|
27
|
+
2. And then execute:
|
|
28
|
+
```ruby
|
|
29
|
+
bundle install
|
|
30
|
+
```
|
|
31
|
+
3. Add this line to your application's `config/routes.rb` file:
|
|
32
|
+
```ruby
|
|
33
|
+
mount NeetoApprovalsEngine::Engine => "/neeto_approvals_engine"
|
|
34
|
+
```
|
|
35
|
+
4. Run the following command to copy the migrations from the engine to the host application:
|
|
36
|
+
```ruby
|
|
37
|
+
bundle exec rails neeto_approvals_engine:install:migrations
|
|
38
|
+
```
|
|
39
|
+
5. Add the migrations to the database:
|
|
40
|
+
```ruby
|
|
41
|
+
bundle exec rails db:migrate
|
|
42
|
+
```
|
|
2
43
|
|
|
3
|
-
|
|
44
|
+
### Usage
|
|
4
45
|
|
|
5
|
-
|
|
46
|
+
You can learn more about the setup and usage here:
|
|
47
|
+
1. [Models](/docs/engine/models.md)
|
|
48
|
+
2. [Controllers](/docs/engine/controllers.md)
|
|
49
|
+
3. [Services](/docs/engine/services.md)
|
|
6
50
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
command:
|
|
51
|
+
## Frontend package
|
|
52
|
+
The package exports three components: `Approvals`, `Form`, and `Public`.
|
|
10
53
|
|
|
54
|
+
### Installation
|
|
55
|
+
1. `neeto-approvals-nano` has a few peer dependencies that are required for the proper functioning of the package. Install all the peer dependencies using the below command:
|
|
11
56
|
```zsh
|
|
12
57
|
yarn add @bigbinary/neeto-icons@1.8.46 @bigbinary/neetoui@4.1.33 axios@1.2.1 classnames@2.3.2 formik@2.2.9 ramda@0.28.0 react-router-dom@5.3.3 react-toastify@8.2.0 react-query@3.39.2 yup@0.32.11
|
|
13
58
|
```
|
|
14
59
|
|
|
15
|
-
2. Now install the latest
|
|
16
|
-
|
|
60
|
+
2. Now install the latest `neeto-approvals-nano` package using the below command:
|
|
17
61
|
```zsh
|
|
18
62
|
yarn add @bigbinary/neeto-approvals-frontend
|
|
19
63
|
```
|
|
20
64
|
|
|
21
|
-
|
|
65
|
+
### Components
|
|
66
|
+
#### `Approvals` ([source code](https://github.com/bigbinary/neeto-approvals-nano/blob/13500c56e311a488fce886876781b8c26a0f0145/app/javascript/src/components/Approvals/index.jsx))
|
|
67
|
+
This component manages approval requests, approval templates and history of approval requests. It consists of three tabs: `Pending`, `Templates`, and `History`
|
|
68
|
+
1. `Pending` - Lists all pending approval requests.
|
|
69
|
+
2. `Templates` - Lists all approval templates.
|
|
70
|
+
3. `History` - Lists all approved, rejected, and cancelled approval requests.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
##### Props
|
|
74
|
+
- `config`: Configuration object that includes specifications for paths, URLs, template placeholders and breadcrumbs. It also allows optional configurations for help articles.
|
|
75
|
+
|
|
76
|
+
##### Configuration
|
|
77
|
+
Refer to the [Approvals](/docs/frontend/approvals.md) section for detailed information on the available configurations for the `Approvals` component.
|
|
78
|
+
|
|
79
|
+
##### Usage
|
|
22
80
|
```jsx
|
|
23
81
|
import React from "react";
|
|
24
82
|
|
|
83
|
+
import { Approvals } from "@bigbinary/neeto-approvals-frontend";
|
|
25
84
|
import { routes } from "common/routes";
|
|
26
85
|
import { BrowserRouter, Redirect, Route, Switch } from "react-router-dom";
|
|
27
86
|
import { ToastContainer } from "react-toastify";
|
|
28
87
|
|
|
29
88
|
import SideBar from "./Common/SideBar";
|
|
30
89
|
|
|
31
|
-
import { Approvals } from "neetoapprovals";
|
|
32
90
|
|
|
33
91
|
const Main = () => (
|
|
34
92
|
<BrowserRouter>
|
|
@@ -39,40 +97,10 @@ const Main = () => (
|
|
|
39
97
|
path={routes.approvals}
|
|
40
98
|
render={() => (
|
|
41
99
|
<Approvals
|
|
42
|
-
config={
|
|
43
|
-
approvalsPath: routes.approvals,
|
|
44
|
-
templateUrl: "templatesUrl",
|
|
45
|
-
requestUrl: "requestsUrl",
|
|
46
|
-
templatePlaceholders: [
|
|
47
|
-
{
|
|
48
|
-
category: "ticket",
|
|
49
|
-
label: "Ticket",
|
|
50
|
-
variables: [
|
|
51
|
-
{ key: "id", label: "ticket.id" },
|
|
52
|
-
{ key: "number", label: "ticket.number" },
|
|
53
|
-
{ key: "subject", label: "ticket.subject" },
|
|
54
|
-
],
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
category: "requester",
|
|
58
|
-
label: "Customer",
|
|
59
|
-
variables: [
|
|
60
|
-
{ key: "id", label: "customer.id" },
|
|
61
|
-
{ key: "name", label: "customer.name" },
|
|
62
|
-
{ key: "email", label: "customer.email" },
|
|
63
|
-
],
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
breadcrumbs: [
|
|
67
|
-
{ text: "Settings", link: routes.settings },
|
|
68
|
-
{ text: "General settings", link: routes.settings.general },
|
|
69
|
-
{ text: "Approvals" },
|
|
70
|
-
],
|
|
71
|
-
}}
|
|
100
|
+
config={APPROVALS_CONFIG}
|
|
72
101
|
/>
|
|
73
102
|
)}
|
|
74
103
|
/>
|
|
75
|
-
<Redirect to={routes.approvals} />
|
|
76
104
|
</Switch>
|
|
77
105
|
</div>
|
|
78
106
|
<ToastContainer />
|
|
@@ -82,45 +110,73 @@ const Main = () => (
|
|
|
82
110
|
export default Main;
|
|
83
111
|
```
|
|
84
112
|
|
|
85
|
-
|
|
113
|
+
#### `Form` ([source code](https://github.com/bigbinary/neeto-approvals-nano/blob/13500c56e311a488fce886876781b8c26a0f0145/app/javascript/src/components/Approvals/CreateRequestForm.jsx))
|
|
114
|
+
This component handles creation and updation of approval templates.
|
|
115
|
+
|
|
116
|
+
##### Props
|
|
117
|
+
- `isLoading` - Boolean value to show the loading state in the submit button
|
|
118
|
+
- `isOpen` - Boolean value to open the pane
|
|
119
|
+
- `setIsPaneOpen` - Set it to false to close the pane
|
|
120
|
+
- `requestableId` - ID of the entity to which we are associating requests. This is used to parse messages based on the entity's attributes in the engine.
|
|
121
|
+
- `onSubmit` - Function which calls the API to submit approval request details such as request message, template title, approver ID and requestable ID.
|
|
86
122
|
|
|
87
|
-
|
|
123
|
+
##### Usage
|
|
124
|
+
```jsx
|
|
125
|
+
import React from "react";
|
|
126
|
+
import { Form } from "@bigbinary/neeto-approvals-frontend";
|
|
127
|
+
|
|
128
|
+
const RequestApproval = () => {
|
|
129
|
+
const { mutate: createRequest, isLoading } = useCreateRequest();
|
|
130
|
+
|
|
131
|
+
const onSubmit = (request, template, onClose) => {
|
|
132
|
+
createRequest(
|
|
133
|
+
{
|
|
134
|
+
request: {
|
|
135
|
+
...request,
|
|
136
|
+
title: template.name,
|
|
137
|
+
approverId: template.approverId,
|
|
138
|
+
requestableId: requestableId, // Specify the ID of the requestable associated entity
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
{ onSuccess: onClose }
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<Form
|
|
147
|
+
isLoading={isLoading}
|
|
148
|
+
isOpen={isNewApprovalRequestPaneOpen}
|
|
149
|
+
setIsPaneOpen={setIsNewApprovalRequestPaneOpen}
|
|
150
|
+
requestableId={requestableId} // Specify the ID of the requestable associated entity
|
|
151
|
+
onSubmit={onSubmit}
|
|
152
|
+
/>
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export default RequestApproval;
|
|
157
|
+
```
|
|
88
158
|
|
|
89
|
-
|
|
90
|
-
2. [Form](./docs/form/README.md)
|
|
159
|
+
#### `Public` ([source code](https://github.com/bigbinary/neeto-approvals-nano/blob/13500c56e311a488fce886876781b8c26a0f0145/app/javascript/src/components/Approvals/Public/index.jsx))
|
|
91
160
|
|
|
92
|
-
|
|
161
|
+
This component is used to show the approval request detail without any user login.
|
|
93
162
|
|
|
94
|
-
|
|
163
|
+
##### Props
|
|
164
|
+
No props need to be passed. However, ensure that the path of the page rendering the `Public` component contains the `id` param for the request ID.
|
|
95
165
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
166
|
+
##### Usage
|
|
167
|
+
```jsx
|
|
168
|
+
import React from "react";
|
|
169
|
+
import { Public } from "@bigbinary/neeto-approvals-frontend";
|
|
99
170
|
|
|
100
|
-
|
|
171
|
+
const PublicRequestApproval = () => {
|
|
172
|
+
return (
|
|
173
|
+
<Public />
|
|
174
|
+
);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export default PublicRequestApproval;
|
|
178
|
+
```
|
|
101
179
|
|
|
102
|
-
```zsh
|
|
103
|
-
yarn dev
|
|
104
|
-
```
|
|
105
180
|
|
|
106
|
-
#
|
|
107
|
-
|
|
108
|
-
The `@bigbinary/neeto-approvals-frontend` package gets published to NPM when we
|
|
109
|
-
merge a PR with `patch`, `minor` or `major` label to the `main` branch. The
|
|
110
|
-
`patch` label is used for bug fixes, `minor` label is used for new features and
|
|
111
|
-
`major` label is used for breaking changes. You can checkout the
|
|
112
|
-
`Create and publish releases` workflow in GitHub Actions to get a live update.
|
|
113
|
-
|
|
114
|
-
In case if you missed to add the label, you can manually publish the package.
|
|
115
|
-
For that first you need to create a PR to update the version number in the
|
|
116
|
-
`package.json` file and merge it to the `main` branch. After merging the PR, you
|
|
117
|
-
need to create a
|
|
118
|
-
[new github release](https://github.com/bigbinary/neeto-approvals-frontend/releases/new)
|
|
119
|
-
from main branch. Whenever a new release is created with a new version number,
|
|
120
|
-
the github actions will automatically publish the built package to npm. You can
|
|
121
|
-
checkout the `Publish to npm` workflow in GitHub Actions to get a live update.
|
|
122
|
-
|
|
123
|
-
Please note that before publishing the package, you need to verify the
|
|
124
|
-
functionality in some of the neeto web-apps locally using `yalc` package
|
|
125
|
-
manager. The usage of yalc is explained in this video:
|
|
126
|
-
https://youtu.be/QBiYGP0Rhe0
|
|
181
|
+
# Instructions for Publishing
|
|
182
|
+
Consult the [building and releasing packages](https://neeto-engineering.neetokb.com/articles/building-and-releasing-packages) guide for details on how to publish.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"neetoApprovals": {
|
|
3
3
|
"alerts": {
|
|
4
|
-
"deleting_": "You are permanently deleting the {{what}} <strong>{{
|
|
4
|
+
"deleting_": "You are permanently deleting the {{what}} <strong>{{name, anyCase}}</strong>. This can't be undone."
|
|
5
5
|
},
|
|
6
6
|
"buttons": {
|
|
7
7
|
"cancel": "Cancel",
|
|
@@ -30,9 +30,6 @@
|
|
|
30
30
|
"name": "Name",
|
|
31
31
|
"notFound_": "There are no {{what}} to show",
|
|
32
32
|
"notFound": "Could not find the approval request.",
|
|
33
|
-
"visibility": "Visibility",
|
|
34
|
-
"variable": "Variable",
|
|
35
|
-
"variable_": "Variable {{number}}",
|
|
36
33
|
"pendingApproval_one": "Pending approval",
|
|
37
34
|
"pendingApproval_other": "Pending approvals",
|
|
38
35
|
"title": "Title",
|
|
@@ -48,12 +45,12 @@
|
|
|
48
45
|
"waitingFor": "Waiting for",
|
|
49
46
|
"templateDetails": "Template details",
|
|
50
47
|
"field": "Field",
|
|
51
|
-
"noDataHelpText": "Here is how you can use <a>{{entity}}.</a>"
|
|
48
|
+
"noDataHelpText": "Here is how you can use <a>{{entity, anyCase}}.</a>"
|
|
52
49
|
},
|
|
53
50
|
"validations": {
|
|
54
51
|
"limitExceeded": "You have exceeded the limit of {{limit}} characters for the {{what}}.",
|
|
55
52
|
"approver": "Please select a approver",
|
|
56
|
-
"required": "{{what}} is required",
|
|
53
|
+
"required": "{{what, anyCase}} is required",
|
|
57
54
|
"variableName": "Name must be alphanumeric, may include underscore, must start with a letter and must not end with an underscore.",
|
|
58
55
|
"pleaseEnter_": "Please enter {{what}}"
|
|
59
56
|
},
|