Skip to content

Commit

Permalink
Update Macaw and bindings to pre-106 (#791)
Browse files Browse the repository at this point in the history
* Bump macaw UI

* Adjust rhf-macaw binding to use new macaw API

* Adjust CRM to use new macaw api

* adjust apps to work with new macaw

* Update combo box

* fix combobox value
  • Loading branch information
lkostrowski committed Jul 24, 2023
1 parent 2fab86b commit aa6fec1
Show file tree
Hide file tree
Showing 33 changed files with 516 additions and 420 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-ladybugs-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-app-emails-and-messages": patch
---

Fixed badly aligned Toggles. Now icon and label are centered
17 changes: 17 additions & 0 deletions .changeset/lucky-islands-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
"@saleor/react-hook-form-macaw": patch
"saleor-app-emails-and-messages": patch
"saleor-app-data-importer": patch
"saleor-app-products-feed": patch
"@saleor/apps-shared": patch
"saleor-app-invoices": patch
"saleor-app-klaviyo": patch
"saleor-app-cms-v2": patch
"saleor-app-search": patch
"@saleor/apps-ui": patch
"saleor-app-slack": patch
"saleor-app-taxes": patch
"saleor-app-crm": patch
---

Updated Macaw UI to pre-106
5 changes: 5 additions & 0 deletions .changeset/stale-readers-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@saleor/react-hook-form-macaw": patch
---

Updated Macaw UI bindings to reflect breaking changes in Select APIs
2 changes: 1 addition & 1 deletion apps/cms-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@saleor/app-sdk": "0.41.1",
"@saleor/apps-shared": "workspace:*",
"@saleor/apps-ui": "workspace:*",
"@saleor/macaw-ui": "0.8.0-pre.95",
"@saleor/macaw-ui": "0.8.0-pre.106",
"@saleor/react-hook-form-macaw": "workspace:*",
"@sentry/nextjs": "7.55.2",
"@tanstack/react-query": "^4.29.19",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ export const AddConnectionForm = (props: {
control={control}
name="channelSlug"
label="Channel"
options={channels?.map((c) => ({
value: c.slug,
label: c.name,
}))}
options={
channels?.map((c) => ({
value: c.slug,
label: c.name,
})) ?? []
}
/>
<ArrowRightIcon />
<Select
Expand All @@ -69,10 +71,12 @@ export const AddConnectionForm = (props: {
control={control}
name="providerId"
label="Provider"
options={providers?.map((p) => ({
value: p.id,
label: p.configName,
}))}
options={
providers?.map((p) => ({
value: p.id,
label: p.configName,
})) ?? []
}
/>
</Box>
{errors.root?.serverError && (
Expand Down
2 changes: 1 addition & 1 deletion apps/crm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@mailchimp/mailchimp_marketing": "^3.0.80",
"@saleor/app-sdk": "0.41.1",
"@saleor/apps-shared": "workspace:*",
"@saleor/macaw-ui": "0.8.0-pre.95",
"@saleor/macaw-ui": "0.8.0-pre.106",
"@sentry/nextjs": "7.55.2",
"@tanstack/react-query": "4.29.19",
"@trpc/client": "10.34.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box, Button, Checkbox, Text } from "@saleor/macaw-ui/next";
import { trpcClient } from "../../../trpc/trpc-client";
import { ComponentProps, useEffect, useState } from "react";
import { ChangeEvent, ComponentProps, useEffect, useState } from "react";
import { Section } from "../../../ui/section/section";
import { useDashboardNotification } from "@saleor/apps-shared";
import { MailchimpListPicker } from "../../mailchimp-list-picker/mailchimp-list-picker";
Expand Down Expand Up @@ -69,8 +69,8 @@ export const WebhookConfiguration = (props: ComponentProps<typeof Box>) => {
return null;
}

const handleCheckboxChange = (checked: boolean) => {
checked
const handleCheckboxChange = (e: ChangeEvent<HTMLInputElement>) => {
e.target.checked
? setLocalState({
selected: true,
listId: listsData[0].id,
Expand Down Expand Up @@ -106,7 +106,7 @@ export const WebhookConfiguration = (props: ComponentProps<typeof Box>) => {
Each time customer is created, it will be added to selected audience list in Mailchimp
</Text>
<Box display="flex" gap={1.5} flexDirection="column">
<Checkbox onCheckedChange={handleCheckboxChange} checked={localState.selected}>
<Checkbox onChange={handleCheckboxChange} checked={localState.selected}>
<Text marginRight="auto">Enable customers sync</Text>
</Checkbox>
<Box display="flex" alignItems="center">
Expand Down
41 changes: 23 additions & 18 deletions apps/crm/src/test/webhooks/customer-created-webhook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
IMailchimpConfigSettingsManagerV1,
MailchimpConfigType,
} from "../../modules/mailchimp/mailchimp-config-settings-manager";
import { NextApiRequest, NextApiResponse } from "next";

/**
* Mock settings manager. Consider mocking graphQL api instead
Expand Down Expand Up @@ -48,25 +49,29 @@ describe("CUSTOMER_CREATED webhook", () => {
it("Call Mailchimp client to add customer with properly mapped data and tags", async () => {
const { req, res } = createMocks({});

await customerCreatedHandler(req, res, {
authData: mockAuthData,
payload: {
user: {
id: "user-id",
email: "someuser@gmail.com",
firstName: "John",
lastName: "Doe",
privateMetadata: [
{
key: "mailchimp_tags",
value: JSON.stringify(["tag1"]),
},
],
await customerCreatedHandler(
req as unknown as NextApiRequest,
res as unknown as NextApiResponse,
{
authData: mockAuthData,
payload: {
user: {
id: "user-id",
email: "someuser@gmail.com",
firstName: "John",
lastName: "Doe",
privateMetadata: [
{
key: "mailchimp_tags",
value: JSON.stringify(["tag1"]),
},
],
},
},
},
event: "CUSTOMER_CREATED",
baseUrl: "localhost:3000",
});
event: "CUSTOMER_CREATED",
baseUrl: "localhost:3000",
}
);

return expect(mailchimp_marketing.lists.addListMember).toHaveBeenCalledWith("saleor", {
email_address: "someuser@gmail.com",
Expand Down
2 changes: 1 addition & 1 deletion apps/data-importer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@material-ui/lab": "4.0.0-alpha.61",
"@saleor/app-sdk": "0.41.1",
"@saleor/apps-shared": "workspace:*",
"@saleor/macaw-ui": "^0.7.2",
"@saleor/macaw-ui": "0.8.0-pre.106",
"@sentry/nextjs": "7.55.2",
"@urql/exchange-auth": "^2.1.4",
"@vitejs/plugin-react": "4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/emails-and-messages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@saleor/app-sdk": "0.41.1",
"@saleor/apps-shared": "workspace:*",
"@saleor/apps-ui": "workspace:*",
"@saleor/macaw-ui": "0.8.0-pre.95",
"@saleor/macaw-ui": "0.8.0-pre.106",
"@saleor/react-hook-form-macaw": "workspace:*",
"@sendgrid/client": "^7.7.0",
"@sendgrid/mail": "^7.7.0",
Expand Down
4 changes: 3 additions & 1 deletion apps/emails-and-messages/src/components/basic-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export const BasicLayout = ({ children, breadcrumbs, isLoading = false }: BasicL
{breadcrumbs?.length && (
<Breadcrumbs>
{breadcrumbs.map((breadcrumb) => (
<Breadcrumbs.Item href={breadcrumb.href}>{breadcrumb.name}</Breadcrumbs.Item>
<Breadcrumbs.Item key={breadcrumb.name} href={breadcrumb.href}>
{breadcrumb.name}
</Breadcrumbs.Item>
))}
</Breadcrumbs>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,16 @@ export const UniversalChannelsSection = ({
onValueChange={onChange}
>
<Switch.Item id="1" value="restrict">
<TableEditIcon size="medium" />
<Text>Include</Text>
<Box display="flex" alignItems="center" gap={1}>
<TableEditIcon size="medium" />
<Text>Include</Text>
</Box>
</Switch.Item>
<Switch.Item id="2" value="exclude">
<ProductsIcons size="medium" />
<Text>Exclude</Text>
<Box display="flex" alignItems="center" gap={1}>
<ProductsIcons size="medium" />
<Text>Exclude</Text>
</Box>
</Switch.Item>
</Switch>
)}
Expand Down
2 changes: 1 addition & 1 deletion apps/invoices/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@hookform/resolvers": "^3.1.0",
"@saleor/app-sdk": "0.41.1",
"@saleor/apps-shared": "workspace:*",
"@saleor/macaw-ui": "0.8.0-pre.95",
"@saleor/macaw-ui": "0.8.0-pre.106",
"@sentry/nextjs": "7.55.2",
"@tanstack/react-query": "4.29.19",
"@trpc/client": "10.34.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/klaviyo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@material-ui/lab": "4.0.0-alpha.61",
"@saleor/app-sdk": "0.41.1",
"@saleor/apps-shared": "workspace:*",
"@saleor/macaw-ui": "0.8.0-pre.95",
"@saleor/macaw-ui": "0.8.0-pre.106",
"@sentry/nextjs": "7.55.2",
"@urql/exchange-auth": "^2.1.4",
"clsx": "^1.2.1",
Expand Down
2 changes: 1 addition & 1 deletion apps/products-feed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@saleor/app-sdk": "0.41.1",
"@saleor/apps-shared": "workspace:*",
"@saleor/apps-ui": "workspace:*",
"@saleor/macaw-ui": "0.8.0-pre.95",
"@saleor/macaw-ui": "0.8.0-pre.106",
"@saleor/react-hook-form-macaw": "workspace:*",
"@sentry/nextjs": "7.55.2",
"@tanstack/react-query": "4.29.19",
Expand Down
2 changes: 1 addition & 1 deletion apps/search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@saleor/app-sdk": "0.41.1",
"@saleor/apps-shared": "workspace:*",
"@saleor/apps-ui": "workspace:*",
"@saleor/macaw-ui": "0.8.0-pre.95",
"@saleor/macaw-ui": "0.8.0-pre.106",
"@saleor/react-hook-form-macaw": "workspace:*",
"@sentry/nextjs": "7.55.2",
"@tanstack/react-query": "4.29.19",
Expand Down
2 changes: 1 addition & 1 deletion apps/slack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@saleor/app-sdk": "0.41.1",
"@saleor/apps-shared": "workspace:*",
"@saleor/apps-ui": "workspace:*",
"@saleor/macaw-ui": "0.8.0-pre.95",
"@saleor/macaw-ui": "0.8.0-pre.106",
"@saleor/react-hook-form-macaw": "workspace:*",
"@sentry/nextjs": "7.55.2",
"@urql/exchange-auth": "^2.1.4",
Expand Down
2 changes: 1 addition & 1 deletion apps/taxes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@saleor/app-sdk": "0.41.1",
"@saleor/apps-shared": "workspace:*",
"@saleor/apps-ui": "workspace:*",
"@saleor/macaw-ui": "^0.8.0-pre.84",
"@saleor/macaw-ui": "0.8.0-pre.106",
"@saleor/react-hook-form-macaw": "workspace:*",
"@sentry/nextjs": "7.55.2",
"@tanstack/react-query": "4.29.19",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const SelectTaxCode = ({ taxClassId }: { taxClassId: string }) => {

return (
<Select
value={value ?? ""}
value={value ?? null}
disabled={isLoading}
onChange={(value) => changeValue(String(value))}
options={[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Select } from "@saleor/macaw-ui/next";
import React from "react";
import { trpcClient } from "../../trpc/trpc-client";
import { Table } from "../../ui/table";
import { ChannelConfig } from "../channel-config";
import { useDashboardNotification } from "@saleor/apps-shared";
import { Select } from "../../ui/_select";

const SelectProvider = (channelConfig: ChannelConfig) => {
const {
Expand Down Expand Up @@ -33,7 +33,7 @@ const SelectProvider = (channelConfig: ChannelConfig) => {

return (
<Select
value={value ?? ""}
value={value ?? null}
onChange={(value) => changeValue(String(value))}
options={[
{ value: "", label: "Not assigned" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const SelectTaxCode = ({ taxClassId }: { taxClassId: string }) => {

return (
<Select
value={value ?? ""}
value={value ?? null}
disabled={isLoading}
onChange={(value) => changeValue(String(value))}
options={[
Expand Down
11 changes: 9 additions & 2 deletions apps/taxes/src/modules/ui/_select.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import { Select as _Select } from "@saleor/macaw-ui/next";

type SelectProps = React.ComponentProps<typeof _Select>;
type SelectProps = Omit<React.ComponentProps<typeof _Select>, "value" | "onChange"> & {
value: string | null;
onChange: (value: string) => void;
};
/**
* The macaw-ui Select doesn't truncate the label text, so we need to override it.
* @see: https://github.com/saleor/macaw-ui/issues/477
*
* TODO: Migrate to react-hook-form-macaw bindings package
*/
export const Select = (props: SelectProps) => {
export const Select = ({ value, ...props }: SelectProps) => {
return (
<_Select
{...props}
__whiteSpace={"preline"}
__overflow={"hidden"}
__textOverflow={"ellipsis"}
value={props.options.find((option) => option.value === value) ?? null}
onChange={(value) => props.onChange(value.value)}
/>
);
};
15 changes: 8 additions & 7 deletions packages/react-hook-form-macaw/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ export default {
name: "@storybook/react-vite",
options: {},
},
staticDirs: [
{
from: "../public",
to: "/assets",
},
"./public",
],
// This causes a build error TODO:
// staticDirs: [
// {
// from: "../public",
// to: "/assets",
// },
// "./public",
// ],
features: {
storyStoreV7: true,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-hook-form-macaw/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"devDependencies": {
"@babel/core": "^7.21.8",
"@saleor/macaw-ui": "0.8.0-pre.95",
"@saleor/macaw-ui": "0.8.0-pre.106",
"@storybook/addon-actions": "^7.0.12",
"@storybook/addon-essentials": "^7.0.12",
"@storybook/addon-interactions": "^7.0.12",
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,10 @@ export const WithHelpText: Story = {
helperText: "Helper text",
},
};

export const NoValue: Story = {
...ComboboxTemplate,
args: {
value: null,
},
};
Loading

0 comments on commit aa6fec1

Please sign in to comment.