-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add VizPanelExploreButton scene object #804
Conversation
function VizPanelExploreButtonComponent({ model }: SceneComponentProps<VizPanelExploreButton>) { | ||
const { options } = model.useState(); | ||
|
||
const { data } = sceneGraph.getData(model).useState(); | ||
|
||
const targets = useMemo(() => data?.request?.targets ?? [], [data]); | ||
|
||
const { from, to } = sceneGraph.getTimeRange(model).useState(); | ||
|
||
const { value: interpolatedQueries } = useAsync(async () => { | ||
const scopedVars: ScopedVars = { | ||
__sceneObject: { text: '__sceneObject', value: model }, | ||
}; | ||
return ( | ||
await Promise.allSettled( | ||
targets.map(async (q) => { | ||
const queryDs = await getDataSourceSrv().get(q.datasource); | ||
return queryDs.interpolateVariablesInQueries?.([q], scopedVars ?? {})[0] || q; | ||
}) | ||
) | ||
) | ||
.filter((promise): promise is PromiseFulfilledResult<DataQuery> => promise.status === 'fulfilled') | ||
.map((q) => q.value) | ||
.map((q) => options.transform?.(q) ?? q); | ||
}, [targets, model]); | ||
|
||
const left = useMemo(() => { |
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 usually prefer plain links vs buttons with onClick , but feels a bit unnecessary to do all this work on every data refresh (and re-render Linkbutton), vs doing onClick. Maybe building the URL onHover and onFocus ?
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 think this button is a link styled as a button, it does have proper href
. the onClick
is an optional callback for adding tracking of clicks via Faro/Rudderstack if needed. However I'm now not sure it will react to variable updates properly, needs investigation 🤔 maybe onHover is a good idea
@domasx2 why did you close, think this is a great addition. sorry for not approving it, it must have slipped of my radar / review list |
I realized this has been hanging for a long while, and thought if I didn't find time and energy to push it, best close it. Do you think with some tests added this would be ok to merge, or needs more work? |
packages/scenes/src/components/VizPanel/VizPanelExploreButton.tsx
Outdated
Show resolved
Hide resolved
72db51e
to
2c63320
Compare
extracted "getExploreURL" as separate util for use cases outside of button component, added "return to previous" integration, made it ad hoc filters aware |
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.
nice!
Maybe post about this one in #proj-scene-apps
🚀 PR was released in |
Hey,
On popular request, contributing a panel explore button derived from app o11y implementation. It's been copied around to other apps, so seems to make sense to contribute it to scenes.
Does this make sense? If so, I'll add tests. Also thinking it's maybe whorthwile to make a
getExploreUrl(sceneObject)
util as it's own thing in case you want something else than a button