@adminforth/crud-approve-plugin 1.0.13 → 1.0.14
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/.woodpecker/buildSlackNotify.sh +3 -1
- package/.woodpecker/release.yml +27 -9
- package/05-CRUDApprove.md +0 -130
- package/build.log +15 -0
- package/custom/ListPageDiffView.vue +1 -1
- package/custom/pnpm-lock.yaml +308 -0
- package/dist/custom/ListPageDiffView.vue +86 -0
- package/dist/custom/ShowPageDiffView.vue +95 -0
- package/dist/custom/package-lock.json +420 -0
- package/dist/custom/package.json +6 -1
- package/dist/custom/pnpm-lock.yaml +308 -0
- package/dist/index.js +364 -19
- package/dist/types.js +10 -3
- package/index.ts +13 -1
- package/package.json +4 -4
|
@@ -4,8 +4,10 @@ set -x
|
|
|
4
4
|
|
|
5
5
|
COMMIT_SHORT_SHA=$(echo $CI_COMMIT_SHA | cut -c1-8)
|
|
6
6
|
|
|
7
|
+
STATUS=${1}
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
if [ "$STATUS" = "success" ]; then
|
|
9
11
|
MESSAGE="Did a build without issues on \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\`. Commit: _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
|
|
10
12
|
|
|
11
13
|
curl -s -X POST -H "Content-Type: application/json" -d '{
|
package/.woodpecker/release.yml
CHANGED
|
@@ -16,24 +16,42 @@ steps:
|
|
|
16
16
|
commands:
|
|
17
17
|
- infisical export --domain https://vault.devforth.io/api --format=dotenv-export --env="prod" > /woodpecker/deploy.vault.env
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
image:
|
|
19
|
+
build:
|
|
20
|
+
image: devforth/node20-pnpm:latest
|
|
21
21
|
when:
|
|
22
22
|
- event: push
|
|
23
23
|
commands:
|
|
24
24
|
- apt update && apt install -y rsync
|
|
25
|
-
-
|
|
26
|
-
-
|
|
25
|
+
- . /woodpecker/deploy.vault.env
|
|
26
|
+
- pnpm install
|
|
27
27
|
- /bin/bash ./.woodpecker/buildRelease.sh
|
|
28
28
|
- npm audit signatures
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
release:
|
|
31
|
+
image: devforth/node20-pnpm:latest
|
|
32
|
+
when:
|
|
33
|
+
- event:
|
|
34
|
+
- push
|
|
35
|
+
branch:
|
|
36
|
+
- main
|
|
37
|
+
commands:
|
|
38
|
+
- . /woodpecker/deploy.vault.env
|
|
39
|
+
- pnpm exec semantic-release
|
|
30
40
|
|
|
31
41
|
slack-on-failure:
|
|
42
|
+
image: curlimages/curl
|
|
32
43
|
when:
|
|
33
44
|
- event: push
|
|
34
|
-
status: [failure
|
|
35
|
-
|
|
45
|
+
status: [failure]
|
|
46
|
+
commands:
|
|
47
|
+
- . /woodpecker/deploy.vault.env
|
|
48
|
+
- /bin/sh ./.woodpecker/buildSlackNotify.sh failure
|
|
49
|
+
|
|
50
|
+
slack-on-success:
|
|
36
51
|
image: curlimages/curl
|
|
52
|
+
when:
|
|
53
|
+
- event: push
|
|
54
|
+
status: [success]
|
|
37
55
|
commands:
|
|
38
|
-
-
|
|
39
|
-
- /bin/sh ./.woodpecker/buildSlackNotify.sh
|
|
56
|
+
- . /woodpecker/deploy.vault.env
|
|
57
|
+
- /bin/sh ./.woodpecker/buildSlackNotify.sh success
|
package/05-CRUDApprove.md
CHANGED
|
@@ -18,133 +18,3 @@ import { AdminForthResourceInput, AdminForthDataTypes } from 'adminforth'
|
|
|
18
18
|
|
|
19
19
|
[Getting Started](<../001-gettingStarted.md>) will be used as base for this example.
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
## Creating table for storing activity data
|
|
23
|
-
For the first, to track records changes, we need to set up the database and table with certain fields inside where requests for changes will be stored.
|
|
24
|
-
|
|
25
|
-
First of all you should create this table in your own database `./schema.prisma`:
|
|
26
|
-
|
|
27
|
-
```ts title='./schema.prisma'
|
|
28
|
-
model crud_manual_approve {
|
|
29
|
-
_id String @id
|
|
30
|
-
created_at DateTime /// timestamp of applied change
|
|
31
|
-
resource_id String /// identifier of resource where change were applied
|
|
32
|
-
author_id String /// identifier of user who made the changes
|
|
33
|
-
responser_id String /// identifier of user who approved/rejected the request
|
|
34
|
-
action String /// type of change (create, edit, delete)
|
|
35
|
-
status String /// status of request (pending, approved, rejected)
|
|
36
|
-
data String? /// delta betwen before/after versions
|
|
37
|
-
record_id String? /// identifier of record that been changed
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
And `prisma migrate`:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
npm run makemigration -- --name add-crud-manual-approve ; npm run migrate:local
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
Also to make this code start
|
|
48
|
-
|
|
49
|
-
## Setting up the resource and dataSource for plugin
|
|
50
|
-
Add this code in `crud_manual_approve.ts`:
|
|
51
|
-
|
|
52
|
-
```ts title='./resources/crud_manual_approve.ts'
|
|
53
|
-
|
|
54
|
-
import AuditLogPlugin from "@adminforth/crud-approve/index.js";
|
|
55
|
-
import { AdminForthDataTypes } from "adminforth";
|
|
56
|
-
import { randomUUID } from "crypto";
|
|
57
|
-
|
|
58
|
-
export default {
|
|
59
|
-
dataSource: 'maindb',
|
|
60
|
-
table: 'crud_manual_approve',
|
|
61
|
-
columns: [
|
|
62
|
-
{ name: 'id', primaryKey: true, required: false, fillOnCreate: ({initialRecord}: any) => randomUUID(),
|
|
63
|
-
showIn: {
|
|
64
|
-
list: false,
|
|
65
|
-
edit: false,
|
|
66
|
-
create: false,
|
|
67
|
-
filter: false,
|
|
68
|
-
} },
|
|
69
|
-
{ name: 'created_at', required: false },
|
|
70
|
-
{ name: 'resource_id', required: false },
|
|
71
|
-
{ name: 'user_id', required: false,
|
|
72
|
-
foreignResource: {
|
|
73
|
-
resourceId: 'adminuser',
|
|
74
|
-
} },
|
|
75
|
-
{ name: 'action', required: false },
|
|
76
|
-
{ name: 'diff', required: false, type: AdminForthDataTypes.JSON, showIn: {
|
|
77
|
-
list: false,
|
|
78
|
-
edit: false,
|
|
79
|
-
create: false,
|
|
80
|
-
filter: false,
|
|
81
|
-
} },
|
|
82
|
-
{ name: 'record_id', required: false },
|
|
83
|
-
],
|
|
84
|
-
options: {
|
|
85
|
-
allowedActions: {
|
|
86
|
-
edit: false,
|
|
87
|
-
delete: false,
|
|
88
|
-
create: false
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
plugins: [
|
|
92
|
-
new AuditLogPlugin({
|
|
93
|
-
// if you want to exclude some resources from logging
|
|
94
|
-
//excludeResourceIds: ['adminuser'],
|
|
95
|
-
resourceColumns: {
|
|
96
|
-
resourceIdColumnName: 'resource_id',
|
|
97
|
-
resourceActionColumnName: 'action',
|
|
98
|
-
resourceDataColumnName: 'diff',
|
|
99
|
-
resourceUserIdColumnName: 'user_id',
|
|
100
|
-
resourceRecordIdColumnName: 'record_id',
|
|
101
|
-
resourceCreatedColumnName: 'created_at'
|
|
102
|
-
}
|
|
103
|
-
}),
|
|
104
|
-
],
|
|
105
|
-
}
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
Then you need to import `./resources/auditLogs`:
|
|
109
|
-
|
|
110
|
-
```ts title="./index.ts"
|
|
111
|
-
//diff-add
|
|
112
|
-
import auditLogsResource from "./resources/auditLogs"
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
... new AdminForth({
|
|
116
|
-
dataSources: [...],
|
|
117
|
-
...
|
|
118
|
-
resources: [
|
|
119
|
-
apartmentsResource,
|
|
120
|
-
usersResource,
|
|
121
|
-
//diff-add
|
|
122
|
-
auditLogsResource
|
|
123
|
-
],
|
|
124
|
-
...
|
|
125
|
-
]
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
Also, we need to add it to menu:
|
|
129
|
-
```ts
|
|
130
|
-
menu: [
|
|
131
|
-
...
|
|
132
|
-
//diff-add
|
|
133
|
-
{
|
|
134
|
-
//diff-add
|
|
135
|
-
label: 'Audit Logs',
|
|
136
|
-
//diff-add
|
|
137
|
-
icon: 'flowbite:search-outline',
|
|
138
|
-
//diff-add
|
|
139
|
-
resourceId: 'audit_logs',
|
|
140
|
-
//diff-add
|
|
141
|
-
}
|
|
142
|
-
]
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
That's it! Now you can see the logs in the table
|
|
146
|
-
|
|
147
|
-

|
|
148
|
-
|
|
149
|
-
<!-- See [API Reference](/docs/api/plugins/audit-log/types/type-aliases/PluginOptions.md) for more all options. -->
|
|
150
|
-
|
package/build.log
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
> @adminforth/crud-approve-plugin@1.0.13 build
|
|
3
|
+
> tsc && rsync -av --exclude 'node_modules' custom dist/
|
|
4
|
+
|
|
5
|
+
sending incremental file list
|
|
6
|
+
custom/
|
|
7
|
+
custom/ListPageDiffView.vue
|
|
8
|
+
custom/ShowPageDiffView.vue
|
|
9
|
+
custom/package-lock.json
|
|
10
|
+
custom/package.json
|
|
11
|
+
custom/pnpm-lock.yaml
|
|
12
|
+
custom/tsconfig.json
|
|
13
|
+
|
|
14
|
+
sent 32,973 bytes received 134 bytes 66,214.00 bytes/sec
|
|
15
|
+
total size is 32,471 speedup is 0.98
|
|
@@ -43,7 +43,7 @@ async function sendApproveRequest(approved) {
|
|
|
43
43
|
} else {
|
|
44
44
|
adminforth.alert({ message: `Successfully ${approved ? 'approved' : 'rejected'} the change.`, variant: 'success' });
|
|
45
45
|
// reload page
|
|
46
|
-
|
|
46
|
+
adminforth.list.refresh();
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
lockfileVersion: '9.0'
|
|
2
|
+
|
|
3
|
+
settings:
|
|
4
|
+
autoInstallPeers: true
|
|
5
|
+
excludeLinksFromLockfile: false
|
|
6
|
+
|
|
7
|
+
importers:
|
|
8
|
+
|
|
9
|
+
.:
|
|
10
|
+
dependencies:
|
|
11
|
+
'@git-diff-view/file':
|
|
12
|
+
specifier: ^0.0.35
|
|
13
|
+
version: 0.0.35
|
|
14
|
+
'@git-diff-view/vue':
|
|
15
|
+
specifier: ^0.0.35
|
|
16
|
+
version: 0.0.35(vue@3.5.30)
|
|
17
|
+
dayjs:
|
|
18
|
+
specifier: ^1.11.19
|
|
19
|
+
version: 1.11.20
|
|
20
|
+
|
|
21
|
+
packages:
|
|
22
|
+
|
|
23
|
+
'@babel/helper-string-parser@7.27.1':
|
|
24
|
+
resolution: {integrity: sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==}
|
|
25
|
+
engines: {node: '>=6.9.0'}
|
|
26
|
+
|
|
27
|
+
'@babel/helper-validator-identifier@7.28.5':
|
|
28
|
+
resolution: {integrity: sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==}
|
|
29
|
+
engines: {node: '>=6.9.0'}
|
|
30
|
+
|
|
31
|
+
'@babel/parser@7.29.2':
|
|
32
|
+
resolution: {integrity: sha512-4GgRzy/+fsBa72/RZVJmGKPmZu9Byn8o4MoLpmNe1m8ZfYnz5emHLQz3U4gLud6Zwl0RZIcgiLD7Uq7ySFuDLA==}
|
|
33
|
+
engines: {node: '>=6.0.0'}
|
|
34
|
+
hasBin: true
|
|
35
|
+
|
|
36
|
+
'@babel/types@7.29.0':
|
|
37
|
+
resolution: {integrity: sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==}
|
|
38
|
+
engines: {node: '>=6.9.0'}
|
|
39
|
+
|
|
40
|
+
'@git-diff-view/core@0.0.35':
|
|
41
|
+
resolution: {integrity: sha512-cdH3BopR6AWUW+6hP78zGyryKxR9JkPgryd1JN78i5k+F9Eo4x/4S23ZF1VZnrpPlGLrSuYfiAZ0ho5m+pTuKg==}
|
|
42
|
+
|
|
43
|
+
'@git-diff-view/file@0.0.35':
|
|
44
|
+
resolution: {integrity: sha512-1dDtW3fFpvM4Sj37m251Ofr/8mYJKE3YdiK3lKIDHBkdymF7vWp3O2dHUASKy1/HSd27NcHPrMRFqGUIMQN5Tg==}
|
|
45
|
+
|
|
46
|
+
'@git-diff-view/lowlight@0.0.35':
|
|
47
|
+
resolution: {integrity: sha512-MVpOxrNn1oHVOTOWUjxLbbf1W4OtVHjj6CHxwJbBRg9ZWZdShBINjuEgHVMSGB6vZuHKfwruRfXw8XxV3aF8zw==}
|
|
48
|
+
|
|
49
|
+
'@git-diff-view/vue@0.0.35':
|
|
50
|
+
resolution: {integrity: sha512-9Hy0iDYNoKWhb1HdlitcyLvMkZ89QJ7d/FTADGg/H7Wy4lOSLJ3fX7mAtuMacomI+blRFD3tK5AAOUnMRozczw==}
|
|
51
|
+
peerDependencies:
|
|
52
|
+
vue: ^3
|
|
53
|
+
|
|
54
|
+
'@jridgewell/sourcemap-codec@1.5.5':
|
|
55
|
+
resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==}
|
|
56
|
+
|
|
57
|
+
'@types/hast@3.0.4':
|
|
58
|
+
resolution: {integrity: sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==}
|
|
59
|
+
|
|
60
|
+
'@types/unist@3.0.3':
|
|
61
|
+
resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==}
|
|
62
|
+
|
|
63
|
+
'@vue/compiler-core@3.5.30':
|
|
64
|
+
resolution: {integrity: sha512-s3DfdZkcu/qExZ+td75015ljzHc6vE+30cFMGRPROYjqkroYI5NV2X1yAMX9UeyBNWB9MxCfPcsjpLS11nzkkw==}
|
|
65
|
+
|
|
66
|
+
'@vue/compiler-dom@3.5.30':
|
|
67
|
+
resolution: {integrity: sha512-eCFYESUEVYHhiMuK4SQTldO3RYxyMR/UQL4KdGD1Yrkfdx4m/HYuZ9jSfPdA+nWJY34VWndiYdW/wZXyiPEB9g==}
|
|
68
|
+
|
|
69
|
+
'@vue/compiler-sfc@3.5.30':
|
|
70
|
+
resolution: {integrity: sha512-LqmFPDn89dtU9vI3wHJnwaV6GfTRD87AjWpTWpyrdVOObVtjIuSeZr181z5C4PmVx/V3j2p+0f7edFKGRMpQ5A==}
|
|
71
|
+
|
|
72
|
+
'@vue/compiler-ssr@3.5.30':
|
|
73
|
+
resolution: {integrity: sha512-NsYK6OMTnx109PSL2IAyf62JP6EUdk4Dmj6AkWcJGBvN0dQoMYtVekAmdqgTtWQgEJo+Okstbf/1p7qZr5H+bA==}
|
|
74
|
+
|
|
75
|
+
'@vue/reactivity@3.5.30':
|
|
76
|
+
resolution: {integrity: sha512-179YNgKATuwj9gB+66snskRDOitDiuOZqkYia7mHKJaidOMo/WJxHKF8DuGc4V4XbYTJANlfEKb0yxTQotnx4Q==}
|
|
77
|
+
|
|
78
|
+
'@vue/runtime-core@3.5.30':
|
|
79
|
+
resolution: {integrity: sha512-e0Z+8PQsUTdwV8TtEsLzUM7SzC7lQwYKePydb7K2ZnmS6jjND+WJXkmmfh/swYzRyfP1EY3fpdesyYoymCzYfg==}
|
|
80
|
+
|
|
81
|
+
'@vue/runtime-dom@3.5.30':
|
|
82
|
+
resolution: {integrity: sha512-2UIGakjU4WSQ0T4iwDEW0W7vQj6n7AFn7taqZ9Cvm0Q/RA2FFOziLESrDL4GmtI1wV3jXg5nMoJSYO66egDUBw==}
|
|
83
|
+
|
|
84
|
+
'@vue/server-renderer@3.5.30':
|
|
85
|
+
resolution: {integrity: sha512-v+R34icapydRwbZRD0sXwtHqrQJv38JuMB4JxbOxd8NEpGLny7cncMp53W9UH/zo4j8eDHjQ1dEJXwzFQknjtQ==}
|
|
86
|
+
peerDependencies:
|
|
87
|
+
vue: 3.5.30
|
|
88
|
+
|
|
89
|
+
'@vue/shared@3.5.30':
|
|
90
|
+
resolution: {integrity: sha512-YXgQ7JjaO18NeK2K9VTbDHaFy62WrObMa6XERNfNOkAhD1F1oDSf3ZJ7K6GqabZ0BvSDHajp8qfS5Sa2I9n8uQ==}
|
|
91
|
+
|
|
92
|
+
csstype@3.2.3:
|
|
93
|
+
resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==}
|
|
94
|
+
|
|
95
|
+
dayjs@1.11.20:
|
|
96
|
+
resolution: {integrity: sha512-YbwwqR/uYpeoP4pu043q+LTDLFBLApUP6VxRihdfNTqu4ubqMlGDLd6ErXhEgsyvY0K6nCs7nggYumAN+9uEuQ==}
|
|
97
|
+
|
|
98
|
+
dequal@2.0.3:
|
|
99
|
+
resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==}
|
|
100
|
+
engines: {node: '>=6'}
|
|
101
|
+
|
|
102
|
+
devlop@1.1.0:
|
|
103
|
+
resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==}
|
|
104
|
+
|
|
105
|
+
diff@8.0.3:
|
|
106
|
+
resolution: {integrity: sha512-qejHi7bcSD4hQAZE0tNAawRK1ZtafHDmMTMkrrIGgSLl7hTnQHmKCeB45xAcbfTqK2zowkM3j3bHt/4b/ARbYQ==}
|
|
107
|
+
engines: {node: '>=0.3.1'}
|
|
108
|
+
|
|
109
|
+
entities@7.0.1:
|
|
110
|
+
resolution: {integrity: sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==}
|
|
111
|
+
engines: {node: '>=0.12'}
|
|
112
|
+
|
|
113
|
+
estree-walker@2.0.2:
|
|
114
|
+
resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}
|
|
115
|
+
|
|
116
|
+
fast-diff@1.3.0:
|
|
117
|
+
resolution: {integrity: sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==}
|
|
118
|
+
|
|
119
|
+
highlight.js@11.11.1:
|
|
120
|
+
resolution: {integrity: sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w==}
|
|
121
|
+
engines: {node: '>=12.0.0'}
|
|
122
|
+
|
|
123
|
+
lowlight@3.3.0:
|
|
124
|
+
resolution: {integrity: sha512-0JNhgFoPvP6U6lE/UdVsSq99tn6DhjjpAj5MxG49ewd2mOBVtwWYIT8ClyABhq198aXXODMU6Ox8DrGy/CpTZQ==}
|
|
125
|
+
|
|
126
|
+
magic-string@0.30.21:
|
|
127
|
+
resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}
|
|
128
|
+
|
|
129
|
+
nanoid@3.3.11:
|
|
130
|
+
resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==}
|
|
131
|
+
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
|
|
132
|
+
hasBin: true
|
|
133
|
+
|
|
134
|
+
picocolors@1.1.1:
|
|
135
|
+
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
|
|
136
|
+
|
|
137
|
+
postcss@8.5.8:
|
|
138
|
+
resolution: {integrity: sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg==}
|
|
139
|
+
engines: {node: ^10 || ^12 || >=14}
|
|
140
|
+
|
|
141
|
+
source-map-js@1.2.1:
|
|
142
|
+
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
|
143
|
+
engines: {node: '>=0.10.0'}
|
|
144
|
+
|
|
145
|
+
vue@3.5.30:
|
|
146
|
+
resolution: {integrity: sha512-hTHLc6VNZyzzEH/l7PFGjpcTvUgiaPK5mdLkbjrTeWSRcEfxFrv56g/XckIYlE9ckuobsdwqd5mk2g1sBkMewg==}
|
|
147
|
+
peerDependencies:
|
|
148
|
+
typescript: '*'
|
|
149
|
+
peerDependenciesMeta:
|
|
150
|
+
typescript:
|
|
151
|
+
optional: true
|
|
152
|
+
|
|
153
|
+
snapshots:
|
|
154
|
+
|
|
155
|
+
'@babel/helper-string-parser@7.27.1': {}
|
|
156
|
+
|
|
157
|
+
'@babel/helper-validator-identifier@7.28.5': {}
|
|
158
|
+
|
|
159
|
+
'@babel/parser@7.29.2':
|
|
160
|
+
dependencies:
|
|
161
|
+
'@babel/types': 7.29.0
|
|
162
|
+
|
|
163
|
+
'@babel/types@7.29.0':
|
|
164
|
+
dependencies:
|
|
165
|
+
'@babel/helper-string-parser': 7.27.1
|
|
166
|
+
'@babel/helper-validator-identifier': 7.28.5
|
|
167
|
+
|
|
168
|
+
'@git-diff-view/core@0.0.35':
|
|
169
|
+
dependencies:
|
|
170
|
+
'@git-diff-view/lowlight': 0.0.35
|
|
171
|
+
fast-diff: 1.3.0
|
|
172
|
+
highlight.js: 11.11.1
|
|
173
|
+
lowlight: 3.3.0
|
|
174
|
+
|
|
175
|
+
'@git-diff-view/file@0.0.35':
|
|
176
|
+
dependencies:
|
|
177
|
+
'@git-diff-view/core': 0.0.35
|
|
178
|
+
diff: 8.0.3
|
|
179
|
+
fast-diff: 1.3.0
|
|
180
|
+
highlight.js: 11.11.1
|
|
181
|
+
lowlight: 3.3.0
|
|
182
|
+
|
|
183
|
+
'@git-diff-view/lowlight@0.0.35':
|
|
184
|
+
dependencies:
|
|
185
|
+
'@types/hast': 3.0.4
|
|
186
|
+
highlight.js: 11.11.1
|
|
187
|
+
lowlight: 3.3.0
|
|
188
|
+
|
|
189
|
+
'@git-diff-view/vue@0.0.35(vue@3.5.30)':
|
|
190
|
+
dependencies:
|
|
191
|
+
'@git-diff-view/core': 0.0.35
|
|
192
|
+
'@types/hast': 3.0.4
|
|
193
|
+
fast-diff: 1.3.0
|
|
194
|
+
highlight.js: 11.11.1
|
|
195
|
+
lowlight: 3.3.0
|
|
196
|
+
vue: 3.5.30
|
|
197
|
+
|
|
198
|
+
'@jridgewell/sourcemap-codec@1.5.5': {}
|
|
199
|
+
|
|
200
|
+
'@types/hast@3.0.4':
|
|
201
|
+
dependencies:
|
|
202
|
+
'@types/unist': 3.0.3
|
|
203
|
+
|
|
204
|
+
'@types/unist@3.0.3': {}
|
|
205
|
+
|
|
206
|
+
'@vue/compiler-core@3.5.30':
|
|
207
|
+
dependencies:
|
|
208
|
+
'@babel/parser': 7.29.2
|
|
209
|
+
'@vue/shared': 3.5.30
|
|
210
|
+
entities: 7.0.1
|
|
211
|
+
estree-walker: 2.0.2
|
|
212
|
+
source-map-js: 1.2.1
|
|
213
|
+
|
|
214
|
+
'@vue/compiler-dom@3.5.30':
|
|
215
|
+
dependencies:
|
|
216
|
+
'@vue/compiler-core': 3.5.30
|
|
217
|
+
'@vue/shared': 3.5.30
|
|
218
|
+
|
|
219
|
+
'@vue/compiler-sfc@3.5.30':
|
|
220
|
+
dependencies:
|
|
221
|
+
'@babel/parser': 7.29.2
|
|
222
|
+
'@vue/compiler-core': 3.5.30
|
|
223
|
+
'@vue/compiler-dom': 3.5.30
|
|
224
|
+
'@vue/compiler-ssr': 3.5.30
|
|
225
|
+
'@vue/shared': 3.5.30
|
|
226
|
+
estree-walker: 2.0.2
|
|
227
|
+
magic-string: 0.30.21
|
|
228
|
+
postcss: 8.5.8
|
|
229
|
+
source-map-js: 1.2.1
|
|
230
|
+
|
|
231
|
+
'@vue/compiler-ssr@3.5.30':
|
|
232
|
+
dependencies:
|
|
233
|
+
'@vue/compiler-dom': 3.5.30
|
|
234
|
+
'@vue/shared': 3.5.30
|
|
235
|
+
|
|
236
|
+
'@vue/reactivity@3.5.30':
|
|
237
|
+
dependencies:
|
|
238
|
+
'@vue/shared': 3.5.30
|
|
239
|
+
|
|
240
|
+
'@vue/runtime-core@3.5.30':
|
|
241
|
+
dependencies:
|
|
242
|
+
'@vue/reactivity': 3.5.30
|
|
243
|
+
'@vue/shared': 3.5.30
|
|
244
|
+
|
|
245
|
+
'@vue/runtime-dom@3.5.30':
|
|
246
|
+
dependencies:
|
|
247
|
+
'@vue/reactivity': 3.5.30
|
|
248
|
+
'@vue/runtime-core': 3.5.30
|
|
249
|
+
'@vue/shared': 3.5.30
|
|
250
|
+
csstype: 3.2.3
|
|
251
|
+
|
|
252
|
+
'@vue/server-renderer@3.5.30(vue@3.5.30)':
|
|
253
|
+
dependencies:
|
|
254
|
+
'@vue/compiler-ssr': 3.5.30
|
|
255
|
+
'@vue/shared': 3.5.30
|
|
256
|
+
vue: 3.5.30
|
|
257
|
+
|
|
258
|
+
'@vue/shared@3.5.30': {}
|
|
259
|
+
|
|
260
|
+
csstype@3.2.3: {}
|
|
261
|
+
|
|
262
|
+
dayjs@1.11.20: {}
|
|
263
|
+
|
|
264
|
+
dequal@2.0.3: {}
|
|
265
|
+
|
|
266
|
+
devlop@1.1.0:
|
|
267
|
+
dependencies:
|
|
268
|
+
dequal: 2.0.3
|
|
269
|
+
|
|
270
|
+
diff@8.0.3: {}
|
|
271
|
+
|
|
272
|
+
entities@7.0.1: {}
|
|
273
|
+
|
|
274
|
+
estree-walker@2.0.2: {}
|
|
275
|
+
|
|
276
|
+
fast-diff@1.3.0: {}
|
|
277
|
+
|
|
278
|
+
highlight.js@11.11.1: {}
|
|
279
|
+
|
|
280
|
+
lowlight@3.3.0:
|
|
281
|
+
dependencies:
|
|
282
|
+
'@types/hast': 3.0.4
|
|
283
|
+
devlop: 1.1.0
|
|
284
|
+
highlight.js: 11.11.1
|
|
285
|
+
|
|
286
|
+
magic-string@0.30.21:
|
|
287
|
+
dependencies:
|
|
288
|
+
'@jridgewell/sourcemap-codec': 1.5.5
|
|
289
|
+
|
|
290
|
+
nanoid@3.3.11: {}
|
|
291
|
+
|
|
292
|
+
picocolors@1.1.1: {}
|
|
293
|
+
|
|
294
|
+
postcss@8.5.8:
|
|
295
|
+
dependencies:
|
|
296
|
+
nanoid: 3.3.11
|
|
297
|
+
picocolors: 1.1.1
|
|
298
|
+
source-map-js: 1.2.1
|
|
299
|
+
|
|
300
|
+
source-map-js@1.2.1: {}
|
|
301
|
+
|
|
302
|
+
vue@3.5.30:
|
|
303
|
+
dependencies:
|
|
304
|
+
'@vue/compiler-dom': 3.5.30
|
|
305
|
+
'@vue/compiler-sfc': 3.5.30
|
|
306
|
+
'@vue/runtime-dom': 3.5.30
|
|
307
|
+
'@vue/server-renderer': 3.5.30(vue@3.5.30)
|
|
308
|
+
'@vue/shared': 3.5.30
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useCoreStore } from '@/stores/core';
|
|
3
|
+
import { computed, ref, watch } from 'vue';
|
|
4
|
+
import "@git-diff-view/vue/styles/diff-view.css";
|
|
5
|
+
import { DiffView, DiffModeEnum } from "@git-diff-view/vue";
|
|
6
|
+
import { generateDiffFile } from "@git-diff-view/file";
|
|
7
|
+
import { callAdminForthApi } from '@/utils';
|
|
8
|
+
import adminforth from '@/adminforth';
|
|
9
|
+
import { Button } from '@/afcl'
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
const props = defineProps(['column', 'record', 'meta', 'resource', 'adminUser']);
|
|
13
|
+
const coreStore = useCoreStore();
|
|
14
|
+
const theme = computed(() => coreStore.theme);
|
|
15
|
+
|
|
16
|
+
const oldContent = JSON.stringify(props.record[props.meta.resourceColumns.dataColumnName].oldRecord, null, 2)
|
|
17
|
+
const newContent = JSON.stringify(props.record[props.meta.resourceColumns.dataColumnName].newRecord, null, 2)
|
|
18
|
+
|
|
19
|
+
const diffFile = ref();
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
async function sendApproveRequest(approved) {
|
|
23
|
+
let code = '123456'
|
|
24
|
+
if (approved) {
|
|
25
|
+
code = await (window).adminforthTwoFaModal.get2FaConfirmationResult?.("Approve Action Confirmation");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const data = await callAdminForthApi({
|
|
29
|
+
path: `/plugin/crud-approve/update-status`,
|
|
30
|
+
method: 'POST',
|
|
31
|
+
body: {
|
|
32
|
+
meta: { confirmationResult: code },
|
|
33
|
+
connectorId: props.resource.connectorId,
|
|
34
|
+
resourceId: props.resource.resourceId,
|
|
35
|
+
action: props.record[props.meta.resourceColumns.actionColumnName],
|
|
36
|
+
recordId: props.record[props.meta.resourceColumns.recordIdColumnName],
|
|
37
|
+
diffId: props.record[props.meta.resourceColumns.idColumnName],
|
|
38
|
+
approved: approved
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
if (data.error && data.error !== 'Operation aborted by hook') {
|
|
42
|
+
adminforth.alert({ message: `Error: ${data.error}`, variant: 'warning' });
|
|
43
|
+
} else {
|
|
44
|
+
adminforth.alert({ message: `Successfully ${approved ? 'approved' : 'rejected'} the change.`, variant: 'success' });
|
|
45
|
+
// reload page
|
|
46
|
+
adminforth.list.refresh();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function initDiffFile() {
|
|
51
|
+
const file = generateDiffFile(
|
|
52
|
+
'diff.json', oldContent.slice(2, -1),
|
|
53
|
+
'diff.json', newContent.slice(2, -1),
|
|
54
|
+
'json', 'json'
|
|
55
|
+
);
|
|
56
|
+
file.initTheme(theme.value === 'dark' ? 'dark' : 'light');
|
|
57
|
+
file.init();
|
|
58
|
+
file.buildUnifiedDiffLines();
|
|
59
|
+
diffFile.value = file;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
initDiffFile();
|
|
63
|
+
|
|
64
|
+
watch([theme], ([t]) => {
|
|
65
|
+
if (!diffFile.value) return;
|
|
66
|
+
diffFile.value.initTheme(t === 'dark' ? 'dark' : 'light');
|
|
67
|
+
diffFile.value.buildUnifiedDiffLines();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<template>
|
|
73
|
+
<DiffView
|
|
74
|
+
:diff-file="diffFile"
|
|
75
|
+
:diff-view-mode="DiffModeEnum.Unified"
|
|
76
|
+
:diff-view-theme="theme === 'dark' ? 'dark' : 'light'"
|
|
77
|
+
:diff-view-highlight="true"
|
|
78
|
+
:diff-view-wrap="true"
|
|
79
|
+
:diff-view-font-size="14"
|
|
80
|
+
/>
|
|
81
|
+
<div v-if="record[meta.resourceColumns.statusColumnName] === 1" style="margin-top: 16px; display: flex; gap: 8px;">
|
|
82
|
+
<Button style="background-color: green; color: white;" @click="sendApproveRequest(true)" :loader="false" class="w-full">Approve</Button>
|
|
83
|
+
<Button style="background-color: red; color: white;" @click="sendApproveRequest(false)" :loader="false" class="w-full">Reject</Button>
|
|
84
|
+
</div>
|
|
85
|
+
</template>
|
|
86
|
+
|