[FEATURE/BREAKINGCHANGE] DataQueriesProvider: use full queryDefinitions + remove QueryCountProvider + add edit query name in QueryEditorContainer#69
Conversation
38ae3b3 to
60437f2
Compare
cdab1e5 to
e170f4c
Compare
…ns + remove QueryCountProvider + add edit query name in QueryEditorContainer Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
|
@jgbernalp If you have any opinion about this breaking change, else I proceed with merge :) |
There was a problem hiding this comment.
Pull request overview
This PR introduces breaking changes to the query runtime API by switching DataQueriesProvider to consume full QueryDefinition objects (instead of plugin Definitions), removing QueryCountProvider/useQueryType, and adds UI support for editing query names in QueryEditorContainer with an explicit edit/submit flow to avoid noisy re-renders.
Changes:
- Update
DataQueriesProviderto accept/store fullQueryDefinitions and expose them via context (enabling query count retrieval without a separate provider). - Remove
QueryCountProviderexports and related wiring. - Add query-name utilities and implement editable query names in
QueryEditorContainer.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| plugin-system/src/runtime/QueryCountProvider.tsx | Removes the QueryCount context/provider (breaking change). |
| plugin-system/src/runtime/index.ts | Stops exporting QueryCountProvider. |
| plugin-system/src/runtime/DataQueriesProvider/model.ts | Updates provider props/context types to use full QueryDefinitions; removes useQueryType. |
| plugin-system/src/runtime/DataQueriesProvider/DataQueriesProvider.tsx | Uses full QueryDefinitions directly; exposes queryDefinitions in context and filters by query type. |
| plugin-system/src/runtime/DataQueriesProvider/DataQueriesProvider.test.tsx | Updates tests to the new QueryDefinition shape and removes useQueryType tests. |
| plugin-system/src/components/PanelSpecEditor/PanelSpecEditor.tsx | Removes QueryCountProvider wrapper usage. |
| plugin-system/src/components/PanelSpecEditor/PanelSpecEditor.test.tsx | Updates mocked DataQueries context to include queryDefinitions. |
| plugin-system/src/components/MultiQueryEditor/utils.tsx | Adds helpers for default/query names (new export). |
| plugin-system/src/components/MultiQueryEditor/QueryEditorContainer.tsx | Adds UI/state for editing query names with save/cancel. |
| plugin-system/src/components/MultiQueryEditor/index.tsx | Exports the new query-name utilities. |
| dashboards/src/components/PanelDrawer/PanelQueriesSharedControls.tsx | Updates preview definitions to use full QueryDefinitions (no more mapping to plugin-only definitions). |
| dashboards/src/components/GridLayout/GridItemContent.tsx | Passes full query definitions into DataQueriesProvider and QueryViewerDialog. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const [isEditingName, setIsEditingName] = useState(false); | ||
| const [name, setName] = useState(query.spec.name ?? defaultQueryName(index)); | ||
|
|
||
| function handleNameChange(): void { | ||
| setIsEditingName(false); | ||
| onChange( | ||
| index, | ||
| produce(query, (draft) => { | ||
| draft.spec.name = name; | ||
| }) | ||
| ); | ||
| } | ||
|
|
||
| function handleNameCancel(): void { | ||
| setName(query.spec.name ?? defaultQueryName(index)); | ||
| setIsEditingName(false); | ||
| } |
| <TextField | ||
| size="small" | ||
| variant="outlined" | ||
| value={name} | ||
| onChange={(e) => setName(e.target.value)} | ||
| fullWidth={true} | ||
| InputProps={{ | ||
| endAdornment: ( | ||
| <InputAdornment position="end"> | ||
| <IconButton size="small" aria-label="cancel edit" onClick={handleNameCancel} edge="end"> | ||
| <CloseIcon /> | ||
| </IconButton> | ||
| <IconButton size="small" aria-label="save query name" onClick={handleNameChange} edge="end"> | ||
| <CheckIcon /> | ||
| </IconButton> | ||
| </InputAdornment> | ||
| ), | ||
| }} | ||
| /> | ||
| ) : ( | ||
| <Typography variant="overline" component="h4"> | ||
| {name} | ||
| </Typography> |
|
if there is an assuming breaking change. Can you please provide the migration plan please @Gladorme ? |
|
DataQueriesProvider: need full query definitions instead of just definition (Definition => QueryDefinition) Migration should be easy, because Definition is often calculated from QueryDefinition. Worst case: Before: export function TestComponent(props: TestComponentProps): ReactElement {
...
const definitions = [
{
kind: 'PrometheusTimeSeriesQuery',
spec: {
datasource: datasource,
query: expr,
},
},
];
return (
<DataQueriesProvider definitions={definitions}>
{/* ... */}
</DataQueriesProvider>
)
}After: export function TestComponent(props: TestComponentProps): ReactElement {
...
const queryDefinitions = [
{
kind: 'TimeSeriesQuery',
spec: {
plugin: {
kind: 'PrometheusTimeSeriesQuery',
spec: {
datasource: datasource,
query: expr,
},
},
},
},
];
return (
<DataQueriesProvider definitions={queryDefinitions}>
{/* ... */}
</DataQueriesProvider>
)
} |

Description
Depends on: perses/perses#3915
This PR is doing some breaking changes:
This PR allow user to edit query names, using a self edit/submit button in order to not spam rerender when updating it
Migration should be easy, because Definition is often calculated from QueryDefinition. Worst case:
Before:
After:
Screenshots
On edit:

Checklist
[<catalog_entry>] <commit message>naming convention using one of thefollowing
catalog_entryvalues:FEATURE,ENHANCEMENT,BUGFIX,BREAKINGCHANGE,DOC,IGNORE.UI Changes
See e2e docs for more details. Common issues include: