Add information about immediate save (#1900)

* Add information about immediate save

* Remove leftover code

* Add info about immediate save in sales

* Add info about immediate save in orders

* Add info about immediate save in attributes

* Add info about immediate save in shipping

* Add saved notification

* Fix type errors

* Update messages

* Remove debug code

* Update messages

* Lint project
This commit is contained in:
Dominik Żegleń 2022-03-21 12:29:08 +01:00 committed by GitHub
parent fc0e3757ae
commit 045f1d068d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 331 additions and 190 deletions

View file

@ -1856,7 +1856,7 @@
}, },
"src_dot_components_dot_AssignAttributeDialog_dot_assignButton": { "src_dot_components_dot_AssignAttributeDialog_dot_assignButton": {
"context": "button", "context": "button",
"string": "Assign attributes" "string": "Assign and save"
}, },
"src_dot_components_dot_AssignAttributeDialog_dot_noMembersFound": { "src_dot_components_dot_AssignAttributeDialog_dot_noMembersFound": {
"context": "description", "context": "description",
@ -1874,6 +1874,10 @@
"context": "dialog header", "context": "dialog header",
"string": "Assign Attribute" "string": "Assign Attribute"
}, },
"src_dot_components_dot_AssignAttributeValueDialog_dot_confirmBtn": {
"context": "assign reference to product, button",
"string": "Assign"
},
"src_dot_components_dot_AssignAttributeValueDialog_dot_header": { "src_dot_components_dot_AssignAttributeValueDialog_dot_header": {
"context": "dialog header", "context": "dialog header",
"string": "Assign Attribute Value" "string": "Assign Attribute Value"
@ -1898,6 +1902,10 @@
"context": "dialog search placeholder", "context": "dialog search placeholder",
"string": "Search by category name, etc..." "string": "Search by category name, etc..."
}, },
"src_dot_components_dot_AssignCategoryDialog_dot_confirmButton": {
"context": "assign categories to sale and save",
"string": "Assign and save"
},
"src_dot_components_dot_AssignCollectionDialog_dot_assignCollectionDialogHeader": { "src_dot_components_dot_AssignCollectionDialog_dot_assignCollectionDialogHeader": {
"context": "dialog header", "context": "dialog header",
"string": "Assign Collection" "string": "Assign Collection"
@ -1910,13 +1918,17 @@
"context": "dialog search placeholder", "context": "dialog search placeholder",
"string": "Search by collection name, etc..." "string": "Search by collection name, etc..."
}, },
"src_dot_components_dot_AssignCollectionDialog_dot_confirmBtn": {
"context": "assign collections to sale and save",
"string": "Assign and save"
},
"src_dot_components_dot_AssignContainerDialog_dot_assignContainerDialogButton": { "src_dot_components_dot_AssignContainerDialog_dot_assignContainerDialogButton": {
"context": "button", "context": "button",
"string": "Assign" "string": "Assign"
}, },
"src_dot_components_dot_AssignProductDialog_dot_assignProductDialogButton": { "src_dot_components_dot_AssignProductDialog_dot_assignProductDialogButton": {
"context": "button", "context": "button",
"string": "Assign" "string": "Assign and save"
}, },
"src_dot_components_dot_AssignProductDialog_dot_assignProductDialogContent": { "src_dot_components_dot_AssignProductDialog_dot_assignProductDialogContent": {
"string": "Search Products" "string": "Search Products"
@ -1932,8 +1944,8 @@
"string": "No products available in order channel matching given query" "string": "No products available in order channel matching given query"
}, },
"src_dot_components_dot_AssignVariantDialog_dot_assignVariantDialogButton": { "src_dot_components_dot_AssignVariantDialog_dot_assignVariantDialogButton": {
"context": "button", "context": "button, assign variants to sale and save",
"string": "Assign" "string": "Assign and save"
}, },
"src_dot_components_dot_AssignVariantDialog_dot_assignVariantDialogContent": { "src_dot_components_dot_AssignVariantDialog_dot_assignVariantDialogContent": {
"string": "Search Variants" "string": "Search Variants"
@ -1949,7 +1961,12 @@
"src_dot_components_dot_AssignVariantDialog_dot_assignVariantDialogSearch": { "src_dot_components_dot_AssignVariantDialog_dot_assignVariantDialogSearch": {
"string": "Search by product name, attribute, product type etc..." "string": "Search by product name, attribute, product type etc..."
}, },
"src_dot_components_dot_AttributeUnassignDialog_dot_2037985699": { "src_dot_components_dot_AttributeUnassignDialog_dot_confirmBtn": {
"context": "button, unassign attribute from object",
"string": "Unassign and save"
},
"src_dot_components_dot_AttributeUnassignDialog_dot_content": {
"context": "unassign attribute from object",
"string": "Are you sure you want to unassign {attributeName} from {itemTypeName}?" "string": "Are you sure you want to unassign {attributeName} from {itemTypeName}?"
}, },
"src_dot_components_dot_Attributes_dot_attributesNumber": { "src_dot_components_dot_Attributes_dot_attributesNumber": {
@ -1975,7 +1992,11 @@
"src_dot_components_dot_AutocompleteSelectMenu_dot_2332404293": { "src_dot_components_dot_AutocompleteSelectMenu_dot_2332404293": {
"string": "No results" "string": "No results"
}, },
"src_dot_components_dot_BulkAttributeUnassignDialog_dot_3177750460": { "src_dot_components_dot_BulkAttributeUnassignDialog_dot_confirmBtn": {
"context": "button, unassign attribute from object",
"string": "Unassign and save"
},
"src_dot_components_dot_BulkAttributeUnassignDialog_dot_content": {
"context": "unassign multiple attributes from item", "context": "unassign multiple attributes from item",
"string": "{counter,plural,one{Are you sure you want to unassign this attribute from {itemTypeName}?} other{Are you sure you want to unassign {attributeQuantity} attributes from {itemTypeName}?}}" "string": "{counter,plural,one{Are you sure you want to unassign this attribute from {itemTypeName}?} other{Are you sure you want to unassign {attributeQuantity} attributes from {itemTypeName}?}}"
}, },
@ -3398,8 +3419,8 @@
"string": "Delete Sale" "string": "Delete Sale"
}, },
"src_dot_discounts_dot_views_dot_SaleDetails_dot_saleDetailsUnassignCategory": { "src_dot_discounts_dot_views_dot_SaleDetails_dot_saleDetailsUnassignCategory": {
"context": "unassign category from sale, button", "context": "unassign category from sale and save, button",
"string": "Unassign" "string": "Unassign and save"
}, },
"src_dot_discounts_dot_views_dot_SaleDetails_dot_saleDetailsUnassignCategoryDialog": { "src_dot_discounts_dot_views_dot_SaleDetails_dot_saleDetailsUnassignCategoryDialog": {
"context": "dialog content", "context": "dialog content",
@ -3410,8 +3431,8 @@
"string": "Unassign Categories From Sale" "string": "Unassign Categories From Sale"
}, },
"src_dot_discounts_dot_views_dot_SaleDetails_dot_saleDetailsUnassignCollection": { "src_dot_discounts_dot_views_dot_SaleDetails_dot_saleDetailsUnassignCollection": {
"context": "unassign collection from sale, button", "context": "unassign collection from sale and save, button",
"string": "Unassign" "string": "Unassign and save"
}, },
"src_dot_discounts_dot_views_dot_SaleDetails_dot_saleDetailsUnassignCollectionDialog": { "src_dot_discounts_dot_views_dot_SaleDetails_dot_saleDetailsUnassignCollectionDialog": {
"context": "dialog content", "context": "dialog content",
@ -3426,8 +3447,8 @@
"string": "Are you sure you want to delete {saleName}?" "string": "Are you sure you want to delete {saleName}?"
}, },
"src_dot_discounts_dot_views_dot_SaleDetails_dot_saleDetailsUnassignProduct": { "src_dot_discounts_dot_views_dot_SaleDetails_dot_saleDetailsUnassignProduct": {
"context": "unassign product from sale, button", "context": "unassign product from sale and save, button",
"string": "Unassign" "string": "Unassign and save"
}, },
"src_dot_discounts_dot_views_dot_SaleDetails_dot_saleDetailsUnassignProductDialog": { "src_dot_discounts_dot_views_dot_SaleDetails_dot_saleDetailsUnassignProductDialog": {
"context": "dialog content", "context": "dialog content",
@ -3438,8 +3459,8 @@
"string": "Unassign Product From Sale" "string": "Unassign Product From Sale"
}, },
"src_dot_discounts_dot_views_dot_SaleDetails_dot_saleDetailsUnassignVariant": { "src_dot_discounts_dot_views_dot_SaleDetails_dot_saleDetailsUnassignVariant": {
"context": "unassign variant from sale, button", "context": "unassign variant from sale and save, button",
"string": "Unassign" "string": "Unassign and save"
}, },
"src_dot_discounts_dot_views_dot_SaleDetails_dot_saleDetailsUnassignVariantDialog": { "src_dot_discounts_dot_views_dot_SaleDetails_dot_saleDetailsUnassignVariantDialog": {
"context": "dialog content", "context": "dialog content",
@ -3463,13 +3484,14 @@
"src_dot_discounts_dot_views_dot_VoucherCreate_dot_655651329": { "src_dot_discounts_dot_views_dot_VoucherCreate_dot_655651329": {
"string": "Successfully created voucher" "string": "Successfully created voucher"
}, },
"src_dot_discounts_dot_views_dot_VoucherDetails_dot_1162257691": {
"string": "Deleted voucher"
},
"src_dot_discounts_dot_views_dot_VoucherDetails_dot_1402402714": { "src_dot_discounts_dot_views_dot_VoucherDetails_dot_1402402714": {
"context": "dialog header", "context": "dialog header",
"string": "Unassign Collections From Voucher" "string": "Unassign Collections From Voucher"
}, },
"src_dot_discounts_dot_views_dot_VoucherDetails_dot_1569805915": {
"context": "button",
"string": "Unassign and save"
},
"src_dot_discounts_dot_views_dot_VoucherDetails_dot_2072403265": { "src_dot_discounts_dot_views_dot_VoucherDetails_dot_2072403265": {
"context": "dialog header", "context": "dialog header",
"string": "Unassign Products From Voucher" "string": "Unassign Products From Voucher"
@ -7172,6 +7194,10 @@
"src_dot_shipping_dot_components_dot_ShippingMethodProductsAddDialog_dot_353369701": { "src_dot_shipping_dot_components_dot_ShippingMethodProductsAddDialog_dot_353369701": {
"string": "No products matching given query" "string": "No products matching given query"
}, },
"src_dot_shipping_dot_components_dot_ShippingMethodProductsAddDialog_dot_3657244300": {
"context": "assign products to shipping rate and save, button",
"string": "Assign and save"
},
"src_dot_shipping_dot_components_dot_ShippingMethodProductsAddDialog_dot_3756118423": { "src_dot_shipping_dot_components_dot_ShippingMethodProductsAddDialog_dot_3756118423": {
"context": "dialog header", "context": "dialog header",
"string": "Assign Products" "string": "Assign Products"
@ -7223,8 +7249,8 @@
"string": "Create New Warehouse" "string": "Create New Warehouse"
}, },
"src_dot_shipping_dot_components_dot_ShippingZoneCountriesAssignDialog_dot_assignCountriesButton": { "src_dot_shipping_dot_components_dot_ShippingZoneCountriesAssignDialog_dot_assignCountriesButton": {
"context": "button", "context": "assign countries to shipping zone and save, button",
"string": "Assign countries" "string": "Assign and save"
}, },
"src_dot_shipping_dot_components_dot_ShippingZoneCountriesAssignDialog_dot_assignCountriesDescription": { "src_dot_shipping_dot_components_dot_ShippingZoneCountriesAssignDialog_dot_assignCountriesDescription": {
"context": "dialog description", "context": "dialog description",
@ -7427,6 +7453,10 @@
"context": "dialog header", "context": "dialog header",
"string": "Unassign Products From Shipping" "string": "Unassign Products From Shipping"
}, },
"src_dot_shipping_dot_components_dot_UnassignDialog_dot_1569805915": {
"context": "unassign products from shipping rate and save, button",
"string": "Unassign and save"
},
"src_dot_shipping_dot_components_dot_UnassignDialog_dot_3215481647": { "src_dot_shipping_dot_components_dot_UnassignDialog_dot_3215481647": {
"context": "dialog content", "context": "dialog content",
"string": "{counter,plural,one{Are you sure you want to unassign this product?} other{Are you sure you want to unassign {displayQuantity} products?}}" "string": "{counter,plural,one{Are you sure you want to unassign this product?} other{Are you sure you want to unassign {displayQuantity} products?}}"
@ -7465,13 +7495,17 @@
"context": "dialog header", "context": "dialog header",
"string": "Delete Shipping Zone" "string": "Delete Shipping Zone"
}, },
"src_dot_shipping_dot_views_dot_ShippingZoneDetails_dot_131963671": { "src_dot_shipping_dot_views_dot_ShippingZoneDetails_dot_1790261672": {
"context": "unassign country", "context": "unassign country",
"string": "Are you sure you want to delete {countryName} from this shipping zone?" "string": "Are you sure you want to remove {countryName} from this shipping zone?"
}, },
"src_dot_shipping_dot_views_dot_ShippingZoneDetails_dot_3133838427": { "src_dot_shipping_dot_views_dot_ShippingZoneDetails_dot_4243932177": {
"context": "unassign country, dialog header", "context": "unassign country, dialog header",
"string": "Delete from Shipping Zone" "string": "Remove from Shipping Zone"
},
"src_dot_shipping_dot_views_dot_ShippingZoneDetails_dot_4279089621": {
"context": "remove country from shipping zone and save, button",
"string": "Remove and save"
}, },
"src_dot_shipping_dot_weight": { "src_dot_shipping_dot_weight": {
"context": "error message", "context": "error message",
@ -8488,15 +8522,15 @@
"string": "Unlimited" "string": "Unlimited"
}, },
"voucherDetailsUnassignCategory": { "voucherDetailsUnassignCategory": {
"context": "unassign category from voucher, button", "context": "button",
"string": "Unassign" "string": "Unassign"
}, },
"voucherDetailsUnassignCollection": { "voucherDetailsUnassignCollection": {
"context": "unassign collection from voucher, button", "context": "button",
"string": "Unassign" "string": "Unassign"
}, },
"voucherDetailsUnassignProduct": { "voucherDetailsUnassignProduct": {
"context": "unassign product from voucher, button", "context": "button",
"string": "Unassign" "string": "Unassign"
}, },
"will become available on": { "will become available on": {

2
package-lock.json generated
View file

@ -1,6 +1,6 @@
{ {
"name": "saleor-dashboard", "name": "saleor-dashboard",
"version": "3.0.0-b.11", "version": "3.1.0-dev",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View file

@ -17,7 +17,7 @@ import useLocalPaginator, {
import useNavigator from "@saleor/hooks/useNavigator"; import useNavigator from "@saleor/hooks/useNavigator";
import useNotifier from "@saleor/hooks/useNotifier"; import useNotifier from "@saleor/hooks/useNotifier";
import { commonMessages } from "@saleor/intl"; import { commonMessages } from "@saleor/intl";
import { extractMutationErrors } from "@saleor/misc"; import { extractMutationErrors, getStringOrPlaceholder } from "@saleor/misc";
import { ListViews, ReorderEvent } from "@saleor/types"; import { ListViews, ReorderEvent } from "@saleor/types";
import getAttributeErrorMessage from "@saleor/utils/errors/attribute"; import getAttributeErrorMessage from "@saleor/utils/errors/attribute";
import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers"; import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers";
@ -83,6 +83,12 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({ id, params }) => {
valuesPaginationState valuesPaginationState
); );
const notifySaved = () =>
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
const [attributeDelete, attributeDeleteOpts] = useAttributeDeleteMutation({ const [attributeDelete, attributeDeleteOpts] = useAttributeDeleteMutation({
onCompleted: data => { onCompleted: data => {
if (data?.attributeDelete.errors.length === 0) { if (data?.attributeDelete.errors.length === 0) {
@ -121,10 +127,7 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({ id, params }) => {
] = useAttributeValueUpdateMutation({ ] = useAttributeValueUpdateMutation({
onCompleted: data => { onCompleted: data => {
if (data?.attributeValueUpdate.errors.length === 0) { if (data?.attributeValueUpdate.errors.length === 0) {
notify({ notifySaved();
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
closeModal(); closeModal();
} }
} }
@ -133,10 +136,7 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({ id, params }) => {
const [attributeUpdate, attributeUpdateOpts] = useAttributeUpdateMutation({ const [attributeUpdate, attributeUpdateOpts] = useAttributeUpdateMutation({
onCompleted: data => { onCompleted: data => {
if (data?.attributeUpdate.errors.length === 0) { if (data?.attributeUpdate.errors.length === 0) {
notify({ notifySaved();
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
} }
} }
}); });
@ -169,6 +169,8 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({ id, params }) => {
intl intl
) )
}); });
} else {
notifySaved();
} }
} }
}); });
@ -281,12 +283,11 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({ id, params }) => {
<AttributeValueDeleteDialog <AttributeValueDeleteDialog
attributeName={data?.attribute?.name ?? "..."} attributeName={data?.attribute?.name ?? "..."}
open={params.action === "remove-value"} open={params.action === "remove-value"}
name={ name={getStringOrPlaceholder(
(data?.attribute?.choices?.edges?.find( data?.attribute?.choices?.edges?.find(
value => params.id === value.node.id value => params.id === value.node.id
)?.node.name, )?.node.name
"...") )}
}
useName={true} useName={true}
confirmButtonState={attributeValueDeleteOpts.status} confirmButtonState={attributeValueDeleteOpts.status}
onClose={closeModal} onClose={closeModal}

View file

@ -122,6 +122,11 @@ export const CategoryDetails: React.FC<CategoryDetailsProps> = ({
text: intl.formatMessage(errorMessages.imageUploadErrorText) text: intl.formatMessage(errorMessages.imageUploadErrorText)
}); });
} }
} else {
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
} }
}; };

View file

@ -18,7 +18,7 @@ export const messages = defineMessages({
description: "description" description: "description"
}, },
assignButton: { assignButton: {
defaultMessage: "Assign attributes", defaultMessage: "Assign and save",
description: "button" description: "button"
} }
}); });

View file

@ -7,6 +7,10 @@ import AssignContainerDialog, {
} from "../AssignContainerDialog"; } from "../AssignContainerDialog";
const messages = defineMessages({ const messages = defineMessages({
confirmBtn: {
defaultMessage: "Assign",
description: "assign reference to product, button"
},
header: { header: {
defaultMessage: "Assign Attribute Value", defaultMessage: "Assign Attribute Value",
description: "dialog header" description: "dialog header"
@ -24,7 +28,7 @@ const messages = defineMessages({
interface AssignAttributeValueDialogProps interface AssignAttributeValueDialogProps
extends Omit< extends Omit<
AssignContainerDialogProps, AssignContainerDialogProps,
"containers" | "title" | "search" | "confirmButtonState" "containers" | "title" | "search" | "confirmButtonState" | "labels"
> { > {
attributeValues: AttributeReference[]; attributeValues: AttributeReference[];
} }
@ -41,11 +45,12 @@ const AssignAttributeValueDialog: React.FC<AssignAttributeValueDialogProps> = ({
id: value.value, id: value.value,
name: value.label name: value.label
}))} }))}
search={{ labels={{
confirmBtn: intl.formatMessage(messages.confirmBtn),
label: intl.formatMessage(messages.searchLabel), label: intl.formatMessage(messages.searchLabel),
placeholder: intl.formatMessage(messages.searchPlaceholder) placeholder: intl.formatMessage(messages.searchPlaceholder),
title: intl.formatMessage(messages.header)
}} }}
title={intl.formatMessage(messages.header)}
confirmButtonState="default" confirmButtonState="default"
{...rest} {...rest}
/> />

View file

@ -9,7 +9,7 @@ import AssignContainerDialog, {
import { messages } from "./messages"; import { messages } from "./messages";
interface AssignCategoryDialogProps interface AssignCategoryDialogProps
extends Omit<AssignContainerDialogProps, "containers" | "title" | "search"> { extends Omit<AssignContainerDialogProps, "containers" | "labels"> {
categories: RelayToFlat<SearchCategoriesQuery["search"]>; categories: RelayToFlat<SearchCategoriesQuery["search"]>;
} }
@ -22,13 +22,14 @@ const AssignCategoryDialog: React.FC<AssignCategoryDialogProps> = ({
return ( return (
<AssignContainerDialog <AssignContainerDialog
containers={categories} containers={categories}
search={{ labels={{
title: intl.formatMessage(messages.assignCategoryDialogHeader),
label: intl.formatMessage(messages.assignCategoryDialogLabel), label: intl.formatMessage(messages.assignCategoryDialogLabel),
placeholder: intl.formatMessage( placeholder: intl.formatMessage(
messages.assignCategoryDialogPlaceholder messages.assignCategoryDialogPlaceholder
) ),
confirmBtn: intl.formatMessage(messages.confirmButton)
}} }}
title={intl.formatMessage(messages.assignCategoryDialogHeader)}
{...rest} {...rest}
/> />
); );

View file

@ -12,5 +12,9 @@ export const messages = defineMessages({
assignCategoryDialogHeader: { assignCategoryDialogHeader: {
defaultMessage: "Assign Category", defaultMessage: "Assign Category",
description: "dialog header" description: "dialog header"
},
confirmButton: {
defaultMessage: "Assign and save",
description: "assign categories to sale and save"
} }
}); });

View file

@ -9,7 +9,7 @@ import AssignContainerDialog, {
import { messages } from "./messages"; import { messages } from "./messages";
interface AssignCollectionDialogProps interface AssignCollectionDialogProps
extends Omit<AssignContainerDialogProps, "containers" | "title" | "search"> { extends Omit<AssignContainerDialogProps, "containers" | "labels"> {
collections: RelayToFlat<SearchCollectionsQuery["search"]>; collections: RelayToFlat<SearchCollectionsQuery["search"]>;
} }
@ -22,13 +22,14 @@ const AssignCollectionDialog: React.FC<AssignCollectionDialogProps> = ({
return ( return (
<AssignContainerDialog <AssignContainerDialog
containers={collections} containers={collections}
search={{ labels={{
title: intl.formatMessage(messages.assignCollectionDialogHeader),
label: intl.formatMessage(messages.assignCollectionDialogLabel), label: intl.formatMessage(messages.assignCollectionDialogLabel),
placeholder: intl.formatMessage( placeholder: intl.formatMessage(
messages.assignCollectionDialogPlaceholder messages.assignCollectionDialogPlaceholder
) ),
confirmBtn: intl.formatMessage(messages.confirmBtn)
}} }}
title={intl.formatMessage(messages.assignCollectionDialogHeader)}
{...rest} {...rest}
/> />
); );

View file

@ -12,5 +12,9 @@ export const messages = defineMessages({
assignCollectionDialogHeader: { assignCollectionDialogHeader: {
defaultMessage: "Assign Collection", defaultMessage: "Assign Collection",
description: "dialog header" description: "dialog header"
},
confirmBtn: {
defaultMessage: "Assign and save",
description: "assign collections to sale and save"
} }
}); });

View file

@ -16,12 +16,10 @@ import useScrollableDialogStyle from "@saleor/styles/useScrollableDialogStyle";
import { DialogProps, FetchMoreProps, Node } from "@saleor/types"; import { DialogProps, FetchMoreProps, Node } from "@saleor/types";
import React from "react"; import React from "react";
import InfiniteScroll from "react-infinite-scroll-component"; import InfiniteScroll from "react-infinite-scroll-component";
import { FormattedMessage } from "react-intl";
import BackButton from "../BackButton"; import BackButton from "../BackButton";
import Checkbox from "../Checkbox"; import Checkbox from "../Checkbox";
import ConfirmButton from "../ConfirmButton"; import ConfirmButton from "../ConfirmButton";
import { messages } from "./messages";
import { useStyles } from "./styles"; import { useStyles } from "./styles";
export interface AssignContainerDialogFormData { export interface AssignContainerDialogFormData {
@ -29,6 +27,7 @@ export interface AssignContainerDialogFormData {
query: string; query: string;
} }
type Labels = Record<"confirmBtn" | "title" | "label" | "placeholder", string>;
interface Container extends Node { interface Container extends Node {
name: string; name: string;
} }
@ -38,8 +37,7 @@ export interface AssignContainerDialogProps
confirmButtonState: ConfirmButtonTransitionState; confirmButtonState: ConfirmButtonTransitionState;
containers: Container[]; containers: Container[];
loading: boolean; loading: boolean;
search: Record<"label" | "placeholder", string>; labels: Labels;
title: string;
onFetch: (value: string) => void; onFetch: (value: string) => void;
onSubmit: (data: string[]) => void; onSubmit: (data: string[]) => void;
} }
@ -70,8 +68,7 @@ const AssignContainerDialog: React.FC<AssignContainerDialogProps> = props => {
hasMore, hasMore,
loading, loading,
open, open,
search, labels,
title,
onClose, onClose,
onFetch, onFetch,
onFetchMore, onFetchMore,
@ -95,14 +92,14 @@ const AssignContainerDialog: React.FC<AssignContainerDialogProps> = props => {
fullWidth fullWidth
maxWidth="sm" maxWidth="sm"
> >
<DialogTitle>{title}</DialogTitle> <DialogTitle>{labels.title}</DialogTitle>
<DialogContent className={scrollableDialogClasses.topArea}> <DialogContent className={scrollableDialogClasses.topArea}>
<TextField <TextField
name="query" name="query"
value={query} value={query}
onChange={onQueryChange} onChange={onQueryChange}
label={search.label} label={labels.label}
placeholder={search.placeholder} placeholder={labels.placeholder}
fullWidth fullWidth
InputProps={{ InputProps={{
autoComplete: "off", autoComplete: "off",
@ -168,7 +165,7 @@ const AssignContainerDialog: React.FC<AssignContainerDialogProps> = props => {
type="submit" type="submit"
onClick={handleSubmit} onClick={handleSubmit}
> >
<FormattedMessage {...messages.assignContainerDialogButton} /> {labels.confirmBtn}
</ConfirmButton> </ConfirmButton>
</DialogActions> </DialogActions>
</Dialog> </Dialog>

View file

@ -6,7 +6,7 @@ export const messages = defineMessages({
description: "dialog header" description: "dialog header"
}, },
assignProductDialogButton: { assignProductDialogButton: {
defaultMessage: "Assign", defaultMessage: "Assign and save",
description: "button" description: "button"
}, },
assignProductDialogContent: { assignProductDialogContent: {

View file

@ -6,8 +6,8 @@ export const messages = defineMessages({
description: "dialog header" description: "dialog header"
}, },
assignVariantDialogButton: { assignVariantDialogButton: {
defaultMessage: "Assign", defaultMessage: "Assign and save",
description: "button" description: "button, assign variants to sale and save"
}, },
assignVariantDialogContent: { assignVariantDialogContent: {
defaultMessage: "Search Variants" defaultMessage: "Search Variants"

View file

@ -2,7 +2,9 @@ import { DialogContentText } from "@material-ui/core";
import ActionDialog from "@saleor/components/ActionDialog"; import ActionDialog from "@saleor/components/ActionDialog";
import { ConfirmButtonTransitionState } from "@saleor/macaw-ui"; import { ConfirmButtonTransitionState } from "@saleor/macaw-ui";
import React from "react"; import React from "react";
import { FormattedMessage } from "react-intl"; import { FormattedMessage, useIntl } from "react-intl";
import messages from "./messages";
export interface AttributeUnassignDialogProps { export interface AttributeUnassignDialogProps {
title: string; title: string;
@ -22,24 +24,29 @@ const AttributeUnassignDialog: React.FC<AttributeUnassignDialogProps> = ({
itemTypeName, itemTypeName,
onClose, onClose,
onConfirm onConfirm
}) => ( }) => {
<ActionDialog const intl = useIntl();
confirmButtonState={confirmButtonState}
open={open} return (
onClose={onClose} <ActionDialog
onConfirm={onConfirm} confirmButtonState={confirmButtonState}
title={title} open={open}
> onClose={onClose}
<DialogContentText> onConfirm={onConfirm}
<FormattedMessage title={title}
defaultMessage="Are you sure you want to unassign {attributeName} from {itemTypeName}?" confirmButtonLabel={intl.formatMessage(messages.confirmBtn)}
values={{ >
attributeName: <strong>{attributeName}</strong>, <DialogContentText>
itemTypeName: <strong>{itemTypeName}</strong> <FormattedMessage
}} {...messages.content}
/> values={{
</DialogContentText> attributeName: <strong>{attributeName}</strong>,
</ActionDialog> itemTypeName: <strong>{itemTypeName}</strong>
); }}
/>
</DialogContentText>
</ActionDialog>
);
};
AttributeUnassignDialog.displayName = "AttributeUnassignDialog"; AttributeUnassignDialog.displayName = "AttributeUnassignDialog";
export default AttributeUnassignDialog; export default AttributeUnassignDialog;

View file

@ -0,0 +1,15 @@
import { defineMessages } from "react-intl";
const messages = defineMessages({
confirmBtn: {
defaultMessage: "Unassign and save",
description: "button, unassign attribute from object"
},
content: {
defaultMessage:
"Are you sure you want to unassign {attributeName} from {itemTypeName}?",
description: "unassign attribute from object"
}
});
export default messages;

View file

@ -2,7 +2,9 @@ import { DialogContentText } from "@material-ui/core";
import ActionDialog from "@saleor/components/ActionDialog"; import ActionDialog from "@saleor/components/ActionDialog";
import { ConfirmButtonTransitionState } from "@saleor/macaw-ui"; import { ConfirmButtonTransitionState } from "@saleor/macaw-ui";
import React from "react"; import React from "react";
import { FormattedMessage } from "react-intl"; import { FormattedMessage, useIntl } from "react-intl";
import messages from "./messages";
export interface BulkAttributeUnassignDialogProps { export interface BulkAttributeUnassignDialogProps {
title: string; title: string;
@ -22,26 +24,30 @@ const BulkAttributeUnassignDialog: React.FC<BulkAttributeUnassignDialogProps> =
itemTypeName, itemTypeName,
onClose, onClose,
onConfirm onConfirm
}) => ( }) => {
<ActionDialog const intl = useIntl();
confirmButtonState={confirmButtonState}
open={open} return (
onClose={onClose} <ActionDialog
onConfirm={onConfirm} confirmButtonState={confirmButtonState}
title={title} open={open}
> onClose={onClose}
<DialogContentText> onConfirm={onConfirm}
<FormattedMessage title={title}
defaultMessage="{counter,plural,one{Are you sure you want to unassign this attribute from {itemTypeName}?} other{Are you sure you want to unassign {attributeQuantity} attributes from {itemTypeName}?}}" confirmButtonLabel={intl.formatMessage(messages.confirmBtn)}
description="unassign multiple attributes from item" >
values={{ <DialogContentText>
attributeQuantity: <strong>{attributeQuantity}</strong>, <FormattedMessage
counter: attributeQuantity, {...messages.content}
itemTypeName: <strong>{itemTypeName}</strong> values={{
}} attributeQuantity: <strong>{attributeQuantity}</strong>,
/> counter: attributeQuantity,
</DialogContentText> itemTypeName: <strong>{itemTypeName}</strong>
</ActionDialog> }}
); />
</DialogContentText>
</ActionDialog>
);
};
BulkAttributeUnassignDialog.displayName = "BulkAttributeUnassignDialog"; BulkAttributeUnassignDialog.displayName = "BulkAttributeUnassignDialog";
export default BulkAttributeUnassignDialog; export default BulkAttributeUnassignDialog;

View file

@ -0,0 +1,15 @@
import { defineMessages } from "react-intl";
const messages = defineMessages({
confirmBtn: {
defaultMessage: "Unassign and save",
description: "button, unassign attribute from object"
},
content: {
defaultMessage:
"{counter,plural,one{Are you sure you want to unassign this attribute from {itemTypeName}?} other{Are you sure you want to unassign {attributeQuantity} attributes from {itemTypeName}?}}",
description: "unassign multiple attributes from item"
}
});
export default messages;

View file

@ -347,7 +347,7 @@ const VoucherDetailsPage: React.FC<VoucherDetailsPageProps> = ({
onProductUnassign={onProductUnassign} onProductUnassign={onProductUnassign}
onRowClick={onProductClick} onRowClick={onProductClick}
pageInfo={pageInfo} pageInfo={pageInfo}
products={mapEdgesToItems(voucher.products)} products={mapEdgesToItems(voucher?.products)}
isChecked={isChecked} isChecked={isChecked}
selected={selected} selected={selected}
toggle={toggle} toggle={toggle}

View file

@ -151,13 +151,16 @@ export const SaleDetails: React.FC<SaleDetailsProps> = ({ id, params }) => {
const [selectedChannel] = useLocalStorage("salesListChannel", ""); const [selectedChannel] = useLocalStorage("salesListChannel", "");
const notifySaved = () =>
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
const [saleUpdate, saleUpdateOpts] = useSaleUpdateMutation({ const [saleUpdate, saleUpdateOpts] = useSaleUpdateMutation({
onCompleted: data => { onCompleted: data => {
if (data.saleUpdate.errors.length === 0) { if (data.saleUpdate.errors.length === 0) {
notify({ notifySaved();
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
} }
} }
}); });
@ -165,10 +168,7 @@ export const SaleDetails: React.FC<SaleDetailsProps> = ({ id, params }) => {
const [saleDelete, saleDeleteOpts] = useSaleDeleteMutation({ const [saleDelete, saleDeleteOpts] = useSaleDeleteMutation({
onCompleted: data => { onCompleted: data => {
if (data.saleDelete.errors.length === 0) { if (data.saleDelete.errors.length === 0) {
notify({ notifySaved();
status: "success",
text: intl.formatMessage(messages.saleDetailsSaleDeleteDialog)
});
navigate(saleListUrl(), { replace: true }); navigate(saleListUrl(), { replace: true });
} }
} }
@ -180,6 +180,7 @@ export const SaleDetails: React.FC<SaleDetailsProps> = ({ id, params }) => {
] = useSaleCataloguesAddMutation({ ] = useSaleCataloguesAddMutation({
onCompleted: data => { onCompleted: data => {
if (data.saleCataloguesAdd.errors.length === 0) { if (data.saleCataloguesAdd.errors.length === 0) {
notifySaved();
closeModal(); closeModal();
} }
} }
@ -191,6 +192,7 @@ export const SaleDetails: React.FC<SaleDetailsProps> = ({ id, params }) => {
] = useSaleCataloguesRemoveMutation({ ] = useSaleCataloguesRemoveMutation({
onCompleted: data => { onCompleted: data => {
if (data.saleCataloguesRemove.errors.length === 0) { if (data.saleCataloguesRemove.errors.length === 0) {
notifySaved();
closeModal(); closeModal();
reset(); reset();
} }
@ -308,17 +310,29 @@ export const SaleDetails: React.FC<SaleDetailsProps> = ({ id, params }) => {
onCategoryClick={id => () => navigate(categoryUrl(id))} onCategoryClick={id => () => navigate(categoryUrl(id))}
onCollectionAssign={() => openModal("assign-collection")} onCollectionAssign={() => openModal("assign-collection")}
onCollectionUnassign={collectionId => onCollectionUnassign={collectionId =>
handleCollectionsUnassign([collectionId]) openModal("unassign-collection", {
ids: [collectionId]
})
} }
onCategoryUnassign={categoryId => onCategoryUnassign={categoryId =>
handleCategoriesUnassign([categoryId]) openModal("unassign-category", {
ids: [categoryId]
})
} }
onCollectionClick={id => () => navigate(collectionUrl(id))} onCollectionClick={id => () => navigate(collectionUrl(id))}
onProductAssign={() => openModal("assign-product")} onProductAssign={() => openModal("assign-product")}
onProductUnassign={productId => handleProductsUnassign([productId])} onProductUnassign={productId =>
openModal("unassign-product", {
ids: [productId]
})
}
onProductClick={id => () => navigate(productUrl(id))} onProductClick={id => () => navigate(productUrl(id))}
onVariantAssign={() => openModal("assign-variant")} onVariantAssign={() => openModal("assign-variant")}
onVariantUnassign={variantId => handleVariantsUnassign([variantId])} onVariantUnassign={variantId =>
openModal("unassign-variant", {
ids: [variantId]
})
}
onVariantClick={(productId, variantId) => () => onVariantClick={(productId, variantId) => () =>
navigate(productVariantEditPath(productId, variantId))} navigate(productVariantEditPath(productId, variantId))}
activeTab={activeTab} activeTab={activeTab}
@ -476,6 +490,9 @@ export const SaleDetails: React.FC<SaleDetailsProps> = ({ id, params }) => {
confirmButtonState={saleCataloguesRemoveOpts.status} confirmButtonState={saleCataloguesRemoveOpts.status}
onClose={closeModal} onClose={closeModal}
onConfirm={() => handleCategoriesUnassign(params.ids)} onConfirm={() => handleCategoriesUnassign(params.ids)}
confirmButtonLabel={intl.formatMessage(
messages.saleDetailsUnassignCategory
)}
> >
{canOpenBulkActionDialog && ( {canOpenBulkActionDialog && (
<DialogContentText> <DialogContentText>
@ -499,6 +516,9 @@ export const SaleDetails: React.FC<SaleDetailsProps> = ({ id, params }) => {
confirmButtonState={saleCataloguesRemoveOpts.status} confirmButtonState={saleCataloguesRemoveOpts.status}
onClose={closeModal} onClose={closeModal}
onConfirm={() => handleCollectionsUnassign(params.ids)} onConfirm={() => handleCollectionsUnassign(params.ids)}
confirmButtonLabel={intl.formatMessage(
messages.saleDetailsUnassignCollection
)}
> >
{canOpenBulkActionDialog && ( {canOpenBulkActionDialog && (
<DialogContentText> <DialogContentText>
@ -520,6 +540,9 @@ export const SaleDetails: React.FC<SaleDetailsProps> = ({ id, params }) => {
confirmButtonState={saleCataloguesRemoveOpts.status} confirmButtonState={saleCataloguesRemoveOpts.status}
onClose={closeModal} onClose={closeModal}
onConfirm={() => handleProductsUnassign(params.ids)} onConfirm={() => handleProductsUnassign(params.ids)}
confirmButtonLabel={intl.formatMessage(
messages.saleDetailsUnassignProduct
)}
> >
{canOpenBulkActionDialog && ( {canOpenBulkActionDialog && (
<DialogContentText> <DialogContentText>
@ -541,6 +564,9 @@ export const SaleDetails: React.FC<SaleDetailsProps> = ({ id, params }) => {
confirmButtonState={saleCataloguesRemoveOpts.status} confirmButtonState={saleCataloguesRemoveOpts.status}
onClose={closeModal} onClose={closeModal}
onConfirm={() => handleVariantsUnassign(params.ids)} onConfirm={() => handleVariantsUnassign(params.ids)}
confirmButtonLabel={intl.formatMessage(
messages.saleDetailsUnassignVariant
)}
> >
{canOpenBulkActionDialog && ( {canOpenBulkActionDialog && (
<DialogContentText> <DialogContentText>

View file

@ -2,20 +2,20 @@ import { defineMessages } from "react-intl";
export const messages = defineMessages({ export const messages = defineMessages({
saleDetailsUnassignCategory: { saleDetailsUnassignCategory: {
defaultMessage: "Unassign", defaultMessage: "Unassign and save",
description: "unassign category from sale, button" description: "unassign category from sale and save, button"
}, },
saleDetailsUnassignCollection: { saleDetailsUnassignCollection: {
defaultMessage: "Unassign", defaultMessage: "Unassign and save",
description: "unassign collection from sale, button" description: "unassign collection from sale and save, button"
}, },
saleDetailsUnassignProduct: { saleDetailsUnassignProduct: {
defaultMessage: "Unassign", defaultMessage: "Unassign and save",
description: "unassign product from sale, button" description: "unassign product from sale and save, button"
}, },
saleDetailsUnassignVariant: { saleDetailsUnassignVariant: {
defaultMessage: "Unassign", defaultMessage: "Unassign and save",
description: "unassign variant from sale, button" description: "unassign variant from sale and save, button"
}, },
saleDetailsUnassignCategoryDialog: { saleDetailsUnassignCategoryDialog: {
defaultMessage: defaultMessage:

View file

@ -162,14 +162,17 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
updateChannelsOpts updateChannelsOpts
] = useVoucherChannelListingUpdateMutation({}); ] = useVoucherChannelListingUpdateMutation({});
const notifySaved = () =>
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
const [voucherUpdate, voucherUpdateOpts] = useVoucherUpdateMutation({ const [voucherUpdate, voucherUpdateOpts] = useVoucherUpdateMutation({
onCompleted: data => { onCompleted: data => {
if (data.voucherUpdate.errors.length === 0) { if (data.voucherUpdate.errors.length === 0) {
closeModal(); closeModal();
notify({ notifySaved();
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
} }
} }
}); });
@ -177,12 +180,7 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
const [voucherDelete, voucherDeleteOpts] = useVoucherDeleteMutation({ const [voucherDelete, voucherDeleteOpts] = useVoucherDeleteMutation({
onCompleted: data => { onCompleted: data => {
if (data.voucherDelete.errors.length === 0) { if (data.voucherDelete.errors.length === 0) {
notify({ notifySaved();
status: "success",
text: intl.formatMessage({
defaultMessage: "Deleted voucher"
})
});
navigate(voucherListUrl(), { replace: true }); navigate(voucherListUrl(), { replace: true });
} }
} }
@ -194,6 +192,7 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
] = useVoucherCataloguesRemoveMutation({ ] = useVoucherCataloguesRemoveMutation({
onCompleted: data => { onCompleted: data => {
if (data.voucherCataloguesRemove.errors.length === 0) { if (data.voucherCataloguesRemove.errors.length === 0) {
notifySaved();
closeModal(); closeModal();
reset(); reset();
} }
@ -206,6 +205,7 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
] = useVoucherCataloguesAddMutation({ ] = useVoucherCataloguesAddMutation({
onCompleted: data => { onCompleted: data => {
if (data.voucherCataloguesAdd.errors.length === 0) { if (data.voucherCataloguesAdd.errors.length === 0) {
notifySaved();
closeModal(); closeModal();
} }
} }
@ -323,14 +323,8 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
onCategoryClick={id => () => navigate(categoryUrl(id))} onCategoryClick={id => () => navigate(categoryUrl(id))}
onCollectionAssign={() => openModal("assign-collection")} onCollectionAssign={() => openModal("assign-collection")}
onCollectionUnassign={collectionId => onCollectionUnassign={collectionId =>
voucherCataloguesRemove({ openModal("unassign-collection", {
variables: { ids: [collectionId]
...paginationState,
id,
input: {
collections: [collectionId]
}
}
}) })
} }
onCountryAssign={() => openModal("assign-country")} onCountryAssign={() => openModal("assign-country")}
@ -348,27 +342,15 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
}) })
} }
onCategoryUnassign={categoryId => onCategoryUnassign={categoryId =>
voucherCataloguesRemove({ openModal("unassign-category", {
variables: { ids: [categoryId]
...paginationState,
id,
input: {
categories: [categoryId]
}
}
}) })
} }
onCollectionClick={id => () => navigate(collectionUrl(id))} onCollectionClick={id => () => navigate(collectionUrl(id))}
onProductAssign={() => openModal("assign-product")} onProductAssign={() => openModal("assign-product")}
onProductUnassign={productId => onProductUnassign={productId =>
voucherCataloguesRemove({ openModal("unassign-product", {
variables: { ids: [productId]
...paginationState,
id,
input: {
products: [productId]
}
}
}) })
} }
onProductClick={id => () => navigate(productUrl(id))} onProductClick={id => () => navigate(productUrl(id))}
@ -390,7 +372,7 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
> >
<FormattedMessage <FormattedMessage
defaultMessage="Unassign" defaultMessage="Unassign"
description="unassign category from voucher, button" description="button"
id="voucherDetailsUnassignCategory" id="voucherDetailsUnassignCategory"
/> />
</Button> </Button>
@ -405,7 +387,7 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
> >
<FormattedMessage <FormattedMessage
defaultMessage="Unassign" defaultMessage="Unassign"
description="unassign collection from voucher, button" description="button"
id="voucherDetailsUnassignCollection" id="voucherDetailsUnassignCollection"
/> />
</Button> </Button>
@ -420,7 +402,7 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
> >
<FormattedMessage <FormattedMessage
defaultMessage="Unassign" defaultMessage="Unassign"
description="unassign product from voucher, button" description="button"
id="voucherDetailsUnassignProduct" id="voucherDetailsUnassignProduct"
/> />
</Button> </Button>
@ -528,6 +510,10 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
confirmButtonState={voucherCataloguesRemoveOpts.status} confirmButtonState={voucherCataloguesRemoveOpts.status}
onClose={closeModal} onClose={closeModal}
onConfirm={() => handleCategoriesUnassign(params.ids)} onConfirm={() => handleCategoriesUnassign(params.ids)}
confirmButtonLabel={intl.formatMessage({
defaultMessage: "Unassign and save",
description: "button"
})}
> >
{canOpenBulkActionDialog && ( {canOpenBulkActionDialog && (
<DialogContentText> <DialogContentText>
@ -553,6 +539,10 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
confirmButtonState={voucherCataloguesRemoveOpts.status} confirmButtonState={voucherCataloguesRemoveOpts.status}
onClose={closeModal} onClose={closeModal}
onConfirm={() => handleCollectionsUnassign(params.ids)} onConfirm={() => handleCollectionsUnassign(params.ids)}
confirmButtonLabel={intl.formatMessage({
defaultMessage: "Unassign and save",
description: "button"
})}
> >
{canOpenBulkActionDialog && ( {canOpenBulkActionDialog && (
<DialogContentText> <DialogContentText>
@ -576,6 +566,10 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
confirmButtonState={voucherCataloguesRemoveOpts.status} confirmButtonState={voucherCataloguesRemoveOpts.status}
onClose={closeModal} onClose={closeModal}
onConfirm={() => handleProductsUnassign(params.ids)} onConfirm={() => handleProductsUnassign(params.ids)}
confirmButtonLabel={intl.formatMessage({
defaultMessage: "Unassign and save",
description: "button"
})}
> >
{canOpenBulkActionDialog && ( {canOpenBulkActionDialog && (
<DialogContentText> <DialogContentText>

View file

@ -5,10 +5,8 @@ import { FormattedMessage } from "react-intl";
const useStyles = makeStyles( const useStyles = makeStyles(
theme => ({ theme => ({
button: { button: {
letterSpacing: 2,
marginBottom: theme.spacing(1), marginBottom: theme.spacing(1),
marginTop: theme.spacing(3), marginTop: theme.spacing(3)
padding: 0
} }
}), }),
{ name: "MaximalButton" } { name: "MaximalButton" }

View file

@ -37,7 +37,7 @@ import {
orderFulfillUrl, orderFulfillUrl,
orderListUrl, orderListUrl,
orderRefundUrl, orderRefundUrl,
orderReturnPath, orderReturnUrl,
orderUrl, orderUrl,
OrderUrlQueryParams OrderUrlQueryParams
} from "../../../urls"; } from "../../../urls";
@ -139,7 +139,7 @@ export const OrderNormalDetails: React.FC<OrderNormalDetailsProps> = ({
)} )}
/> />
<OrderDetailsPage <OrderDetailsPage
onOrderReturn={() => navigate(orderReturnPath(id))} onOrderReturn={() => navigate(orderReturnUrl(id))}
disabled={ disabled={
updateMetadataOpts.loading || updatePrivateMetadataOpts.loading updateMetadataOpts.loading || updatePrivateMetadataOpts.loading
} }

View file

@ -43,7 +43,7 @@ import {
orderFulfillUrl, orderFulfillUrl,
orderListUrl, orderListUrl,
orderRefundUrl, orderRefundUrl,
orderReturnPath, orderReturnUrl,
orderUrl, orderUrl,
OrderUrlQueryParams OrderUrlQueryParams
} from "../../../urls"; } from "../../../urls";
@ -163,7 +163,7 @@ export const OrderUnconfirmedDetails: React.FC<OrderUnconfirmedDetailsProps> = (
<OrderDiscountProvider order={order}> <OrderDiscountProvider order={order}>
<OrderLineDiscountProvider order={order}> <OrderLineDiscountProvider order={order}>
<OrderDetailsPage <OrderDetailsPage
onOrderReturn={() => navigate(orderReturnPath(id))} onOrderReturn={() => navigate(orderReturnUrl(id))}
disabled={ disabled={
updateMetadataOpts.loading || updatePrivateMetadataOpts.loading updateMetadataOpts.loading || updatePrivateMetadataOpts.loading
} }

View file

@ -50,16 +50,19 @@ export const PageTypeDetails: React.FC<PageTypeDetailsProps> = ({
const attributeListActions = useBulkActions(); const attributeListActions = useBulkActions();
const intl = useIntl(); const intl = useIntl();
const notifySaved = () =>
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
const [updatePageType, updatePageTypeOpts] = usePageTypeUpdateMutation({ const [updatePageType, updatePageTypeOpts] = usePageTypeUpdateMutation({
onCompleted: updateData => { onCompleted: updateData => {
if ( if (
!updateData.pageTypeUpdate.errors || !updateData.pageTypeUpdate.errors ||
updateData.pageTypeUpdate.errors.length === 0 updateData.pageTypeUpdate.errors.length === 0
) { ) {
notify({ notifySaved();
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
} }
} }
}); });
@ -80,10 +83,7 @@ export const PageTypeDetails: React.FC<PageTypeDetailsProps> = ({
{ {
onCompleted: data => { onCompleted: data => {
if (data.pageAttributeAssign.errors.length === 0) { if (data.pageAttributeAssign.errors.length === 0) {
notify({ notifySaved();
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
closeModal(); closeModal();
} }
} }
@ -104,7 +104,13 @@ export const PageTypeDetails: React.FC<PageTypeDetailsProps> = ({
} }
} }
}); });
const [reorderAttribute] = usePageTypeAttributeReorderMutation({}); const [reorderAttribute] = usePageTypeAttributeReorderMutation({
onCompleted: data => {
if (data.pageTypeReorderAttributes.errors.length === 0) {
notifySaved();
}
}
});
const pageTypeDeleteData = usePageTypeDelete({ const pageTypeDeleteData = usePageTypeDelete({
singleId: id, singleId: id,

View file

@ -9,6 +9,7 @@ import { DEFAULT_INITIAL_SEARCH_DATA } from "@saleor/config";
import { import {
AssignProductAttributeMutation, AssignProductAttributeMutation,
ProductAttributeType, ProductAttributeType,
ProductTypeAttributeReorderMutation,
ProductTypeDeleteMutation, ProductTypeDeleteMutation,
UnassignProductAttributeMutation, UnassignProductAttributeMutation,
useProductAttributeAssignmentUpdateMutation, useProductAttributeAssignmentUpdateMutation,
@ -219,6 +220,17 @@ export const ProductTypeUpdate: React.FC<ProductTypeUpdateProps> = ({
} }
}; };
const handleAttributeReorderSuccess = (
data: ProductTypeAttributeReorderMutation
) => {
if (data.productTypeReorderAttributes.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
}
};
const { const {
assignAttribute, assignAttribute,
deleteProductType, deleteProductType,
@ -226,7 +238,7 @@ export const ProductTypeUpdate: React.FC<ProductTypeUpdateProps> = ({
reorderAttribute reorderAttribute
} = useProductTypeOperations({ } = useProductTypeOperations({
onAssignAttribute: handleAttributeAssignSuccess, onAssignAttribute: handleAttributeAssignSuccess,
onProductTypeAttributeReorder: () => undefined, onProductTypeAttributeReorder: handleAttributeReorderSuccess,
onProductTypeDelete: handleProductTypeDeleteSuccess, onProductTypeDelete: handleProductTypeDeleteSuccess,
onUnassignAttribute: handleAttributeUnassignSuccess, onUnassignAttribute: handleAttributeUnassignSuccess,
productType: data?.productType productType: data?.productType

View file

@ -21,7 +21,6 @@ import {
ShippingPriceExcludeProductMutation ShippingPriceExcludeProductMutation
} from "@saleor/graphql"; } from "@saleor/graphql";
import useSearchQuery from "@saleor/hooks/useSearchQuery"; import useSearchQuery from "@saleor/hooks/useSearchQuery";
import { buttonMessages } from "@saleor/intl";
import { ConfirmButtonTransitionState, makeStyles } from "@saleor/macaw-ui"; import { ConfirmButtonTransitionState, makeStyles } from "@saleor/macaw-ui";
import { renderCollection } from "@saleor/misc"; import { renderCollection } from "@saleor/misc";
import { FetchMoreProps, RelayToFlat } from "@saleor/types"; import { FetchMoreProps, RelayToFlat } from "@saleor/types";
@ -234,7 +233,10 @@ const ShippingMethodProductsAddDialog: React.FC<ShippingMethodProductsAddDialogP
disabled={loading || !selectedProducts?.length} disabled={loading || !selectedProducts?.length}
onClick={handleSubmit} onClick={handleSubmit}
> >
<FormattedMessage {...buttonMessages.confirm} /> <FormattedMessage
defaultMessage="Assign and save"
description="assign products to shipping rate and save, button"
/>
</ConfirmButton> </ConfirmButton>
</DialogActions> </DialogActions>
</Dialog> </Dialog>

View file

@ -36,7 +36,7 @@ export const messages = defineMessages({
description: "checkbox description" description: "checkbox description"
}, },
assignCountriesButton: { assignCountriesButton: {
defaultMessage: "Assign countries", defaultMessage: "Assign and save",
description: "button" description: "assign countries to shipping zone and save, button"
} }
}); });

View file

@ -30,6 +30,10 @@ export const UnassignDialog: React.FC<UnassignDialogProps> = ({
confirmButtonState={confirmButtonState} confirmButtonState={confirmButtonState}
onClose={closeModal} onClose={closeModal}
onConfirm={onConfirm} onConfirm={onConfirm}
confirmButtonLabel={intl.formatMessage({
defaultMessage: "Unassign and save",
description: "unassign products from shipping rate and save, button"
})}
> >
<DialogContentText> <DialogContentText>
<FormattedMessage <FormattedMessage

View file

@ -330,14 +330,18 @@ const ShippingZoneDetails: React.FC<ShippingZoneDetailsProps> = ({
} }
open={params.action === "unassign-country"} open={params.action === "unassign-country"}
title={intl.formatMessage({ title={intl.formatMessage({
defaultMessage: "Delete from Shipping Zone", defaultMessage: "Remove from Shipping Zone",
description: "unassign country, dialog header" description: "unassign country, dialog header"
})} })}
variant="delete" variant="delete"
confirmButtonLabel={intl.formatMessage({
defaultMessage: "Remove and save",
description: "remove country from shipping zone and save, button"
})}
> >
<DialogContentText> <DialogContentText>
<FormattedMessage <FormattedMessage
defaultMessage="Are you sure you want to delete {countryName} from this shipping zone?" defaultMessage="Are you sure you want to remove {countryName} from this shipping zone?"
description="unassign country" description="unassign country"
values={{ values={{
countryName: ( countryName: (