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

SceneTimeRange: onTimeZoneChange and onTimeRangeChange to set #389

Closed
wants to merge 4 commits into from

Conversation

tskarhed
Copy link

@tskarhed tskarhed commented Oct 3, 2023

This step will help a little bit, but I think I want to make another PR to change these to setTimeZone and setTimeRange.

Here is my suggestion for doing so, please give me your thoughts:

  1. Mark these as deprecated
  2. Add setTimeZone and setTimeRange.
  3. Call the new methods from the deprecated methods
  4. Update unit test with new methods

Then it is possible to do a gradual change. Thoughts?

@tskarhed tskarhed requested a review from dprokop October 3, 2023 15:08
@dprokop
Copy link
Member

dprokop commented Oct 4, 2023

Thanks @tskarhed . This sounds like a good plan! Mind adding docs as well for what you've just learned about setting time range externally? Think adding it to https://grafana.com/developers/scenes/advanced-data#use-time-range would make sense.

Copy link
Member

@torkelo torkelo left a comment

Choose a reason for hiding this comment

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

would this not break the guideline we have for react callback handlers to begin with onXX ? to match when we hook them up like this.

image

I do agree that this naming does make it feel like something you should maybe not call manually (outside a react callback handler).

Do we have any other onXX interface/ scene object methods in scenes (want to make sure we do not add some inconsistency here). I think MultiValueVariable has changeValueTo (so not using onXX).

Not seeing and change to stop using the deprecated versions here

Comment on lines +79 to +80
const from = toUtc(1696405657);
const to = toUtc(1696405687);
Copy link
Author

Choose a reason for hiding this comment

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

Use dateTime when it is an epoch

@tskarhed tskarhed changed the title SceneTimeRange: Add docstrings for onTimeZoneChange and onTimeRangeChange SceneTimeRange: onTimeZoneChange and onTimeRangeChange to set Oct 4, 2023
@tskarhed
Copy link
Author

tskarhed commented Oct 4, 2023

would this not break the guideline we have for react callback handlers to begin with onXX ? to match when we hook them up like this.

image

I do agree that this naming does make it feel like something you should maybe not call manually (outside a react callback handler).

Do we have any other onXX interface/ scene object methods in scenes (want to make sure we do not add some inconsistency here). I think MultiValueVariable has changeValueTo (so not using onXX).

Not seeing and change to stop using the deprecated versions here

Hmm, I see your point. Would it make sense for these two to just exist in parallel, just for the sake of good naming? You would use setTimeRange whenever you need to do it manually, and onTimeRangeChange for callback handling.

Maybe that would add complexity when implementing the interface though.

@dprokop
Copy link
Member

dprokop commented Oct 5, 2023

Hmm, I see your point. Would it make sense for these two to just exist in parallel, just for the sake of good naming? You would use setTimeRange whenever you need to do it manually, and onTimeRangeChange for callback handling.

@torkelo @tskarhed I don't think having two makes sense. API is one thing, the callback is another. For the SceneTimePicker and any other usages that are callbacks the model can wrap the API in a higher-level function that will follow the on... convention. But since we are talking about API that can be used in multiple contexts, I think we need to name it in a way that is understandable and context agnostic. With that in mind I would suggest callin it updateTimeRange or setTimeRange and follow this for all the public model methods that can be used in an ambiguous way.

@torkelo
Copy link
Member

torkelo commented Oct 5, 2023

@dprokop yea, agree.

@tskarhed tskarhed closed this May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants