Skip to content

Commit

Permalink
Merge branch 'main' into merx-791-migrate-dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
poulch committed Aug 12, 2024
2 parents c45a9a2 + d6fd63b commit efedfe3
Show file tree
Hide file tree
Showing 51 changed files with 494 additions and 194 deletions.
5 changes: 0 additions & 5 deletions .changeset/brown-carrots-search.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/dull-pens-matter.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/five-oranges-crash.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/fresh-bikes-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

You can now see a message instead of a loading animation when there are no categories, collections, products or variants assigned in Discounts
5 changes: 0 additions & 5 deletions .changeset/good-plums-push.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/honest-donuts-tap.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/khaki-spies-protect.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/large-carrots-jog.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/nice-humans-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Gift card details page and customer details page no longer crash when you have only some required permissions. This means that you can now view gift card details page if you have only gift card permissions and customer details page if you have only customer permissions.
5 changes: 0 additions & 5 deletions .changeset/nine-steaks-build.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/ninety-dogs-mate.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/shaggy-spoons-explode.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/silver-spies-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

You can click save button on voucher creation page to trigger validation
5 changes: 0 additions & 5 deletions .changeset/thin-elephants-join.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/violet-teachers-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

You can now update quantity per checkout in site settings
5 changes: 0 additions & 5 deletions .changeset/wet-ties-perform.md

This file was deleted.

