Skip to content
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

Merged
merged 16 commits into from
Nov 8, 2021

Conversation

torkelo
Copy link
Member

@torkelo torkelo commented Oct 10, 2021

This was something that we wanted to do for v7 and v8 but we never had time to complete.

  • Shows a small info dot (orange) when data config is found for an option. The tooltip currently shows the data fields and config values, not sure if this really needed. Makes the tooltip a bit bigger.
  • Unit test for data config info dots
  • Show small info dot (blue) for override rules that override a default
  • Unit test for override rule info dots
  • Find a way to add filter action for each option that has are overridden by an override rule, the filter action would add the option name to option search so you would see the default and all override rules that contain that option and the option values. '

Issues

  • Find our Tooltip component's tooltips a bit hard to read, both the small text & the small padding/contrast/lack of border make them blend into the background too much.
  • Show data override config values or not? For some properties that have object values (data links, color scheme) it will just be json blob which just looks bad.

Todo

  • What colors to use for dots?
  • Feedback from ux team

Screenshots:
Unit has data override and No value has an override rule that overrides it
Screenshot from 2021-10-10 11-23-25

Options can have both data & override rule overrides
Screenshot from 2021-10-10 11-36-32

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.
Screenshot from 2021-10-10 11-26-10

override rule info dot tooltip:
Screenshot from 2021-10-10 11-27-07

@torkelo torkelo requested a review from a team as a code owner October 10, 2021 09:39
@torkelo torkelo requested review from kaydelaney and removed request for a team October 10, 2021 09:39
@ryantxu
Copy link
Member

ryantxu commented Oct 10, 2021

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

@hugohaggmark hugohaggmark requested a review from a team October 11, 2021 05:16
Copy link
Contributor

@hugohaggmark hugohaggmark left a 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?

Comment on lines +68 to +73
renderOverrides() {
const { overrides } = this.props;
if (!overrides || overrides.length === 0) {
return;
}
}
Copy link
Contributor

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?

Copy link
Member Author

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

Copy link
Member Author

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

Comment on lines 26 to 34
style={{
backgroundColor: theme.colors[override.color].main,
width: 8,
height: 8,
borderRadius: '50%',
marginLeft: theme.spacing(1),
position: 'relative',
top: '-1px',
}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the inline style?

Copy link
Member Author

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

@torkelo
Copy link
Member Author

torkelo commented Oct 11, 2021

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?

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

@dprokop
Copy link
Member

dprokop commented Oct 11, 2021

Found a small issue when one property has multiple overrides. There are as many dots being rendered as overrides:

image

If this is intentional, I would rather expect to be sth like this ⬤ x N?

return (
<>
{overrides.map((override, index) => (
<Tooltip content={override.tooltip} key={index.toString()} placement="top">
Copy link
Member

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:

  1. Would be great if the tooltip had an icon (magnifying glass?) that clicked would take the user directly to an override (if user defined).
  2. 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.

Copy link
Member Author

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.

Copy link
Member

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.

@torkelo
Copy link
Member Author

torkelo commented Oct 11, 2021

Found a small issue when one property has multiple overrides. There are as many dots being rendered as overrides:

think I am missing a break in the search for overrides loop :)

@Willena
Copy link
Contributor

Willena commented Oct 12, 2021

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 ?

@torkelo torkelo requested a review from a team October 13, 2021 13:39
export function useCombinedRefs<T>(...refs: any) {
const targetRef = React.useRef<T>(null);

React.useEffect(() => {
Copy link
Contributor

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?

Copy link
Member Author

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

@torkelo
Copy link
Member Author

torkelo commented Oct 28, 2021

@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)

@torkelo
Copy link
Member Author

torkelo commented Oct 28, 2021

@ryantxu @dprokop @ryantxu Can you take a quick look a this again, think this is close to mergable in current form and want to merge it and we can iterate on it in further PRs.

@dprokop
Copy link
Member

dprokop commented Oct 28, 2021

yup, sure

Copy link
Member

@dprokop dprokop left a 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.

Copy link
Contributor

@hugohaggmark hugohaggmark left a 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(
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@torkelo torkelo merged commit 3dee34c into main Nov 8, 2021
@torkelo torkelo deleted the field-overrides-label-info-dots branch November 8, 2021 12:18
leventebalogh added a commit that referenced this pull request Nov 8, 2021
* 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)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants