[RFC] Dashboard/CRUD framework #3311
Janpot
announced in
Early feedback
Replies: 1 comment
-
Hey! This looks great, the CRUD reminds me of Refine.dev which can be a good influence for this use-case. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Which problem do we want to solve?
How will we solve it?
CrudPage
component that encapsulates routing, filtering, editing, deep linking.The DataProvider interface
To create a data provider, the user has to implement a minimal interface
getMany
and afields
property.createDataProvider
function and are always top-level values. Components in the page will assume they are referentially stable.Data components
We will provide versions of the X
DataGrid
,LineChart
,BarChart
,… components that take adataProvider
as a prop and that initialize the component with loading and error handling, and sensible defaults for columns, series, axes, legends,… All these defaults can be overwritten with the corresponding props in the original X component.e.g.
When CRUD methods are provided we will make the grid editable and automatically call those methods after the user made the CRUD interaction.
DataContext
This binds a data provider to a filter for its subtree:
This allows for sharing filters between data display components.
Persistent state hooks
To make it more straightforward to store filter state of the dashboard in the url, We will provide state hooks that automatically sync with a query parameter:
We will provide:
useSearchParameterState
: for syncing with a query parameter in the urluseLocalStorageState
: for syncing with a value in local storageuseSessionsStorageState
: for syncing with a value in session storageThe hook will take a
codec
parameter which is responsible for parsing/stringifying the values before persisting. We will provide a set of codecs for common data types.It will also be possible to support more complex use-cases by providing your own custom codec. Or to create a codec based on a schema (e.g.
zod
)We will make sure to guarantee in typescript a strong relationship between the
state
,setState
types and the codec.Demo: npm downloads
npmStats.mov
source: https://github.com/Janpot/dashboard-framework-prototype/tree/master/src/app/npm-stats
live: https://dashboard-framework-prototype.vercel.app/npm-stats
Demo: weather dashboard
Here's a simple dashboard that crunches some weather forecast data, and all the code for it:
weather.mov
CRUD pages
The concept of data providers starts from the data, and can therefore be reused, not only to augment the existing X components, but also to create rich data interaction components.
This component, when rendered in a Next.js dynamic route, will provide pages
/myData
: lists the content of the data provider/myData/new
: form to create a new record/myData/show/:id
: shows record withid
. This page has edit and delete buttons/myData/edit/:id
: edit form for record withid
We will centralize validation for the records in the data provider and have that reused for both the create and edit flow.
Demo
Here's a demo of all the functionality that this component would enable:
crudPage.mov
Note: we use the
/show/
and/edit/
prefixes to avoid:id
clashing with the/new
routeCustomization
We will provide a set of hooks to support interacting with the data providers:
These hooks will also be aware of the data context and automatically apply the filter
License
As we're wrapping MUI X components, we'll have to consider licensing. We'll provide two packages:
@toolpad/core
: contains all the free code. it'll export all the MIT licensed APIs and components@toolpad/enterprise
: contains all the commercial code. It'll export wrappedDataGridPro
andDataGridPremium
. To use these exports, the user will require a corresponding MUI X license.Prototypes
We have prototyped examples for some of the components:
source: https://github.com/Janpot/dashboard-framework-prototype/tree/master/src/app/forecast
live: https://dashboard-framework-prototype.vercel.app/forecast
source: https://github.com/Janpot/dashboard-framework-prototype/tree/master/src/app/npm-stats
live: https://dashboard-framework-prototype.vercel.app/npm-stats
source: https://github.com/Janpot/dashboard-framework-prototype/tree/master/src/app/crud
live: https://dashboard-framework-prototype.vercel.app/crud
Our Vision
The mission at MUI is to enable developers to build beautiful apps fast. To contribute to that, our vision in the Toolpad team is to create a product that is code-first, with pluggable low-code features. Think: developers building dashboards and internal tools super-fast with code, and non-devs being able to use UIs for configuration and access management. All in code that you own!
Beta Was this translation helpful? Give feedback.
All reactions