diff --git a/.changeset/tall-trainers-approve.md b/.changeset/tall-trainers-approve.md new file mode 100644 index 00000000000..0d5b09d00a6 --- /dev/null +++ b/.changeset/tall-trainers-approve.md @@ -0,0 +1,5 @@ +--- +"saleor-dashboard": patch +--- + +Modals in the Dashboard have been aligned, so that all contains close button diff --git a/src/apps/components/AppDialog/AppDialog.tsx b/src/apps/components/AppDialog/AppDialog.tsx index c79af3ad4b5..f7991d6da8a 100644 --- a/src/apps/components/AppDialog/AppDialog.tsx +++ b/src/apps/components/AppDialog/AppDialog.tsx @@ -12,15 +12,7 @@ export const AppDialog: React.FC = ({ children, title, onClose, return ( - - {title} - - + {title} {children} diff --git a/src/apps/components/AppPermissionsDialog/AppPermissionsDialog.tsx b/src/apps/components/AppPermissionsDialog/AppPermissionsDialog.tsx index ae22228eb7c..b645ef21db9 100644 --- a/src/apps/components/AppPermissionsDialog/AppPermissionsDialog.tsx +++ b/src/apps/components/AppPermissionsDialog/AppPermissionsDialog.tsx @@ -111,7 +111,7 @@ 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..b6acf1c2910 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)}> - - {intl.formatMessage(messages.title)} - setDevModeVisibility(false)} /> - + {intl.formatMessage(messages.title)} diff --git a/src/components/DryRun/DryRun.tsx b/src/components/DryRun/DryRun.tsx index f3965f02d8c..56346ff84e1 100644 --- a/src/components/DryRun/DryRun.tsx +++ b/src/components/DryRun/DryRun.tsx @@ -69,10 +69,7 @@ const DryRun: React.FC = ({ return ( - - {intl.formatMessage(messages.header)} - - + {intl.formatMessage(messages.header)} {intl.formatMessage(messages.unavailableSyncEvents)} @@ -85,10 +82,7 @@ const DryRun: React.FC = ({ return ( - - {intl.formatMessage(messages.header)} - - + {intl.formatMessage(messages.header)} {intl.formatMessage(messages.selectObject)} diff --git a/src/components/Form/ExitFormDialog.tsx b/src/components/Form/ExitFormDialog.tsx index 1589fc605b5..f31590aad3c 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/Modal/Header.tsx b/src/components/Modal/Header.tsx new file mode 100644 index 00000000000..f9c54336d48 --- /dev/null +++ b/src/components/Modal/Header.tsx @@ -0,0 +1,21 @@ +import { useModalContext } from "@dashboard/components/Modal/context"; +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; +} + +export const Header = ({ children, ...rest }: HeaderProps) => { + const { onChange } = useModalContext(); + + return ( + + {children} + onChange?.(false)} /> + + ); +}; diff --git a/src/components/Modal/Root.tsx b/src/components/Modal/Root.tsx index 3b423af088b..cd05e5b0cba 100644 --- a/src/components/Modal/Root.tsx +++ b/src/components/Modal/Root.tsx @@ -1,6 +1,15 @@ +import { ModalContextProvider } from "@dashboard/components/Modal/context"; import { Modal, ModalRootProps } from "@saleor/macaw-ui-next"; import React from "react"; -export const Root = ({ children, ...rest }: ModalRootProps) => { - return {children}; +type RootProps = ModalRootProps; + +export const Root = ({ children, onChange, open, ...rest }: RootProps) => { + 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/context.tsx b/src/components/Modal/context.tsx new file mode 100644 index 00000000000..60bc8692c7b --- /dev/null +++ b/src/components/Modal/context.tsx @@ -0,0 +1,30 @@ +import React, { createContext } from "react"; + +interface ModalContextValues { + open?: boolean; + onChange?: (open: boolean) => void; +} + +const ModalContext = createContext(null); + +export const ModalContextProvider = ({ + children, + onChange, + open, +}: { + children: React.ReactNode; + onChange?: (open: boolean) => void; + open?: boolean; +}) => { + return {children}; +}; + +export const useModalContext = () => { + const context = React.useContext(ModalContext); + + if (!context) { + throw new Error("useModalContext must be used within a ModalContextProvider"); + } + + return context; +}; 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, }); diff --git a/src/components/SaveFilterTabDialog/SaveFilterTabDialog.tsx b/src/components/SaveFilterTabDialog/SaveFilterTabDialog.tsx index 10ad42860ce..4fa000981f1 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..80a1838af7a 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..d7152c5b9fb 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)} - - + {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..e53a0f2cce9 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..477a2f52865 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..829089ae410 100644 --- a/src/giftCards/GiftCardCreateDialog/GiftCardCreateDialogContent.tsx +++ b/src/giftCards/GiftCardCreateDialog/GiftCardCreateDialogContent.tsx @@ -78,7 +78,7 @@ 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..7a1956b634d 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..8788167c53e 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..e7a4789bb03 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..71328d69e90 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..c03b8fbf9e8 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..392eb861ede 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..626524bd182 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)} ( <> - + - +