Skip to content

Commit

Permalink
[docs] Remove redundant encoding in the mock data source server (mui#…
Browse files Browse the repository at this point in the history
  • Loading branch information
MBilalShafi authored Aug 13, 2024
1 parent 0c21145 commit 10d946e
Show file tree
Hide file tree
Showing 17 changed files with 57 additions and 89 deletions.
8 changes: 3 additions & 5 deletions docs/data/data-grid/server-side-data/ServerSideDataGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ function ServerSideDataGrid() {
() => ({
getRows: async (params) => {
const urlParams = new URLSearchParams({
paginationModel: encodeURIComponent(
JSON.stringify(params.paginationModel),
),
filterModel: encodeURIComponent(JSON.stringify(params.filterModel)),
sortModel: encodeURIComponent(JSON.stringify(params.sortModel)),
paginationModel: JSON.stringify(params.paginationModel),
filterModel: JSON.stringify(params.filterModel),
sortModel: JSON.stringify(params.sortModel),
});
const getRowsResponse = await fetchRows(
`https://mui.com/x/api/data-grid?${urlParams.toString()}`,
Expand Down
8 changes: 3 additions & 5 deletions docs/data/data-grid/server-side-data/ServerSideDataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ function ServerSideDataGrid() {
() => ({
getRows: async (params) => {
const urlParams = new URLSearchParams({
paginationModel: encodeURIComponent(
JSON.stringify(params.paginationModel),
),
filterModel: encodeURIComponent(JSON.stringify(params.filterModel)),
sortModel: encodeURIComponent(JSON.stringify(params.sortModel)),
paginationModel: JSON.stringify(params.paginationModel),
filterModel: JSON.stringify(params.filterModel),
sortModel: JSON.stringify(params.sortModel),
});
const getRowsResponse = await fetchRows(
`https://mui.com/x/api/data-grid?${urlParams.toString()}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ export default function ServerSideDataGridNoCache() {
() => ({
getRows: async (params) => {
const urlParams = new URLSearchParams({
paginationModel: encodeURIComponent(
JSON.stringify(params.paginationModel),
),
filterModel: encodeURIComponent(JSON.stringify(params.filterModel)),
sortModel: encodeURIComponent(JSON.stringify(params.sortModel)),
paginationModel: JSON.stringify(params.paginationModel),
filterModel: JSON.stringify(params.filterModel),
sortModel: JSON.stringify(params.sortModel),
});
const getRowsResponse = await fetchRows(
`https://mui.com/x/api/data-grid?${urlParams.toString()}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ export default function ServerSideDataGridNoCache() {
() => ({
getRows: async (params) => {
const urlParams = new URLSearchParams({
paginationModel: encodeURIComponent(
JSON.stringify(params.paginationModel),
),
filterModel: encodeURIComponent(JSON.stringify(params.filterModel)),
sortModel: encodeURIComponent(JSON.stringify(params.sortModel)),
paginationModel: JSON.stringify(params.paginationModel),
filterModel: JSON.stringify(params.filterModel),
sortModel: JSON.stringify(params.sortModel),
});
const getRowsResponse = await fetchRows(
`https://mui.com/x/api/data-grid?${urlParams.toString()}`,
Expand Down
8 changes: 3 additions & 5 deletions docs/data/data-grid/server-side-data/ServerSideDataGridTTL.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ function ServerSideDataGridTTL() {
() => ({
getRows: async (params) => {
const urlParams = new URLSearchParams({
paginationModel: encodeURIComponent(
JSON.stringify(params.paginationModel),
),
filterModel: encodeURIComponent(JSON.stringify(params.filterModel)),
sortModel: encodeURIComponent(JSON.stringify(params.sortModel)),
paginationModel: JSON.stringify(params.paginationModel),
filterModel: JSON.stringify(params.filterModel),
sortModel: JSON.stringify(params.sortModel),
});
const getRowsResponse = await fetchRows(
`https://mui.com/x/api/data-grid?${urlParams.toString()}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ function ServerSideDataGridTTL() {
() => ({
getRows: async (params) => {
const urlParams = new URLSearchParams({
paginationModel: encodeURIComponent(
JSON.stringify(params.paginationModel),
),
filterModel: encodeURIComponent(JSON.stringify(params.filterModel)),
sortModel: encodeURIComponent(JSON.stringify(params.sortModel)),
paginationModel: JSON.stringify(params.paginationModel),
filterModel: JSON.stringify(params.filterModel),
sortModel: JSON.stringify(params.sortModel),
});
const getRowsResponse = await fetchRows(
`https://mui.com/x/api/data-grid?${urlParams.toString()}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ export default function ServerSideErrorHandling() {
() => ({
getRows: async (params) => {
const urlParams = new URLSearchParams({
paginationModel: encodeURIComponent(
JSON.stringify(params.paginationModel),
),
filterModel: encodeURIComponent(JSON.stringify(params.filterModel)),
sortModel: encodeURIComponent(JSON.stringify(params.sortModel)),
paginationModel: JSON.stringify(params.paginationModel),
filterModel: JSON.stringify(params.filterModel),
sortModel: JSON.stringify(params.sortModel),
});
const getRowsResponse = await fetchRows(
`https://mui.com/x/api/data-grid?${urlParams.toString()}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,9 @@ export default function ServerSideErrorHandling() {
() => ({
getRows: async (params) => {
const urlParams = new URLSearchParams({
paginationModel: encodeURIComponent(
JSON.stringify(params.paginationModel),
),
filterModel: encodeURIComponent(JSON.stringify(params.filterModel)),
sortModel: encodeURIComponent(JSON.stringify(params.sortModel)),
paginationModel: JSON.stringify(params.paginationModel),
filterModel: JSON.stringify(params.filterModel),
sortModel: JSON.stringify(params.sortModel),
});
const getRowsResponse = await fetchRows(
`https://mui.com/x/api/data-grid?${urlParams.toString()}`,
Expand Down
10 changes: 4 additions & 6 deletions docs/data/data-grid/server-side-data/ServerSideTreeData.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ export default function ServerSideTreeData() {
() => ({
getRows: async (params) => {
const urlParams = new URLSearchParams({
paginationModel: encodeURIComponent(
JSON.stringify(params.paginationModel),
),
filterModel: encodeURIComponent(JSON.stringify(params.filterModel)),
sortModel: encodeURIComponent(JSON.stringify(params.sortModel)),
groupKeys: encodeURIComponent(JSON.stringify(params.groupKeys)),
paginationModel: JSON.stringify(params.paginationModel),
filterModel: JSON.stringify(params.filterModel),
sortModel: JSON.stringify(params.sortModel),
groupKeys: JSON.stringify(params.groupKeys),
});
const getRowsResponse = await fetchRows(
`https://mui.com/x/api/data-grid?${urlParams.toString()}`,
Expand Down
10 changes: 4 additions & 6 deletions docs/data/data-grid/server-side-data/ServerSideTreeData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ export default function ServerSideTreeData() {
() => ({
getRows: async (params) => {
const urlParams = new URLSearchParams({
paginationModel: encodeURIComponent(
JSON.stringify(params.paginationModel),
),
filterModel: encodeURIComponent(JSON.stringify(params.filterModel)),
sortModel: encodeURIComponent(JSON.stringify(params.sortModel)),
groupKeys: encodeURIComponent(JSON.stringify(params.groupKeys)),
paginationModel: JSON.stringify(params.paginationModel),
filterModel: JSON.stringify(params.filterModel),
sortModel: JSON.stringify(params.sortModel),
groupKeys: JSON.stringify(params.groupKeys),
});
const getRowsResponse = await fetchRows(
`https://mui.com/x/api/data-grid?${urlParams.toString()}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,10 @@ export default function ServerSideTreeDataCustomCache() {
() => ({
getRows: async (params) => {
const urlParams = new URLSearchParams({
paginationModel: encodeURIComponent(
JSON.stringify(params.paginationModel),
),
filterModel: encodeURIComponent(JSON.stringify(params.filterModel)),
sortModel: encodeURIComponent(JSON.stringify(params.sortModel)),
groupKeys: encodeURIComponent(JSON.stringify(params.groupKeys)),
paginationModel: JSON.stringify(params.paginationModel),
filterModel: JSON.stringify(params.filterModel),
sortModel: JSON.stringify(params.sortModel),
groupKeys: JSON.stringify(params.groupKeys),
});
const getRowsResponse = await fetchRows(
`https://mui.com/x/api/data-grid?${urlParams.toString()}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,10 @@ export default function ServerSideTreeDataCustomCache() {
() => ({
getRows: async (params) => {
const urlParams = new URLSearchParams({
paginationModel: encodeURIComponent(
JSON.stringify(params.paginationModel),
),
filterModel: encodeURIComponent(JSON.stringify(params.filterModel)),
sortModel: encodeURIComponent(JSON.stringify(params.sortModel)),
groupKeys: encodeURIComponent(JSON.stringify(params.groupKeys)),
paginationModel: JSON.stringify(params.paginationModel),
filterModel: JSON.stringify(params.filterModel),
sortModel: JSON.stringify(params.sortModel),
groupKeys: JSON.stringify(params.groupKeys),
});
const getRowsResponse = await fetchRows(
`https://mui.com/x/api/data-grid?${urlParams.toString()}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ export default function ServerSideTreeDataErrorHandling() {
() => ({
getRows: async (params) => {
const urlParams = new URLSearchParams({
paginationModel: encodeURIComponent(
JSON.stringify(params.paginationModel),
),
filterModel: encodeURIComponent(JSON.stringify(params.filterModel)),
sortModel: encodeURIComponent(JSON.stringify(params.sortModel)),
groupKeys: encodeURIComponent(JSON.stringify(params.groupKeys)),
paginationModel: JSON.stringify(params.paginationModel),
filterModel: JSON.stringify(params.filterModel),
sortModel: JSON.stringify(params.sortModel),
groupKeys: JSON.stringify(params.groupKeys),
});
const getRowsResponse = await fetchRows(
`https://mui.com/x/api/data-grid?${urlParams.toString()}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ export default function ServerSideTreeDataErrorHandling() {
() => ({
getRows: async (params) => {
const urlParams = new URLSearchParams({
paginationModel: encodeURIComponent(
JSON.stringify(params.paginationModel),
),
filterModel: encodeURIComponent(JSON.stringify(params.filterModel)),
sortModel: encodeURIComponent(JSON.stringify(params.sortModel)),
groupKeys: encodeURIComponent(JSON.stringify(params.groupKeys)),
paginationModel: JSON.stringify(params.paginationModel),
filterModel: JSON.stringify(params.filterModel),
sortModel: JSON.stringify(params.sortModel),
groupKeys: JSON.stringify(params.groupKeys),
});
const getRowsResponse = await fetchRows(
`https://mui.com/x/api/data-grid?${urlParams.toString()}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ export default function ServerSideTreeDataGroupExpansion() {
() => ({
getRows: async (params) => {
const urlParams = new URLSearchParams({
paginationModel: encodeURIComponent(
JSON.stringify(params.paginationModel),
),
filterModel: encodeURIComponent(JSON.stringify(params.filterModel)),
sortModel: encodeURIComponent(JSON.stringify(params.sortModel)),
groupKeys: encodeURIComponent(JSON.stringify(params.groupKeys)),
paginationModel: JSON.stringify(params.paginationModel),
filterModel: JSON.stringify(params.filterModel),
sortModel: JSON.stringify(params.sortModel),
groupKeys: JSON.stringify(params.groupKeys),
});
const getRowsResponse = await fetchRows(
`https://mui.com/x/api/data-grid?${urlParams.toString()}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ export default function ServerSideTreeDataGroupExpansion() {
() => ({
getRows: async (params) => {
const urlParams = new URLSearchParams({
paginationModel: encodeURIComponent(
JSON.stringify(params.paginationModel),
),
filterModel: encodeURIComponent(JSON.stringify(params.filterModel)),
sortModel: encodeURIComponent(JSON.stringify(params.sortModel)),
groupKeys: encodeURIComponent(JSON.stringify(params.groupKeys)),
paginationModel: JSON.stringify(params.paginationModel),
filterModel: JSON.stringify(params.filterModel),
sortModel: JSON.stringify(params.sortModel),
groupKeys: JSON.stringify(params.groupKeys),
});
const getRowsResponse = await fetchRows(
`https://mui.com/x/api/data-grid?${urlParams.toString()}`,
Expand Down
2 changes: 1 addition & 1 deletion packages/x-data-grid-generator/src/hooks/useMockServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function decodeParams(url: string): GridGetRowsParams {

for (const [key, value] of array) {
try {
decodedParams[key] = JSON.parse(decodeURIComponent(value));
decodedParams[key] = JSON.parse(value);
} catch (e) {
decodedParams[key] = value;
}
Expand Down

0 comments on commit 10d946e

Please sign in to comment.