@adminforth/crud-approve-plugin 1.0.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/.woodpecker/buildRelease.sh +13 -0
- package/.woodpecker/buildSlackNotify.sh +44 -0
- package/.woodpecker/release.yml +39 -0
- package/05-CRUDApprove.md +150 -0
- package/LICENSE +21 -0
- package/README.md +7 -0
- package/custom/ListPageDiffView.vue +82 -0
- package/custom/ShowPageDiffView.vue +91 -0
- package/custom/package-lock.json +420 -0
- package/custom/package.json +18 -0
- package/custom/tsconfig.json +16 -0
- package/dist/custom/package.json +13 -0
- package/dist/custom/tsconfig.json +16 -0
- package/dist/index.js +51 -0
- package/dist/types.js +6 -0
- package/index.ts +422 -0
- package/package.json +59 -0
- package/tsconfig.json +13 -0
- package/types.ts +32 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
#!/bin/bash
|
|
3
|
+
|
|
4
|
+
# write npm run output both to console and to build.log
|
|
5
|
+
npm run build 2>&1 | tee build.log
|
|
6
|
+
build_status=${PIPESTATUS[0]}
|
|
7
|
+
|
|
8
|
+
# if exist status from the npm run build is not 0
|
|
9
|
+
# then exit with the status code from the npm run build
|
|
10
|
+
if [ $build_status -ne 0 ]; then
|
|
11
|
+
echo "Build failed. Exiting with status code $build_status"
|
|
12
|
+
exit $build_status
|
|
13
|
+
fi
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
set -x
|
|
4
|
+
|
|
5
|
+
COMMIT_SHORT_SHA=$(echo $CI_COMMIT_SHA | cut -c1-8)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
if [ "$CI_STEP_STATUS" = "success" ]; then
|
|
9
|
+
MESSAGE="Did a build without issues on \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\`. Commit: _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
|
|
10
|
+
|
|
11
|
+
curl -s -X POST -H "Content-Type: application/json" -d '{
|
|
12
|
+
"username": "'"$CI_COMMIT_AUTHOR"'",
|
|
13
|
+
"icon_url": "'"$CI_COMMIT_AUTHOR_AVATAR"'",
|
|
14
|
+
"attachments": [
|
|
15
|
+
{
|
|
16
|
+
"mrkdwn_in": ["text", "pretext"],
|
|
17
|
+
"color": "#36a64f",
|
|
18
|
+
"text": "'"$MESSAGE"'"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}' "$DEVELOPERS_SLACK_WEBHOOK"
|
|
22
|
+
exit 0
|
|
23
|
+
fi
|
|
24
|
+
export BUILD_LOG=$(cat ./build.log)
|
|
25
|
+
|
|
26
|
+
BUILD_LOG=$(echo $BUILD_LOG | sed 's/"/\\"/g')
|
|
27
|
+
|
|
28
|
+
MESSAGE="Broke \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\` with commit _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
|
|
29
|
+
CODE_BLOCK="\`\`\`$BUILD_LOG\n\`\`\`"
|
|
30
|
+
|
|
31
|
+
echo "Sending slack message to developers $MESSAGE"
|
|
32
|
+
# Send the message
|
|
33
|
+
curl -sS -X POST -H "Content-Type: application/json" -d '{
|
|
34
|
+
"username": "'"$CI_COMMIT_AUTHOR"'",
|
|
35
|
+
"icon_url": "'"$CI_COMMIT_AUTHOR_AVATAR"'",
|
|
36
|
+
"attachments": [
|
|
37
|
+
{
|
|
38
|
+
"mrkdwn_in": ["text", "pretext"],
|
|
39
|
+
"color": "#8A1C12",
|
|
40
|
+
"text": "'"$CODE_BLOCK"'",
|
|
41
|
+
"pretext": "'"$MESSAGE"'"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}' "$DEVELOPERS_SLACK_WEBHOOK" 2>&1
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
clone:
|
|
2
|
+
git:
|
|
3
|
+
image: woodpeckerci/plugin-git
|
|
4
|
+
settings:
|
|
5
|
+
partial: false
|
|
6
|
+
depth: 5
|
|
7
|
+
|
|
8
|
+
steps:
|
|
9
|
+
init-secrets:
|
|
10
|
+
when:
|
|
11
|
+
- event: push
|
|
12
|
+
image: infisical/cli
|
|
13
|
+
environment:
|
|
14
|
+
INFISICAL_TOKEN:
|
|
15
|
+
from_secret: VAULT_TOKEN
|
|
16
|
+
commands:
|
|
17
|
+
- infisical export --domain https://vault.devforth.io/api --format=dotenv-export --env="prod" > /woodpecker/deploy.vault.env
|
|
18
|
+
|
|
19
|
+
release:
|
|
20
|
+
image: node:20
|
|
21
|
+
when:
|
|
22
|
+
- event: push
|
|
23
|
+
commands:
|
|
24
|
+
- apt update && apt install -y rsync
|
|
25
|
+
- export $(cat /woodpecker/deploy.vault.env | xargs)
|
|
26
|
+
- npm clean-install
|
|
27
|
+
- /bin/bash ./.woodpecker/buildRelease.sh
|
|
28
|
+
- npm audit signatures
|
|
29
|
+
- npx semantic-release
|
|
30
|
+
|
|
31
|
+
slack-on-failure:
|
|
32
|
+
when:
|
|
33
|
+
- event: push
|
|
34
|
+
status: [failure, success]
|
|
35
|
+
- event: push
|
|
36
|
+
image: curlimages/curl
|
|
37
|
+
commands:
|
|
38
|
+
- export $(cat /woodpecker/deploy.vault.env | xargs)
|
|
39
|
+
- /bin/sh ./.woodpecker/buildSlackNotify.sh
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
CRUDApprove plugin allows to send all changes in the resources done from the admin panel for a manual approvement to a trusted users or roles.
|
|
2
|
+
It will allow you to split the responsibility for updating records between users by providing manual approvement features with flexible configuration.
|
|
3
|
+
Requires separate table in the database to store approvement requests.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm i @adminforth/crud-approve --save
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Create `crud_manual_approve.ts` in `resources` folder:
|
|
13
|
+
|
|
14
|
+
```ts title="./resources/crud_manual_approve.ts"
|
|
15
|
+
import CRUDApprovePlugin from '@adminforth/crud-approve';
|
|
16
|
+
import { AdminForthResourceInput, AdminForthDataTypes } from 'adminforth'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
[Getting Started](<../001-gettingStarted.md>) will be used as base for this example.
|
|
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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Devforth.io
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# AdminForth CRUD Approve plugin
|
|
2
|
+
|
|
3
|
+
<img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT" />
|
|
4
|
+
|
|
5
|
+
Adds manual approval for editing actions. Make your admins blame each other for their mistakes 😉
|
|
6
|
+
|
|
7
|
+
## For usage, see [AdminForth CRUDApprove Documentation](https://adminforth.dev/docs/tutorial/Plugins/CRUDApprove/)
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
const code = await (window).adminforthTwoFaModal.get2FaConfirmationResult?.(undefined, "Approve/Reject Action Confirmation");
|
|
24
|
+
const data = await callAdminForthApi({
|
|
25
|
+
path: `/plugin/crud-approve/update-status`,
|
|
26
|
+
method: 'POST',
|
|
27
|
+
body: {
|
|
28
|
+
meta: { confirmationResult: code },
|
|
29
|
+
connectorId: props.resource.connectorId,
|
|
30
|
+
resourceId: props.resource.resourceId,
|
|
31
|
+
action: props.record[props.meta.resourceColumns.actionColumnName],
|
|
32
|
+
recordId: props.record[props.meta.resourceColumns.recordIdColumnName],
|
|
33
|
+
diffId: props.record[props.meta.resourceColumns.idColumnName],
|
|
34
|
+
approved: approved
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
if (data.error) {
|
|
38
|
+
adminforth.alert({ message: `Error: ${data.error}`, variant: 'warning' });
|
|
39
|
+
} else {
|
|
40
|
+
adminforth.alert({ message: `Successfully ${approved ? 'approved' : 'rejected'} the change.`, variant: 'success' });
|
|
41
|
+
// reload page
|
|
42
|
+
window.location.reload();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function initDiffFile() {
|
|
47
|
+
const file = generateDiffFile(
|
|
48
|
+
'diff.json', oldContent.slice(2, -1),
|
|
49
|
+
'diff.json', newContent.slice(2, -1),
|
|
50
|
+
'json', 'json'
|
|
51
|
+
);
|
|
52
|
+
file.initTheme(theme.value === 'dark' ? 'dark' : 'light');
|
|
53
|
+
file.init();
|
|
54
|
+
file.buildUnifiedDiffLines();
|
|
55
|
+
diffFile.value = file;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
initDiffFile();
|
|
59
|
+
|
|
60
|
+
watch([theme], ([t]) => {
|
|
61
|
+
if (!diffFile.value) return;
|
|
62
|
+
diffFile.value.initTheme(t === 'dark' ? 'dark' : 'light');
|
|
63
|
+
diffFile.value.buildUnifiedDiffLines();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<template>
|
|
69
|
+
<DiffView
|
|
70
|
+
:diff-file="diffFile"
|
|
71
|
+
:diff-view-mode="DiffModeEnum.Unified"
|
|
72
|
+
:diff-view-theme="theme === 'dark' ? 'dark' : 'light'"
|
|
73
|
+
:diff-view-highlight="true"
|
|
74
|
+
:diff-view-wrap="true"
|
|
75
|
+
:diff-view-font-size="14"
|
|
76
|
+
/>
|
|
77
|
+
<div v-if="record[meta.resourceColumns.statusColumnName] === 1" style="margin-top: 16px; display: flex; gap: 8px;">
|
|
78
|
+
<Button style="background-color: green; color: white;" @click="sendApproveRequest(true)" :loader="false" class="w-full">Approve</Button>
|
|
79
|
+
<Button style="background-color: red; color: white;" @click="sendApproveRequest(false)" :loader="false" class="w-full">Reject</Button>
|
|
80
|
+
</div>
|
|
81
|
+
</template>
|
|
82
|
+
|
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
import { useRouter } from 'vue-router';
|
|
11
|
+
|
|
12
|
+
const router = useRouter();
|
|
13
|
+
const props = defineProps(['column', 'record', 'meta', 'resource', 'adminUser']);
|
|
14
|
+
const coreStore = useCoreStore();
|
|
15
|
+
const theme = computed(() => coreStore.theme);
|
|
16
|
+
const isMobile = computed(() => /(Android|iPhone|iPad|iPod)/i.test(navigator.userAgent));
|
|
17
|
+
const mode = computed(() => isMobile.value ? DiffModeEnum.Unified : DiffModeEnum.Split);
|
|
18
|
+
|
|
19
|
+
const oldContent = JSON.stringify(props.record[props.meta.resourceColumns.dataColumnName].oldRecord, null, 2)
|
|
20
|
+
const newContent = JSON.stringify(props.record[props.meta.resourceColumns.dataColumnName].newRecord, null, 2)
|
|
21
|
+
|
|
22
|
+
const diffFile = ref();
|
|
23
|
+
|
|
24
|
+
async function sendApproveRequest(approved) {
|
|
25
|
+
const code = await (window).adminforthTwoFaModal.get2FaConfirmationResult?.(undefined, "Approve/Reject Action Confirmation");
|
|
26
|
+
const data = await callAdminForthApi({
|
|
27
|
+
path: `/plugin/crud-approve/update-status`,
|
|
28
|
+
method: 'POST',
|
|
29
|
+
body: {
|
|
30
|
+
meta: { confirmationResult: code },
|
|
31
|
+
connectorId: props.resource.connectorId,
|
|
32
|
+
resourceId: props.resource.resourceId,
|
|
33
|
+
action: props.record[props.meta.resourceColumns.actionColumnName],
|
|
34
|
+
recordId: props.record[props.meta.resourceColumns.recordIdColumnName],
|
|
35
|
+
diffId: props.record[props.meta.resourceColumns.idColumnName],
|
|
36
|
+
approved: approved
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
if (data.error) {
|
|
40
|
+
adminforth.alert({ message: `Error: ${data.error}`, variant: 'warning' });
|
|
41
|
+
} else {
|
|
42
|
+
adminforth.alert({ message: `Successfully ${approved ? 'approved' : 'rejected'} the change.`, variant: 'success' });
|
|
43
|
+
router.push(router.currentRoute.value.fullPath.split('/show')[0]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function initDiffFile() {
|
|
48
|
+
const file = generateDiffFile(
|
|
49
|
+
'diff.json', oldContent,
|
|
50
|
+
'diff.json', newContent,
|
|
51
|
+
'json', 'json'
|
|
52
|
+
);
|
|
53
|
+
file.initTheme(theme.value === 'dark' ? 'dark' : 'light');
|
|
54
|
+
file.init();
|
|
55
|
+
if (mode.value === DiffModeEnum.Split) {
|
|
56
|
+
file.buildSplitDiffLines();
|
|
57
|
+
} else {
|
|
58
|
+
file.buildUnifiedDiffLines();
|
|
59
|
+
}
|
|
60
|
+
diffFile.value = file;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
initDiffFile();
|
|
64
|
+
|
|
65
|
+
watch([mode, theme], ([m, t]) => {
|
|
66
|
+
if (!diffFile.value) return;
|
|
67
|
+
diffFile.value.initTheme(t === 'dark' ? 'dark' : 'light');
|
|
68
|
+
if (m === DiffModeEnum.Split) {
|
|
69
|
+
diffFile.value.buildSplitDiffLines();
|
|
70
|
+
} else {
|
|
71
|
+
diffFile.value.buildUnifiedDiffLines();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<template>
|
|
78
|
+
<DiffView
|
|
79
|
+
:diff-file="diffFile"
|
|
80
|
+
:diff-view-mode="mode"
|
|
81
|
+
:diff-view-theme="theme === 'dark' ? 'dark' : 'light'"
|
|
82
|
+
:diff-view-highlight="true"
|
|
83
|
+
:diff-view-wrap="true"
|
|
84
|
+
:diff-view-font-size="14"
|
|
85
|
+
/>
|
|
86
|
+
<div v-if="record[meta.resourceColumns.statusColumnName] === 1" style="margin-top: 16px; display: flex; gap: 8px;">
|
|
87
|
+
<Button style="background-color: green; color: white;" @click="sendApproveRequest(true)" :loader="false" class="w-full">Approve</Button>
|
|
88
|
+
<Button style="background-color: red; color: white;" @click="sendApproveRequest(false)" :loader="false" class="w-full">Reject</Button>
|
|
89
|
+
</div>
|
|
90
|
+
</template>
|
|
91
|
+
|