PluginExtensions: Make sure to pass default timeZone in context (#76513)

* Fixed so we will return default timeZone to extensions if empty is provided.

* Update public/app/features/dashboard/utils/getPanelMenu.test.ts

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>

---------

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
This commit is contained in:
Marcus Andersson
2023-10-13 14:43:45 +02:00
committed by GitHub
co-authored by Dominik Prokop
parent 151f6d6216
commit d18766e88b
5 changed files with 118 additions and 4 deletions
+6 -1
View File
@@ -1,3 +1,5 @@
import { isEmpty } from 'lodash';
import { TimeZone, DefaultTimeZone } from '../types/time';
/**
@@ -57,5 +59,8 @@ export const setTimeZoneResolver = (resolver: TimeZoneResolver) => {
* @public
*/
export const getTimeZone = <T extends TimeZoneOptions>(options?: T): TimeZone => {
return options?.timeZone ?? defaultTimeZoneResolver() ?? DefaultTimeZone;
if (options?.timeZone && !isEmpty(options.timeZone)) {
return options.timeZone;
}
return defaultTimeZoneResolver() ?? DefaultTimeZone;
};