Skip to content

Commit

Permalink
Merge branch 'develop' into fix/partial-fulfillment-reservations
Browse files Browse the repository at this point in the history
  • Loading branch information
fPolic authored Oct 25, 2024
2 parents 1177d50 + ddf3306 commit 7c97f90
Show file tree
Hide file tree
Showing 793 changed files with 46,563 additions and 43,020 deletions.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "medusajs/medusa" }],
"commit": false,
"fixed": [],
"fixed": [["@medusajs/*", "create-medusa-app", "medusa-dev-cli", "!@medusajs/ui"]],
"linked": [],
"access": "public",
"baseBranch": "develop",
Expand Down
5 changes: 5 additions & 0 deletions .changeset/early-deers-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

fix(medusa): Admin validator filtering and pagination
5 changes: 5 additions & 0 deletions .changeset/four-trees-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/dashboard": patch
---

fix(dashboard): Workflow executions
5 changes: 5 additions & 0 deletions .changeset/mighty-flowers-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/dashboard": patch
---

fix(dashboard): Prevent nested UI Routes from re-using parent component
6 changes: 6 additions & 0 deletions .changeset/perfect-ravens-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/dashboard": patch
"@medusajs/ui": patch
---

fix(dashboard,ui): DateFilter should remain open
54 changes: 54 additions & 0 deletions .github/workflows/docs-update-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Update Version in Docs
on:
release:
types: [published]

jobs:
update-docs-version:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.REFERENCE_PAT }}
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 20
cache: "yarn"

- name: Install dependencies
uses: ./.github/actions/cache-deps
with:
extension: docs-update-version

- name: Install Workspace dependencies
run: yarn install
working-directory: www/utils

- name: Build Workspace packages
run: yarn build
working-directory: www/utils

- name: Update Docs Version
run: yarn update:config-version
working-directory: www/utils/packages/scripts

- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
commit-message: "chore(docs): Update version in documentation (automated)"
base: "develop"
title: "chore(docs): Update version in documentation (automated)"
labels: "type: chore"
add-paths: www/packages/docs-ui/src/global-config.ts
branch: "docs/update-config-version"
branch-suffix: "timestamp"
62 changes: 62 additions & 0 deletions integration-tests/http/__tests__/customer/admin/customer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,68 @@ medusaIntegrationTestRunner({
})
})

describe("POST /admin/customers/:id/customer-groups", () => {
it("should batch add and remove customer to/from customer groups", async () => {
const group1 = (
await api.post(
"/admin/customer-groups",
{
name: "VIP 1",
},
adminHeaders
)
).data.customer_group

const group2 = (
await api.post(
"/admin/customer-groups",
{
name: "VIP 2",
},
adminHeaders
)
).data.customer_group

const group3 = (
await api.post(
"/admin/customer-groups",
{
name: "VIP 3",
},
adminHeaders
)
).data.customer_group

// Add with cg endpoint so we can test remove
await api.post(
`/admin/customer-groups/${group1.id}/customers`,
{
add: [customer1.id],
},
adminHeaders
)

const response = await api.post(
`/admin/customers/${customer1.id}/customer-groups?fields=groups.id`,
{
remove: [group1.id],
add: [group2.id, group3.id],
},
adminHeaders
)

expect(response.status).toEqual(200)

expect(response.data.customer.groups.length).toEqual(2)
expect(response.data.customer.groups).toEqual(
expect.arrayContaining([
expect.objectContaining({ id: group2.id }),
expect.objectContaining({ id: group3.id }),
])
)
})
})

