@cardinali-studio/adminkit 2.2.19 → 2.2.21
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/dist/api.d.ts +28 -6
- package/dist/api.js +1 -1
- package/dist/app/App.d.ts +1 -0
- package/dist/app/App.js +64 -23
- package/dist/app/NextAdminApp.d.ts +8 -0
- package/dist/app/NextAdminApp.js +3 -0
- package/dist/app/app.css +35 -19
- package/dist/app/lib/admin-interface.d.ts +11 -0
- package/dist/app/lib/admin-interface.js +45 -0
- package/dist/app/lib/gallery-layout.d.ts +8 -0
- package/dist/app/lib/gallery-layout.js +13 -0
- package/dist/app/lib/home.d.ts +4 -0
- package/dist/app/lib/home.js +5 -1
- package/dist/app/lib/pages.d.ts +8 -0
- package/dist/app/lib/pages.js +23 -3
- package/dist/app/lib/publish.d.ts +9 -1
- package/dist/app/lib/publish.js +20 -6
- package/dist/app/lib/settings.d.ts +5 -0
- package/dist/app/lib/settings.js +6 -1
- package/dist/app/next.css +826 -0
- package/dist/app/routes/AdminInterfaceSettings.d.ts +12 -0
- package/dist/app/routes/AdminInterfaceSettings.js +14 -0
- package/dist/app/routes/Deliveries.js +1 -1
- package/dist/app/routes/HomeEditor.js +2 -2
- package/dist/app/routes/Overview.js +4 -4
- package/dist/app/routes/PageEditor.js +9 -6
- package/dist/app/routes/Requests.js +2 -2
- package/dist/app/routes/SiteSettingsEditor.d.ts +4 -1
- package/dist/app/routes/SiteSettingsEditor.js +3 -2
- package/dist/app/ui/MediaSlot.js +1 -1
- package/dist/app/ui/OpenCard.js +22 -1
- package/dist/app/ui/icons.js +5 -2
- package/package.json +2 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ContentPublishDocument, type ContentPublishTarget } from "../../index.js";
|
|
1
2
|
export interface PublishState {
|
|
2
3
|
/** Quanti commit ci sono sulla bozza che non sono ancora online. */
|
|
3
4
|
ahead: number;
|
|
@@ -6,13 +7,20 @@ export interface PublishState {
|
|
|
6
7
|
message: string;
|
|
7
8
|
date: string | null;
|
|
8
9
|
}[];
|
|
10
|
+
documents: ContentPublishDocument[];
|
|
11
|
+
siteAccessPending: boolean;
|
|
9
12
|
/** Falso se il branch di bozza non esiste ancora (passo manuale di configurazione). */
|
|
10
13
|
configured: boolean;
|
|
11
14
|
publishing: boolean;
|
|
12
15
|
notice: string | null;
|
|
13
16
|
error: string | null;
|
|
14
17
|
reload(): Promise<void>;
|
|
15
|
-
publish(): Promise<void>;
|
|
18
|
+
publish(target?: ContentPublishTarget): Promise<void>;
|
|
16
19
|
clearNotice(): void;
|
|
17
20
|
}
|
|
21
|
+
export declare function contentPublicationNotice(result: {
|
|
22
|
+
published: boolean;
|
|
23
|
+
message?: string;
|
|
24
|
+
verified?: boolean;
|
|
25
|
+
}): string;
|
|
18
26
|
export declare function usePublish(): PublishState;
|
package/dist/app/lib/publish.js
CHANGED
|
@@ -8,10 +8,20 @@
|
|
|
8
8
|
import { useCallback, useEffect, useState } from "react";
|
|
9
9
|
import { api, ApiError } from "../../index.js";
|
|
10
10
|
import { contentPersistenceMode } from "../site.js";
|
|
11
|
+
export function contentPublicationNotice(result) {
|
|
12
|
+
if (result.published === false) {
|
|
13
|
+
return result.message ?? "Non c'erano modifiche salvate da pubblicare.";
|
|
14
|
+
}
|
|
15
|
+
return result.message ?? (result.verified === true
|
|
16
|
+
? "Pubblicato e verificato online."
|
|
17
|
+
: "Pubblicato. Verifica online in attesa.");
|
|
18
|
+
}
|
|
11
19
|
export function usePublish() {
|
|
12
20
|
const [ahead, setAhead] = useState(0);
|
|
13
21
|
const [commits, setCommits] = useState([]);
|
|
14
22
|
const [configured, setConfigured] = useState(true);
|
|
23
|
+
const [documents, setDocuments] = useState([]);
|
|
24
|
+
const [siteAccessPending, setSiteAccessPending] = useState(false);
|
|
15
25
|
const [publishing, setPublishing] = useState(false);
|
|
16
26
|
const [notice, setNotice] = useState(null);
|
|
17
27
|
const [error, setError] = useState(null);
|
|
@@ -20,6 +30,8 @@ export function usePublish() {
|
|
|
20
30
|
try {
|
|
21
31
|
const d = await api.contentPublishState();
|
|
22
32
|
setAhead(d.ahead ?? 0);
|
|
33
|
+
setDocuments(d.documents ?? []);
|
|
34
|
+
setSiteAccessPending(Boolean(d.siteAccess));
|
|
23
35
|
setCommits((d.documents ?? []).map((document) => ({
|
|
24
36
|
message: `Modifica salvata (${document.kind})`, date: document.updatedAt ? new Date(document.updatedAt).toISOString() : null,
|
|
25
37
|
})).concat((d.mediaOperations ?? [])
|
|
@@ -42,6 +54,8 @@ export function usePublish() {
|
|
|
42
54
|
}
|
|
43
55
|
try {
|
|
44
56
|
const d = await api.publishState();
|
|
57
|
+
setDocuments([]);
|
|
58
|
+
setSiteAccessPending(false);
|
|
45
59
|
setAhead(d.ahead ?? 0);
|
|
46
60
|
setCommits(d.commits ?? []);
|
|
47
61
|
setConfigured(d.configured !== false);
|
|
@@ -57,15 +71,15 @@ export function usePublish() {
|
|
|
57
71
|
* per cui uno guarda quel pulsante, e un conteggio che compare solo dopo esserci passati sopra
|
|
58
72
|
* non serve a niente. È la stessa ragione dei badge di Richieste e Consegne. */
|
|
59
73
|
useEffect(() => { void reload(); }, [reload]);
|
|
60
|
-
const publish = useCallback(async () => {
|
|
74
|
+
const publish = useCallback(async (target) => {
|
|
61
75
|
if (contentPersistenceMode() === "d1") {
|
|
62
76
|
setPublishing(true);
|
|
63
77
|
setNotice(null);
|
|
64
78
|
try {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
79
|
+
if (!target)
|
|
80
|
+
throw new ApiError("Apri il contenuto che vuoi pubblicare.", "invalid_request", 400);
|
|
81
|
+
const r = await api.contentPublish(target);
|
|
82
|
+
setNotice(contentPublicationNotice(r));
|
|
69
83
|
await reload();
|
|
70
84
|
}
|
|
71
85
|
catch (e) {
|
|
@@ -101,7 +115,7 @@ export function usePublish() {
|
|
|
101
115
|
}
|
|
102
116
|
}, [reload]);
|
|
103
117
|
return {
|
|
104
|
-
ahead, commits, configured, publishing, notice, error,
|
|
118
|
+
ahead, commits, documents, siteAccessPending, configured, publishing, notice, error,
|
|
105
119
|
reload, publish, clearNotice: () => setNotice(null),
|
|
106
120
|
};
|
|
107
121
|
}
|
|
@@ -28,4 +28,9 @@ export declare function useSiteSettings(active: boolean): {
|
|
|
28
28
|
setNotice: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
29
29
|
accessDraftPending: boolean;
|
|
30
30
|
discardSiteAccess: () => Promise<void>;
|
|
31
|
+
publishTarget: {
|
|
32
|
+
documentId: string;
|
|
33
|
+
expectedDraftRevisionId: string | null;
|
|
34
|
+
includeSiteAccess: boolean;
|
|
35
|
+
} | null;
|
|
31
36
|
};
|
package/dist/app/lib/settings.js
CHANGED
|
@@ -152,5 +152,10 @@ export function useSiteSettings(active) {
|
|
|
152
152
|
}
|
|
153
153
|
}, [accessState, editorialBaseline]);
|
|
154
154
|
return { data, error, dirty, saving, notice, load, change, save, setNotice,
|
|
155
|
-
accessDraftPending: Boolean(accessState?.draft), discardSiteAccess
|
|
155
|
+
accessDraftPending: Boolean(accessState?.draft), discardSiteAccess,
|
|
156
|
+
publishTarget: contentPersistenceMode() === "d1" && site().siteSettingsDocument && revision
|
|
157
|
+
? { documentId: site().siteSettingsDocument.documentId,
|
|
158
|
+
expectedDraftRevisionId: revision.expected,
|
|
159
|
+
includeSiteAccess: Boolean(accessState?.draft) }
|
|
160
|
+
: null };
|
|
156
161
|
}
|