Files
klz-cables.com/.pnpm-store/v10/files/55/837c4d447b7f721fc512924a1b5b7a556e58d39ef1ca36a41f65487b012a2a3ac1a4b85422fef5bf304f822c1ed85a91a7fb401417ba2325031e230943922b
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

64 lines
1.8 KiB
Plaintext

'use client';
import { jsx as _jsx } from "react/jsx-runtime";
import { getTranslation } from '@payloadcms/translations';
import { Button } from '../../elements/Button/index.js';
import { Popup, PopupList } from '../Popup/index.js';
export const AddNewButton = ({
allowCreate,
baseClass,
buttonStyle,
className,
collections,
i18n,
icon,
label,
onClick,
permissions,
relationTo
}) => {
if (!allowCreate) {
return null;
}
const isPolymorphic = Array.isArray(relationTo);
if (!isPolymorphic) {
return /*#__PURE__*/_jsx(Button, {
buttonStyle: buttonStyle,
className: className,
onClick: () => onClick(),
children: label
});
}
return /*#__PURE__*/_jsx("div", {
className: `${baseClass}__add-new-polymorphic-wrapper`,
children: /*#__PURE__*/_jsx(Popup, {
button: /*#__PURE__*/_jsx(Button, {
buttonStyle: buttonStyle,
className: className,
icon: icon,
children: label
}),
buttonType: "custom",
horizontalAlign: "center",
render: ({
close: closePopup
}) => /*#__PURE__*/_jsx(PopupList.ButtonGroup, {
children: relationTo.map(relatedCollection => {
if (permissions.collections[relatedCollection]?.create) {
return /*#__PURE__*/_jsx(PopupList.Button, {
className: `${baseClass}__relation-button--${relatedCollection}`,
onClick: () => {
closePopup();
onClick(relatedCollection);
},
children: getTranslation(collections.find(each => each.slug === relatedCollection).labels.singular, i18n)
}, relatedCollection);
}
return null;
})
}),
size: "medium"
})
});
};
//# sourceMappingURL=AddNewButton.js.map