-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[DataGridPremium] Prompt input control #15401
Conversation
Localization writing tips ✍️Seems you are updating localization 🌍 files. Thank you for contributing to the localization! 🎉 To make your PR perfect, here is a list of elements to check: ✔️
Deploy preview: https://deploy-preview-15401--material-ui-x.netlify.app/ Updated pages: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick look
packages/x-data-grid-premium/src/components/promptControl/GridToolbarPromptControl.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-premium/src/components/promptControl/GridToolbarPromptControl.tsx
Show resolved
Hide resolved
packages/x-data-grid-premium/src/components/promptControl/RecordButton.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-premium/src/components/promptControl/RecordButton.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-premium/src/hooks/features/promptControl/api.ts
Outdated
Show resolved
Hide resolved
packages/x-data-grid-premium/src/hooks/features/promptControl/api.ts
Outdated
Show resolved
Hide resolved
packages/x-data-grid-premium/src/components/promptControl/GridToolbarPromptControl.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-premium/src/components/promptControl/GridToolbarPromptControl.tsx
Show resolved
Hide resolved
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
2044401
to
7398b1d
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
0151c49
to
892e9b3
Compare
packages/x-data-grid-premium/src/components/promptControl/GridToolbarPromptControl.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-premium/src/components/promptControl/GridToolbarPromptControl.tsx
Outdated
Show resolved
Hide resolved
allowedOperators: column.filterOperators?.map((operator) => operator.value) ?? [], | ||
})); | ||
|
||
return `${apiRef.current.getLocaleText('toolbarPromptControlColumnsContextIntro')}\n${JSON.stringify(columnsContext)}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use a locale text here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a static text providing some context for the columns. I was thinking that, in case someone uses a model in another language, they will need a different string here.
This is the english string used here
The columns are described by the following JSON:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I wonder if the language matters in this context 🤔
@romgrk What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After checking this, I see that this part ends up as a system input in our backend which is in english.
I will do some testing to see if the languages can be mixed. For now, this string will not be translatable
packages/x-data-grid-premium/src/components/promptControl/RecordButton.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-premium/src/components/promptControl/RecordButton.tsx
Outdated
Show resolved
Hide resolved
83ee52d
to
1fe6121
Compare
<Stack flex={1} gap={0.5} sx={{ px: 0.5 }}> | ||
<GridToolbar /> | ||
<Box sx={{ px: 0.5 }}> | ||
<GridToolbarPromptControl onPrompt={mockPromptResolver} allowDataSampling /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we need a special prompt resolver mock for this demo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated mock server to return the same data set as in the other examples
But there is another issue that we have to resolve
once the prompt response is there it triggers couple of updates at once, which triggers a couple of events
data source reacts to all of them separately, so it makes a few requests at once and the last response may not be the last update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this the same issue as #13878 (comment) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but apart from addressing the race condition I have added a point to support handling all of the prompt response changes with one additional request
packages/x-data-grid-premium/src/components/promptControl/RecordButton.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-premium/src/components/promptControl/RecordButton.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work 👏
I added a few minor comments/suggestions, apart from that it LGTM.
GridToolbar, | ||
} from '@mui/x-data-grid-premium'; | ||
import { | ||
mockPromptResolver, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In context to the discoverability issue people face with the utilities hidden behind a package, would it be feasible to make mockPromptResolver
part of each demo instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure how much of a difference it would make, since you don't have to change/extend anything from it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the users have to implement their own function similar to this, having the code readily available will give them an idea how it works. We could handle it as a follow-up too.
packages/x-data-grid-premium/src/components/promptControl/GridToolbarPromptControl.tsx
Outdated
Show resolved
Hide resolved
const interestColumns = [] as string[]; | ||
|
||
apiRef.current.setFilterModel({ | ||
items: result.filters.map((filter, index) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about expecting the same naming and structure in result.x
as the respective state model.
For example result.filterModel
instead of result.filters
?
Or the aim is to be generic here?
packages/x-data-grid-premium/src/components/promptControl/GridToolbarPromptControl.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-premium/src/components/promptControl/GridToolbarPromptControl.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-premium/src/components/promptControl/GridToolbarPromptControl.tsx
Outdated
Show resolved
Hide resolved
|
||
export type PromptResponse = { | ||
select: number; | ||
filters: Filter[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we keep it aligned with GridFilterModel
to keep the possibilities such as the following open:
// Search all the data for a text containing "John" or "Abraham"
filterModel = {
items: [],
quickFilterLogicOperator: GridLogicOperator.Or,
quickFilterValues: ["John", "Abraham"],
}
filters: Filter[]; | |
filterModel: GridFilterModel; |
May apply to other models similarly too. Wdyt?
aggregation: Aggregation; | ||
sorting: Sort[]; | ||
grouping: Grouping[]; | ||
error: string | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is meant to show a custom error below the prompt input field, right?
9f62076
to
2cc82fc
Compare
Co-authored-by: Andrew Cherniavskii <andrew.cherniavskii@gmail.com> Signed-off-by: Armin Mehinovic <4390250+arminmeh@users.noreply.github.com>
Co-authored-by: Bilal Shafi <bilalshafidev@gmail.com> Signed-off-by: Armin Mehinovic <4390250+arminmeh@users.noreply.github.com>
2cc82fc
to
45b5ea9
Compare
Merging this for the next alpha release |
Signed-off-by: Armin Mehinovic <4390250+arminmeh@users.noreply.github.com> Co-authored-by: Rom Grk <romgrk.cc@gmail.com> Co-authored-by: Kenan Yusuf <kenan.m.yusuf@gmail.com> Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com> Co-authored-by: Andrew Cherniavskii <andrew.cherniavskii@gmail.com> Co-authored-by: Bilal Shafi <bilalshafidev@gmail.com>
Todo:
Follow up issue
Preview: https://deploy-preview-15401--material-ui-x.netlify.app/x/react-data-grid/prompt/