@nitrogenbuilder/connector-payload 0.1.52 → 0.1.53
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.
|
@@ -85,7 +85,7 @@ export const NitrogenEditButtonRuntime = ({ collection, routePattern }) => {
|
|
|
85
85
|
const [authorId, setAuthorId] = useState(undefined);
|
|
86
86
|
const [templateSlug, setTemplateSlug] = useState(undefined);
|
|
87
87
|
const formStatus = useFormFields(([fields]) => fields?._status?.value);
|
|
88
|
-
const {
|
|
88
|
+
const { previewURL } = useLivePreviewContext();
|
|
89
89
|
useEffect(() => {
|
|
90
90
|
const segments = window.location.pathname.split('/').filter(Boolean);
|
|
91
91
|
const docId = segments.length >= 4 ? segments[3] : undefined;
|
|
@@ -178,7 +178,6 @@ export const NitrogenEditButtonRuntime = ({ collection, routePattern }) => {
|
|
|
178
178
|
: undefined;
|
|
179
179
|
const viewAction = resolveNitrogenViewAction({
|
|
180
180
|
documentStatus: formStatus ?? persistedStatus,
|
|
181
|
-
isPreviewEnabled,
|
|
182
181
|
previewURL,
|
|
183
182
|
publicHref,
|
|
184
183
|
});
|
|
@@ -2,9 +2,8 @@ export type NitrogenViewAction = {
|
|
|
2
2
|
href: string;
|
|
3
3
|
label: 'Preview Draft' | 'View Page';
|
|
4
4
|
};
|
|
5
|
-
export declare function resolveNitrogenViewAction({ documentStatus,
|
|
5
|
+
export declare function resolveNitrogenViewAction({ documentStatus, previewURL, publicHref, }: {
|
|
6
6
|
documentStatus?: unknown;
|
|
7
|
-
isPreviewEnabled: boolean;
|
|
8
7
|
previewURL?: string;
|
|
9
8
|
publicHref?: string;
|
|
10
9
|
}): NitrogenViewAction | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export function resolveNitrogenViewAction({ documentStatus,
|
|
1
|
+
export function resolveNitrogenViewAction({ documentStatus, previewURL, publicHref, }) {
|
|
2
2
|
if (documentStatus === 'draft') {
|
|
3
|
-
const href =
|
|
3
|
+
const href = previewURL?.trim();
|
|
4
4
|
return href ? { href, label: 'Preview Draft' } : null;
|
|
5
5
|
}
|
|
6
6
|
const href = publicHref?.trim();
|
package/package.json
CHANGED