4 changes: 4 additions & 0 deletions locale/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2605,6 +2605,10 @@
"FTYkgw": {
"string": "Delete collections"
},
"FWaL+x": {
"context": "gift card history message",
"string": "Gift card balance was reset"
},
"FWbv/u": {
"context": "page header",
"string": "Create Discount"
Expand Down
13 changes: 10 additions & 3 deletions playwright/pages/siteSettingsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ export class SiteSettingsPage extends BasePage {
readonly addressLine2Input = page.getByTestId("company-address-line-2-input").locator("input"),
readonly city = page.getByTestId("company-city-input").locator("input"),
readonly countryInput = page.getByTestId("address-edit-country-select-field"),
readonly autocompleteDropdown = page.getByTestId("autocomplete-dropdown"),
readonly autocompleteDropdownCountry = page.locator(
'[data-portal-for="autocomplete-dropdown-country"]',
),
readonly autocompleteDropdownCountryArea = page.locator(
'[data-portal-for="autocomplete-dropdown-country-area"]',
),
readonly countryAreaDropdown = page.getByTestId("address-edit-country-area-field"),
readonly zipInput = page.getByTestId("company-zip-input").locator("input"),
readonly phoneInput = page.getByTestId("company-phone-input").locator("input"),
Expand Down Expand Up @@ -58,9 +63,11 @@ export class SiteSettingsPage extends BasePage {
await this.addressLine2Input.fill(addressLine2);
await this.city.fill(city);
await this.countryInput.click();
await this.autocompleteDropdown.getByText(country, { exact: true }).click();
await this.autocompleteDropdownCountry.getByText(country, { exact: true }).click();
await this.autocompleteDropdownCountry.blur();
await this.countryAreaDropdown.fill(countryArea);
await this.autocompleteDropdown.getByText(countryArea, { exact: true }).click();
await this.autocompleteDropdownCountryArea.getByText(countryArea, { exact: true }).click();
await this.autocompleteDropdownCountryArea.blur();
await this.zipInput.fill(zip);
await this.phoneInput.fill(phone);
}
Expand Down
2 changes: 1 addition & 1 deletion playwright/tests/siteSettings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let siteSettingsPage: SiteSettingsPage;
test.beforeEach(({ page }) => {
siteSettingsPage = new SiteSettingsPage(page);
});
test("TC: SALEOR_132 Should be able to update site settings", async () => {
test("TC: SALEOR_132 Should be able to update site settings @e2e", async () => {
const companyName = faker.company.companyName();

await siteSettingsPage.gotoSiteSettings();
Expand Down
2 changes: 2 additions & 0 deletions src/components/CompanyAddressInput/CompanyAddressForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ const CompanyAddressForm: React.FC<CompanyAddressFormProps> = props => {
<FormSpacer />
<Grid>
<Combobox
id="autocomplete-dropdown-country"
data-test-id="address-edit-country-select-field"
autoComplete="off"
spellCheck={false}
Expand All @@ -192,6 +193,7 @@ const CompanyAddressForm: React.FC<CompanyAddressFormProps> = props => {

{isFieldAllowed("countryArea") && (
<Combobox
id="autocomplete-dropdown-country-area"
data-test-id="address-edit-country-area-field"
autoComplete="off"
spellCheck={false}
Expand Down
10 changes: 7 additions & 3 deletions src/components/Timeline/TimelineNote.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GiftCardEventFragment, OrderEventFragment } from "@dashboard/graphql";
import { GiftCardEventsQuery, OrderEventFragment } from "@dashboard/graphql";
import { getUserInitials, getUserName } from "@dashboard/misc";
import { makeStyles } from "@saleor/macaw-ui";
import { Text } from "@saleor/macaw-ui-next";
Expand Down Expand Up @@ -31,11 +31,15 @@ const useStyles = makeStyles(
{ name: "TimelineNote" },
);

type TimelineAppType =
| NonNullable<GiftCardEventsQuery["giftCard"]>["events"][0]["app"]
| OrderEventFragment["app"];

interface TimelineNoteProps {
date: string;
message: string | null;
user: OrderEventFragment["user"];
app: OrderEventFragment["app"] | GiftCardEventFragment["app"];
app: TimelineAppType;
hasPlainDate?: boolean;
}

Expand All @@ -61,7 +65,7 @@ const TimelineAvatar = ({
className,
}: {
user: OrderEventFragment["user"];
app: OrderEventFragment["app"] | GiftCardEventFragment["app"];
app: TimelineAppType;
className: string;
}) => {
if (user) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ const CustomerDetailsPage: React.FC<CustomerDetailsPageProps> = ({
lastName: customer?.lastName || "",
metadata: customer?.metadata.map(mapMetadataItemToInput),
note: customer?.note || "",
privateMetadata: customer?.privateMetadata.map(mapMetadataItemToInput),
privateMetadata: customer?.privateMetadata
? customer?.privateMetadata.map(mapMetadataItemToInput)
: [],
};
const { makeChangeHandler: makeMetadataChangeHandler } = useMetadataChangeTrigger();
const { CUSTOMER_DETAILS_MORE_ACTIONS } = useExtensions(extensionMountPoints.CUSTOMER_DETAILS);
Expand Down
12 changes: 11 additions & 1 deletion src/customers/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,19 @@ export const customerList = gql`
`;

export const customerDetails = gql`
query CustomerDetails($id: ID!, $PERMISSION_MANAGE_ORDERS: Boolean!) {
query CustomerDetails(
$id: ID!
$PERMISSION_MANAGE_ORDERS: Boolean!
$PERMISSION_MANAGE_STAFF: Boolean!
) {
user(id: $id) {
...CustomerDetails
metadata {
...MetadataItem
}
privateMetadata @include(if: $PERMISSION_MANAGE_STAFF) {
...MetadataItem
}
orders(last: 5) @include(if: $PERMISSION_MANAGE_ORDERS) {
edges {
node {
Expand Down
5 changes: 4 additions & 1 deletion src/customers/views/CustomerDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ const CustomerDetailsViewInner: React.FC<CustomerDetailsViewProps> = ({ id, para
);

const handleSubmit = createMetadataUpdateHandler(
user,
{
...user,
privateMetadata: user?.privateMetadata || [],
},
updateData,
variables => updateMetadata({ variables }),
variables => updatePrivateMetadata({ variables }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import TableHead from "@dashboard/components/TableHead";
import { TablePaginationWithContext } from "@dashboard/components/TablePagination";
import TableRowLink from "@dashboard/components/TableRowLink";
import { SaleDetailsFragment, VoucherDetailsFragment } from "@dashboard/graphql";
import { mapEdgesToItems } from "@dashboard/utils/maps";
import { getLoadableList, mapEdgesToItems } from "@dashboard/utils/maps";
import { TableBody, TableCell, TableFooter } from "@material-ui/core";
import { DeleteIcon, IconButton } from "@saleor/macaw-ui";
import { Skeleton } from "@saleor/macaw-ui-next";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";

import { maybe, renderCollection } from "../../../misc";
import { renderCollection } from "../../../misc";
import { ListActions, ListProps } from "../../../types";
import { messages } from "./messages";
import { useStyles } from "./styles";
Expand Down Expand Up @@ -87,7 +87,7 @@ const DiscountCategories: React.FC<DiscountCategoriesProps> = props => {
</TableFooter>
<TableBody data-test-id="assigned-specific-products-table">
{renderCollection(
mapEdgesToItems(discount?.categories),
getLoadableList(discount?.categories),
category => {
const isSelected = category ? isChecked(category.id) : false;

Expand All @@ -108,10 +108,8 @@ const DiscountCategories: React.FC<DiscountCategoriesProps> = props => {
onChange={() => toggle(category.id)}
/>
</TableCell>
<TableCell>{maybe<React.ReactNode>(() => category.name, <Skeleton />)}</TableCell>
<TableCell className={classes.colProducts}>
{maybe<React.ReactNode>(() => category.products.totalCount, <Skeleton />)}
</TableCell>
<TableCell>{category ? category.name : <Skeleton />}</TableCell>
<TableCell>{category ? category.products.totalCount : <Skeleton />}</TableCell>
<TableCell className={classes.colActions}>
<TableButtonWrapper>
<IconButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import TableHead from "@dashboard/components/TableHead";
import { TablePaginationWithContext } from "@dashboard/components/TablePagination";
import TableRowLink from "@dashboard/components/TableRowLink";
import { SaleDetailsFragment, VoucherDetailsFragment } from "@dashboard/graphql";
import { mapEdgesToItems } from "@dashboard/utils/maps";
import { getLoadableList, mapEdgesToItems } from "@dashboard/utils/maps";
import { TableBody, TableCell, TableFooter } from "@material-ui/core";
import { DeleteIcon, IconButton } from "@saleor/macaw-ui";
import { Skeleton } from "@saleor/macaw-ui-next";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";

import { maybe, renderCollection } from "../../../misc";
import { renderCollection } from "../../../misc";
import { ListActions, ListProps } from "../../../types";
import { messages } from "./messages";
import { useStyles } from "./styles";
Expand Down Expand Up @@ -85,7 +85,7 @@ const DiscountCollections: React.FC<DiscountCollectionsProps> = props => {
</TableFooter>
<TableBody data-test-id="assigned-specific-products-table">
{renderCollection(
mapEdgesToItems(sale?.collections),
getLoadableList(sale?.collections),
collection => {
const isSelected = collection ? isChecked(collection.id) : false;

Expand All @@ -107,10 +107,10 @@ const DiscountCollections: React.FC<DiscountCollectionsProps> = props => {
/>
</TableCell>
<TableCell className={classes.colName}>
{maybe<React.ReactNode>(() => collection.name, <Skeleton />)}
{collection ? collection.name : <Skeleton />}
</TableCell>
<TableCell className={classes.colProducts}>
{maybe<React.ReactNode>(() => collection.products.totalCount, <Skeleton />)}
{collection ? collection.products.totalCount : <Skeleton />}
</TableCell>
<TableCell className={classes.colActions}>
<TableButtonWrapper>
Expand Down
17 changes: 9 additions & 8 deletions src/discounts/components/DiscountProducts/DiscountProducts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,28 @@ import { TablePaginationWithContext } from "@dashboard/components/TablePaginatio
import TableRowLink from "@dashboard/components/TableRowLink";
import { SaleDetailsFragment, VoucherDetailsFragment } from "@dashboard/graphql";
import { productUrl } from "@dashboard/products/urls";
import { getLoadableList, mapEdgesToItems } from "@dashboard/utils/maps";
import { TableBody, TableCell, TableFooter } from "@material-ui/core";
import { DeleteIcon, IconButton } from "@saleor/macaw-ui";
import { Skeleton } from "@saleor/macaw-ui-next";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";

import { maybe, renderCollection } from "../../../misc";
import { ListActions, ListProps, RelayToFlat } from "../../../types";
import { ListActions, ListProps } from "../../../types";
import { messages } from "./messages";
import { useStyles } from "./styles";

export interface SaleProductsProps extends ListProps, ListActions {
products:
| RelayToFlat<SaleDetailsFragment["products"]>
| RelayToFlat<VoucherDetailsFragment["products"]>;
discount: SaleDetailsFragment | VoucherDetailsFragment;
onProductAssign: () => void;
onProductUnassign: (id: string) => void;
}

const numberOfColumns = 5;
const DiscountProducts: React.FC<SaleProductsProps> = props => {
const {
products,
discount,
disabled,
onProductAssign,
onProductUnassign,
Expand All @@ -46,6 +45,8 @@ const DiscountProducts: React.FC<SaleProductsProps> = props => {
const classes = useStyles(props);
const intl = useIntl();

const productsList = mapEdgesToItems(discount?.products);

return (
<DashboardCard data-test-id="assign-product-section">
<DashboardCard.Header>
Expand All @@ -71,12 +72,12 @@ const DiscountProducts: React.FC<SaleProductsProps> = props => {
colSpan={numberOfColumns}
selected={selected}
disabled={disabled}
items={products}
items={productsList}
toggleAll={toggleAll}
toolbar={toolbar}
>
<TableCell className={classes.colName}>
<span className={products?.length > 0 && classes.colNameLabel}>
<span className={productsList?.length > 0 && classes.colNameLabel}>
<FormattedMessage {...messages.discountProductsTableProductHeader} />
</span>
</TableCell>
Expand All @@ -95,7 +96,7 @@ const DiscountProducts: React.FC<SaleProductsProps> = props => {
</TableFooter>
<TableBody data-test-id="assigned-specific-products-table">
{renderCollection(
products,
getLoadableList(discount?.products),
product => {
const isSelected = product ? isChecked(product.id) : false;

Expand Down
Loading

0 comments on commit efedfe3

Please sign in to comment.