Skip to content

Grafana firefox #77

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

Merged
merged 3 commits into from
Jun 16, 2023
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 .yarn/sdks/prettier/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prettier",
"version": "2.8.1-sdk",
"version": "2.8.4-sdk",
"main": "./index.js",
"type": "commonjs"
}
2 changes: 2 additions & 0 deletions .yarn/sdks/typescript/lib/tsserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ const moduleWrapper = tsserver => {
str = `zip:${str}`;
} break;
}
} else {
str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`);
}
}

Expand Down
2 changes: 2 additions & 0 deletions .yarn/sdks/typescript/lib/tsserverlibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ const moduleWrapper = tsserver => {
str = `zip:${str}`;
} break;
}
} else {
str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`);
}
}

Expand Down
3 changes: 2 additions & 1 deletion public/app/features/dashboard/dashgrid/LazyLoader.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isFunction } from 'lodash';
import React, { useRef, useState } from 'react';
import { useEffectOnce } from 'react-use';

Expand Down Expand Up @@ -55,7 +56,7 @@ LazyLoader.addCallback = (id: string, c: (e: IntersectionObserverEntry) => void)
LazyLoader.observer = new IntersectionObserver(
(entries) => {
for (const entry of entries) {
LazyLoader.callbacks[entry.target.id](entry);
isFunction(LazyLoader.callbacks[entry.target.id]) && LazyLoader.callbacks[entry.target.id](entry);
}
},
{ rootMargin: '100px' }
Expand Down
8 changes: 4 additions & 4 deletions public/app/fn-app/fn-app-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export const FnAppProvider: FC<FnAppProviderProps> = (props) => {
<BrowserRouter>
<ErrorBoundaryAlert style="page">
<GrafanaContext.Provider value={app.context}>
<ThemeProvider value={config.theme2} children={
<ThemeProvider value={config.theme2}>
<>
<GlobalStyles />
{children || null}
</>}
/>
{children}
</>
</ThemeProvider>
</GrafanaContext.Provider>
</ErrorBoundaryAlert>
</BrowserRouter>
Expand Down
24 changes: 10 additions & 14 deletions public/app/fn-app/fn-dashboard-page/fn-dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { pick } from 'lodash';
import React, { FC, Suspense, useMemo } from 'react';
import { lazily } from 'react-lazily';
import React, { FC, useMemo } from 'react';
import { connect, MapStateToProps } from 'react-redux';

import {
Expand All @@ -11,25 +10,23 @@ import {
FnPropsMappedFromState,
} from 'app/core/reducers/fn-slice';

import { AngularRoot } from '../../angular/AngularRoot';
import { FnAppProvider } from '../fn-app-provider';
import { FNDashboardProps } from '../types';
import { RenderPortal } from '../utils';

const { RenderFNDashboard } = lazily(() => import('./render-fn-dashboard'));
const { FnAppProvider } = lazily(() => import('../fn-app-provider'));
const { AngularRoot } = lazily(() => import('../../angular/AngularRoot'));
import { RenderFNDashboard } from './render-fn-dashboard';

type FNDashboardComponentProps = Omit<FNDashboardProps, FnPropMappedFromState>;

export const FNDashboard: FC<FNDashboardComponentProps> = (props) => {
return (
<Suspense fallback={<>{props.fnLoader}</>}>
<FnAppProvider fnError={props.fnError}>
<div className="page-dashboard">
<AngularRoot />
<DashboardPortal {...props} />
</div>
</FnAppProvider>
</Suspense>
<FnAppProvider fnError={props.fnError}>
<div className="page-dashboard">
<AngularRoot />
<DashboardPortal {...props} />
</div>
</FnAppProvider>
);
};

Expand All @@ -42,7 +39,6 @@ function mapStateToProps(): MapStateToProps<
}

export const DashboardPortalComponent: FC<FNDashboardComponentProps & FnPropsMappedFromState> = (props) => {

const content = useMemo(() => {
if (!props.FNDashboard) {
// TODO Use no data
Expand Down
12 changes: 5 additions & 7 deletions public/app/fn-app/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC } from 'react';
import { FC, PropsWithChildren } from 'react';
import ReactDOM from 'react-dom';

export interface RenderPortalProps {
Expand All @@ -7,14 +7,12 @@ export interface RenderPortalProps {

export const getPortalContainer = (ID: string): HTMLElement | null => document.getElementById(ID);

export const RenderPortal: FC<RenderPortalProps> = ({ ID, children }) => {
const portalDiv = getPortalContainer(ID)
if(!portalDiv){
export const RenderPortal: FC<PropsWithChildren<RenderPortalProps>> = ({ ID, children }) => {
const portalDiv = getPortalContainer(ID);

if (!portalDiv) {
return null;
}

return ReactDOM.createPortal(children, portalDiv);
};