describe("GET /admin/customers/:id", () => {
it("should fetch a customer", async () => {
const response = await api.get(
Expand Down
12 changes: 12 additions & 0 deletions integration-tests/http/__tests__/customer/store/customer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ medusaIntegrationTestRunner({
email: "[email protected]",
first_name: "John",
last_name: "Doe",
metadata: {
loyalty_level: "gold",
preferences: {
newsletter: true,
},
},
},
{
headers: {
Expand All @@ -69,6 +75,12 @@ medusaIntegrationTestRunner({
first_name: "John",
last_name: "Doe",
has_account: true,
metadata: {
loyalty_level: "gold",
preferences: {
newsletter: true,
},
},
}),
})
})
Expand Down
24 changes: 23 additions & 1 deletion integration-tests/modules/__tests__/modules/remote-query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ medusaIntegrationTestRunner({
query = appContainer.resolve(ContainerRegistrationKeys.QUERY)
})

let product
beforeEach(async () => {
await createAdminUser(dbConnection, adminHeaders, appContainer)

Expand All @@ -224,11 +225,13 @@ medusaIntegrationTestRunner({
],
}

await api
const res = await api
.post("/admin/products", payload, adminHeaders)
.catch((err) => {
console.log(err)
})

product = res.data.product
})

it(`should throw if not exists`, async () => {
Expand Down Expand Up @@ -265,6 +268,25 @@ medusaIntegrationTestRunner({
)
})

it(`should support filtering using operators on a primary column`, async () => {
const { data } = await query.graph({
entity: "product",
fields: ["id", "title"],
filters: {
id: {
$in: [product.id],
},
},
})

expect(data).toEqual([
expect.objectContaining({
id: product.id,
title: product.title,
}),
])
})

it(`should perform cross module query and apply filters correctly to the correct modules [1]`, async () => {
const { data } = await query.graph({
entity: "product",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const UserMenu = () => {
</DropdownMenu.Item>
<DropdownMenu.Separator />
<DropdownMenu.Item asChild>
<Link to="https://docs.medusajs.com/v2" target="_blank">
<Link to="https://docs.medusajs.com" target="_blank">
<BookOpen className="text-ui-fg-subtle mr-2" />
{t("app.menus.user.documentation")}
</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { useTranslation } from "react-i18next"
import { useDate } from "../../../../hooks/use-date"
import { useSelectedParams } from "../hooks"
import { useDataTableFilterContext } from "./context"
import { IFilter } from "./types"
import FilterChip from "./filter-chip"
import { IFilter } from "./types"

type DateFilterProps = IFilter

Expand Down Expand Up @@ -97,7 +97,9 @@ export const DateFilter = ({

const displayValue = getDisplayValueFromPresets() || getCustomDisplayValue()

const [previousValue, setPreviousValue] = useState<string | undefined>(displayValue)
const [previousValue, setPreviousValue] = useState<string | undefined>(
displayValue
)

const handleRemove = () => {
selectedParams.delete()
Expand Down Expand Up @@ -210,6 +212,7 @@ export const DateFilter = ({
</div>
<div className="px-2 py-1">
<DatePicker
modal
maxValue={customEndValue}
value={customStartValue}
onChange={(d) => handleCustomDateChange(d, "start")}
Expand All @@ -224,6 +227,7 @@ export const DateFilter = ({
</div>
<div className="px-2 py-1">
<DatePicker
modal
minValue={customStartValue}
value={customEndValue || undefined}
onChange={(d) => {
Expand Down
47 changes: 25 additions & 22 deletions packages/admin/dashboard/src/extensions/routes/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ComponentType } from "react"
import { RouteObject } from "react-router-dom"
import { ErrorBoundary } from "../../components/utilities/error-boundary"
import { RouteExtension, RouteModule } from "../types"

/**
Expand Down Expand Up @@ -27,41 +28,43 @@ export const createRouteMap = (
const root: RouteObject[] = []

const addRoute = (
fullPath: string,
pathSegments: string[],
Component: ComponentType,
currentLevel: RouteObject[]
) => {
const pathSegments = fullPath.split("/").filter(Boolean)
let currentArray = currentLevel
if (!pathSegments.length) {
return
}

for (let i = 0; i < pathSegments.length; i++) {
const segment = pathSegments[i]
let route = currentArray.find((r) => r.path === segment)
const [currentSegment, ...remainingSegments] = pathSegments
let route = currentLevel.find((r) => r.path === currentSegment)

if (!route) {
route = {
path: segment,
lazy: async () => ({ Component }),
}
currentArray.push(route)
}
if (!route) {
route = { path: currentSegment, children: [] }
currentLevel.push(route)
}

if (i < pathSegments.length - 1) {
// This is not the last segment, so we need to move to the next level
if (!route.children) {
route.children = []
}
currentArray = route.children
}
if (remainingSegments.length === 0) {
route.children ||= []
route.children.push({
path: "",
ErrorBoundary: ErrorBoundary,
async lazy() {
return { Component }
},
})
} else {
route.children ||= []
addRoute(remainingSegments, Component, route.children)
}
}

routes.forEach(({ path, Component }) => {
// Remove the ignore segment from the path if it is provided
const cleanedPath = ignore
? path.replace(ignore, "").replace(/^\/+/, "")
: path.replace(/^\/+/, "")
addRoute(cleanedPath, Component, root)
const pathSegments = cleanedPath.split("/").filter(Boolean)
addRoute(pathSegments, Component, root)
})

return root
Expand Down
4 changes: 4 additions & 0 deletions packages/admin/dashboard/src/hooks/api/categories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ export const useUpdateProductCategoryProducts = (
queryKey: productsQueryKeys.lists(),
})

queryClient.invalidateQueries({
queryKey: productsQueryKeys.details(),
})

options?.onSuccess?.(data, variables, context)
},
...options,
Expand Down
Loading

0 comments on commit 7c97f90

Please sign in to comment.