From bc9e693faae403a1c30c0ea07c9fc9d50c999c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chy=C5=82a?= Date: Fri, 27 Sep 2024 12:14:17 +0200 Subject: [PATCH 1/7] Introduce modal Header component --- src/components/Modal/Header.tsx | 19 +++++++++++++++++++ src/components/Modal/Title.tsx | 2 +- src/components/Modal/index.ts | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/components/Modal/Header.tsx diff --git a/src/components/Modal/Header.tsx b/src/components/Modal/Header.tsx new file mode 100644 index 00000000000..617dc8b1298 --- /dev/null +++ b/src/components/Modal/Header.tsx @@ -0,0 +1,19 @@ +import { Box } from "@saleor/macaw-ui-next"; +import React, { ReactNode } from "react"; + +import { Close } from "./Close"; +import { Title, TitleProps } from "./Title"; + +interface HeaderProps extends TitleProps { + children: ReactNode; + onClose: () => void; +} + +export const Header = ({ children, onClose, ...rest }: HeaderProps) => { + return ( + + {children} + + + ); +}; diff --git a/src/components/Modal/Title.tsx b/src/components/Modal/Title.tsx index 6d335727c6c..c3f34418ca0 100644 --- a/src/components/Modal/Title.tsx +++ b/src/components/Modal/Title.tsx @@ -1,7 +1,7 @@ import { Text, TextProps } from "@saleor/macaw-ui-next"; import React, { ReactNode } from "react"; -interface TitleProps extends TextProps { +export interface TitleProps extends TextProps { children: ReactNode; } diff --git a/src/components/Modal/index.ts b/src/components/Modal/index.ts index fbcb28fd223..0a2cf217007 100644 --- a/src/components/Modal/index.ts +++ b/src/components/Modal/index.ts @@ -2,6 +2,7 @@ import { Actions } from "./Actions"; import { Close } from "./Close"; import { Content, ContentSize } from "./Content"; import { Grid } from "./Grid"; +import { Header } from "./Header"; import { Root } from "./Root"; import { Title } from "./Title"; @@ -13,4 +14,5 @@ export const DashboardModal = Object.assign(Root, { Actions, Close, Grid, + Header, }); From 42f9ce5fcbfbf95eb2154cee64e6af33bae4e609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chy=C5=82a?= Date: Fri, 27 Sep 2024 12:14:50 +0200 Subject: [PATCH 2/7] Migrate modals to use Header component --- src/apps/components/AppDialog/AppDialog.tsx | 10 ++-------- .../AppPermissionsDialog.tsx | 4 +++- .../AttributeValueEditDialog.tsx | 4 ++-- src/components/ActionDialog/ActionDialog.tsx | 2 +- .../AssignAttributeDialog.tsx | 4 ++-- .../AssignContainerDialog.tsx | 2 +- .../AssignProductDialog.tsx | 4 ++-- .../AssignVariantDialog.tsx | 4 ++-- src/components/DevModePanel/DevModePanel.tsx | 5 ++--- src/components/DryRun/DryRun.tsx | 10 ++++------ src/components/Form/ExitFormDialog.tsx | 5 ++--- .../SaveFilterTabDialog.tsx | 4 ++-- .../TypeDeleteWarningDialog.tsx | 6 ++---- .../TokenCreateDialog/TokenCreateDialog.tsx | 4 ++-- .../CustomerAddressDialog.tsx | 4 ++-- .../DiscountCountrySelectDialog.tsx | 4 ++-- .../DiscountDeleteModal.tsx | 4 ++-- .../RuleDeleteModal/RuleDeleteModal.tsx | 5 ++--- .../RuleFormModal/RuleFormModal.tsx | 5 ++--- .../VoucherCodesDeleteDialog.tsx | 4 ++-- .../VoucherCodesGenerateDialog.tsx | 4 +++- .../VoucherCodesManualDialog.tsx | 4 ++-- .../GiftCardBulkCreateDialog.tsx | 4 +++- .../GiftCardBulkCreateSuccessDialog.tsx | 4 ++-- .../GiftCardCreateDialogContent.tsx | 4 +++- .../GiftCardExportDialogContent.tsx | 4 ++-- .../MenuCreateDialog/MenuCreateDialog.tsx | 4 ++-- .../MenuItemDialog/MenuItemDialog.tsx | 4 ++-- .../OrderCancelDialog/OrderCancelDialog.tsx | 4 ++-- .../OrderCannotCancelOrderDialog.tsx | 4 ++-- .../OrderChangeWarehouseDialog.tsx | 12 ++++-------- .../OrderCustomerAddressesEditDialog.tsx | 4 ++-- .../OrderCustomerChangeDialog.tsx | 4 ++-- .../OrderFulfillmentApproveDialog.tsx | 4 ++-- .../OrderFulfillmentCancelDialog.tsx | 4 ++-- .../OrderFulfillmentTrackingDialog.tsx | 4 ++-- .../OrderInvoiceEmailSendDialog.tsx | 4 ++-- .../OrderManualTransactionDialog.tsx | 5 ++--- .../OrderMetadataDialog.tsx | 4 ++-- .../OrderPaymentDialog/OrderPaymentDialog.tsx | 4 ++-- .../OrderPaymentVoidDialog.tsx | 4 ++-- .../OrderProductAddDialog.tsx | 4 ++-- .../OrderRefundDialog/OrderRefundDialog.tsx | 4 ++-- .../OrderShippingMethodEditDialog.tsx | 4 ++-- .../OrderTransactionActionDialog.tsx | 4 ++-- .../OrderTransactionReasonModal.tsx | 5 ++--- .../PageTypePickerDialog.tsx | 4 ++-- .../AssignMembersDialog.tsx | 4 ++-- .../PluginSecretFieldDialog.tsx | 4 ++-- .../ProductExportDialog.tsx | 4 ++-- .../ProductExternalMediaDialog.tsx | 4 ++-- .../ProductVariantDeleteDialog.tsx | 6 +++--- .../ProductVariantMediaSelectDialog.tsx | 4 ++-- .../ShippingMethodProductsAddDialog.tsx | 4 ++-- .../ShippingWeightUnitDialog.tsx | 18 +++++++----------- .../ShippingZoneAddWarehouseDialog.tsx | 4 ++-- .../ShippingZoneCountriesAssignDialog.tsx | 4 ++-- .../ShippingZonePostalCodeRangeDialog.tsx | 4 ++-- .../StaffAddMemberDialog.tsx | 4 ++-- .../StaffPasswordResetDialog.tsx | 4 ++-- .../TaxCountryDialog/TaxCountryDialog.tsx | 5 ++--- 61 files changed, 134 insertions(+), 151 deletions(-) diff --git a/src/apps/components/AppDialog/AppDialog.tsx b/src/apps/components/AppDialog/AppDialog.tsx index c79af3ad4b5..9f03d5d7920 100644 --- a/src/apps/components/AppDialog/AppDialog.tsx +++ b/src/apps/components/AppDialog/AppDialog.tsx @@ -12,15 +12,9 @@ export const AppDialog: React.FC = ({ children, title, onClose, return ( - + {title} - - + {children} diff --git a/src/apps/components/AppPermissionsDialog/AppPermissionsDialog.tsx b/src/apps/components/AppPermissionsDialog/AppPermissionsDialog.tsx index ae22228eb7c..b08d684560d 100644 --- a/src/apps/components/AppPermissionsDialog/AppPermissionsDialog.tsx +++ b/src/apps/components/AppPermissionsDialog/AppPermissionsDialog.tsx @@ -111,7 +111,9 @@ export const AppPermissionsDialog = ({ return ( - {formatMessage(messages.heading)} + + {formatMessage(messages.heading)} + {formatMessage(messages.info)} = ({
{({ errors, set, change, clearErrors, setError, data, submit }) => ( - + {attributeValue === null ? ( = ({ description="edit attribute value" /> )} - + - {title} + {title} {children} {backButtonText} diff --git a/src/components/AssignAttributeDialog/AssignAttributeDialog.tsx b/src/components/AssignAttributeDialog/AssignAttributeDialog.tsx index 68d52fac640..9845afd5c4e 100644 --- a/src/components/AssignAttributeDialog/AssignAttributeDialog.tsx +++ b/src/components/AssignAttributeDialog/AssignAttributeDialog.tsx @@ -82,9 +82,9 @@ const AssignAttributeDialog: React.FC = ({ return ( - + - + = props => { return ( - {labels.title} + {labels.title} = props => { return ( - + - + = props => { return ( - + - + { setDevModeVisibility(false)}> - + setDevModeVisibility(false)}> {intl.formatMessage(messages.title)} - setDevModeVisibility(false)} /> - + diff --git a/src/components/DryRun/DryRun.tsx b/src/components/DryRun/DryRun.tsx index f3965f02d8c..a9ef6f186f9 100644 --- a/src/components/DryRun/DryRun.tsx +++ b/src/components/DryRun/DryRun.tsx @@ -69,10 +69,9 @@ const DryRun: React.FC = ({ return ( - + {intl.formatMessage(messages.header)} - - + {intl.formatMessage(messages.unavailableSyncEvents)} @@ -85,10 +84,9 @@ const DryRun: React.FC = ({ return ( - + {intl.formatMessage(messages.header)} - - + {intl.formatMessage(messages.selectObject)} diff --git a/src/components/Form/ExitFormDialog.tsx b/src/components/Form/ExitFormDialog.tsx index 1589fc605b5..7a8849480c0 100644 --- a/src/components/Form/ExitFormDialog.tsx +++ b/src/components/Form/ExitFormDialog.tsx @@ -18,10 +18,9 @@ const ExitFormDialog: React.FC = ({ onLeave, onClose, isOpe return ( - + {intl.formatMessage(messages.unableToSaveTitle)} - - + {intl.formatMessage(messages.keepEditing)} diff --git a/src/components/SaveFilterTabDialog/SaveFilterTabDialog.tsx b/src/components/SaveFilterTabDialog/SaveFilterTabDialog.tsx index 10ad42860ce..37c5d818da9 100644 --- a/src/components/SaveFilterTabDialog/SaveFilterTabDialog.tsx +++ b/src/components/SaveFilterTabDialog/SaveFilterTabDialog.tsx @@ -47,13 +47,13 @@ const SaveFilterTabDialog: React.FC = ({ {({ change, data, submit }) => ( - + - + ({ return ( - + {intl.formatMessage(baseMessages.title, { selectedTypesCount: typesToDelete.length, })} - - - + {isLoading ? ( diff --git a/src/custom-apps/components/TokenCreateDialog/TokenCreateDialog.tsx b/src/custom-apps/components/TokenCreateDialog/TokenCreateDialog.tsx index 6990828d6e3..bbbe7565482 100644 --- a/src/custom-apps/components/TokenCreateDialog/TokenCreateDialog.tsx +++ b/src/custom-apps/components/TokenCreateDialog/TokenCreateDialog.tsx @@ -61,9 +61,9 @@ const TokenCreateDialog: React.FC = props => { onCreate(data.name)}> {({ change, data, submit }) => ( - + - + {step === "form" ? ( <> diff --git a/src/customers/components/CustomerAddressDialog/CustomerAddressDialog.tsx b/src/customers/components/CustomerAddressDialog/CustomerAddressDialog.tsx index da5eb20ef81..5d5b11004fa 100644 --- a/src/customers/components/CustomerAddressDialog/CustomerAddressDialog.tsx +++ b/src/customers/components/CustomerAddressDialog/CustomerAddressDialog.tsx @@ -82,7 +82,7 @@ const CustomerAddressDialog: React.FC = ({ return ( - + {variant === "create" ? ( = ({ description="dialog title" /> )} - + = __gridTemplateRows="auto auto auto auto auto 1fr auto" height="100%" > - + - + - + - + - + {intl.formatMessage(messages.deleteRule)} - - + diff --git a/src/discounts/components/DiscountRules/componenets/RuleFormModal/RuleFormModal.tsx b/src/discounts/components/DiscountRules/componenets/RuleFormModal/RuleFormModal.tsx index 31d3d501e42..38b9570f1f3 100644 --- a/src/discounts/components/DiscountRules/componenets/RuleFormModal/RuleFormModal.tsx +++ b/src/discounts/components/DiscountRules/componenets/RuleFormModal/RuleFormModal.tsx @@ -39,10 +39,9 @@ export const RuleFormModal = ({ return ( - + - - + {children} diff --git a/src/discounts/components/VoucherCodesDeleteDialog/VoucherCodesDeleteDialog.tsx b/src/discounts/components/VoucherCodesDeleteDialog/VoucherCodesDeleteDialog.tsx index 58f42296cb8..eb8a1ef694d 100644 --- a/src/discounts/components/VoucherCodesDeleteDialog/VoucherCodesDeleteDialog.tsx +++ b/src/discounts/components/VoucherCodesDeleteDialog/VoucherCodesDeleteDialog.tsx @@ -24,9 +24,9 @@ export const VoucherCodesDeleteDialog = ({ return ( - + - + - {intl.formatMessage(messages.title)} + + {intl.formatMessage(messages.title)} + - + - + = ({ onClose, open }) => { <> - {intl.formatMessage(messages.title)} + + {intl.formatMessage(messages.title)} + {!loadingChannelCurrencies && ( - + {intl.formatMessage(messages.bulkCreateIssuedTitle)} - + {intl.formatMessage(messages.bulkCreateIssuedExplanation)} diff --git a/src/giftCards/GiftCardCreateDialog/GiftCardCreateDialogContent.tsx b/src/giftCards/GiftCardCreateDialog/GiftCardCreateDialogContent.tsx index 070ca314457..fffaf608c8d 100644 --- a/src/giftCards/GiftCardCreateDialog/GiftCardCreateDialogContent.tsx +++ b/src/giftCards/GiftCardCreateDialog/GiftCardCreateDialogContent.tsx @@ -78,7 +78,9 @@ const GiftCardCreateDialogContent: React.FC = return ( - {intl.formatMessage(messages.title)} + + {intl.formatMessage(messages.title)} + {cardCode ? ( ) : ( diff --git a/src/giftCards/GiftCardExportDialogContent/GiftCardExportDialogContent.tsx b/src/giftCards/GiftCardExportDialogContent/GiftCardExportDialogContent.tsx index 270e5b2d80c..099184789e2 100644 --- a/src/giftCards/GiftCardExportDialogContent/GiftCardExportDialogContent.tsx +++ b/src/giftCards/GiftCardExportDialogContent/GiftCardExportDialogContent.tsx @@ -97,9 +97,9 @@ const GiftCardExportDialog: React.FC< return ( - + - + {!loading && ( diff --git a/src/navigation/components/MenuCreateDialog/MenuCreateDialog.tsx b/src/navigation/components/MenuCreateDialog/MenuCreateDialog.tsx index 17421a42c50..8d5a677d2c4 100644 --- a/src/navigation/components/MenuCreateDialog/MenuCreateDialog.tsx +++ b/src/navigation/components/MenuCreateDialog/MenuCreateDialog.tsx @@ -44,13 +44,13 @@ const MenuCreateDialog: React.FC = ({
{({ change, data, submit }) => ( - + - + = ({ - + {initial ? intl.formatMessage({ id: "KKQUMK", @@ -110,7 +110,7 @@ const MenuItemDialog: React.FC = ({ defaultMessage: "Add Item", description: "create new menu item, header", })} - + = props => { return ( - + - + = ({ open, onClose }) return ( - + - + - - - - - - - + + + - + {debounceSearchChange => { diff --git a/src/orders/components/OrderCustomerAddressesEditDialog/OrderCustomerAddressesEditDialog.tsx b/src/orders/components/OrderCustomerAddressesEditDialog/OrderCustomerAddressesEditDialog.tsx index 6dc3c0a1d3f..628b76c1fac 100644 --- a/src/orders/components/OrderCustomerAddressesEditDialog/OrderCustomerAddressesEditDialog.tsx +++ b/src/orders/components/OrderCustomerAddressesEditDialog/OrderCustomerAddressesEditDialog.tsx @@ -253,9 +253,9 @@ const OrderCustomerAddressesEditDialog: React.FC - + - + {addressSearchState.open ? ( = prop {({ change, data }) => ( - + - + diff --git a/src/orders/components/OrderFulfillmentApproveDialog/OrderFulfillmentApproveDialog.tsx b/src/orders/components/OrderFulfillmentApproveDialog/OrderFulfillmentApproveDialog.tsx index d3c18068202..8dfc5911cb5 100644 --- a/src/orders/components/OrderFulfillmentApproveDialog/OrderFulfillmentApproveDialog.tsx +++ b/src/orders/components/OrderFulfillmentApproveDialog/OrderFulfillmentApproveDialog.tsx @@ -35,9 +35,9 @@ const OrderFulfillmentApproveDialog: React.FC {({ change, data, submit }) => ( - + - + diff --git a/src/orders/components/OrderFulfillmentCancelDialog/OrderFulfillmentCancelDialog.tsx b/src/orders/components/OrderFulfillmentCancelDialog/OrderFulfillmentCancelDialog.tsx index 03639f2777f..8d19dcaa03a 100644 --- a/src/orders/components/OrderFulfillmentCancelDialog/OrderFulfillmentCancelDialog.tsx +++ b/src/orders/components/OrderFulfillmentCancelDialog/OrderFulfillmentCancelDialog.tsx @@ -63,13 +63,13 @@ const OrderFulfillmentCancelDialog: React.FC return ( - + - + {({ change, data, submit }) => ( - + - + = return ( - + {intl.formatMessage({ id: "5JT4v2", defaultMessage: "Send Invoice", description: "dialog header", })} - + - + - - + diff --git a/src/orders/components/OrderMetadataDialog/OrderMetadataDialog.tsx b/src/orders/components/OrderMetadataDialog/OrderMetadataDialog.tsx index 932c73f6250..83f1ff336d3 100644 --- a/src/orders/components/OrderMetadataDialog/OrderMetadataDialog.tsx +++ b/src/orders/components/OrderMetadataDialog/OrderMetadataDialog.tsx @@ -20,9 +20,9 @@ export const OrderMetadataDialog = ({ onClose, open, data, loading }: OrderMetad return ( - + : {data?.productName ?? ""} - + = ({ > {({ data, change, submit }) => ( - + {intl.formatMessage({ id: "+PbHKD", defaultMessage: "Capture Payment", description: "dialog header", })} - + = ({ return ( - + - + = props => { return ( - + - + diff --git a/src/orders/components/OrderRefundDialog/OrderRefundDialog.tsx b/src/orders/components/OrderRefundDialog/OrderRefundDialog.tsx index a9834fe48bd..52e67dc9dc3 100644 --- a/src/orders/components/OrderRefundDialog/OrderRefundDialog.tsx +++ b/src/orders/components/OrderRefundDialog/OrderRefundDialog.tsx @@ -28,9 +28,9 @@ export const OrderRefundDialog = ({ return ( - + {intl.formatMessage(orderRefundDialogMesages.title)} - + {intl.formatMessage(orderRefundDialogMesages.subtitle)} ( <> - + - +