Skip to content

Commit

Permalink
Migrate graph usage of saved_objects module constants for uiSettings …
Browse files Browse the repository at this point in the history
…to setting accessors
  • Loading branch information
kertal committed May 11, 2020
1 parent 72e29b7 commit 785c3a5
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/plugins/saved_objects/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ export {
isErrorNonFatal,
} from './saved_object';
export { SavedObjectSaveOpts, SavedObjectKibanaServices, SavedObject } from './types';
export { SavedObjectsStart } from './plugin';

export const plugin = () => new SavedObjectsPublicPlugin();
4 changes: 4 additions & 0 deletions src/plugins/saved_objects/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import { PER_PAGE_SETTING, LISTING_LIMIT_SETTING } from '../common';

export interface SavedObjectsStart {
SavedObjectClass: any;
settings: {
getPerPage: () => number;
getListingLimit: () => number;
};
}

export interface SavedObjectsStartDeps {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/graph/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"kibanaVersion": "kibana",
"server": true,
"ui": true,
"requiredPlugins": ["licensing", "data", "navigation"],
"requiredPlugins": ["licensing", "data", "navigation", "savedObjects"],
"optionalPlugins": ["home", "features"],
"configPath": ["xpack", "graph"]
}
10 changes: 3 additions & 7 deletions x-pack/plugins/graph/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import { isColorDark, hexToRgb } from '@elastic/eui';

import { toMountPoint } from '../../../../src/plugins/kibana_react/public';
import { showSaveModal } from '../../../../src/plugins/saved_objects/public';
import {
LISTING_LIMIT_SETTING,
PER_PAGE_SETTING,
} from '../../../../src/plugins/saved_objects/common';

import appTemplate from './angular/templates/index.html';
import listingTemplate from './angular/templates/listing_ng_wrapper.html';
Expand Down Expand Up @@ -50,13 +46,13 @@ export function initGraphApp(angularModule, deps) {
addBasePath,
getBasePath,
data,
config,
capabilities,
coreStart,
storage,
canEditDrillDownUrls,
graphSavePolicy,
overlays,
savedObjects,
} = deps;

const app = angularModule;
Expand Down Expand Up @@ -116,8 +112,8 @@ export function initGraphApp(angularModule, deps) {
template: listingTemplate,
badge: getReadonlyBadge,
controller: function($location, $scope) {
$scope.listingLimit = config.get(LISTING_LIMIT_SETTING);
$scope.initialPageSize = config.get(PER_PAGE_SETTING);
$scope.listingLimit = savedObjects.settings.getListingLimit();
$scope.initialPageSize = savedObjects.settings.getPerPage();
$scope.create = () => {
$location.url(getNewPath());
};
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/graph/public/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
PluginInitializerContext,
SavedObjectsClientContract,
ToastsStart,
IUiSettingsClient,
OverlayStart,
} from 'kibana/public';
// @ts-ignore
Expand All @@ -40,6 +39,7 @@ import {
} from '../../../../src/plugins/kibana_legacy/public';

import './index.scss';
import { SavedObjectsStart } from '../../../../src/plugins/saved_objects/public';

/**
* These are dependencies of the Graph app besides the base dependencies
Expand All @@ -57,7 +57,6 @@ export interface GraphDependencies {
navigation: NavigationStart;
licensing: LicensingPluginSetup;
chrome: ChromeStart;
config: IUiSettingsClient;
toastNotifications: ToastsStart;
indexPatterns: IndexPatternsContract;
data: ReturnType<DataPlugin['start']>;
Expand All @@ -68,6 +67,7 @@ export interface GraphDependencies {
canEditDrillDownUrls: boolean;
graphSavePolicy: string;
overlays: OverlayStart;
savedObjects: SavedObjectsStart;
}

export const renderApp = ({ appBasePath, element, ...deps }: GraphDependencies) => {
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/graph/public/components/listing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export function Listing(props: ListingProps) {
tableListTitle={i18n.translate('xpack.graph.listing.graphsTitle', {
defaultMessage: 'Graphs',
})}
uiSettings={props.coreStart.uiSettings}
/>
</I18nProvider>
);
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/graph/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
} from '../../../../src/plugins/home/public';
import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/public';
import { ConfigSchema } from '../config';
import { SavedObjectsStart } from '../../../../src/plugins/saved_objects/public';

export interface GraphPluginSetupDependencies {
licensing: LicensingPluginSetup;
Expand All @@ -32,6 +33,7 @@ export interface GraphPluginSetupDependencies {
export interface GraphPluginStartDependencies {
navigation: NavigationStart;
data: DataPublicPluginStart;
savedObjects: SavedObjectsStart;
}

export class GraphPlugin
Expand Down Expand Up @@ -89,10 +91,10 @@ export class GraphPlugin
capabilities: coreStart.application.capabilities.graph,
coreStart,
chrome: coreStart.chrome,
config: coreStart.uiSettings,
toastNotifications: coreStart.notifications.toasts,
indexPatterns: pluginsStart.data!.indexPatterns,
overlays: coreStart.overlays,
savedObjects: pluginsStart.savedObjects,
});
},
});
Expand Down

0 comments on commit 785c3a5

Please sign in to comment.