Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Upgrade Material IU to v6 #6490

Open
wants to merge 32 commits into
base: releases/december-2024
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
370722c
feat: update material ui to 6
alicanerdurmaz Nov 13, 2024
f51abc6
Merge branch 'master' into RK-798-refine-mui-6-upgrade
alicanerdurmaz Nov 13, 2024
130faa5
fix(docs): typo
alicanerdurmaz Nov 13, 2024
a8bbc70
fix(inferencer): remove debug script
alicanerdurmaz Nov 13, 2024
1f65aa8
feat: update @mui/x-data-grid to 7
alicanerdurmaz Nov 15, 2024
599cf09
Merge branch 'master' into RK-798-refine-mui-6-upgrade
alicanerdurmaz Nov 15, 2024
8b3cf2f
test(inferencer): update snapshots
alicanerdurmaz Nov 15, 2024
ba002de
test(mui): fix type error
alicanerdurmaz Nov 15, 2024
e9f33d3
test: fix cypress errors
alicanerdurmaz Nov 15, 2024
561cfae
test: fix cypress errors
alicanerdurmaz Nov 15, 2024
7badd80
test: fix cypress errors
alicanerdurmaz Nov 15, 2024
d2b7c1b
test: fix cypress errors
alicanerdurmaz Nov 18, 2024
0629309
docs: add migration guide for material ui v6 and x data grid v7
alicanerdurmaz Nov 18, 2024
f2590d4
chore: revert unrelated changes
alicanerdurmaz Nov 18, 2024
4c77723
chore: update mui grid blog
alicanerdurmaz Nov 18, 2024
237e781
chore: add changeset
alicanerdurmaz Nov 18, 2024
9ecbd45
fix(docs): redirect
alicanerdurmaz Nov 18, 2024
908363b
fix(docs): redirection
alicanerdurmaz Nov 18, 2024
5847c5b
chore: bumb @mui/material version
alicanerdurmaz Nov 19, 2024
1433ac2
test(table-material-ui-advanced): add more test
alicanerdurmaz Nov 19, 2024
0a6a20a
feat(mui): remove deprecated components
alicanerdurmaz Nov 20, 2024
90fc213
fix(mui): mui examples
alicanerdurmaz Nov 20, 2024
ffd0d35
test(table-material-ui-advanced): add more test
alicanerdurmaz Nov 20, 2024
0efde6c
Merge branch 'master' into RK-798-refine-mui-6-upgrade
alicanerdurmaz Nov 21, 2024
3e9cc9e
feat(examples): replace deprecated sider component
alicanerdurmaz Nov 21, 2024
a09612b
feat(mui): add more test
alicanerdurmaz Nov 21, 2024
32e4295
fix(mui): test
alicanerdurmaz Nov 21, 2024
cbeb3df
feat(mui): use ref instead of state for columnsTypes
alicanerdurmaz Nov 21, 2024
36e6a37
feat(finefoods-material-ui): change column type
alicanerdurmaz Nov 22, 2024
5fb7a88
revert(mui): tsup changes
alicanerdurmaz Nov 22, 2024
5d8efa8
revert(finefoods-material-ui): debug code
alicanerdurmaz Nov 22, 2024
8599036
Merge branch 'releases/december-2024' into RK-798-refine-mui-6-upgrade
alicanerdurmaz Nov 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .changeset/chilly-lobsters-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
"@refinedev/inferencer": major
---

feat: added support for Material UI v6 and X Data Grid v7

```diff
- "@mui/icons-material": "^5.8.3",
+ "@mui/icons-material": "^6.1.6",
- "@mui/lab": "^5.0.0-alpha.85",
+ "@mui/lab": "^6.0.0-beta.14",
- "@mui/material": "^5.14.2",
+ "@mui/material": "^6.1.7",

- "@mui/x-data-grid": "^6.6.0",
+ "@mui/x-data-grid": "^7.22.2",
```

Here is the updated version alignment:

| @refinedev/mui | @mui/x-data-grid | @mui/material | @mui/system | @mui/lab | @mui/icons-material | @refinedev/inferencer |
| -------------- | ---------------- | ------------- | ----------- | -------- | ------------------- | --------------------- |
| 5.x.x | 6.x.x | 5.x.x | 5.x.x | 5.x.x | 5.x.x | 4.x.x |
| 6.x.x | 7.x.x | 6.x.x | 6.x.x | 6.x.x | 6.x.x | 5.x.x |

