Skip to content

SceneShareLinksButton: expose share links button to scene apps#1022

Open
gtk-grafana wants to merge 1 commit intomainfrom
gtk-grafana/short-links-share-button-scene
Open

SceneShareLinksButton: expose share links button to scene apps#1022
gtk-grafana wants to merge 1 commit intomainfrom
gtk-grafana/short-links-share-button-scene

Conversation

@gtk-grafana
Copy link
Copy Markdown
Contributor

Exposes SceneShareLinksButton scene for scene apps.
SceneShareLinksButton allows consumers to define:

  • optional onCopyLink callback (for tracking) on link copy
  • optional getSceneTimeRange function to specify which SceneTimeRangeLike should be used for the link generation.
image
image

@gtk-grafana gtk-grafana self-assigned this Jan 7, 2025
@gtk-grafana gtk-grafana added usecase/app-plugins Needed for scene app plugins release Create a release when this pr is merged minor Increment the minor version when merged labels Jan 7, 2025
@gtk-grafana gtk-grafana marked this pull request as ready for review January 7, 2025 16:53
@gtk-grafana gtk-grafana requested review from dprokop and torkelo January 9, 2025 13:54
Copy link
Copy Markdown
Collaborator

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

I wonder, this ain't very framework-ish component. Why do we even need it in scenes library?

key: string;
label: string;
icon: IconName;
getUrl: Function;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

shouldn't this be () => string | undefined?

public onCopyLink(shorten: boolean, absTime: boolean, url?: string) {
if (shorten) {
createAndCopyShortLink(url || global.location.href);
reportInteraction('grafana_explore_shortened_link_clicked', { isAbsoluteTime: absTime });
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

you are leaking explore specific interactions reporting to scenes, not nice ;)

: global.location.href
);

if (this.state.onCopyLink) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this won't be called if someone wants a shortened link. is this expected?

const url = lastSelected.getUrl();
model.onCopyLink(lastSelected.shorten, lastSelected.absTime, url);
}}
aria-label={'Copy shortened URL'}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

think this needs sth like lastSelected.label, otherwise this can be innacurate label.

<Dropdown
overlay={<SceneShareLinksButton.MenuActions model={model} />}
placement="bottom-end"
onVisibleChange={model.setIsOpen.bind(model)}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit - this is a new function created on every render

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor Increment the minor version when merged release Create a release when this pr is merged usecase/app-plugins Needed for scene app plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants