Dashboard: Use preferred timezone on create (#89833)

* Dashboard: Use preferred timezone on create

* Add test
This commit is contained in:
Alex Khomenko 2024-07-02 14:15:23 +03:00 committed by GitHub
parent 92ad6c71d1
commit df15678455
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -44,6 +44,11 @@ jest.mock('@grafana/runtime', () => ({
featureToggles: {
newDashboardWithFiltersAndGroupBy: false,
},
bootData: {
user: {
timezone: 'Africa/Abidjan',
},
},
},
getDataSourceSrv: () => ({
get: (): Promise<DataSourceApi> => {
@ -72,5 +77,10 @@ describe('buildNewDashboardSaveModel', () => {
expect(result.dashboard.templating?.list?.[0].type).toBe('adhoc');
expect(result.dashboard.templating?.list?.[1].type).toBe('groupby');
});
it("should set the new dashboard's timezone to the user's timezone", async () => {
const result = await buildNewDashboardSaveModel();
expect(result.dashboard.timezone).toEqual('Africa/Abidjan');
});
});
});

View File

@ -46,6 +46,7 @@ export async function buildNewDashboardSaveModel(urlFolderUid?: string): Promise
uid: '',
title: 'New dashboard',
panels: [],
timezone: config.bootData.user?.timezone || defaultDashboard.timezone,
},
};