mirror of
https://github.com/grafana/grafana.git
synced 2026-09-05 04:40:13 -05:00
Angular: Option to disable angular support and isolate angular dependencies (#45421)
* Angular: Initial setting that disables angular, load angular support in separate chunk * Load angular panels on demand * Load alerting in separate chunk only when angularSupportEnabled * progress, do not export core_module if angular disabled * Progress * Update public/app/features/plugins/built_in_plugins.ts Co-authored-by: Ryan McKinley <ryantxu@gmail.com> * Removing remaining usage of angular from outside angular app (not counting plugins) * Update config and docs * Fix sample.ini * Update public/app/features/alerting/AlertTab.tsx Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com> * Fixing prettier issue Co-authored-by: Ryan McKinley <ryantxu@gmail.com> Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
This commit is contained in:
co-authored by
Ryan McKinley
Levente Balogh
parent
8bb3de3037
commit
2b9e46d1f8
+11
-21
@@ -15,15 +15,16 @@ import { GrafanaRoute } from './core/navigation/GrafanaRoute';
|
||||
import { AppNotificationList } from './core/components/AppNotifications/AppNotificationList';
|
||||
import { SearchWrapper } from 'app/features/search';
|
||||
import { LiveConnectionWarning } from './features/live/LiveConnectionWarning';
|
||||
import { AngularRoot } from './angular/AngularRoot';
|
||||
import { I18nProvider } from './core/localisation';
|
||||
import { AngularRoot } from './angular/AngularRoot';
|
||||
import { loadAndInitAngularIfEnabled } from './angular/loadAndInitAngularIfEnabled';
|
||||
|
||||
interface AppWrapperProps {
|
||||
app: GrafanaApp;
|
||||
}
|
||||
|
||||
interface AppWrapperState {
|
||||
ngInjector: any;
|
||||
ready?: boolean;
|
||||
}
|
||||
|
||||
/** Used by enterprise */
|
||||
@@ -39,27 +40,14 @@ export function addPageBanner(fn: ComponentType) {
|
||||
}
|
||||
|
||||
export class AppWrapper extends React.Component<AppWrapperProps, AppWrapperState> {
|
||||
container = React.createRef<HTMLDivElement>();
|
||||
|
||||
constructor(props: AppWrapperProps) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
ngInjector: null,
|
||||
};
|
||||
this.state = {};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (this.container) {
|
||||
this.bootstrapNgApp();
|
||||
} else {
|
||||
throw new Error('Failed to boot angular app, no container to attach to');
|
||||
}
|
||||
}
|
||||
|
||||
bootstrapNgApp() {
|
||||
const injector = this.props.app.angularApp.bootstrap();
|
||||
this.setState({ ngInjector: injector });
|
||||
async componentDidMount() {
|
||||
await loadAndInitAngularIfEnabled();
|
||||
this.setState({ ready: true });
|
||||
$('.preloader').remove();
|
||||
}
|
||||
|
||||
@@ -91,6 +79,8 @@ export class AppWrapper extends React.Component<AppWrapperProps, AppWrapperState
|
||||
}
|
||||
|
||||
render() {
|
||||
const { ready } = this.state;
|
||||
|
||||
navigationLogger('AppWrapper', false, 'rendering');
|
||||
|
||||
const newNavigationEnabled = Boolean(config.featureToggles.newNavigation);
|
||||
@@ -111,10 +101,10 @@ export class AppWrapper extends React.Component<AppWrapperProps, AppWrapperState
|
||||
<Banner key={index.toString()} />
|
||||
))}
|
||||
|
||||
<AngularRoot ref={this.container} />
|
||||
<AngularRoot />
|
||||
<AppNotificationList />
|
||||
<SearchWrapper />
|
||||
{this.state.ngInjector && this.renderRoutes()}
|
||||
{ready && this.renderRoutes()}
|
||||
{bodyRenderHooks.map((Hook, index) => (
|
||||
<Hook key={index.toString()} />
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user