Please refer to the [Migration Guide for Material UI v6 and X Data Grid v7](https://refine.dev/docs/ui-integrations/material-ui/migration-guide/material-ui-v5-to-v6) for more information.
28 changes: 28 additions & 0 deletions .changeset/rare-actors-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
"@refinedev/mui": major
---

feat: added support for Material UI v6 and X Data Grid v7 #6333

```diff
- "@mui/icons-material": "^5.8.3",
+ "@mui/icons-material": "^6.1.6",
- "@mui/lab": "^5.0.0-alpha.85",
+ "@mui/lab": "^6.0.0-beta.14",
- "@mui/material": "^5.14.2",
+ "@mui/material": "^6.1.7",

- "@mui/x-data-grid": "^6.6.0",
+ "@mui/x-data-grid": "^7.22.2",
```

Here is the updated version alignment:

| @refinedev/mui | @mui/x-data-grid | @mui/material | @mui/system | @mui/lab | @mui/icons-material | @refinedev/inferencer |
| -------------- | ---------------- | ------------- | ----------- | -------- | ------------------- | --------------------- |
| 5.x.x | 6.x.x | 5.x.x | 5.x.x | 5.x.x | 5.x.x | 4.x.x |
| 6.x.x | 7.x.x | 6.x.x | 6.x.x | 6.x.x | 6.x.x | 5.x.x |

Please refer to the [Migration Guide for Material UI v6 and X Data Grid v7](https://refine.dev/docs/ui-integrations/material-ui/migration-guide/material-ui-v5-to-v6) for more information.

Resolves [#6333](https://github.com/refinedev/refine/issues/6333)
2 changes: 0 additions & 2 deletions cypress/e2e/form-material-ui-use-drawer-form/all.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,12 @@ describe("form-material-ui-use-drawer-form", () => {
"modal-posts-create[open]=true",
);
});

it("should create record", () => {
cy.getCreateButton().click();
isDrawerOpen();

fillForm();
submitForm();
cy.getSaveButton().should("be.disabled");

cy.wait("@postPost").then((interception) => {
const response = interception?.response;
Expand Down
88 changes: 72 additions & 16 deletions cypress/e2e/table-material-ui-advanced/data-grid.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,89 @@ describe("table-material-ui-advanced", () => {
});

it("should work with filter", () => {
// wait for loading
cy.wait("@getPosts");
cy.getMaterialUILoadingCircular().should("not.exist");

// open the column menu of title
cy.getMaterialUIColumnHeader(2).within(() =>
cy.get(".MuiDataGrid-menuIcon > button").click({ force: true }),
);

// click the filter menu item
cy.get(".MuiDataGrid-menu > div > .MuiList-root").children().eq(3).click();

cy.intercept(
{
url: "/posts*",
query: {
title_like: "lorem",
},
},
{
fixture: "posts.json",
},
).as("getFilteredPosts");

// type the filter value
cy.get("[placeholder='Filter value']").type("lorem");

// url should contain the filter
cy.url().should(
"include",
"filters[0][field]=title&filters[0][value]=lorem&filters[0][operator]=contains",
);
// request should have filter
cy.wait("@getPosts").then((interception) => {
const request = interception.request;
const query = request.query;
expect(query.title_like).to.eq("lorem");
});

// simulate outside click to close the filter dialog
cy.get(".MuiCardHeader-content > .MuiTypography-root").click();

// open the column menu of status
cy.getMaterialUIColumnHeader(4).within(() =>
cy.get(".MuiDataGrid-menuIcon > button").click({ force: true }),
);
// click the filter menu item
cy.get(".MuiDataGrid-menu > div > .MuiList-root").children().eq(3).click();
// opening the filter dialog resets filters. we need to wait for again
cy.wait("@getPosts");
// open select menu
cy.get(".MuiFormLabel-root").contains("Value").siblings().first().click();
// select the filter value
cy.get(".MuiMenuItem-root[data-value='published']").click();
// url should contain the filter
cy.url().should(
"include",
"filters[0][field]=status&filters[0][value]=published&filters[0][operator]=eq",
);
// request should have filter
cy.wait("@getPosts").then((interception) => {
const request = interception.request;
const query = request.query;
expect(query.status).to.eq("published");
});
});

it("should work with sorters", () => {
// wait for loading
cy.wait("@getPosts");
cy.getMaterialUILoadingCircular().should("not.exist");

cy.wait("@getFilteredPosts");
// click the ID column header to sort ascending
cy.get(".MuiDataGrid-columnHeaderTitle").contains("ID").click();
cy.url().should("include", "sorters[0][field]=id&sorters[0][order]=asc");
cy.wait("@getPosts").then((interception) => {
const request = interception.request;
const query = request.query;
expect(query._sort).to.eq("id");
expect(query._order).to.eq("asc");
});
// click the ID column header to sort descending
cy.get(".MuiDataGrid-columnHeaderTitle").contains("ID").click();
cy.url().should("include", "sorters[0][field]=id&sorters[0][order]=desc");
cy.wait("@getPosts").then((interception) => {
const request = interception.request;
const query = request.query;
expect(query._sort).to.eq("id");
expect(query._order).to.eq("desc");
});
// click to remove
cy.get(".MuiDataGrid-columnHeaderTitle").contains("ID").click();
cy.url().should("not.include", "sorters[0][field]=id");
cy.wait("@getPosts").then((interception) => {
const request = interception.request;
const query = request.query;
expect(query._sort).to.be.undefined;
expect(query._order).to.be.undefined;
});
});
});
148 changes: 82 additions & 66 deletions cypress/e2e/table-material-ui-data-grid-pro/all.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,101 +3,117 @@

describe("table-material-ui-data-grid-pro", () => {
beforeEach(() => {
cy.interceptGETPosts();
cy.visit("/");
});

it("should work with sorter", () => {
cy.wait("@getPosts");
cy.getMaterialUILoadingCircular().should("not.exist");

cy.intercept(
{
url: "/posts*",
query: {
_sort: "title",
_order: "desc",
},
},
{
fixture: "posts.json",
},
).as("getDescPosts");

// sort by title
cy.getMaterialUIColumnHeader(2).click();
// url should contain the sorter with asc
cy.url().should("include", "sorters[0][field]=title&sorters[0][order]=asc");
// request should have sorter
cy.wait("@getPosts").then((interception) => {
const request = interception.request;
const query = request.query;
expect(query._sort).to.eq("title");
expect(query._order).to.eq("asc");
});

cy.url().should(
"include",
"sorters[0][field]=title&sorters[0][order]=desc",
);

cy.wait("@getDescPosts");

cy.interceptGETPosts();

// click the title column header again to sort desc
cy.getMaterialUIColumnHeader(2).click();

// url should contain the sorter with desc
cy.url().should(
"not.include",
"include",
"sorters[0][field]=title&sorters[0][order]=desc",
);

cy.wait("@getPosts").then((interception) => {
const { request } = interception;
const { _sort, _order } = request.query;

expect(_sort).to.undefined;
expect(_order).to.undefined;
const request = interception.request;
const query = request.query;
expect(query._sort).to.eq("title");
expect(query._order).to.eq("desc");
});

cy.intercept(
{
url: "/posts*",
query: {
_sort: "title",
_order: "asc",
},
},
{
fixture: "posts.json",
},
).as("getAscPosts");

// click again to remove the sorter
cy.getMaterialUIColumnHeader(2).click();

cy.url().should("include", "sorters[0][field]=title&sorters[0][order]=asc");

cy.wait("@getAscPosts", { timeout: 120000 });
cy.url().should("not.include", "sorters[0][field]=title");
cy.wait("@getPosts").then((interception) => {
const request = interception.request;
const query = request.query;
expect(query._sort).to.be.undefined;
expect(query._order).to.be.undefined;
});
});

it("should work with filter", () => {
it("should work with multiple filter", () => {
// wait for loading
cy.wait("@getPosts");
cy.getMaterialUILoadingCircular().should("not.exist");

// open the column menu of title
cy.getMaterialUIColumnHeader(2).within(() =>
cy.get(".MuiDataGrid-menuIcon > button").click({ force: true }),
);

cy.get(".MuiList-root").children().eq(7).click();

// click the filter menu item
cy.contains("Filter").click();
// type the filter value
cy.get("[placeholder='Filter value']").type("lorem");
// url should contain the filter
cy.url().should(
"include",
"filters[0][field]=title&filters[0][value]=lorem&filters[0][operator]=contains",
);
// request should have filter
cy.wait("@getPosts").then((interception) => {
const request = interception.request;
const query = request.query;
expect(query.title_like).to.eq("lorem");
});

cy.intercept(
{
url: "/posts*",
query: {
title_like: "lorem",
},
},
{
fixture: "posts.json",
},
).as("getFilteredPosts");

cy.get("[placeholder='Filter value']").eq(1).clear().type("lorem");
// simulate outside click to close the filter dialog
cy.get(".MuiCardHeader-content > .MuiTypography-root").click();

// open the column menu of status
cy.getMaterialUIColumnHeader(4).within(() =>
cy.get(".MuiDataGrid-menuIcon > button").click({ force: true }),
);
// click the filter menu item
cy.contains("Filter").click();
// open select menu
cy.get(".MuiFormLabel-root").last().siblings().first().click();
// select the filter value
cy.get(".MuiMenuItem-root[data-value='published']").click();
// url should contain the filter
cy.url().should(
"include",
"filters[1][field]=title&filters[1][value]=lorem&filters[1][operator]=contains",
"filters[1][field]=status&filters[1][value]=published&filters[1][operator]=eq",
);
// request should have filter
cy.wait("@getPosts").then((interception) => {
const request = interception.request;
const query = request.query;
expect(query.title_like).to.eq("lorem");
expect(query.status).to.eq("published");
});

cy.wait("@getFilteredPosts");
// reload the page and check if the filters are still there
cy.reload();
cy.wait("@getPosts").then((interception) => {
const request = interception.request;
const query = request.query;
expect(query.title_like).to.eq("lorem");
expect(query.status).to.eq("published");
});
cy.url().should(
"include",
"filters[0][field]=title&filters[0][value]=lorem&filters[0][operator]=contains",
);
cy.url().should(
"include",
"filters[1][field]=status&filters[1][value]=published&filters[1][operator]=eq",
);
});
});
Loading
Loading