mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Improve some types (#64675)
* some type fixes * few more * more type fixes * fix the majority of (window as any) calls * don't make new variable for event * few more * MOAR
This commit is contained in:
@@ -43,16 +43,6 @@ function mockLocationHref(href: string) {
|
||||
};
|
||||
}
|
||||
|
||||
function setUTCTimeZone() {
|
||||
(window as any).Intl.DateTimeFormat = () => {
|
||||
return {
|
||||
resolvedOptions: () => {
|
||||
return { timeZone: 'UTC' };
|
||||
},
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
const mockUid = 'abc123';
|
||||
jest.mock('@grafana/runtime', () => {
|
||||
const original = jest.requireActual('@grafana/runtime');
|
||||
@@ -80,7 +70,13 @@ describe('ShareModal', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
const defaultTimeRange = getDefaultTimeRange();
|
||||
setUTCTimeZone();
|
||||
jest.spyOn(window.Intl, 'DateTimeFormat').mockImplementation(() => {
|
||||
return {
|
||||
resolvedOptions: () => {
|
||||
return { timeZone: 'UTC' };
|
||||
},
|
||||
} as Intl.DateTimeFormat;
|
||||
});
|
||||
mockLocationHref('http://server/#!/test');
|
||||
config.rendererAvailable = true;
|
||||
config.bootData.user.orgId = 1;
|
||||
|
||||
@@ -95,7 +95,7 @@ export class ShareModal extends React.Component<Props, State> {
|
||||
reportInteraction('grafana_dashboards_share_modal_viewed');
|
||||
}
|
||||
|
||||
onSelectTab = (t: any) => {
|
||||
onSelectTab: React.ComponentProps<typeof ModalTabsHeader>['onChangeTab'] = (t) => {
|
||||
this.setState((prevState) => ({ ...prevState, activeTab: t.value }));
|
||||
};
|
||||
|
||||
|
||||
@@ -121,11 +121,11 @@ export function getLocalTimeZone() {
|
||||
const utcOffset = '&tz=UTC' + encodeURIComponent(dateTime().format('Z'));
|
||||
|
||||
// Older browser does not the internationalization API
|
||||
if (!(window as any).Intl) {
|
||||
if (!window.Intl) {
|
||||
return utcOffset;
|
||||
}
|
||||
|
||||
const dateFormat = (window as any).Intl.DateTimeFormat();
|
||||
const dateFormat = window.Intl.DateTimeFormat();
|
||||
if (!dateFormat.resolvedOptions) {
|
||||
return utcOffset;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user