@medusajs/dashboard 2.22.3 → 2.22.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/dist/app.js +3142 -2648
- package/dist/app.mjs +1 -1
- package/dist/{chunk-GBUMG3AT.mjs → chunk-DUUYIEXV.mjs} +486 -23
- package/dist/{chunk-ZU7MUXFY.mjs → chunk-ODGLX5SI.mjs} +1 -1
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/{invite-BEMJK2UX.mjs → invite-SOLUZ6PY.mjs} +33 -3
- package/dist/{order-detail-LCEVEUIR.mjs → order-detail-XZEJSMIZ.mjs} +1 -1
- package/dist/{product-attributes-44KC3O5H.mjs → product-attributes-HEJKFIWK.mjs} +1 -1
- package/dist/{product-create-7U2FFSX6.mjs → product-create-75A5WK7S.mjs} +1 -1
- package/dist/{product-detail-NDBVS3WK.mjs → product-detail-FI6SFWJD.mjs} +2 -2
- package/dist/{product-edit-MR7HPS4Y.mjs → product-edit-RFHTL3MQ.mjs} +1 -1
- package/dist/{product-options-manage-EFUX6E3S.mjs → product-options-manage-VHGM7NLR.mjs} +2 -2
- package/dist/{product-organization-5XNP3UM6.mjs → product-organization-KWPYEBPB.mjs} +1 -1
- package/package.json +12 -13
- package/src/components/layout/main-layout/__tests__/main-layout.spec.tsx +145 -0
- package/src/components/layout/main-layout/main-layout.tsx +1 -1
- package/src/components/layout/shell/__tests__/breadcrumbs.spec.tsx +81 -0
- package/src/components/layout/shell/shell.tsx +4 -2
- package/src/components/layout/shell/use-remembered-search.ts +22 -0
- package/src/i18n/translations/$schema.json +12 -0
- package/src/i18n/translations/ar.json +13 -0
- package/src/i18n/translations/bg.json +13 -0
- package/src/i18n/translations/bs.json +13 -0
- package/src/i18n/translations/cs.json +13 -0
- package/src/i18n/translations/de.json +13 -0
- package/src/i18n/translations/el.json +13 -0
- package/src/i18n/translations/en.json +3 -0
- package/src/i18n/translations/enGB.json +13 -0
- package/src/i18n/translations/es.json +13 -0
- package/src/i18n/translations/fa.json +13 -0
- package/src/i18n/translations/fi.json +13 -0
- package/src/i18n/translations/fr.json +13 -0
- package/src/i18n/translations/he.json +13 -0
- package/src/i18n/translations/hr.json +13 -0
- package/src/i18n/translations/hu.json +13 -0
- package/src/i18n/translations/id.json +13 -0
- package/src/i18n/translations/it.json +13 -0
- package/src/i18n/translations/ja.json +13 -0
- package/src/i18n/translations/ko.json +13 -0
- package/src/i18n/translations/lt.json +13 -0
- package/src/i18n/translations/mk.json +13 -0
- package/src/i18n/translations/mn.json +13 -0
- package/src/i18n/translations/nl.json +13 -0
- package/src/i18n/translations/pl.json +13 -0
- package/src/i18n/translations/ptBR.json +13 -0
- package/src/i18n/translations/ptPT.json +13 -0
- package/src/i18n/translations/ro.json +13 -0
- package/src/i18n/translations/ru.json +13 -0
- package/src/i18n/translations/sv.json +13 -0
- package/src/i18n/translations/th.json +13 -0
- package/src/i18n/translations/tr.json +13 -0
- package/src/i18n/translations/uk.json +13 -0
- package/src/i18n/translations/vi.json +13 -0
- package/src/i18n/translations/zhCN.json +13 -0
- package/src/i18n/translations/zhTW.json +13 -0
- package/src/routes/invite/invite.tsx +43 -2
- package/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.spec.tsx +175 -0
- package/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx +80 -83
package/dist/index.d.mts
CHANGED
|
@@ -3448,6 +3448,9 @@ declare const resources: {
|
|
|
3448
3448
|
invalidTokenTitle: string;
|
|
3449
3449
|
invalidTokenHint: string;
|
|
3450
3450
|
passwordMismatch: string;
|
|
3451
|
+
signedInTitle: string;
|
|
3452
|
+
signedInHint: string;
|
|
3453
|
+
signOut: string;
|
|
3451
3454
|
toast: {
|
|
3452
3455
|
accepted: string;
|
|
3453
3456
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -3448,6 +3448,9 @@ declare const resources: {
|
|
|
3448
3448
|
invalidTokenTitle: string;
|
|
3449
3449
|
invalidTokenHint: string;
|
|
3450
3450
|
passwordMismatch: string;
|
|
3451
|
+
signedInTitle: string;
|
|
3452
|
+
signedInHint: string;
|
|
3453
|
+
signOut: string;
|
|
3451
3454
|
toast: {
|
|
3452
3455
|
accepted: string;
|
|
3453
3456
|
};
|
|
@@ -9,13 +9,19 @@ import {
|
|
|
9
9
|
Form
|
|
10
10
|
} from "./chunk-OBQI23QM.mjs";
|
|
11
11
|
import {
|
|
12
|
+
useLogout,
|
|
12
13
|
useSignInWithEmailPass,
|
|
13
14
|
useSignUpWithEmailPass
|
|
14
15
|
} from "./chunk-CXRGHH7Y.mjs";
|
|
15
16
|
import {
|
|
16
17
|
useAcceptInvite
|
|
17
18
|
} from "./chunk-MLVYQMPS.mjs";
|
|
18
|
-
import
|
|
19
|
+
import {
|
|
20
|
+
useMe
|
|
21
|
+
} from "./chunk-UQC5JC6W.mjs";
|
|
22
|
+
import {
|
|
23
|
+
queryClient
|
|
24
|
+
} from "./chunk-56JWEPQ5.mjs";
|
|
19
25
|
import "./chunk-NFEK63OE.mjs";
|
|
20
26
|
import "./chunk-QZ7TP4HQ.mjs";
|
|
21
27
|
|
|
@@ -28,7 +34,7 @@ import { useState } from "react";
|
|
|
28
34
|
import { useForm } from "react-hook-form";
|
|
29
35
|
import { useTranslation } from "react-i18next";
|
|
30
36
|
import { decodeToken } from "react-jwt";
|
|
31
|
-
import { Link, useSearchParams } from "react-router-dom";
|
|
37
|
+
import { Link, useNavigate, useSearchParams } from "react-router-dom";
|
|
32
38
|
import * as z from "zod";
|
|
33
39
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
34
40
|
var CreateAccountSchema = z.object({
|
|
@@ -52,9 +58,13 @@ var Invite = () => {
|
|
|
52
58
|
const token = searchParams.get("token");
|
|
53
59
|
const invite = token ? decodeToken(token) : null;
|
|
54
60
|
const isValidInvite = invite && validateDecodedInvite(invite);
|
|
61
|
+
const { user, isPending: isLoadingUser } = useMe({ fields: "email" });
|
|
62
|
+
if (isLoadingUser) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
55
65
|
return /* @__PURE__ */ jsx("div", { className: "relative flex min-h-dvh w-dvw items-center justify-center bg-ui-bg-subtle p-4", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[360px] flex-col items-center", children: [
|
|
56
66
|
/* @__PURE__ */ jsx(AvatarBox, { checked: success }),
|
|
57
|
-
/* @__PURE__ */ jsx("div", { className: "max-h-[557px] w-full will-change-contents", children: isValidInvite ? /* @__PURE__ */ jsx(AnimatePresence, { children: !success ? /* @__PURE__ */ jsx(
|
|
67
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-[557px] w-full will-change-contents", children: user ? /* @__PURE__ */ jsx(SignedInView, { email: user.email }) : isValidInvite ? /* @__PURE__ */ jsx(AnimatePresence, { children: !success ? /* @__PURE__ */ jsx(
|
|
58
68
|
motion.div,
|
|
59
69
|
{
|
|
60
70
|
initial: false,
|
|
@@ -150,6 +160,26 @@ var InvalidView = () => {
|
|
|
150
160
|
/* @__PURE__ */ jsx(LoginLink, {})
|
|
151
161
|
] });
|
|
152
162
|
};
|
|
163
|
+
var SignedInView = ({ email }) => {
|
|
164
|
+
const { t } = useTranslation();
|
|
165
|
+
const navigate = useNavigate();
|
|
166
|
+
const { mutateAsync: logout, isPending } = useLogout();
|
|
167
|
+
const handleLogout = async () => {
|
|
168
|
+
await logout(void 0, {
|
|
169
|
+
onSuccess: () => {
|
|
170
|
+
queryClient.clear();
|
|
171
|
+
navigate(0);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col items-center gap-y-6", children: [
|
|
176
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-y-1", children: [
|
|
177
|
+
/* @__PURE__ */ jsx(Heading, { className: "text-center", children: t("invite.signedInTitle") }),
|
|
178
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-center text-ui-fg-subtle", children: t("invite.signedInHint", { email }) })
|
|
179
|
+
] }),
|
|
180
|
+
/* @__PURE__ */ jsx(Button, { className: "w-full", onClick: handleLogout, isLoading: isPending, children: t("invite.signOut") })
|
|
181
|
+
] });
|
|
182
|
+
};
|
|
153
183
|
var CreateView = ({
|
|
154
184
|
onSuccess,
|
|
155
185
|
token,
|
|
@@ -3079,7 +3079,7 @@ var OrderSummarySection = ({
|
|
|
3079
3079
|
/* @__PURE__ */ jsx17(CostBreakdown, { order }),
|
|
3080
3080
|
/* @__PURE__ */ jsx17(DiscountAndTotalBreakdown, { order, plugins }),
|
|
3081
3081
|
/* @__PURE__ */ jsx17(Total2, { order }),
|
|
3082
|
-
showReturns || showAllocateButton || showPayment || showRefund && /* @__PURE__ */ jsxs18("div", { className: "flex items-center justify-end gap-x-2 rounded-b-xl bg-ui-bg-subtle px-4 py-4", children: [
|
|
3082
|
+
(showReturns || showAllocateButton || showPayment || showRefund) && /* @__PURE__ */ jsxs18("div", { className: "flex items-center justify-end gap-x-2 rounded-b-xl bg-ui-bg-subtle px-4 py-4", children: [
|
|
3083
3083
|
showReturns && (receivableReturns.length === 1 ? /* @__PURE__ */ jsx17(Button9, { asChild: true, variant: "secondary", size: "small", children: /* @__PURE__ */ jsx17(
|
|
3084
3084
|
Link3,
|
|
3085
3085
|
{
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-AM2BU2RH.mjs";
|
|
7
7
|
import {
|
|
8
8
|
PRODUCT_DETAIL_FIELDS
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ODGLX5SI.mjs";
|
|
10
10
|
import {
|
|
11
11
|
SidebarLink
|
|
12
12
|
} from "./chunk-TBU4TBPD.mjs";
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
getFormattedCountry
|
|
20
20
|
} from "./chunk-B6ZOPCPA.mjs";
|
|
21
21
|
import "./chunk-DG7J63J2.mjs";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-DUUYIEXV.mjs";
|
|
23
23
|
import "./chunk-ONB3JEHR.mjs";
|
|
24
24
|
import "./chunk-JAW6ZD7F.mjs";
|
|
25
25
|
import "./chunk-4GQOUCX6.mjs";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PRODUCT_DETAIL_FIELDS
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ODGLX5SI.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useExtendableForm
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DUUYIEXV.mjs";
|
|
7
7
|
import "./chunk-ONB3JEHR.mjs";
|
|
8
8
|
import "./chunk-JAW6ZD7F.mjs";
|
|
9
9
|
import "./chunk-4GQOUCX6.mjs";
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/dashboard",
|
|
3
|
-
"version": "2.22.
|
|
3
|
+
"version": "2.22.4",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"typecheck": "
|
|
6
|
+
"typecheck": "yarn run -T tsc --noEmit -p tsconfig.typecheck.json",
|
|
7
7
|
"generate:static": "node ./scripts/generate-currencies.js && prettier --write ./src/lib/currencies.ts",
|
|
8
8
|
"dev": "../../../node_modules/.bin/vite",
|
|
9
9
|
"build": "yarn typecheck && yarn run -T tsup",
|
|
@@ -72,10 +72,10 @@
|
|
|
72
72
|
"@dnd-kit/utilities": "^3.2.2",
|
|
73
73
|
"@hookform/error-message": "^2.0.1",
|
|
74
74
|
"@hookform/resolvers": "6.0.0",
|
|
75
|
-
"@medusajs/admin-shared": "2.22.
|
|
76
|
-
"@medusajs/icons": "2.22.
|
|
77
|
-
"@medusajs/js-sdk": "2.22.
|
|
78
|
-
"@medusajs/ui": "4.2.
|
|
75
|
+
"@medusajs/admin-shared": "2.22.4",
|
|
76
|
+
"@medusajs/icons": "2.22.4",
|
|
77
|
+
"@medusajs/js-sdk": "2.22.4",
|
|
78
|
+
"@medusajs/ui": "4.2.11",
|
|
79
79
|
"@radix-ui/react-dialog": "1.1.4",
|
|
80
80
|
"@radix-ui/react-dismissable-layer": "1.1.4",
|
|
81
81
|
"@tanstack/react-query": "5.64.2",
|
|
@@ -107,16 +107,15 @@
|
|
|
107
107
|
"zod": "4.6.6"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
|
-
"@medusajs/admin-shared": "2.22.
|
|
111
|
-
"@medusajs/admin-vite-plugin": "2.22.
|
|
112
|
-
"@medusajs/types": "2.22.
|
|
113
|
-
"@medusajs/ui-preset": "2.22.
|
|
110
|
+
"@medusajs/admin-shared": "2.22.4",
|
|
111
|
+
"@medusajs/admin-vite-plugin": "2.22.4",
|
|
112
|
+
"@medusajs/types": "2.22.4",
|
|
113
|
+
"@medusajs/ui-preset": "2.22.4",
|
|
114
114
|
"@types/qrcode": "^1.5.5",
|
|
115
|
-
"@typescript/native-preview": "^7.0.0-dev.20260423.1",
|
|
116
115
|
"eslint": "^9.39.5",
|
|
117
|
-
"typescript": "
|
|
116
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2"
|
|
118
117
|
},
|
|
119
|
-
"packageManager": "yarn@
|
|
118
|
+
"packageManager": "yarn@4.18.1",
|
|
120
119
|
"engines": {
|
|
121
120
|
"node": ">=22.22.0"
|
|
122
121
|
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { renderToStaticMarkup } from "react-dom/server"
|
|
3
|
+
import { MemoryRouter } from "react-router-dom"
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from "vitest"
|
|
5
|
+
|
|
6
|
+
import { MainLayout } from "../main-layout"
|
|
7
|
+
|
|
8
|
+
const mocks = vi.hoisted(() => ({
|
|
9
|
+
menuItems: [] as Record<string, unknown>[],
|
|
10
|
+
}))
|
|
11
|
+
|
|
12
|
+
vi.mock("react-i18next", () => ({
|
|
13
|
+
useTranslation: () => ({
|
|
14
|
+
t: (key: string) => key,
|
|
15
|
+
}),
|
|
16
|
+
}))
|
|
17
|
+
|
|
18
|
+
vi.mock("../../../../hooks/use-resource-permissions", () => {
|
|
19
|
+
const allowed = () => ({ canRead: true })
|
|
20
|
+
return {
|
|
21
|
+
useCampaignPermissions: allowed,
|
|
22
|
+
useCustomerGroupPermissions: allowed,
|
|
23
|
+
useCustomerPermissions: allowed,
|
|
24
|
+
useInventoryItemPermissions: allowed,
|
|
25
|
+
useOrderPermissions: allowed,
|
|
26
|
+
usePriceListPermissions: allowed,
|
|
27
|
+
useProductCategoryPermissions: allowed,
|
|
28
|
+
useProductCollectionPermissions: allowed,
|
|
29
|
+
useProductPermissions: allowed,
|
|
30
|
+
usePromotionPermissions: allowed,
|
|
31
|
+
useReservationItemPermissions: allowed,
|
|
32
|
+
useResourcePermissions: allowed,
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
vi.mock("../../../../providers/extension-provider", () => ({
|
|
37
|
+
useExtension: () => ({
|
|
38
|
+
getMenu: () => mocks.menuItems,
|
|
39
|
+
}),
|
|
40
|
+
}))
|
|
41
|
+
|
|
42
|
+
vi.mock("../../../../providers/search-provider", () => ({
|
|
43
|
+
useSearch: () => ({ toggleSearch: vi.fn() }),
|
|
44
|
+
}))
|
|
45
|
+
|
|
46
|
+
vi.mock("../../../../hooks/api/store", () => ({
|
|
47
|
+
useStore: () => ({ store: undefined, isPending: true }),
|
|
48
|
+
}))
|
|
49
|
+
|
|
50
|
+
vi.mock("../../../../hooks/api", () => ({
|
|
51
|
+
useLogout: () => ({ mutateAsync: vi.fn() }),
|
|
52
|
+
}))
|
|
53
|
+
|
|
54
|
+
vi.mock("../../../../lib/query-client", () => ({
|
|
55
|
+
queryClient: { clear: vi.fn() },
|
|
56
|
+
}))
|
|
57
|
+
|
|
58
|
+
vi.mock("../../../../hooks/use-document-direction", () => ({
|
|
59
|
+
useDocumentDirection: () => "ltr",
|
|
60
|
+
}))
|
|
61
|
+
|
|
62
|
+
vi.mock("../../../common/permission-guard", () => ({
|
|
63
|
+
PermissionGuard: () => null,
|
|
64
|
+
}))
|
|
65
|
+
|
|
66
|
+
vi.mock("../../user-menu", () => ({
|
|
67
|
+
UserMenu: () => null,
|
|
68
|
+
}))
|
|
69
|
+
|
|
70
|
+
vi.mock("../../shell", () => ({
|
|
71
|
+
Shell: ({ children }: { children: React.ReactNode }) => <>{children}</>,
|
|
72
|
+
}))
|
|
73
|
+
|
|
74
|
+
vi.mock("../../../layout-composer", () => {
|
|
75
|
+
const LayoutComposer = ({
|
|
76
|
+
sections,
|
|
77
|
+
}: {
|
|
78
|
+
sections: { main: React.ReactNode }
|
|
79
|
+
}) => <>{sections.main}</>
|
|
80
|
+
LayoutComposer.Entry = ({ children }: { children: React.ReactNode }) => (
|
|
81
|
+
<>{children}</>
|
|
82
|
+
)
|
|
83
|
+
return { LayoutComposer }
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
vi.mock("../../nav-item", () => ({
|
|
87
|
+
usePermittedNavItems: (items: unknown[]) => items,
|
|
88
|
+
NavItem: ({ to, items }: { to: string; items?: { to: string }[] }) => (
|
|
89
|
+
<p>{`${to}=[${(items ?? []).map((item) => item.to).join(",")}]`}</p>
|
|
90
|
+
),
|
|
91
|
+
}))
|
|
92
|
+
|
|
93
|
+
const renderNav = () => {
|
|
94
|
+
const markup = renderToStaticMarkup(
|
|
95
|
+
<MemoryRouter>
|
|
96
|
+
<MainLayout />
|
|
97
|
+
</MemoryRouter>
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
return Object.fromEntries(
|
|
101
|
+
[...markup.matchAll(/<p>([^=<]+)=\[([^\]]*)\]<\/p>/g)].map(
|
|
102
|
+
([, to, items]) => [to, items ? items.split(",") : []]
|
|
103
|
+
)
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
describe("MainLayout", () => {
|
|
108
|
+
afterEach(() => {
|
|
109
|
+
mocks.menuItems = []
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it("should nest an extension route under the core Orders route", () => {
|
|
113
|
+
mocks.menuItems = [
|
|
114
|
+
{ label: "Draft Orders", to: "/draft-orders", nested: "/orders" },
|
|
115
|
+
]
|
|
116
|
+
|
|
117
|
+
const nav = renderNav()
|
|
118
|
+
|
|
119
|
+
expect(nav["/orders"]).toEqual(["/draft-orders"])
|
|
120
|
+
expect(nav["/draft-orders"]).toBeUndefined()
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
it("should nest an extension route under a core route without children", () => {
|
|
124
|
+
mocks.menuItems = [
|
|
125
|
+
{ label: "Custom Prices", to: "/custom-prices", nested: "/price-lists" },
|
|
126
|
+
]
|
|
127
|
+
|
|
128
|
+
const nav = renderNav()
|
|
129
|
+
|
|
130
|
+
expect(nav["/price-lists"]).toEqual(["/custom-prices"])
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
it("should keep core children when nesting an extension route", () => {
|
|
134
|
+
mocks.menuItems = [{ label: "Bundles", to: "/bundles", nested: "/products" }]
|
|
135
|
+
|
|
136
|
+
const nav = renderNav()
|
|
137
|
+
|
|
138
|
+
expect(nav["/products"]).toEqual([
|
|
139
|
+
"/collections",
|
|
140
|
+
"/categories",
|
|
141
|
+
"/product-options",
|
|
142
|
+
"/bundles",
|
|
143
|
+
])
|
|
144
|
+
})
|
|
145
|
+
})
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act, cleanup, render, screen } from "@testing-library/react"
|
|
3
|
+
import {
|
|
4
|
+
Link,
|
|
5
|
+
Outlet,
|
|
6
|
+
RouterProvider,
|
|
7
|
+
createMemoryRouter,
|
|
8
|
+
} from "react-router-dom"
|
|
9
|
+
import { afterEach, describe, expect, it } from "vitest"
|
|
10
|
+
|
|
11
|
+
import { Breadcrumbs } from "../shell"
|
|
12
|
+
|
|
13
|
+
const createRouter = (initialEntry: string) =>
|
|
14
|
+
createMemoryRouter(
|
|
15
|
+
[
|
|
16
|
+
{
|
|
17
|
+
path: "/",
|
|
18
|
+
element: (
|
|
19
|
+
<>
|
|
20
|
+
<Breadcrumbs />
|
|
21
|
+
<Outlet />
|
|
22
|
+
</>
|
|
23
|
+
),
|
|
24
|
+
children: [
|
|
25
|
+
{
|
|
26
|
+
path: "orders",
|
|
27
|
+
handle: { breadcrumb: () => "Orders" },
|
|
28
|
+
children: [
|
|
29
|
+
{
|
|
30
|
+
path: "",
|
|
31
|
+
element: <Link to="/orders/order_1">Open order</Link>,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
path: ":id",
|
|
35
|
+
handle: { breadcrumb: () => "#1" },
|
|
36
|
+
element: <div>Order details</div>,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
{ initialEntries: [initialEntry] }
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
describe("Breadcrumbs", () => {
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
cleanup()
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it("should link back to the list with the search params it was left with", async () => {
|
|
52
|
+
const listSearch =
|
|
53
|
+
"?created_at=%7B%22%24gte%22%3A%222024-01-01%22%7D&offset=40&q=foo"
|
|
54
|
+
const router = createRouter(`/orders${listSearch}`)
|
|
55
|
+
|
|
56
|
+
render(<RouterProvider router={router} />)
|
|
57
|
+
|
|
58
|
+
await act(async () => {
|
|
59
|
+
await router.navigate("/orders/order_1")
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
expect(screen.getByText("Order details")).toBeTruthy()
|
|
63
|
+
expect(
|
|
64
|
+
screen.getByRole("link", { name: "Orders" }).getAttribute("href")
|
|
65
|
+
).toBe(`/orders${listSearch}`)
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it("should link to the plain list path when the list was opened without search params", async () => {
|
|
69
|
+
const router = createRouter("/orders")
|
|
70
|
+
|
|
71
|
+
render(<RouterProvider router={router} />)
|
|
72
|
+
|
|
73
|
+
await act(async () => {
|
|
74
|
+
await router.navigate("/orders/order_1")
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
expect(
|
|
78
|
+
screen.getByRole("link", { name: "Orders" }).getAttribute("href")
|
|
79
|
+
).toBe("/orders")
|
|
80
|
+
})
|
|
81
|
+
})
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
LAYOUT_CONTROLS_LOCATION,
|
|
29
29
|
} from "../../layout-composer/constants"
|
|
30
30
|
import { CORE_LAYOUT_IDS } from "@medusajs/admin-shared"
|
|
31
|
+
import { useRememberedSearch } from "./use-remembered-search"
|
|
31
32
|
|
|
32
33
|
export const Shell = ({ children }: PropsWithChildren) => {
|
|
33
34
|
const globalShortcuts = useGlobalShortcuts()
|
|
@@ -104,7 +105,8 @@ const Gutter = ({ children }: PropsWithChildren) => {
|
|
|
104
105
|
)
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
const Breadcrumbs = () => {
|
|
108
|
+
export const Breadcrumbs = () => {
|
|
109
|
+
const withRememberedSearch = useRememberedSearch()
|
|
108
110
|
const matches = useMatches() as unknown as UIMatch<
|
|
109
111
|
unknown,
|
|
110
112
|
{
|
|
@@ -151,7 +153,7 @@ const Breadcrumbs = () => {
|
|
|
151
153
|
{!isLast ? (
|
|
152
154
|
<Link
|
|
153
155
|
className="transition-fg hover:text-ui-fg-subtle"
|
|
154
|
-
to={crumb.path}
|
|
156
|
+
to={withRememberedSearch(crumb.path)}
|
|
155
157
|
>
|
|
156
158
|
{crumb.label}
|
|
157
159
|
</Link>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from "react"
|
|
2
|
+
import { useLocation } from "react-router-dom"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Remembers the last search string visited for each pathname, and returns a
|
|
6
|
+
* function that appends it to a pathname. This lets breadcrumb links return
|
|
7
|
+
* to a list page with the filters, search, and pagination it was left with.
|
|
8
|
+
*/
|
|
9
|
+
export const useRememberedSearch = () => {
|
|
10
|
+
const location = useLocation()
|
|
11
|
+
const searchByPathname = useRef(new Map<string, string>())
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
searchByPathname.current.set(location.pathname, location.search)
|
|
15
|
+
}, [location.pathname, location.search])
|
|
16
|
+
|
|
17
|
+
return useCallback(
|
|
18
|
+
(pathname: string) =>
|
|
19
|
+
`${pathname}${searchByPathname.current.get(pathname) ?? ""}`,
|
|
20
|
+
[]
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -12854,6 +12854,15 @@
|
|
|
12854
12854
|
"passwordMismatch": {
|
|
12855
12855
|
"type": "string"
|
|
12856
12856
|
},
|
|
12857
|
+
"signedInTitle": {
|
|
12858
|
+
"type": "string"
|
|
12859
|
+
},
|
|
12860
|
+
"signedInHint": {
|
|
12861
|
+
"type": "string"
|
|
12862
|
+
},
|
|
12863
|
+
"signOut": {
|
|
12864
|
+
"type": "string"
|
|
12865
|
+
},
|
|
12857
12866
|
"toast": {
|
|
12858
12867
|
"type": "object",
|
|
12859
12868
|
"properties": {
|
|
@@ -12879,6 +12888,9 @@
|
|
|
12879
12888
|
"invalidTokenTitle",
|
|
12880
12889
|
"invalidTokenHint",
|
|
12881
12890
|
"passwordMismatch",
|
|
12891
|
+
"signedInTitle",
|
|
12892
|
+
"signedInHint",
|
|
12893
|
+
"signOut",
|
|
12882
12894
|
"toast"
|
|
12883
12895
|
],
|
|
12884
12896
|
"additionalProperties": false
|
|
@@ -163,6 +163,7 @@
|
|
|
163
163
|
"reset": "إعادة تعيين",
|
|
164
164
|
"confirm": "تأكيد",
|
|
165
165
|
"edit": "تحرير",
|
|
166
|
+
"view": "عرض",
|
|
166
167
|
"addItems": "إضافة عناصر",
|
|
167
168
|
"download": "تنزيل",
|
|
168
169
|
"clear": "مسح",
|
|
@@ -2925,6 +2926,7 @@
|
|
|
2925
2926
|
"editUser": "تحرير المستخدم",
|
|
2926
2927
|
"inviteUser": "دعوة مستخدم",
|
|
2927
2928
|
"inviteUserHint": "دعوة مستخدم جديد إلى متجرك.",
|
|
2929
|
+
"inviteRolesTooltip": "إذا لم يتم تحديد أي دور، سيتم دعوة المستخدم بدون أي أذونات. يمكنك تعيين الأدوار لاحقاً.",
|
|
2928
2930
|
"sendInvite": "إرسال الدعوة",
|
|
2929
2931
|
"pendingInvites": "الدعوات المعلقة",
|
|
2930
2932
|
"deleteInviteWarning": "أنت على وشك حذف الدعوة لـ {{email}}. لا يمكن التراجع عن هذا الإجراء.",
|
|
@@ -3027,6 +3029,9 @@
|
|
|
3027
3029
|
"filtered": {
|
|
3028
3030
|
"heading": "لا توجد نتائج",
|
|
3029
3031
|
"description": "لا توجد أذونات تطابق معايير الفلتر الحالية."
|
|
3032
|
+
},
|
|
3033
|
+
"manage": {
|
|
3034
|
+
"successToast": "تم تحديث الأذونات بنجاح."
|
|
3030
3035
|
}
|
|
3031
3036
|
},
|
|
3032
3037
|
"list": {
|
|
@@ -3050,6 +3055,7 @@
|
|
|
3050
3055
|
},
|
|
3051
3056
|
"edit": {
|
|
3052
3057
|
"header": "تعديل السياسة",
|
|
3058
|
+
"identityHint": "المفتاح والمورد والعملية تُعرِّف السياسة ولا يمكن تغييرها. أنشئ سياسة جديدة بدلاً من ذلك.",
|
|
3053
3059
|
"successToast": "تم تحديث السياسة {{key}}"
|
|
3054
3060
|
},
|
|
3055
3061
|
"delete": {
|
|
@@ -3543,6 +3549,9 @@
|
|
|
3543
3549
|
"invalidTokenTitle": "رمز الدعوة غير صالح",
|
|
3544
3550
|
"invalidTokenHint": "حاول طلب رابط دعوة جديد.",
|
|
3545
3551
|
"passwordMismatch": "كلمات المرور غير متطابقة",
|
|
3552
|
+
"signedInTitle": "أنت مسجّل الدخول بالفعل",
|
|
3553
|
+
"signedInHint": "أنت مسجّل الدخول بوصفك {{email}}. سجّل الخروج لقبول هذه الدعوة.",
|
|
3554
|
+
"signOut": "تسجيل الخروج",
|
|
3546
3555
|
"toast": {
|
|
3547
3556
|
"accepted": "تم قبول الدعوة بنجاح"
|
|
3548
3557
|
}
|
|
@@ -4008,6 +4017,10 @@
|
|
|
4008
4017
|
"requiredPermission": "الإذن المطلوب: {{permission}}",
|
|
4009
4018
|
"action": "ليس لديك إذن لتنفيذ هذا الإجراء."
|
|
4010
4019
|
},
|
|
4020
|
+
"noPermissions": {
|
|
4021
|
+
"title": "لا توجد أذونات بعد",
|
|
4022
|
+
"description": "لم يتم تعيين أي أذونات لك بعد. تواصل مع المسؤول لطلب الوصول إلى المناطق التي تحتاجها."
|
|
4023
|
+
},
|
|
4011
4024
|
"requiredPermissions": {
|
|
4012
4025
|
"title": "الأذونات المطلوبة",
|
|
4013
4026
|
"none": "لم يتم الإعلان عن أذونات في هذا العرض.",
|
|
@@ -143,6 +143,7 @@
|
|
|
143
143
|
"reset": "Нулирай",
|
|
144
144
|
"confirm": "Потвърди",
|
|
145
145
|
"edit": "Редактирай",
|
|
146
|
+
"view": "Преглед",
|
|
146
147
|
"addItems": "Добави елементи",
|
|
147
148
|
"download": "Изтегли",
|
|
148
149
|
"clear": "Изчисти",
|
|
@@ -2786,6 +2787,7 @@
|
|
|
2786
2787
|
"editUser": "Редактиране на потребител",
|
|
2787
2788
|
"inviteUser": "Покани потребител",
|
|
2788
2789
|
"inviteUserHint": "Поканете нов потребител във вашия магазин.",
|
|
2790
|
+
"inviteRolesTooltip": "Ако не е избрана роля, потребителят ще бъде поканен без никакви разрешения. Можете да присвоите роли по-късно.",
|
|
2789
2791
|
"sendInvite": "Изпрати покана",
|
|
2790
2792
|
"pendingInvites": "Чакащи покани",
|
|
2791
2793
|
"deleteInviteWarning": "Ще изтриете поканата за {{email}}. Това действие не може да бъде отменено.",
|
|
@@ -2887,6 +2889,9 @@
|
|
|
2887
2889
|
"filtered": {
|
|
2888
2890
|
"heading": "Няма резултати",
|
|
2889
2891
|
"description": "Нито едно разрешение не отговаря на текущите критерии за филтриране."
|
|
2892
|
+
},
|
|
2893
|
+
"manage": {
|
|
2894
|
+
"successToast": "Разрешенията бяха успешно актуализирани."
|
|
2890
2895
|
}
|
|
2891
2896
|
},
|
|
2892
2897
|
"list": {
|
|
@@ -2910,6 +2915,7 @@
|
|
|
2910
2915
|
},
|
|
2911
2916
|
"edit": {
|
|
2912
2917
|
"header": "Редактиране на правило",
|
|
2918
|
+
"identityHint": "Ключът, ресурсът и операцията идентифицират правилото и не могат да бъдат променяни. Вместо това създайте ново правило.",
|
|
2913
2919
|
"successToast": "Правилото {{key}} е актуализирано"
|
|
2914
2920
|
},
|
|
2915
2921
|
"delete": {
|
|
@@ -3371,6 +3377,9 @@
|
|
|
3371
3377
|
"invalidTokenTitle": "Вашият токен за покана е невалиден",
|
|
3372
3378
|
"invalidTokenHint": "Опитайте да поискате нова покана.",
|
|
3373
3379
|
"passwordMismatch": "Паролите не съвпадат",
|
|
3380
|
+
"signedInTitle": "Вече сте вписани",
|
|
3381
|
+
"signedInHint": "Вписани сте като {{email}}. Излезте, за да приемете тази покана.",
|
|
3382
|
+
"signOut": "Изход",
|
|
3374
3383
|
"toast": {
|
|
3375
3384
|
"accepted": "Поканата беше приета успешно"
|
|
3376
3385
|
}
|
|
@@ -3804,6 +3813,10 @@
|
|
|
3804
3813
|
"requiredPermission": "Необходимо разрешение: {{permission}}",
|
|
3805
3814
|
"action": "Нямате разрешение за извършване на това действие."
|
|
3806
3815
|
},
|
|
3816
|
+
"noPermissions": {
|
|
3817
|
+
"title": "Все още няма разрешения",
|
|
3818
|
+
"description": "Все още нямате присвоени разрешения. Свържете се с вашия администратор, за да поискате достъп до необходимите ви области."
|
|
3819
|
+
},
|
|
3807
3820
|
"requiredPermissions": {
|
|
3808
3821
|
"title": "Необходими разрешения",
|
|
3809
3822
|
"none": "Няма декларирани разрешения в този изглед.",
|