medusa-product-helper 0.0.28 → 0.0.29
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.
|
@@ -650,7 +650,7 @@ const CollectionMetadataTableWidget = ({ data }) => {
|
|
|
650
650
|
throw new Error((payload == null ? void 0 : payload.message) ?? "Unable to save metadata");
|
|
651
651
|
}
|
|
652
652
|
const updated = await response.json();
|
|
653
|
-
const nextMetadata = updated.
|
|
653
|
+
const nextMetadata = updated.collection.metadata;
|
|
654
654
|
setBaselineMetadata(nextMetadata);
|
|
655
655
|
setValues(buildInitialFormState(descriptors, nextMetadata));
|
|
656
656
|
ui.toast.success("Metadata saved");
|
|
@@ -975,6 +975,63 @@ const HideCategoryDefaultMetadataWidget = () => {
|
|
|
975
975
|
adminSdk.defineWidgetConfig({
|
|
976
976
|
zone: "product_category.details.side.before"
|
|
977
977
|
});
|
|
978
|
+
const HideCollectionDefaultMetadataWidget = () => {
|
|
979
|
+
react.useEffect(() => {
|
|
980
|
+
const hideMetadataSection = () => {
|
|
981
|
+
const headings = document.querySelectorAll("h2");
|
|
982
|
+
headings.forEach((heading) => {
|
|
983
|
+
var _a;
|
|
984
|
+
if (((_a = heading.textContent) == null ? void 0 : _a.trim()) === "Metadata") {
|
|
985
|
+
let container = heading.parentElement;
|
|
986
|
+
while (container && container !== document.body) {
|
|
987
|
+
const hasContainerClass = container.classList.toString().includes("Container");
|
|
988
|
+
const isInSidebar = container.closest('[class*="Sidebar"]') || container.closest('[class*="sidebar"]');
|
|
989
|
+
if (hasContainerClass || isInSidebar) {
|
|
990
|
+
const editLink = container.querySelector('a[href*="metadata/edit"]');
|
|
991
|
+
const badge = container.querySelector('div[class*="Badge"]');
|
|
992
|
+
if (editLink && badge) {
|
|
993
|
+
container.style.display = "none";
|
|
994
|
+
container.setAttribute("data-collection-metadata-hidden", "true");
|
|
995
|
+
return;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
container = container.parentElement;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
});
|
|
1002
|
+
};
|
|
1003
|
+
const runHide = () => {
|
|
1004
|
+
setTimeout(hideMetadataSection, 100);
|
|
1005
|
+
};
|
|
1006
|
+
runHide();
|
|
1007
|
+
const observer = new MutationObserver(() => {
|
|
1008
|
+
const alreadyHidden = document.querySelector(
|
|
1009
|
+
'[data-collection-metadata-hidden="true"]'
|
|
1010
|
+
);
|
|
1011
|
+
if (!alreadyHidden) {
|
|
1012
|
+
runHide();
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
1015
|
+
observer.observe(document.body, {
|
|
1016
|
+
childList: true,
|
|
1017
|
+
subtree: true
|
|
1018
|
+
});
|
|
1019
|
+
return () => {
|
|
1020
|
+
observer.disconnect();
|
|
1021
|
+
const hidden = document.querySelector(
|
|
1022
|
+
'[data-collection-metadata-hidden="true"]'
|
|
1023
|
+
);
|
|
1024
|
+
if (hidden) {
|
|
1025
|
+
hidden.style.display = "";
|
|
1026
|
+
hidden.removeAttribute("data-collection-metadata-hidden");
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
}, []);
|
|
1030
|
+
return null;
|
|
1031
|
+
};
|
|
1032
|
+
adminSdk.defineWidgetConfig({
|
|
1033
|
+
zone: "product_collection.details.after"
|
|
1034
|
+
});
|
|
978
1035
|
const HideDefaultMetadataWidget = () => {
|
|
979
1036
|
react.useEffect(() => {
|
|
980
1037
|
const hideMetadataSection = () => {
|
|
@@ -1933,6 +1990,10 @@ const widgetModule = { widgets: [
|
|
|
1933
1990
|
Component: HideCategoryDefaultMetadataWidget,
|
|
1934
1991
|
zone: ["product_category.details.side.before"]
|
|
1935
1992
|
},
|
|
1993
|
+
{
|
|
1994
|
+
Component: HideCollectionDefaultMetadataWidget,
|
|
1995
|
+
zone: ["product_collection.details.after"]
|
|
1996
|
+
},
|
|
1936
1997
|
{
|
|
1937
1998
|
Component: HideDefaultMetadataWidget,
|
|
1938
1999
|
zone: ["product.details.side.before"]
|
|
@@ -649,7 +649,7 @@ const CollectionMetadataTableWidget = ({ data }) => {
|
|
|
649
649
|
throw new Error((payload == null ? void 0 : payload.message) ?? "Unable to save metadata");
|
|
650
650
|
}
|
|
651
651
|
const updated = await response.json();
|
|
652
|
-
const nextMetadata = updated.
|
|
652
|
+
const nextMetadata = updated.collection.metadata;
|
|
653
653
|
setBaselineMetadata(nextMetadata);
|
|
654
654
|
setValues(buildInitialFormState(descriptors, nextMetadata));
|
|
655
655
|
toast.success("Metadata saved");
|
|
@@ -974,6 +974,63 @@ const HideCategoryDefaultMetadataWidget = () => {
|
|
|
974
974
|
defineWidgetConfig({
|
|
975
975
|
zone: "product_category.details.side.before"
|
|
976
976
|
});
|
|
977
|
+
const HideCollectionDefaultMetadataWidget = () => {
|
|
978
|
+
useEffect(() => {
|
|
979
|
+
const hideMetadataSection = () => {
|
|
980
|
+
const headings = document.querySelectorAll("h2");
|
|
981
|
+
headings.forEach((heading) => {
|
|
982
|
+
var _a;
|
|
983
|
+
if (((_a = heading.textContent) == null ? void 0 : _a.trim()) === "Metadata") {
|
|
984
|
+
let container = heading.parentElement;
|
|
985
|
+
while (container && container !== document.body) {
|
|
986
|
+
const hasContainerClass = container.classList.toString().includes("Container");
|
|
987
|
+
const isInSidebar = container.closest('[class*="Sidebar"]') || container.closest('[class*="sidebar"]');
|
|
988
|
+
if (hasContainerClass || isInSidebar) {
|
|
989
|
+
const editLink = container.querySelector('a[href*="metadata/edit"]');
|
|
990
|
+
const badge = container.querySelector('div[class*="Badge"]');
|
|
991
|
+
if (editLink && badge) {
|
|
992
|
+
container.style.display = "none";
|
|
993
|
+
container.setAttribute("data-collection-metadata-hidden", "true");
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
container = container.parentElement;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
});
|
|
1001
|
+
};
|
|
1002
|
+
const runHide = () => {
|
|
1003
|
+
setTimeout(hideMetadataSection, 100);
|
|
1004
|
+
};
|
|
1005
|
+
runHide();
|
|
1006
|
+
const observer = new MutationObserver(() => {
|
|
1007
|
+
const alreadyHidden = document.querySelector(
|
|
1008
|
+
'[data-collection-metadata-hidden="true"]'
|
|
1009
|
+
);
|
|
1010
|
+
if (!alreadyHidden) {
|
|
1011
|
+
runHide();
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
1014
|
+
observer.observe(document.body, {
|
|
1015
|
+
childList: true,
|
|
1016
|
+
subtree: true
|
|
1017
|
+
});
|
|
1018
|
+
return () => {
|
|
1019
|
+
observer.disconnect();
|
|
1020
|
+
const hidden = document.querySelector(
|
|
1021
|
+
'[data-collection-metadata-hidden="true"]'
|
|
1022
|
+
);
|
|
1023
|
+
if (hidden) {
|
|
1024
|
+
hidden.style.display = "";
|
|
1025
|
+
hidden.removeAttribute("data-collection-metadata-hidden");
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
}, []);
|
|
1029
|
+
return null;
|
|
1030
|
+
};
|
|
1031
|
+
defineWidgetConfig({
|
|
1032
|
+
zone: "product_collection.details.after"
|
|
1033
|
+
});
|
|
977
1034
|
const HideDefaultMetadataWidget = () => {
|
|
978
1035
|
useEffect(() => {
|
|
979
1036
|
const hideMetadataSection = () => {
|
|
@@ -1932,6 +1989,10 @@ const widgetModule = { widgets: [
|
|
|
1932
1989
|
Component: HideCategoryDefaultMetadataWidget,
|
|
1933
1990
|
zone: ["product_category.details.side.before"]
|
|
1934
1991
|
},
|
|
1992
|
+
{
|
|
1993
|
+
Component: HideCollectionDefaultMetadataWidget,
|
|
1994
|
+
zone: ["product_collection.details.after"]
|
|
1995
|
+
},
|
|
1935
1996
|
{
|
|
1936
1997
|
Component: HideDefaultMetadataWidget,
|
|
1937
1998
|
zone: ["product.details.side.before"]
|