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

DEV-45352 Fix unknown logzio property in window object #26

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/grafana-data/src/utils/logzioProvider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// LOGZ.IO GRAFANA CHANGE
export let logzioServices: any = (global as any).parent.__logzio__.services;
export let logzioServices: any = (global as any).parent.__logzio__?.services;
export const logzioConfigs = new Proxy<any>({}, {
get(target, prop) {
return (window as any).logzio?.configs[prop];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// LOGZ.IO GRAFANA CHANGE :: DEV-19985: add datasource logos
export const changeDatasourceLogos = (datasources: any): any => {
if (!datasources) { return }
const logos = {
metrics: 'public/app/plugins/datasource/elasticsearch/img/logzio-metrics.svg',
logs: 'public/app/plugins/datasource/elasticsearch/img/logzio-logs.svg',
Expand Down
5 changes: 2 additions & 3 deletions packages/grafana-runtime/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,9 @@ export class GrafanaBootConfig implements GrafanaConfig {
changeDatasourceLogos(options.datasources);

// LOGZ.IO GRAFANA CHANGE :: Add logzio presets to grafana config
if (Object.keys(logzioConfigs).length === 0) {
console.error('Error loading logzioConfigs');
if (Object.keys(logzioConfigs).length > 0) {
merge(this, defaults, options, logzioConfigs);
}
merge(this, defaults, options, logzioConfigs);
// LOGZ.IO GRAFANA CHANGE :: end

this.buildInfo = options.buildInfo || defaults.buildInfo;
Expand Down
8 changes: 8 additions & 0 deletions public/test/jest-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ initIconCache();
const testAppEvents = new EventBusSrv();
const global = window as any;
global.$ = global.jQuery = $;
const logzio = {
log: jest.fn(),
configs: {},
services: {},
productLoaded: jest.fn(),
};
global.logzio = logzio;
global.parent.__logzio__ = logzio;

// mock the default window.grafanaBootData settings
const settings: Partial<GrafanaBootConfig> = {
Expand Down