@mvriu5/payload-ai 1.2.0 → 1.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 +118 -13
- package/dist/ai/providerOptions.d.ts +24 -1
- package/dist/ai/providerOptions.js +81 -0
- package/dist/ai/providerRuntime.d.ts +2 -1
- package/dist/ai/providerRuntime.js +5 -2
- package/dist/ai/tokenUsage.d.ts +38 -0
- package/dist/ai/tokenUsage.js +106 -0
- package/dist/components/Icons.d.ts +1 -8
- package/dist/components/Icons.js +10 -207
- package/dist/components/{ActionToast.d.ts → action-toast/ActionToast.d.ts} +5 -2
- package/dist/components/{ActionToast.js → action-toast/ActionToast.js} +81 -54
- package/dist/components/{ActionToast.module.css → action-toast/ActionToast.module.css} +0 -79
- package/dist/components/ai-input/AIInput.d.ts +5 -0
- package/dist/components/ai-input/AIInput.js +548 -0
- package/dist/components/{AIInput.module.css → ai-input/AIInput.module.css} +150 -44
- package/dist/components/ai-input/badge.d.ts +14 -0
- package/dist/components/ai-input/badge.js +85 -0
- package/dist/components/{AuditLogList.d.ts → audit-log-list/AuditLogList.d.ts} +4 -8
- package/dist/components/{AuditLogList.js → audit-log-list/AuditLogList.js} +56 -21
- package/dist/components/{AuditLogList.module.css → audit-log-list/AuditLogList.module.css} +11 -65
- package/dist/components/dashboard/Dashboard.d.ts +2 -0
- package/dist/components/dashboard/Dashboard.js +17 -0
- package/dist/components/dashboard/Dashboard.module.css +13 -0
- package/dist/components/{DiffDialog.d.ts → diff-dialog/DiffDialog.d.ts} +2 -2
- package/dist/components/{DiffDialog.js → diff-dialog/DiffDialog.js} +200 -189
- package/dist/components/{DiffDialog.module.css → diff-dialog/DiffDialog.module.css} +17 -35
- package/dist/components/hooks/useAIChatStream.d.ts +50 -0
- package/dist/components/hooks/useAIChatStream.js +226 -0
- package/dist/components/hooks/useAISettings.d.ts +6 -4
- package/dist/components/hooks/useAISettings.js +68 -27
- package/dist/components/hooks/useAuditLog.d.ts +11 -0
- package/dist/components/hooks/useAuditLog.js +41 -0
- package/dist/components/hooks/useDocumentMentionSuggestions.d.ts +1 -1
- package/dist/components/hooks/useDocumentMentionSuggestions.js +31 -27
- package/dist/components/hooks/useMentions.d.ts +58 -0
- package/dist/components/hooks/useMentions.js +276 -0
- package/dist/components/hooks/usePluginConfig.d.ts +40 -0
- package/dist/components/hooks/usePluginConfig.js +27 -0
- package/dist/components/{MentionPopover.d.ts → mention-popover/MentionPopover.d.ts} +2 -4
- package/dist/components/{MentionPopover.js → mention-popover/MentionPopover.js} +1 -8
- package/dist/components/{MentionPopover.module.css → mention-popover/MentionPopover.module.css} +1 -1
- package/dist/components/text-shimmer/TextShimmer.d.ts +9 -0
- package/dist/components/text-shimmer/TextShimmer.js +34 -0
- package/dist/components/text-shimmer/TextShimmer.module.css +19 -0
- package/dist/exports/client.d.ts +4 -2
- package/dist/exports/client.js +4 -2
- package/dist/handlers/applyActionHandler.js +27 -7
- package/dist/handlers/chatHandler.d.ts +4 -1
- package/dist/handlers/chatHandler.js +499 -74
- package/dist/handlers/mediaUploadHandler.d.ts +7 -0
- package/dist/handlers/mediaUploadHandler.js +99 -0
- package/dist/handlers/mentionSuggestionHandler.js +16 -14
- package/dist/handlers/proposalDiffHandler.js +41 -29
- package/dist/index.d.ts +12 -1
- package/dist/index.js +131 -12
- package/dist/payload/collectionPermissions.js +3 -1
- package/dist/payload/normalizeData.d.ts +0 -6
- package/dist/payload/normalizeData.js +25 -13
- package/dist/payload/proposalData.js +4 -1
- package/dist/payload/schemaContext.js +98 -43
- package/package.json +22 -20
- package/dist/components/AIInput.d.ts +0 -2
- package/dist/components/AIInput.js +0 -896
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
.chatLayout {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
max-width: 1280px;
|
|
2
|
+
width: 100%;
|
|
3
|
+
max-width: none;
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
overflow: hidden;
|
|
8
7
|
}
|
|
9
8
|
|
|
10
9
|
.chat {
|
|
10
|
+
flex: 1;
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
11
13
|
border: 1px solid var(--theme-elevation-150);
|
|
12
14
|
border-radius: 8px;
|
|
15
|
+
min-height: 0;
|
|
16
|
+
overflow: hidden;
|
|
13
17
|
padding: 20px;
|
|
14
18
|
}
|
|
15
19
|
|
|
@@ -26,13 +30,6 @@
|
|
|
26
30
|
margin: 0;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
.chatDescription {
|
|
30
|
-
color: var(--theme-elevation-600);
|
|
31
|
-
font-size: 13px;
|
|
32
|
-
line-height: 1.4;
|
|
33
|
-
margin: 4px 0 0;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
33
|
.settings {
|
|
37
34
|
align-items: flex-end;
|
|
38
35
|
display: flex;
|
|
@@ -87,6 +84,9 @@
|
|
|
87
84
|
.chatInputRow {
|
|
88
85
|
position: relative;
|
|
89
86
|
width: 100%;
|
|
87
|
+
flex: 1 1 0;
|
|
88
|
+
min-height: 0;
|
|
89
|
+
overflow: hidden;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
.chatActionsRow {
|
|
@@ -97,17 +97,69 @@
|
|
|
97
97
|
margin-top: 12px;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
.actions {
|
|
101
|
+
align-items: center;
|
|
102
|
+
display: flex;
|
|
103
|
+
gap: 8px;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.fileInput {
|
|
107
|
+
display: none;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.mediaButton {
|
|
111
|
+
align-items: center;
|
|
112
|
+
background: transparent;
|
|
113
|
+
border: 0;
|
|
114
|
+
bottom: 8px;
|
|
115
|
+
color: var(--theme-elevation-600);
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
display: inline-flex;
|
|
118
|
+
height: 28px;
|
|
119
|
+
justify-content: center;
|
|
120
|
+
padding: 0;
|
|
121
|
+
position: absolute;
|
|
122
|
+
right: 8px;
|
|
123
|
+
width: 28px;
|
|
124
|
+
z-index: 1;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.mediaButton:hover,
|
|
128
|
+
.mediaButton:focus-visible {
|
|
129
|
+
color: var(--theme-text);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.mediaButton:focus-visible {
|
|
133
|
+
outline: 1px solid currentColor;
|
|
134
|
+
outline-offset: 1px;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.mediaButton:disabled {
|
|
138
|
+
cursor: not-allowed;
|
|
139
|
+
opacity: 0.45;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.mediaButton svg {
|
|
143
|
+
height: 16px;
|
|
144
|
+
width: 16px;
|
|
145
|
+
}
|
|
146
|
+
|
|
100
147
|
.chatInput {
|
|
101
148
|
background: transparent;
|
|
102
149
|
border: 0;
|
|
150
|
+
box-sizing: border-box;
|
|
103
151
|
color: var(--theme-text);
|
|
104
|
-
display: block;
|
|
105
152
|
font: inherit;
|
|
106
|
-
|
|
153
|
+
flex: 1 1 0;
|
|
154
|
+
height: 100%;
|
|
155
|
+
min-height: 0;
|
|
107
156
|
overflow-y: auto;
|
|
108
|
-
|
|
157
|
+
overscroll-behavior: contain;
|
|
158
|
+
padding: 0 32px 32px 0;
|
|
109
159
|
white-space: pre-wrap;
|
|
160
|
+
word-break: break-word;
|
|
110
161
|
width: 100%;
|
|
162
|
+
display: block;
|
|
111
163
|
}
|
|
112
164
|
|
|
113
165
|
.chatInput:focus {
|
|
@@ -120,11 +172,16 @@
|
|
|
120
172
|
}
|
|
121
173
|
|
|
122
174
|
.chatInputSurface {
|
|
175
|
+
position: relative;
|
|
123
176
|
background: var(--theme-input-bg);
|
|
124
177
|
border: 1px solid var(--theme-elevation-150);
|
|
125
178
|
box-sizing: border-box;
|
|
126
179
|
border-radius: 4px;
|
|
127
|
-
height:
|
|
180
|
+
height: 100%;
|
|
181
|
+
min-height: 0;
|
|
182
|
+
display: flex;
|
|
183
|
+
flex-direction: column;
|
|
184
|
+
gap: 8px;
|
|
128
185
|
overflow: hidden;
|
|
129
186
|
padding: 12px;
|
|
130
187
|
width: 100%;
|
|
@@ -134,6 +191,76 @@
|
|
|
134
191
|
border-color: var(--theme-success-500);
|
|
135
192
|
}
|
|
136
193
|
|
|
194
|
+
.attachmentTray {
|
|
195
|
+
align-items: center;
|
|
196
|
+
display: flex;
|
|
197
|
+
flex: 0 0 auto;
|
|
198
|
+
flex-wrap: wrap;
|
|
199
|
+
gap: 6px;
|
|
200
|
+
min-height: 22px;
|
|
201
|
+
padding-right: 32px;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.attachmentPill {
|
|
205
|
+
align-items: center;
|
|
206
|
+
background: var(--theme-elevation-100);
|
|
207
|
+
border: 1px solid var(--theme-elevation-150);
|
|
208
|
+
border-radius: 999px;
|
|
209
|
+
color: var(--theme-text);
|
|
210
|
+
display: inline-flex;
|
|
211
|
+
font-size: 11px;
|
|
212
|
+
gap: 4px;
|
|
213
|
+
line-height: 1.2;
|
|
214
|
+
max-width: min(240px, 100%);
|
|
215
|
+
min-height: 24px;
|
|
216
|
+
min-width: 0;
|
|
217
|
+
padding: 2px 5px 3px 8px;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.attachmentName {
|
|
221
|
+
display: block;
|
|
222
|
+
min-width: 0;
|
|
223
|
+
overflow: hidden;
|
|
224
|
+
text-overflow: ellipsis;
|
|
225
|
+
white-space: nowrap;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.attachmentRemove {
|
|
229
|
+
align-items: center;
|
|
230
|
+
background: transparent;
|
|
231
|
+
border: 0;
|
|
232
|
+
color: var(--theme-elevation-600);
|
|
233
|
+
cursor: pointer;
|
|
234
|
+
display: inline-flex;
|
|
235
|
+
flex: 0 0 auto;
|
|
236
|
+
font: inherit;
|
|
237
|
+
font-size: 10px;
|
|
238
|
+
height: 14px;
|
|
239
|
+
justify-content: center;
|
|
240
|
+
line-height: 1;
|
|
241
|
+
padding: 0;
|
|
242
|
+
width: 14px;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.attachmentRemove:hover,
|
|
246
|
+
.attachmentRemove:focus-visible {
|
|
247
|
+
color: #fff;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.attachmentRemove:disabled {
|
|
251
|
+
cursor: not-allowed;
|
|
252
|
+
opacity: 0.55;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.attachmentRemove:disabled:hover {
|
|
256
|
+
color: var(--theme-elevation-600);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.attachmentRemove:focus-visible {
|
|
260
|
+
outline: 1px solid currentColor;
|
|
261
|
+
outline-offset: 1px;
|
|
262
|
+
}
|
|
263
|
+
|
|
137
264
|
.inlineBadge {
|
|
138
265
|
margin: 0 2px;
|
|
139
266
|
vertical-align: middle;
|
|
@@ -198,31 +325,6 @@
|
|
|
198
325
|
border-color: color-mix(in srgb, #2f5da8 28%, var(--theme-elevation-150));
|
|
199
326
|
}
|
|
200
327
|
|
|
201
|
-
.chatButton {
|
|
202
|
-
align-items: center;
|
|
203
|
-
background: var(--theme-text);
|
|
204
|
-
border: 0;
|
|
205
|
-
border-radius: 4px;
|
|
206
|
-
color: var(--theme-bg);
|
|
207
|
-
cursor: pointer;
|
|
208
|
-
display: inline-flex;
|
|
209
|
-
font: inherit;
|
|
210
|
-
gap: 6px;
|
|
211
|
-
justify-content: center;
|
|
212
|
-
line-height: 24px;
|
|
213
|
-
min-height: 24px;
|
|
214
|
-
padding: 0 14px;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
.chatButton svg {
|
|
218
|
-
flex: 0 0 auto;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
.chatButton:disabled {
|
|
222
|
-
cursor: not-allowed;
|
|
223
|
-
opacity: 0.45;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
328
|
.chatError {
|
|
227
329
|
color: var(--theme-error-500);
|
|
228
330
|
font-size: 13px;
|
|
@@ -278,6 +380,10 @@
|
|
|
278
380
|
flex-direction: column;
|
|
279
381
|
}
|
|
280
382
|
|
|
383
|
+
.actions {
|
|
384
|
+
justify-content: flex-end;
|
|
385
|
+
}
|
|
386
|
+
|
|
281
387
|
.settings {
|
|
282
388
|
align-items: stretch;
|
|
283
389
|
width: 100%;
|
|
@@ -292,7 +398,7 @@
|
|
|
292
398
|
width: 100%;
|
|
293
399
|
}
|
|
294
400
|
|
|
295
|
-
.
|
|
296
|
-
|
|
401
|
+
.attachmentPill {
|
|
402
|
+
max-width: 100%;
|
|
297
403
|
}
|
|
298
404
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MentionOption } from "../mention-popover/MentionPopover.js";
|
|
2
|
+
export declare const createBadgePrefix: (suggestion: MentionOption, styles: {
|
|
3
|
+
[key: string]: string;
|
|
4
|
+
}) => HTMLSpanElement;
|
|
5
|
+
export declare const getTextNodeAtOffset: (element: HTMLElement, offset: number) => {
|
|
6
|
+
node: Node;
|
|
7
|
+
offset: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const replaceTextRangeWithBadge: ({ badge, editor, end, start }: {
|
|
10
|
+
badge: HTMLSpanElement;
|
|
11
|
+
editor: HTMLElement;
|
|
12
|
+
end: number;
|
|
13
|
+
start: number;
|
|
14
|
+
}) => void;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const appendSvgPath = (svg, d)=>{
|
|
2
|
+
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
3
|
+
path.setAttribute("d", d);
|
|
4
|
+
svg.append(path);
|
|
5
|
+
};
|
|
6
|
+
const createBadgeIcon = (type, styles)=>{
|
|
7
|
+
if (type === "locale") return null;
|
|
8
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
9
|
+
svg.setAttribute("aria-hidden", "true");
|
|
10
|
+
svg.setAttribute("class", styles.badgeIcon);
|
|
11
|
+
svg.setAttribute("fill", "none");
|
|
12
|
+
svg.setAttribute("stroke", "currentColor");
|
|
13
|
+
svg.setAttribute("stroke-linecap", "round");
|
|
14
|
+
svg.setAttribute("stroke-linejoin", "round");
|
|
15
|
+
svg.setAttribute("stroke-width", "2");
|
|
16
|
+
svg.setAttribute("viewBox", "0 0 24 24");
|
|
17
|
+
if (type === "collection") {
|
|
18
|
+
appendSvgPath(svg, "M5 4h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2");
|
|
19
|
+
}
|
|
20
|
+
if (type === "doc") {
|
|
21
|
+
appendSvgPath(svg, "M14 3v4a1 1 0 0 0 1 1h4");
|
|
22
|
+
appendSvgPath(svg, "M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2");
|
|
23
|
+
}
|
|
24
|
+
if (type === "global") {
|
|
25
|
+
appendSvgPath(svg, "M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0");
|
|
26
|
+
appendSvgPath(svg, "M3.6 9h16.8");
|
|
27
|
+
appendSvgPath(svg, "M3.6 15h16.8");
|
|
28
|
+
appendSvgPath(svg, "M11.5 3a17 17 0 0 0 0 18");
|
|
29
|
+
appendSvgPath(svg, "M12.5 3a17 17 0 0 1 0 18");
|
|
30
|
+
}
|
|
31
|
+
return svg;
|
|
32
|
+
};
|
|
33
|
+
export const createBadgePrefix = (suggestion, styles)=>{
|
|
34
|
+
const prefix = document.createElement("span");
|
|
35
|
+
const icon = createBadgeIcon(suggestion.type, styles);
|
|
36
|
+
prefix.className = styles.prefix;
|
|
37
|
+
if (icon) {
|
|
38
|
+
prefix.append(icon);
|
|
39
|
+
}
|
|
40
|
+
if (suggestion.type === "doc") {
|
|
41
|
+
prefix.append(document.createTextNode(`${suggestion.collection || "document"}:`));
|
|
42
|
+
} else if (suggestion.type === "locale") {
|
|
43
|
+
prefix.textContent = "locale:";
|
|
44
|
+
}
|
|
45
|
+
return prefix;
|
|
46
|
+
};
|
|
47
|
+
export const getTextNodeAtOffset = (element, offset)=>{
|
|
48
|
+
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
|
|
49
|
+
let currentOffset = 0;
|
|
50
|
+
let node = walker.nextNode();
|
|
51
|
+
while(node){
|
|
52
|
+
const nextOffset = currentOffset + (node.textContent?.length || 0);
|
|
53
|
+
if (offset <= nextOffset) {
|
|
54
|
+
return {
|
|
55
|
+
node,
|
|
56
|
+
offset: offset - currentOffset
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
currentOffset = nextOffset;
|
|
60
|
+
node = walker.nextNode();
|
|
61
|
+
}
|
|
62
|
+
const textNode = document.createTextNode("");
|
|
63
|
+
element.append(textNode);
|
|
64
|
+
return {
|
|
65
|
+
node: textNode,
|
|
66
|
+
offset: 0
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export const replaceTextRangeWithBadge = ({ badge, editor, end, start })=>{
|
|
70
|
+
const startPosition = getTextNodeAtOffset(editor, start);
|
|
71
|
+
const endPosition = getTextNodeAtOffset(editor, end);
|
|
72
|
+
const range = document.createRange();
|
|
73
|
+
const trailingSpace = document.createTextNode(" ");
|
|
74
|
+
range.setStart(startPosition.node, startPosition.offset);
|
|
75
|
+
range.setEnd(endPosition.node, endPosition.offset);
|
|
76
|
+
range.deleteContents();
|
|
77
|
+
range.insertNode(trailingSpace);
|
|
78
|
+
range.insertNode(badge);
|
|
79
|
+
const selection = window.getSelection();
|
|
80
|
+
const caretRange = document.createRange();
|
|
81
|
+
caretRange.setStartAfter(trailingSpace);
|
|
82
|
+
caretRange.collapse(true);
|
|
83
|
+
selection?.removeAllRanges();
|
|
84
|
+
selection?.addRange(caretRange);
|
|
85
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ActionProposal } from "
|
|
2
|
-
import { type ProposalDiff } from "
|
|
1
|
+
import type { ActionProposal } from "../action-toast/ActionToast.js";
|
|
2
|
+
import { type ProposalDiff } from "../diff-dialog/DiffDialog.js";
|
|
3
3
|
export type AppliedChange = {
|
|
4
4
|
action?: ActionProposal["action"] | null;
|
|
5
5
|
additions: number;
|
|
@@ -19,14 +19,10 @@ export type AppliedChange = {
|
|
|
19
19
|
userLabel?: string | null;
|
|
20
20
|
url?: string | null;
|
|
21
21
|
};
|
|
22
|
-
type AuditLogListProps = {
|
|
23
|
-
allChangesURL?: string;
|
|
24
|
-
changes: AppliedChange[];
|
|
25
|
-
};
|
|
26
22
|
export type ActiveDiff = {
|
|
27
23
|
change: AppliedChange | null;
|
|
28
24
|
diff: ProposalDiff;
|
|
29
25
|
proposal: ActionProposal;
|
|
30
26
|
};
|
|
31
|
-
|
|
32
|
-
export
|
|
27
|
+
declare const AuditLogList: () => import("react").JSX.Element;
|
|
28
|
+
export default AuditLogList;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { ExternalLinkIcon } from "@payloadcms/ui";
|
|
4
|
-
import { DiffDialog } from "
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { Button, ExternalLinkIcon, useConfig } from "@payloadcms/ui";
|
|
5
|
+
import { DiffDialog } from "../diff-dialog/DiffDialog.js";
|
|
5
6
|
import styles from "./AuditLogList.module.css";
|
|
7
|
+
import { useAuditLog } from "../hooks/useAuditLog.js";
|
|
6
8
|
const getChangeProposal = (change)=>({
|
|
7
9
|
action: change.action || "update",
|
|
8
10
|
collection: change.collection || undefined,
|
|
@@ -10,8 +12,31 @@ const getChangeProposal = (change)=>({
|
|
|
10
12
|
label: change.title,
|
|
11
13
|
slug: change.slug || undefined
|
|
12
14
|
});
|
|
13
|
-
|
|
15
|
+
const fallbackConfig = {
|
|
16
|
+
routes: {
|
|
17
|
+
admin: "/admin",
|
|
18
|
+
api: "/api"
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const AuditLogList = ()=>{
|
|
22
|
+
const payloadConfigContext = useConfig();
|
|
23
|
+
const config = payloadConfigContext?.config ?? fallbackConfig;
|
|
24
|
+
const { loadRecentChanges, allChangesURL, appliedChanges: changes } = useAuditLog({
|
|
25
|
+
adminRoute: config.routes.admin,
|
|
26
|
+
apiRoute: config.routes.api
|
|
27
|
+
});
|
|
14
28
|
const [activeDiff, setActiveDiff] = useState(null);
|
|
29
|
+
useEffect(()=>{
|
|
30
|
+
const refresh = ()=>{
|
|
31
|
+
void loadRecentChanges().catch(()=>undefined);
|
|
32
|
+
};
|
|
33
|
+
window.addEventListener("payload-ai:audit-log-updated", refresh);
|
|
34
|
+
return ()=>{
|
|
35
|
+
window.removeEventListener("payload-ai:audit-log-updated", refresh);
|
|
36
|
+
};
|
|
37
|
+
}, [
|
|
38
|
+
loadRecentChanges
|
|
39
|
+
]);
|
|
15
40
|
return /*#__PURE__*/ _jsxs("aside", {
|
|
16
41
|
className: styles.recentChanges,
|
|
17
42
|
children: [
|
|
@@ -22,9 +47,15 @@ export const RecentChangesList = ({ allChangesURL, changes })=>{
|
|
|
22
47
|
className: styles.title,
|
|
23
48
|
children: "Recent changes"
|
|
24
49
|
}),
|
|
25
|
-
allChangesURL && /*#__PURE__*/ _jsx(
|
|
26
|
-
|
|
27
|
-
|
|
50
|
+
allChangesURL && /*#__PURE__*/ _jsx(Button, {
|
|
51
|
+
url: allChangesURL,
|
|
52
|
+
el: "anchor",
|
|
53
|
+
"aria-label": "View all",
|
|
54
|
+
margin: false,
|
|
55
|
+
buttonStyle: "tab",
|
|
56
|
+
size: "small",
|
|
57
|
+
disabled: !changes || changes.length <= 0,
|
|
58
|
+
newTab: true,
|
|
28
59
|
children: "View all"
|
|
29
60
|
})
|
|
30
61
|
]
|
|
@@ -34,22 +65,25 @@ export const RecentChangesList = ({ allChangesURL, changes })=>{
|
|
|
34
65
|
children: changes.length === 0 ? /*#__PURE__*/ _jsx("div", {
|
|
35
66
|
className: styles.empty,
|
|
36
67
|
children: "No changes yet."
|
|
37
|
-
}) : changes.slice(0,
|
|
68
|
+
}) : changes.slice(0, 8).map((change, index)=>/*#__PURE__*/ _jsxs("div", {
|
|
38
69
|
className: styles.item,
|
|
39
70
|
children: [
|
|
40
71
|
/*#__PURE__*/ _jsxs("div", {
|
|
41
72
|
className: styles.titleRow,
|
|
42
73
|
children: [
|
|
74
|
+
change.url && /*#__PURE__*/ _jsx(Button, {
|
|
75
|
+
url: change.url,
|
|
76
|
+
el: "anchor",
|
|
77
|
+
buttonStyle: "tab",
|
|
78
|
+
size: "small",
|
|
79
|
+
"aria-label": "Open change",
|
|
80
|
+
newTab: true,
|
|
81
|
+
margin: false,
|
|
82
|
+
children: /*#__PURE__*/ _jsx(ExternalLinkIcon, {})
|
|
83
|
+
}),
|
|
43
84
|
/*#__PURE__*/ _jsx("div", {
|
|
44
85
|
className: styles.itemTitle,
|
|
45
86
|
children: change.title
|
|
46
|
-
}),
|
|
47
|
-
change.url && /*#__PURE__*/ _jsx("a", {
|
|
48
|
-
className: styles.ghostButton,
|
|
49
|
-
href: change.url,
|
|
50
|
-
rel: "noreferrer noopener",
|
|
51
|
-
target: "_blank",
|
|
52
|
-
children: /*#__PURE__*/ _jsx(ExternalLinkIcon, {})
|
|
53
87
|
})
|
|
54
88
|
]
|
|
55
89
|
}),
|
|
@@ -72,12 +106,13 @@ export const RecentChangesList = ({ allChangesURL, changes })=>{
|
|
|
72
106
|
})
|
|
73
107
|
]
|
|
74
108
|
}),
|
|
75
|
-
/*#__PURE__*/ _jsx(
|
|
76
|
-
|
|
109
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
110
|
+
buttonStyle: "tab",
|
|
111
|
+
size: "small",
|
|
112
|
+
"aria-label": "Open review",
|
|
113
|
+
margin: false,
|
|
77
114
|
onClick: ()=>{
|
|
78
|
-
if (change.before === undefined || change.after === undefined)
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
115
|
+
if (change.before === undefined || change.after === undefined) return;
|
|
81
116
|
setActiveDiff({
|
|
82
117
|
change,
|
|
83
118
|
diff: {
|
|
@@ -87,7 +122,6 @@ export const RecentChangesList = ({ allChangesURL, changes })=>{
|
|
|
87
122
|
proposal: getChangeProposal(change)
|
|
88
123
|
});
|
|
89
124
|
},
|
|
90
|
-
type: "button",
|
|
91
125
|
children: "Review"
|
|
92
126
|
})
|
|
93
127
|
]
|
|
@@ -102,3 +136,4 @@ export const RecentChangesList = ({ allChangesURL, changes })=>{
|
|
|
102
136
|
]
|
|
103
137
|
});
|
|
104
138
|
};
|
|
139
|
+
export default AuditLogList;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
.recentChanges {
|
|
2
|
+
width: 100%;
|
|
3
|
+
max-width: none;
|
|
2
4
|
border: 1px solid var(--theme-elevation-150);
|
|
3
5
|
border-radius: 8px;
|
|
4
6
|
display: flex;
|
|
@@ -16,19 +18,6 @@
|
|
|
16
18
|
margin-bottom: 10px;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
.headerGhostButton {
|
|
20
|
-
color: var(--theme-elevation-500);
|
|
21
|
-
flex: 0 0 auto;
|
|
22
|
-
font-size: 12px;
|
|
23
|
-
line-height: 24px;
|
|
24
|
-
min-height: 24px;
|
|
25
|
-
text-decoration: none;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.headerGhostButton:hover {
|
|
29
|
-
text-decoration: underline;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
21
|
.title {
|
|
33
22
|
font-size: 14px;
|
|
34
23
|
line-height: 1.3;
|
|
@@ -39,8 +28,8 @@
|
|
|
39
28
|
display: flex;
|
|
40
29
|
flex: 1 1 auto;
|
|
41
30
|
flex-direction: column;
|
|
42
|
-
gap:
|
|
43
|
-
max-height:
|
|
31
|
+
gap: 4px;
|
|
32
|
+
max-height: 300px;
|
|
44
33
|
min-height: 0;
|
|
45
34
|
overflow: auto;
|
|
46
35
|
padding-right: 2px;
|
|
@@ -54,12 +43,15 @@
|
|
|
54
43
|
|
|
55
44
|
.item {
|
|
56
45
|
align-items: center;
|
|
57
|
-
border: 1px solid var(--theme-elevation-100);
|
|
58
|
-
border-radius: 4px;
|
|
46
|
+
border-bottom: 1px solid var(--theme-elevation-100);
|
|
59
47
|
display: grid;
|
|
60
48
|
gap: 8px;
|
|
49
|
+
padding: 0px 0px 4px 0px;
|
|
61
50
|
grid-template-columns: minmax(0, 1fr) auto auto;
|
|
62
|
-
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.item:last-child {
|
|
54
|
+
border-bottom: none;
|
|
63
55
|
}
|
|
64
56
|
|
|
65
57
|
.titleRow {
|
|
@@ -73,7 +65,7 @@
|
|
|
73
65
|
color: var(--theme-text);
|
|
74
66
|
flex: 0 1 auto;
|
|
75
67
|
font-size: 12px;
|
|
76
|
-
font-weight:
|
|
68
|
+
font-weight: 400;
|
|
77
69
|
line-height: 1.4;
|
|
78
70
|
min-width: 0;
|
|
79
71
|
overflow: hidden;
|
|
@@ -104,49 +96,3 @@
|
|
|
104
96
|
background: rgba(160, 26, 26, 0.16);
|
|
105
97
|
color: #a01a1a;
|
|
106
98
|
}
|
|
107
|
-
|
|
108
|
-
.button {
|
|
109
|
-
align-items: center;
|
|
110
|
-
background: var(--theme-elevation-0);
|
|
111
|
-
border: 1px solid var(--theme-elevation-150);
|
|
112
|
-
border-radius: 4px;
|
|
113
|
-
color: var(--theme-text);
|
|
114
|
-
cursor: pointer;
|
|
115
|
-
display: inline-flex;
|
|
116
|
-
font-size: 12px;
|
|
117
|
-
gap: 6px;
|
|
118
|
-
justify-content: center;
|
|
119
|
-
line-height: 24px;
|
|
120
|
-
min-height: 24px;
|
|
121
|
-
padding: 0 10px;
|
|
122
|
-
text-align: center;
|
|
123
|
-
text-decoration: none;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.button:disabled {
|
|
127
|
-
color: var(--theme-elevation-400);
|
|
128
|
-
cursor: not-allowed;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.button svg {
|
|
132
|
-
color: var(--theme-elevation-500);
|
|
133
|
-
flex: 0 0 auto;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.ghostButton {
|
|
137
|
-
color: var(--theme-elevation-500);
|
|
138
|
-
flex: 0 0 auto;
|
|
139
|
-
font-size: 12px;
|
|
140
|
-
line-height: 18px;
|
|
141
|
-
text-decoration: none;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.ghostButton:hover {
|
|
145
|
-
text-decoration: underline;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
@media (max-width: 768px) {
|
|
149
|
-
.list {
|
|
150
|
-
max-height: 220px;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import AIInput from "../ai-input/AIInput.js";
|
|
4
|
+
import AuditLogList from "../audit-log-list/AuditLogList.js";
|
|
5
|
+
import styles from "./Dashboard.module.css";
|
|
6
|
+
const Dashboard = ()=>{
|
|
7
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
8
|
+
className: styles.dashboard,
|
|
9
|
+
children: [
|
|
10
|
+
/*#__PURE__*/ _jsx(AIInput, {
|
|
11
|
+
isDashboard: true
|
|
12
|
+
}),
|
|
13
|
+
/*#__PURE__*/ _jsx(AuditLogList, {})
|
|
14
|
+
]
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export default Dashboard;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ActionProposal } from "
|
|
2
|
-
import type { AppliedChange } from "
|
|
1
|
+
import type { ActionProposal } from "../action-toast/ActionToast.js";
|
|
2
|
+
import type { AppliedChange } from "../audit-log-list/AuditLogList.js";
|
|
3
3
|
export type ProposalDiff = {
|
|
4
4
|
after: unknown;
|
|
5
5
|
before: unknown;
|