-
Notifications
You must be signed in to change notification settings - Fork 61
[ENHANCEMENT] TimeSeriesChart: add query name support for query settings #585
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
2f19a36
71e2bb7
59cbfe1
7b238ae
eb2f80f
2aa0ea3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,7 +40,7 @@ export interface TimeSeriesChartOptions { | |
| } | ||
|
|
||
| export interface QuerySettingsOptions { | ||
| queryIndex: number; | ||
| queryName: string; | ||
| colorMode?: 'fixed' | 'fixed-single'; | ||
| colorValue?: string; | ||
| lineStyle?: LineStyleType; | ||
|
Comment on lines
42
to
50
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand that from the backend perspective a queryName?: strings.MinRunes(1)However, from the UI perspective this field looks mandatory and there is no way to drop it. This means that from UI we could still keep it as a none-optional field.
The fact that we could have empty object query settings is not a good idea in my opinion, although from the UI a export interface QuerySettingsOptions {
queryName?: string;
/**
* @deprecated Use `queryName` instead.
*/
queryIndex?: number;
colorMode?: 'fixed' | 'fixed-single';
colorValue?: string;
lineStyle?: LineStyleType;
areaOpacity?: number;
format?: FormatOptions;
}
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, we can't enforce validation on cue on one field if one is missing and we don't want to do breaking change |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| import { defaultQueryName } from '@perses-dev/plugin-system'; | ||
| import { TimeSeriesChartVisualOptions } from '../time-series-chart-model'; | ||
| import { getSeriesColor, getAutoPaletteColor, getCategoricalPaletteColor, SeriesColorProps } from './palette-gen'; | ||
|
|
||
|
|
@@ -119,7 +120,7 @@ describe('getSeriesColor', () => { | |
| seriesName: testSeriesName, | ||
| seriesIndex: 0, | ||
| querySettings: { | ||
| queryIndex: 0, | ||
| queryName: defaultQueryName(0), | ||
| colorMode: 'fixed', | ||
| colorValue: '#000', | ||
| }, | ||
|
|
@@ -142,7 +143,7 @@ describe('getSeriesColor', () => { | |
| seriesName: testSeriesName, | ||
| seriesIndex: 0, | ||
| querySettings: { | ||
| queryIndex: 0, | ||
| queryName: defaultQueryName(0), | ||
| colorMode: 'fixed', | ||
| colorValue: '#000', | ||
| }, | ||
|
|
@@ -165,7 +166,7 @@ describe('getSeriesColor', () => { | |
| seriesName: testSeriesName, | ||
| seriesIndex: 0, | ||
| querySettings: { | ||
| queryIndex: 0, | ||
| queryName: defaultQueryName(0), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's a massive breaking change. This will break every dashboard created without dashboard as code or by migrating from Grafana.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I will check if I can keep old data model
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I remember why I did this change. We can't keep index, because it will cause issue when re-ordering queries with query settings. I will rename queryName to queryIndex, but result will be the same => they will need to update queryIndex.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure why we are dropping the queryIndex, the index could be 0 and the name could be whatever. If name is a new field for better UX, queryIndex can be kept as it is. |
||
| colorMode: 'fixed-single', | ||
| colorValue: '#000', | ||
| }, | ||
|
|
@@ -188,7 +189,7 @@ describe('getSeriesColor', () => { | |
| seriesName: testSeriesName, | ||
| seriesIndex: 0, | ||
| querySettings: { | ||
| queryIndex: 0, | ||
| queryName: defaultQueryName(0), | ||
| colorMode: 'fixed-single', | ||
| colorValue: '#000', | ||
| }, | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.
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.
Look at the following payload that I crafted and sent to the backend.
Since the schema is fully optional now, such a payload is persisted. I think this should be avoided. If we insist that we should keep all fields optional, then maybe we should intercept the
reqand drop thequerySettingscompletely. (I am just discussing the payload point of view)Uh oh!
There was an error while loading. Please reload this page.
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.
Users could do it yes, but UI form enforce query name. So ok to me with limitation we have
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.
@jgbernalp Could we also have your opinion about this?
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 JSON editor is editing directly you can do all sorts of things, including adding empty fields. IMO this is not an issue on the UI but on the backend validation, for optional fields there might be weird things allowed such as this example, but we probably cannot catch all the cases. I'd say we can improve the backend validation and unmarshalling in a different PR, so the resulting structure excludes empty objects if the schema says so.
Uh oh!
There was an error while loading. Please reload this page.
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.
With Cue, we can't enforce validation on at least one field :/
Uh oh!
There was an error while loading. Please reload this page.
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.
And it has not impact on the UI if empty object