@nitrogenbuilder/connector-payload 0.1.15 → 0.1.16

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.
@@ -8,6 +8,7 @@ export const NitrogenEditButton = ({ collection }) => {
8
8
  const [slug, setSlug] = useState(undefined);
9
9
  const [frontendUrl, setFrontendUrl] = useState(undefined);
10
10
  const [instanceUrl, setInstanceUrl] = useState(undefined);
11
+ const [authorId, setAuthorId] = useState(undefined);
11
12
  useEffect(() => {
12
13
  const segments = window.location.pathname.split("/").filter(Boolean);
13
14
  const docId = segments.length >= 4 ? segments[3] : undefined;
@@ -25,6 +26,17 @@ export const NitrogenEditButton = ({ collection }) => {
25
26
  console.error("Failed to fetch document:", err);
26
27
  });
27
28
  }
29
+ // Fetch the current user's ID for the authorId param
30
+ fetch("/api/users/me")
31
+ .then((res) => res.json())
32
+ .then((data) => {
33
+ if (data.user?.id) {
34
+ setAuthorId(String(data.user.id));
35
+ }
36
+ })
37
+ .catch((err) => {
38
+ console.error("Failed to fetch current user:", err);
39
+ });
28
40
  // Fetch the connector token and URLs from NitrogenSettings global
29
41
  fetch("/api/globals/nitrogen-settings")
30
42
  .then((res) => res.json())
@@ -47,11 +59,11 @@ export const NitrogenEditButton = ({ collection }) => {
47
59
  console.error("Failed to fetch nitrogen settings:", err);
48
60
  });
49
61
  }, [collection]);
50
- if (!id || !token)
62
+ if (!id || !token || !authorId)
51
63
  return null;
52
64
  const param = collection === "nitrogen-templates" ? "templateId" : "pageId";
53
65
  const editorBase = instanceUrl ?? "";
54
- const baseHref = `${editorBase}/nitrogen-editor?token=${encodeURIComponent(token)}&collection=${encodeURIComponent(collection)}&${param}=${id}`;
66
+ const baseHref = `${editorBase}/nitrogen-editor?token=${encodeURIComponent(token)}&collection=${encodeURIComponent(collection)}&${param}=${id}&authorId=${encodeURIComponent(authorId)}`;
55
67
  const buttonStyle = {
56
68
  display: "inline-flex",
57
69
  alignItems: "center",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitrogenbuilder/connector-payload",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "Nitrogen page builder connector plugin for Payload CMS 3.x",
5
5
  "author": "Leonardo Dentzien <leo@torchmedia.ca>",
6
6
  "type": "module",