Skip to content

Commit

Permalink
Remove dashboardStart as a dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Maja Grubic committed Jun 25, 2020
1 parent 5aeb2b2 commit fb45797
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 55 deletions.
2 changes: 0 additions & 2 deletions src/plugins/dashboard/public/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
ScopedHistory,
} from 'kibana/public';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/public';
import { DashboardStart } from 'src/plugins/dashboard/public';
import { Storage } from '../../../kibana_utils/public';
// @ts-ignore
import { initDashboardApp } from './legacy_app';
Expand Down Expand Up @@ -74,7 +73,6 @@ export interface RenderDeps {
navigateToLegacyKibanaUrl: KibanaLegacyStart['navigateToLegacyKibanaUrl'];
scopedHistory: () => ScopedHistory;
savedObjects: SavedObjectsStart;
dashboard: DashboardStart;
restorePreviousUrl: () => void;
}

Expand Down
2 changes: 0 additions & 2 deletions src/plugins/dashboard/public/application/dashboard_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { DashboardAppState, SavedDashboardPanel } from '../types';
import { DashboardAppController } from './dashboard_app_controller';
import { RenderDeps } from './application';
import { SavedObjectDashboard } from '../saved_dashboards';
import { DashboardStart } from '../plugin';

export interface DashboardAppScope extends ng.IScope {
dash: SavedObjectDashboard;
Expand Down Expand Up @@ -61,7 +60,6 @@ export interface DashboardAppScope extends ng.IScope {
enterEditMode: () => void;
timefilterSubscriptions$: Subscription;
isVisible: boolean;
dashboard: DashboardStart;
}

export function initDashboardAppDirective(app: any, deps: RenderDeps) {
Expand Down
55 changes: 4 additions & 51 deletions src/plugins/dashboard/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,9 @@ import {
SavedObjectsClientContract,
ScopedHistory,
} from 'src/core/public';
import { parseUrl } from 'query-string';
import { DashboardContainerInput } from './index';
import { UsageCollectionSetup } from '../../usage_collection/public';
import {
CONTEXT_MENU_TRIGGER,
EmbeddableInput,
EmbeddableSetup,
EmbeddableStart,
} from '../../embeddable/public';
import { DataPublicPluginStart, DataPublicPluginSetup, esFilters } from '../../data/public';
import { CONTEXT_MENU_TRIGGER, EmbeddableSetup, EmbeddableStart } from '../../embeddable/public';
import { DataPublicPluginSetup, DataPublicPluginStart, esFilters } from '../../data/public';
import { SharePluginSetup, SharePluginStart, UrlGeneratorContract } from '../../share/public';
import { UiActionsSetup, UiActionsStart } from '../../ui_actions/public';

Expand All @@ -57,7 +50,7 @@ import {
ExitFullScreenButton as ExitFullScreenButtonUi,
ExitFullScreenButtonProps,
} from '../../kibana_react/public';
import { createKbnUrlTracker, setStateToKbnUrl, Storage } from '../../kibana_utils/public';
import { createKbnUrlTracker, Storage } from '../../kibana_utils/public';
import {
initAngularBootstrap,
KibanaLegacySetup,
Expand Down Expand Up @@ -91,8 +84,6 @@ import { DashboardConstants } from './dashboard_constants';
import { addEmbeddableToDashboardUrl } from './url_utils/url_helper';
import { PlaceholderEmbeddableFactory } from './application/embeddable/placeholder';
import { createDashboardContainerByValueRenderer } from './application';
import { convertPanelStateToSavedDashboardPanel } from './application/lib/embeddable_saved_object_converters';
import { DashboardPanels } from './application/embeddable/types';

declare module '../../share/public' {
export interface UrlGeneratorStateMapping {
Expand All @@ -110,7 +101,6 @@ interface SetupDependencies {
share?: SharePluginSetup;
uiActions: UiActionsSetup;
usageCollection?: UsageCollectionSetup;
dashboard: DashboardStart;
}

interface StartDependencies {
Expand All @@ -123,7 +113,6 @@ interface StartDependencies {
share?: SharePluginStart;
uiActions: UiActionsStart;
savedObjects: SavedObjectsStart;
dashboard: DashboardStart;
}

export type Setup = void;
Expand All @@ -134,11 +123,8 @@ export interface DashboardStart {
embeddableId: string;
embeddableType: string;
}) => void | undefined;
navigateToDashboard: (input: DashboardContainerInput) => void;
dashboardUrlGenerator?: DashboardUrlGenerator;
DashboardContainerByValueRenderer: ReturnType<typeof createDashboardContainerByValueRenderer>;
getLastLoadedDashboardAppDashboardInput: () => DashboardContainerInput | undefined;
setLastLoadedDashboardAppDashboardInput: (dashboard: DashboardContainerInput | undefined) => void;
}

declare module '../../../plugins/ui_actions/public' {
Expand All @@ -151,7 +137,6 @@ declare module '../../../plugins/ui_actions/public' {

export class DashboardPlugin
implements Plugin<Setup, DashboardStart, SetupDependencies, StartDependencies> {
private currentDashboardInput: DashboardContainerInput | undefined;
constructor(private initializerContext: PluginInitializerContext) {}

private appStateUpdater = new BehaviorSubject<AppUpdater>(() => ({}));
Expand Down Expand Up @@ -184,7 +169,7 @@ export class DashboardPlugin
}

const getStartServices = async () => {
const [coreStart, deps, dashboardStart] = await core.getStartServices();
const [coreStart, deps] = await core.getStartServices();

const useHideChrome = ({ toggleChrome } = { toggleChrome: true }) => {
React.useEffect(() => {
Expand Down Expand Up @@ -218,7 +203,6 @@ export class DashboardPlugin
SavedObjectFinder: getSavedObjectFinder(coreStart.savedObjects, coreStart.uiSettings),
ExitFullScreenButton,
uiActions: deps.uiActions,
dashboard: dashboardStart,
};
};

Expand Down Expand Up @@ -311,7 +295,6 @@ export class DashboardPlugin
usageCollection,
scopedHistory: () => this.currentHistory!,
savedObjects,
dashboard: dashboardStart,
restorePreviousUrl,
};
// make sure the index pattern list is up to date
Expand Down Expand Up @@ -373,32 +356,6 @@ export class DashboardPlugin
}
}

private navigateToDashboard(core: CoreStart, dashInput: EmbeddableInput) {
if (!this.getActiveUrl) {
return;
}
const lastDashboardUrl = this.getActiveUrl();
const { query, filters } = dashInput;
const panels = dashInput.panels as DashboardPanels;
const { url } = parseUrl(lastDashboardUrl);
const dashUrl = setStateToKbnUrl(
'_a',
{
query,
filters,
panels: Object.values(panels).map((panel) => {
return convertPanelStateToSavedDashboardPanel(
panel,
this.initializerContext.env.packageInfo.version
);
}),
},
{ useHash: false },
url
);
core.application.navigateToApp('dashboards', { path: dashUrl });
}

private addEmbeddableToDashboard(
core: CoreStart,
{ embeddableId, embeddableType }: { embeddableId: string; embeddableType: string }
Expand Down Expand Up @@ -456,10 +413,6 @@ export class DashboardPlugin
DashboardContainerByValueRenderer: createDashboardContainerByValueRenderer({
factory: dashboardContainerFactory,
}),
getLastLoadedDashboardAppDashboardInput: () => this.currentDashboardInput,
setLastLoadedDashboardAppDashboardInput: (dashboardInput) =>
(this.currentDashboardInput = dashboardInput),
navigateToDashboard: this.navigateToDashboard.bind(this, core),
};
}

Expand Down

0 comments on commit fb45797

Please sign in to comment.