Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const provider: ConfigDeprecationProvider = ({ rename, unused }) => [
| Method | Description |
| --- | --- |
| [rename(oldKey, newKey)](./kibana-plugin-server.configdeprecationfactory.rename.md) | Rename a configuration property from inside a plugin's configuration path. Will log a deprecation warning if the oldKey was found and deprecation applied. |
| [renameFromRoot(oldKey, newKey)](./kibana-plugin-server.configdeprecationfactory.renamefromroot.md) | Rename a configuration property from the root configuration. Will log a deprecation warning if the oldKey was found and deprecation applied.<!-- -->This should be only used when renaming properties from different configuration's path. To rename properties from inside a plugin's configuration, use 'rename' instead. |
| [renameFromRoot(oldKey, newKey, silent)](./kibana-plugin-server.configdeprecationfactory.renamefromroot.md) | Rename a configuration property from the root configuration. Will log a deprecation warning if the oldKey was found and deprecation applied.<!-- -->This should be only used when renaming properties from different configuration's path. To rename properties from inside a plugin's configuration, use 'rename' instead. |
| [unused(unusedKey)](./kibana-plugin-server.configdeprecationfactory.unused.md) | Remove a configuration property from inside a plugin's configuration path. Will log a deprecation warning if the unused key was found and deprecation applied. |
| [unusedFromRoot(unusedKey)](./kibana-plugin-server.configdeprecationfactory.unusedfromroot.md) | Remove a configuration property from the root configuration. Will log a deprecation warning if the unused key was found and deprecation applied.<!-- -->This should be only used when removing properties from outside of a plugin's configuration. To remove properties from inside a plugin's configuration, use 'unused' instead. |

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This should be only used when renaming properties from different configuration's
<b>Signature:</b>

```typescript
renameFromRoot(oldKey: string, newKey: string): ConfigDeprecation;
renameFromRoot(oldKey: string, newKey: string, silent?: boolean): ConfigDeprecation;
```

## Parameters
Expand All @@ -20,6 +20,7 @@ renameFromRoot(oldKey: string, newKey: string): ConfigDeprecation;
| --- | --- | --- |
| oldKey | <code>string</code> | |
| newKey | <code>string</code> | |
| silent | <code>boolean</code> | |

<b>Returns:</b>

Expand Down
20 changes: 13 additions & 7 deletions src/core/server/config/deprecation/deprecation_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const _rename = (
rootPath: string,
log: ConfigDeprecationLogger,
oldKey: string,
newKey: string
newKey: string,
silent?: boolean
) => {
const fullOldPath = getPath(rootPath, oldKey);
const oldValue = get(config, fullOldPath);
Expand All @@ -40,11 +41,16 @@ const _rename = (
const newValue = get(config, fullNewPath);
if (newValue === undefined) {
set(config, fullNewPath, oldValue);
log(`"${fullOldPath}" is deprecated and has been replaced by "${fullNewPath}"`);

if (!silent) {
log(`"${fullOldPath}" is deprecated and has been replaced by "${fullNewPath}"`);
}
} else {
log(
`"${fullOldPath}" is deprecated and has been replaced by "${fullNewPath}". However both key are present, ignoring "${fullOldPath}"`
);
if (!silent) {
log(
`"${fullOldPath}" is deprecated and has been replaced by "${fullNewPath}". However both key are present, ignoring "${fullOldPath}"`
);
}
}
return config;
};
Expand All @@ -67,11 +73,11 @@ const _unused = (
const rename = (oldKey: string, newKey: string): ConfigDeprecation => (config, rootPath, log) =>
_rename(config, rootPath, log, oldKey, newKey);

const renameFromRoot = (oldKey: string, newKey: string): ConfigDeprecation => (
const renameFromRoot = (oldKey: string, newKey: string, silent?: boolean): ConfigDeprecation => (
config,
rootPath,
log
) => _rename(config, '', log, oldKey, newKey);
) => _rename(config, '', log, oldKey, newKey, silent);

const unused = (unusedKey: string): ConfigDeprecation => (config, rootPath, log) =>
_unused(config, rootPath, log, unusedKey);
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/config/deprecation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export interface ConfigDeprecationFactory {
* ]
* ```
*/
renameFromRoot(oldKey: string, newKey: string): ConfigDeprecation;
renameFromRoot(oldKey: string, newKey: string, silent?: boolean): ConfigDeprecation;
/**
* Remove a configuration property from inside a plugin's configuration path.
* Will log a deprecation warning if the unused key was found and deprecation applied.
Expand Down
2 changes: 0 additions & 2 deletions src/core/server/kibana_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export const config = {
path: 'kibana',
schema: schema.object({
enabled: schema.boolean({ defaultValue: true }),
defaultAppId: schema.string({ defaultValue: 'home' }),
index: schema.string({ defaultValue: '.kibana' }),
disableWelcomeScreen: schema.boolean({ defaultValue: false }),
autocompleteTerminateAfter: schema.duration({ defaultValue: 100000 }),
autocompleteTimeout: schema.duration({ defaultValue: 1000 }),
}),
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { uuidServiceMock } from './uuid/uuid_service.mock';

export function pluginInitializerContextConfigMock<T>(config: T) {
const globalConfig: SharedGlobalConfig = {
kibana: { defaultAppId: 'home-mocks', index: '.kibana-tests' },
kibana: { index: '.kibana-tests' },
elasticsearch: {
shardTimeout: duration('30s'),
requestTimeout: duration('30s'),
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/plugins/plugin_context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('Plugin Context', () => {
.pipe(first())
.toPromise();
expect(configObject).toStrictEqual({
kibana: { defaultAppId: 'home', index: '.kibana' },
kibana: { index: '.kibana' },
elasticsearch: {
shardTimeout: duration(30, 's'),
requestTimeout: duration(30, 's'),
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/plugins/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export interface Plugin<

export const SharedGlobalConfigKeys = {
// We can add more if really needed
kibana: ['defaultAppId', 'index'] as const,
kibana: ['index'] as const,
elasticsearch: ['shardTimeout', 'requestTimeout', 'pingTimeout', 'startupTimeout'] as const,
path: ['data'] as const,
};
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ export type ConfigDeprecation = (config: Record<string, any>, fromPath: string,
// @public
export interface ConfigDeprecationFactory {
rename(oldKey: string, newKey: string): ConfigDeprecation;
renameFromRoot(oldKey: string, newKey: string): ConfigDeprecation;
renameFromRoot(oldKey: string, newKey: string, silent?: boolean): ConfigDeprecation;
unused(unusedKey: string): ConfigDeprecation;
unusedFromRoot(unusedKey: string): ConfigDeprecation;
}
Expand Down
2 changes: 0 additions & 2 deletions src/legacy/core_plugins/kibana/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ export default function(kibana) {
config: function(Joi) {
return Joi.object({
enabled: Joi.boolean().default(true),
defaultAppId: Joi.string().default('home'),
index: Joi.string().default('.kibana'),
disableWelcomeScreen: Joi.boolean().default(false),
autocompleteTerminateAfter: Joi.number()
.integer()
.min(1)
Expand Down
2 changes: 0 additions & 2 deletions src/legacy/core_plugins/kibana/inject_vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ export function injectVars(server) {
);

return {
kbnDefaultAppId: serverConfig.get('kibana.defaultAppId'),
disableWelcomeScreen: serverConfig.get('kibana.disableWelcomeScreen'),
importAndExportableTypes,
autocompleteTerminateAfter: serverConfig.get('kibana.autocompleteTerminateAfter'),
autocompleteTimeout: serverConfig.get('kibana.autocompleteTimeout'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { IEmbeddableStart } from '../../../../../../plugins/embeddable/public';
import { NavigationPublicPluginStart as NavigationStart } from '../../../../../../plugins/navigation/public';
import { DataPublicPluginStart as NpDataStart } from '../../../../../../plugins/data/public';
import { SharePluginStart } from '../../../../../../plugins/share/public';
import { KibanaLegacyStart } from '../../../../../../plugins/kibana_legacy/public';

export interface RenderDeps {
core: LegacyCoreStart;
Expand All @@ -62,6 +63,7 @@ export interface RenderDeps {
embeddables: IEmbeddableStart;
localStorage: Storage;
share: SharePluginStart;
config: KibanaLegacyStart['config'];
}

let angularModuleInstance: IModule | null = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export interface DashboardAppScope extends ng.IScope {
export function initDashboardAppDirective(app: any, deps: RenderDeps) {
app.directive('dashboardApp', function($injector: IInjector) {
const confirmModal = $injector.get<ConfirmModalFn>('confirmModal');
const config = deps.uiSettings;

return {
restrict: 'E',
Expand All @@ -106,7 +105,6 @@ export function initDashboardAppDirective(app: any, deps: RenderDeps) {
$route,
$scope,
$routeParams,
config,
confirmModal,
indexPatterns: deps.npDataStart.indexPatterns,
kbnUrlStateStorage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export interface DashboardAppControllerDependencies extends RenderDeps {
$routeParams: any;
indexPatterns: IndexPatternsContract;
dashboardConfig: any;
config: any;
confirmModal: ConfirmModalFn;
history: History;
kbnUrlStateStorage: IKbnUrlStateStorage;
Expand All @@ -109,7 +108,6 @@ export class DashboardAppController {
dashboardConfig,
localStorage,
indexPatterns,
config,
confirmModal,
savedQueryService,
embeddables,
Expand Down Expand Up @@ -376,7 +374,7 @@ export class DashboardAppController {
dashboardStateManager.getQuery() || {
query: '',
language:
localStorage.get('kibana.userQueryLanguage') || config.get('search:queryLanguage'),
localStorage.get('kibana.userQueryLanguage') || uiSettings.get('search:queryLanguage'),
},
queryFilter.getFilters()
);
Expand Down Expand Up @@ -493,7 +491,7 @@ export class DashboardAppController {
{
query: '',
language:
localStorage.get('kibana.userQueryLanguage') || config.get('search:queryLanguage'),
localStorage.get('kibana.userQueryLanguage') || uiSettings.get('search:queryLanguage'),
},
queryFilter.getGlobalFilters()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ export function initDashboardApp(app, deps) {
},
})
.when(`dashboard/:tail*?`, {
redirectTo: `/${deps.core.injectedMetadata.getInjectedVar('kbnDefaultAppId')}`,
redirectTo: `/${deps.config.defaultAppId}`,
})
.when(`dashboards/:tail*?`, {
redirectTo: `/${deps.core.injectedMetadata.getInjectedVar('kbnDefaultAppId')}`,
redirectTo: `/${deps.config.defaultAppId}`,
});
});
}
1 change: 1 addition & 0 deletions src/legacy/core_plugins/kibana/public/dashboard/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export class DashboardPlugin implements Plugin {
chrome: contextCore.chrome,
addBasePath: contextCore.http.basePath.prepend,
uiSettings: contextCore.uiSettings,
config: kibana_legacy.config,
savedQueryService: npDataStart.query.savedQueries,
embeddables,
dashboardCapabilities: contextCore.application.capabilities.dashboard,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ import {
UiSettingsState,
} from 'kibana/public';
import { UiStatsMetricType } from '@kbn/analytics';
import { Environment, FeatureCatalogueEntry } from '../../../../../plugins/home/public';
import {
Environment,
FeatureCatalogueEntry,
HomePublicPluginSetup,
} from '../../../../../plugins/home/public';
import { KibanaLegacySetup } from '../../../../../plugins/kibana_legacy/public';

export interface HomeKibanaServices {
indexPatternService: any;
Expand All @@ -51,6 +56,8 @@ export interface HomeKibanaServices {
chrome: ChromeStart;
telemetryOptInProvider: any;
uiSettings: IUiSettingsClient;
config: KibanaLegacySetup['config'];
homeConfig: HomePublicPluginSetup['config'];
http: HttpStart;
savedObjectsClient: SavedObjectsClientContract;
toastNotifications: NotificationsSetup['toasts'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class Home extends Component {
super(props);

const isWelcomeEnabled = !(
getServices().getInjected('disableWelcomeScreen') ||
getServices().homeConfig.disableWelcomeScreen ||
props.localStorage.getItem(KEY_ENABLE_WELCOME) === 'false'
);
const currentOptInStatus = this.props.getOptInStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jest.mock('../../kibana_services', () => ({
getServices: () => ({
getBasePath: () => 'path',
getInjected: () => '',
homeConfig: { disableWelcomeScreen: false },
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { replaceTemplateStrings } from './tutorial/replace_template_strings';
import { getServices } from '../../kibana_services';
export function HomeApp({ directories }) {
const {
getInjected,
config,
savedObjectsClient,
getBasePath,
addBasePath,
Expand All @@ -41,7 +41,7 @@ export function HomeApp({ directories }) {
const mlEnabled = environment.ml;
const apmUiEnabled = environment.apmUi;

const defaultAppId = getInjected('kbnDefaultAppId', 'discover');
const defaultAppId = config.defaultAppId || 'discover';

const renderTutorialDirectory = props => {
return (
Expand Down
5 changes: 5 additions & 0 deletions src/legacy/core_plugins/kibana/public/home/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
Environment,
FeatureCatalogueEntry,
HomePublicPluginStart,
HomePublicPluginSetup,
} from '../../../../../plugins/home/public';

export interface LegacyAngularInjectedDependencies {
Expand Down Expand Up @@ -59,6 +60,7 @@ export interface HomePluginSetupDependencies {
};
usageCollection: UsageCollectionSetup;
kibana_legacy: KibanaLegacySetup;
home: HomePublicPluginSetup;
}

export class HomePlugin implements Plugin {
Expand All @@ -69,6 +71,7 @@ export class HomePlugin implements Plugin {
setup(
core: CoreSetup,
{
home,
kibana_legacy,
usageCollection,
__LEGACY: { getAngularDependencies, ...legacyServices },
Expand All @@ -95,6 +98,8 @@ export class HomePlugin implements Plugin {
getBasePath: core.http.basePath.get,
indexPatternService: this.dataStart!.indexPatterns,
environment: this.environment!,
config: kibana_legacy.config,
homeConfig: home.config,
...angularDependencies,
});
const { renderApp } = await import('./np_ready/application');
Expand Down
4 changes: 2 additions & 2 deletions src/legacy/core_plugins/kibana/public/kibana.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
// autoloading

// preloading (for faster webpack builds)
import chrome from 'ui/chrome';
import routes from 'ui/routes';
import { uiModules } from 'ui/modules';
import { npSetup } from 'ui/new_platform';
Expand Down Expand Up @@ -64,8 +63,9 @@ localApplicationService.attachToAngular(routes);

routes.enable();

const { config } = npSetup.plugins.kibana_legacy;
routes.otherwise({
redirectTo: `/${chrome.getInjected('kbnDefaultAppId', 'discover')}`,
redirectTo: `/${config.defaultAppId || 'discover'}`,
});

uiModules.get('kibana').run(showAppRedirectNotification);
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { VisualizationsStart } from '../../../visualizations/public';
import { SavedVisualizations } from './np_ready/types';
import { UsageCollectionSetup } from '../../../../../plugins/usage_collection/public';
import { Chrome } from './legacy_imports';
import { KibanaLegacyStart } from '../../../../../plugins/kibana_legacy/public';

export interface VisualizeKibanaServices {
addBasePath: (url: string) => string;
Expand All @@ -52,6 +53,7 @@ export interface VisualizeKibanaServices {
savedVisualizations: SavedVisualizations;
share: SharePluginStart;
uiSettings: IUiSettingsClient;
config: KibanaLegacyStart['config'];
visualizeCapabilities: any;
visualizations: VisualizationsStart;
usageCollection?: UsageCollectionSetup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export function initVisualizeApp(app, deps) {
},
})
.when(`visualize/:tail*?`, {
redirectTo: `/${deps.core.injectedMetadata.getInjectedVar('kbnDefaultAppId')}`,
redirectTo: `/${deps.config.defaultAppId}`,
});
});
}
1 change: 1 addition & 0 deletions src/legacy/core_plugins/kibana/public/visualize/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class VisualizePlugin implements Plugin {
share,
toastNotifications: contextCore.notifications.toasts,
uiSettings: contextCore.uiSettings,
config: kibana_legacy.config,
visualizeCapabilities: contextCore.application.capabilities.visualize,
visualizations,
usageCollection,
Expand Down
3 changes: 3 additions & 0 deletions src/legacy/ui/public/new_platform/__mocks__/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { inspectorPluginMock } from '../../../../../plugins/inspector/public/moc
import { uiActionsPluginMock } from '../../../../../plugins/ui_actions/public/mocks';
import { managementPluginMock } from '../../../../../plugins/management/public/mocks';
import { usageCollectionPluginMock } from '../../../../../plugins/usage_collection/public/mocks';
import { kibanaLegacyPluginMock } from '../../../../../plugins/kibana_legacy/public/mocks';
import { chartPluginMock } from '../../../../../plugins/charts/public/mocks';
/* eslint-enable @kbn/eslint/no-restricted-paths */

Expand All @@ -40,6 +41,7 @@ export const pluginsMock = {
expressions: expressionsPluginMock.createSetupContract(),
uiActions: uiActionsPluginMock.createSetupContract(),
usageCollection: usageCollectionPluginMock.createSetupContract(),
kibana_legacy: kibanaLegacyPluginMock.createSetupContract(),
}),
createStart: () => ({
data: dataPluginMock.createStartContract(),
Expand All @@ -50,6 +52,7 @@ export const pluginsMock = {
expressions: expressionsPluginMock.createStartContract(),
uiActions: uiActionsPluginMock.createStartContract(),
management: managementPluginMock.createStartContract(),
kibana_legacy: kibanaLegacyPluginMock.createStartContract(),
}),
};

Expand Down
Loading