-
Notifications
You must be signed in to change notification settings - Fork 12.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
PanelEdit: Show when field options have override rules or data config that overrides the default #40250
Conversation
On a phone with low/no internet (so you may already do this!)... The case that would be really nice to advertise is when the datasource sets a value for unit, and the ui also sets unit. The one in the ui is just a 'default' so it is ignored |
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.
Did a shallow code review and found some small things.
I think using both orange and blue dot on the same prop looks a bit confusing, maybe we could have one a half orange/half blue dot instead of two?
public/app/features/dashboard/components/PanelEditor/OptionsPaneItemDescriptor.tsx
Show resolved
Hide resolved
renderOverrides() { | ||
const { overrides } = this.props; | ||
if (!overrides || overrides.length === 0) { | ||
return; | ||
} | ||
} |
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 probably an unfinished function?
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.
or rather a relic, moved it out to OptionsPaneItemOverrides
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.
or rather a relic, moved it out to OptionsPaneItemOverrides
style={{ | ||
backgroundColor: theme.colors[override.color].main, | ||
width: 8, | ||
height: 8, | ||
borderRadius: '50%', | ||
marginLeft: theme.spacing(1), | ||
position: 'relative', | ||
top: '-1px', | ||
}} |
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 the inline style?
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.
original reason was emotions poor performance thinking the dots would have different colors, but think there is good reason to do this inline
We could also use just blue dots, having different colors for the two cases might not be needed really, they both tell you the same thing, that the default is overwritten in some cases |
return ( | ||
<> | ||
{overrides.map((override, index) => ( | ||
<Tooltip content={override.tooltip} key={index.toString()} placement="top"> |
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.
Maybe a stupid ideas, but:
- Would be great if the tooltip had an icon (magnifying glass?) that clicked would take the user directly to an override (if user defined).
- Alternatively - not to show JSON blob - we could show the override editor for a given property so that the user could edit it if necessary straight away - but this may be overkill.
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.
@dprokop
My idea was to have a magnifying glass or filter icon when clicked would add the property name to search, then you would see the default & all overrides that has this property.
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.
Was thinking about this too. But don't you think people can find it confusing if we pre-fill the search input? I mean- if we pre-fill the search input then the user will have to figure out to clear it if he/she wants to get back to the full list. Maybe, when pre-filling the input, we need to blink the outline of the search input to indicate what has happened. But worth talking to UX peeps about this too as you planned.
think I am missing a break in the search for overrides loop :) |
I do like this feature :) Just some naive questions : What would happen if I have 20 (or more) series and override properties gets applied using regex ? Will this result in 20 or more colored dots ? Is the "overflow" of dots handled ? |
…neItemDescriptor.tsx Co-authored-by: Hugo Häggmark <[email protected]>
export function useCombinedRefs<T>(...refs: any) { | ||
const targetRef = React.useRef<T>(null); | ||
|
||
React.useEffect(() => { |
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.
Would it be possible to use a useMemo
here instead? Or are we setting any of the refs in other useEffect
hooks?
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.
not sure, the other implementations of a hook like this I have seen used useEffect
@Willena only a single dot is shown if there is any override rule with that propery, same for the data override dot (if any field in the data have it set) |
yup, sure |
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.
Works OK and the code is good too. Can't find anything apart from the yarn pnp things that I think should be checked in in a separate PR.
public/app/features/dashboard/components/PanelEditor/OptionsPaneItemOverrides.tsx
Outdated
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.
Looks good and works as expected 🎉
'Some data fields have this option pre-configured. Add a field override rule to override the pre-configured value.'; | ||
export const overrideRuleTooltipDescription = 'An override rule exists for this property'; | ||
|
||
export function searchForOptionOverrides( |
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.
Maybe we should move these exported functions outside of the component and add tests?
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.
👍
* main: (47 commits) Chore: Prevent loading error from showing too early (#41347) Chore: add context to login (#41316) Update dependency memoize-one to v6 (#41349) Docs: Added note that only string type is supported for query variables. (#41359) Alerting: fix bug where user is able to access rules from namespaces user is not part of (#41403) prometheus: enable new monaco-based query field (#41357) Chore: Go mod tidy (#41374) PanelEdit: Show when field options have override rules or data config that overrides the default (#40250) NodeGraph: Fix subTitle and secondaryStat being truncated in some cases (#40244) MarketTrend: add devenv dashboard (#41334) MarketTrend: add new alpha panel (#40909) StateTimeline: Share cursor with rest of the panels (#41038) Chore: cleanup ES query_builder test (#41360) Prometheus: Fix showing of errors (#41356) Update dependency lru-cache to v6 (#41327) api/ds/query: simplify data sources lookup for queries and expressions (#41172) A11y/UserAdminPage: Improves tab navigation and focus management (#41321) influxdb: improved explanation texts (#41351) prometheus: monaco: fix a corner-case with quotes (#41345) process app plugins first (#41346) ...
This was something that we wanted to do for v7 and v8 but we never had time to complete.
Issues
Todo
Screenshots:

Unit has data override and No value has an override rule that overrides it
Options can have both data & override rule overrides

data override tooltip, not sure I showing values is needed? For some properties that have object values (data links, color scheme) it will just be json blob which just looks bad.

override rule info dot tooltip:
