Merge pull request #192 from mirumee/fix/minor-bugs

Fix minor bugs
This commit is contained in:
Dominik Żegleń 2019-10-02 11:13:40 +02:00 committed by GitHub
commit dda3b0dc7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 17 deletions

View file

@ -1,9 +1,9 @@
import Button from "@material-ui/core/Button"; import Button from "@material-ui/core/Button";
import Card from "@material-ui/core/Card"; import Card from "@material-ui/core/Card";
import React from "react"; import React from "react";
import { FormattedMessage, useIntl } from "react-intl"; import { FormattedMessage, useIntl } from "react-intl";
import AppHeader from "@saleor/components/AppHeader";
import SearchBar from "@saleor/components/SearchBar"; import SearchBar from "@saleor/components/SearchBar";
import { sectionNames } from "@saleor/intl"; import { sectionNames } from "@saleor/intl";
import Container from "../../../components/Container"; import Container from "../../../components/Container";
@ -23,10 +23,12 @@ export interface AttributeListPageProps
SearchPageProps, SearchPageProps,
TabPageProps { TabPageProps {
attributes: AttributeList_attributes_edges_node[]; attributes: AttributeList_attributes_edges_node[];
onBack: () => void;
} }
const AttributeListPage: React.FC<AttributeListPageProps> = ({ const AttributeListPage: React.FC<AttributeListPageProps> = ({
onAdd, onAdd,
onBack,
initialSearch, initialSearch,
onSearchChange, onSearchChange,
currentTab, currentTab,
@ -41,6 +43,9 @@ const AttributeListPage: React.FC<AttributeListPageProps> = ({
return ( return (
<Container> <Container>
<AppHeader onBack={onBack}>
<FormattedMessage {...sectionNames.configuration} />
</AppHeader>
<PageHeader title={intl.formatMessage(sectionNames.attributes)}> <PageHeader title={intl.formatMessage(sectionNames.attributes)}>
<Button onClick={onAdd} color="primary" variant="contained"> <Button onClick={onAdd} color="primary" variant="contained">
<FormattedMessage <FormattedMessage

View file

@ -15,6 +15,7 @@ import DeleteFilterTabDialog from "@saleor/components/DeleteFilterTabDialog";
import SaveFilterTabDialog, { import SaveFilterTabDialog, {
SaveFilterTabDialogFormData SaveFilterTabDialogFormData
} from "@saleor/components/SaveFilterTabDialog"; } from "@saleor/components/SaveFilterTabDialog";
import { configurationMenuUrl } from "@saleor/configuration";
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 usePaginator, { import usePaginator, {
@ -165,6 +166,7 @@ const AttributeList: React.FC<AttributeListProps> = ({ params }) => {
isChecked={isSelected} isChecked={isSelected}
onAdd={() => navigate(attributeAddUrl())} onAdd={() => navigate(attributeAddUrl())}
onAll={() => navigate(attributeListUrl())} onAll={() => navigate(attributeListUrl())}
onBack={() => navigate(configurationMenuUrl)}
onNextPage={loadNextPage} onNextPage={loadNextPage}
onPreviousPage={loadPreviousPage} onPreviousPage={loadPreviousPage}
onRowClick={id => () => navigate(attributeUrl(id))} onRowClick={id => () => navigate(attributeUrl(id))}

View file

@ -222,18 +222,20 @@ export const CategoryList: React.StatelessComponent<CategoryListProps> = ({
})} })}
variant="delete" variant="delete"
> >
<FormattedMessage <DialogContentText>
defaultMessage="Are you sure you want to delete {counter, plural, <FormattedMessage
defaultMessage="Are you sure you want to delete {counter, plural,
one {this category} one {this category}
other {{displayQuantity} categories} other {{displayQuantity} categories}
}?" }?"
values={{ values={{
counter: maybe(() => params.ids.length), counter: maybe(() => params.ids.length),
displayQuantity: ( displayQuantity: (
<strong>{maybe(() => params.ids.length)}</strong> <strong>{maybe(() => params.ids.length)}</strong>
) )
}} }}
/> />
</DialogContentText>
<DialogContentText> <DialogContentText>
<FormattedMessage defaultMessage="Remember this will also delete all products assigned to this category." /> <FormattedMessage defaultMessage="Remember this will also delete all products assigned to this category." />
</DialogContentText> </DialogContentText>

View file

@ -18,6 +18,7 @@ import { SearchCategories_categories_edges_node } from "@saleor/containers/Searc
import { SearchCollections_collections_edges_node } from "@saleor/containers/SearchCollections/types/SearchCollections"; import { SearchCollections_collections_edges_node } from "@saleor/containers/SearchCollections/types/SearchCollections";
import { SearchPages_pages_edges_node } from "@saleor/containers/SearchPages/types/SearchPages"; import { SearchPages_pages_edges_node } from "@saleor/containers/SearchPages/types/SearchPages";
import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors";
import useModalDialogOpen from "@saleor/hooks/useModalDialogOpen";
import useStateFromProps from "@saleor/hooks/useStateFromProps"; import useStateFromProps from "@saleor/hooks/useStateFromProps";
import { buttonMessages, sectionNames } from "@saleor/intl"; import { buttonMessages, sectionNames } from "@saleor/intl";
import { UserError } from "@saleor/types"; import { UserError } from "@saleor/types";
@ -97,17 +98,20 @@ const MenuItemDialog: React.StatelessComponent<MenuItemDialogProps> = ({
); );
const [url, setUrl] = React.useState<string>(undefined); const [url, setUrl] = React.useState<string>(undefined);
// Reset input state after closing dialog
useModalDialogOpen(open, {
onClose: () => {
setData(initial || defaultInitial);
setDisplayValue(initialDisplayValue);
setUrl(undefined);
}
});
// Refresh initial display value if changed // Refresh initial display value if changed
React.useEffect(() => setDisplayValue(initialDisplayValue), [ React.useEffect(() => setDisplayValue(initialDisplayValue), [
initialDisplayValue initialDisplayValue
]); ]);
// Reset input state after closing dialog
React.useEffect(() => {
setDisplayValue(initialDisplayValue);
setUrl(undefined);
}, [open]);
const mutationErrors = getErrors(errors); const mutationErrors = getErrors(errors);
let options: IMenu = []; let options: IMenu = [];

View file

@ -18,7 +18,8 @@ const props: AttributeListPageProps = {
...listActionsProps, ...listActionsProps,
...tabPageProps, ...tabPageProps,
...searchPageProps, ...searchPageProps,
attributes attributes,
onBack: () => undefined
}; };
storiesOf("Views / Attributes / Attribute list", module) storiesOf("Views / Attributes / Attribute list", module)