@nitrogenbuilder/connector-payload 0.1.17 → 0.1.18
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.
|
@@ -7,6 +7,7 @@ export const NitrogenEditButton = ({ collection }) => {
|
|
|
7
7
|
const [hasDevelopmentUrl, setHasDevelopmentUrl] = useState(false);
|
|
8
8
|
const [slug, setSlug] = useState(undefined);
|
|
9
9
|
const [frontendUrl, setFrontendUrl] = useState(undefined);
|
|
10
|
+
const [instanceUrl, setInstanceUrl] = useState(undefined);
|
|
10
11
|
const [authorId, setAuthorId] = useState(undefined);
|
|
11
12
|
useEffect(() => {
|
|
12
13
|
const segments = window.location.pathname.split("/").filter(Boolean);
|
|
@@ -46,6 +47,9 @@ export const NitrogenEditButton = ({ collection }) => {
|
|
|
46
47
|
if (data.developmentUrl) {
|
|
47
48
|
setHasDevelopmentUrl(true);
|
|
48
49
|
}
|
|
50
|
+
if (data.instanceUrl) {
|
|
51
|
+
setInstanceUrl(data.instanceUrl.replace(/\/$/, ""));
|
|
52
|
+
}
|
|
49
53
|
const url = data.frontendUrl;
|
|
50
54
|
if (url) {
|
|
51
55
|
setFrontendUrl(url.replace(/\/$/, ""));
|
|
@@ -58,7 +62,8 @@ export const NitrogenEditButton = ({ collection }) => {
|
|
|
58
62
|
if (!id || !token || !authorId)
|
|
59
63
|
return null;
|
|
60
64
|
const param = collection === "nitrogen-templates" ? "templateId" : "pageId";
|
|
61
|
-
const
|
|
65
|
+
const editorBase = instanceUrl ?? "";
|
|
66
|
+
const baseHref = `${editorBase}/nitrogen-editor?token=${encodeURIComponent(token)}&collection=${encodeURIComponent(collection)}&${param}=${id}&authorId=${encodeURIComponent(authorId)}`;
|
|
62
67
|
const buttonStyle = {
|
|
63
68
|
display: "inline-flex",
|
|
64
69
|
alignItems: "center",
|
package/package.json
CHANGED