Select a visualization type
@@ -1718,7 +1718,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1`
Start creating your visualization by selecting a type for that visualization.
@@ -2844,7 +2844,7 @@ exports[`NewVisModal should render as expected 1`] = `
>
New Visualization
@@ -3317,7 +3317,7 @@ exports[`NewVisModal should render as expected 1`] = `
>
Select a visualization type
@@ -3342,7 +3342,7 @@ exports[`NewVisModal should render as expected 1`] = `
Start creating your visualization by selecting a type for that visualization.
diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/_dialog.scss b/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/_dialog.scss
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/_dialog.scss
rename to src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/_dialog.scss
diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/_index.scss b/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/_index.scss
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/_index.scss
rename to src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/_index.scss
diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/index.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/index.ts
similarity index 94%
rename from src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/index.ts
rename to src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/index.ts
index 7a3fc63af5259..55ac9ddfb5ca8 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/index.ts
+++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/index.ts
@@ -17,5 +17,4 @@
* under the License.
*/
-export { NewVisModal } from './new_vis_modal';
export { showNewVisModal } from './show_new_vis';
diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/new_vis_modal.test.tsx b/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/new_vis_modal.test.tsx
similarity index 89%
rename from src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/new_vis_modal.test.tsx
rename to src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/new_vis_modal.test.tsx
index 0ef1b711eafc8..58f7bc49d1cdb 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/new_vis_modal.test.tsx
+++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/new_vis_modal.test.tsx
@@ -19,15 +19,7 @@
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
-
-import { VisType } from '../../legacy_imports';
-import { TypesStart } from '../../../../../visualizations/public/np_ready/public/types';
-
-jest.mock('../../legacy_imports', () => ({
- State: () => null,
- AppState: () => null,
-}));
-
+import { TypesStart, VisType } from '../types';
import { NewVisModal } from './new_vis_modal';
import { SavedObjectsStart } from 'kibana/public';
@@ -163,6 +155,26 @@ describe('NewVisModal', () => {
expect(window.location.assign).toBeCalledWith('testbasepath/aliasUrl?addToDashboard');
expect(onClose).toHaveBeenCalled();
});
+
+ it('closes and redirects properly if visualization with aliasUrl and without addToDashboard in editorParams', () => {
+ const onClose = jest.fn();
+ window.location.assign = jest.fn();
+ const wrapper = mountWithIntl(
+
+ );
+ const visButton = wrapper.find('button[data-test-subj="visType-visWithAliasUrl"]');
+ visButton.simulate('click');
+ expect(window.location.assign).toBeCalledWith('testbasepath/aliasUrl');
+ expect(onClose).toHaveBeenCalled();
+ });
});
describe('filter for visualization types', () => {
diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/new_vis_modal.tsx b/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/new_vis_modal.tsx
similarity index 93%
rename from src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/new_vis_modal.tsx
rename to src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/new_vis_modal.tsx
index 082fc3bc36b6b..b39e8e8926707 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/new_vis_modal.tsx
+++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/new_vis_modal.tsx
@@ -24,14 +24,9 @@ import { i18n } from '@kbn/i18n';
import { METRIC_TYPE, UiStatsMetricType } from '@kbn/analytics';
import { IUiSettingsClient, SavedObjectsStart } from 'kibana/public';
-import { VisType } from '../../legacy_imports';
-import { VisualizeConstants } from '../visualize_constants';
import { SearchSelection } from './search_selection';
import { TypeSelection } from './type_selection';
-import {
- TypesStart,
- VisTypeAlias,
-} from '../../../../../visualizations/public/np_ready/public/types';
+import { TypesStart, VisType, VisTypeAlias } from '../types';
import { UsageCollectionSetup } from '../../../../../../../plugins/usage_collection/public';
interface TypeSelectionProps {
@@ -50,7 +45,9 @@ interface TypeSelectionState {
visType?: VisType;
}
-const baseUrl = `#${VisualizeConstants.CREATE_PATH}?`;
+// TODO: redirect logic is specific to visualise & dashboard
+// but it is likely should be decoupled. e.g. handled by the container instead
+const baseUrl = `#/visualize/create?`;
class NewVisModal extends React.Component {
public static defaultProps = {
@@ -82,7 +79,7 @@ class NewVisModal extends React.Component void;
@@ -42,13 +42,13 @@ export class SearchSelection extends React.Component {
{' '}
/{' '}
@@ -59,7 +59,7 @@ export class SearchSelection extends React.Component {
onChoose={this.props.onSearchSelected}
showFilter
noItemsMessage={i18n.translate(
- 'kbn.visualize.newVisWizard.searchSelection.notFoundLabel',
+ 'visualizations.newVisWizard.searchSelection.notFoundLabel',
{
defaultMessage: 'No matching indices or saved searches found.',
}
@@ -69,7 +69,7 @@ export class SearchSelection extends React.Component {
type: 'search',
getIconForSavedObject: () => 'search',
name: i18n.translate(
- 'kbn.visualize.newVisWizard.searchSelection.savedObjectType.search',
+ 'visualizations.newVisWizard.searchSelection.savedObjectType.search',
{
defaultMessage: 'Saved search',
}
@@ -79,7 +79,7 @@ export class SearchSelection extends React.Component {
type: 'index-pattern',
getIconForSavedObject: () => 'indexPatternApp',
name: i18n.translate(
- 'kbn.visualize.newVisWizard.searchSelection.savedObjectType.indexPattern',
+ 'visualizations.newVisWizard.searchSelection.savedObjectType.indexPattern',
{
defaultMessage: 'Index pattern',
}
diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/show_new_vis.tsx b/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/show_new_vis.tsx
similarity index 63%
rename from src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/show_new_vis.tsx
rename to src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/show_new_vis.tsx
index 567b7e861ad8e..a79c6ad98edf6 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/show_new_vis.tsx
+++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/show_new_vis.tsx
@@ -21,27 +21,25 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { I18nProvider } from '@kbn/i18n/react';
-import { IUiSettingsClient, SavedObjectsStart } from 'kibana/public';
import { NewVisModal } from './new_vis_modal';
-import { TypesStart } from '../../../../../visualizations/public/np_ready/public/types';
-import { UsageCollectionSetup } from '../../../../../../../plugins/usage_collection/public';
+import { getHttp, getSavedObjects, getTypes, getUISettings, getUsageCollector } from '../services';
-interface ShowNewVisModalParams {
+export interface ShowNewVisModalParams {
editorParams?: string[];
+ onClose?: () => void;
}
-export function showNewVisModal(
- visTypeRegistry: TypesStart,
- { editorParams = [] }: ShowNewVisModalParams = {},
- addBasePath: (path: string) => string,
- uiSettings: IUiSettingsClient,
- savedObjects: SavedObjectsStart,
- usageCollection?: UsageCollectionSetup
-) {
+export function showNewVisModal({ editorParams = [], onClose }: ShowNewVisModalParams = {}) {
const container = document.createElement('div');
- const onClose = () => {
+ let isClosed = false;
+ const handleClose = () => {
+ if (isClosed) return;
ReactDOM.unmountComponentAtNode(container);
document.body.removeChild(container);
+ if (onClose) {
+ onClose();
+ }
+ isClosed = true;
};
document.body.appendChild(container);
@@ -49,15 +47,17 @@ export function showNewVisModal(
);
ReactDOM.render(element, container);
+
+ return () => handleClose();
}
diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/type_selection/index.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/type_selection/index.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/type_selection/index.ts
rename to src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/type_selection/index.ts
diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/type_selection/new_vis_help.test.tsx b/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/type_selection/new_vis_help.test.tsx
similarity index 97%
rename from src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/type_selection/new_vis_help.test.tsx
rename to src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/type_selection/new_vis_help.test.tsx
index a33a82c252fb3..138251beb9593 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/type_selection/new_vis_help.test.tsx
+++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/type_selection/new_vis_help.test.tsx
@@ -49,7 +49,7 @@ describe('NewVisHelp', () => {
diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/type_selection/new_vis_help.tsx b/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/type_selection/new_vis_help.tsx
similarity index 93%
rename from src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/type_selection/new_vis_help.tsx
rename to src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/type_selection/new_vis_help.tsx
index 2f7effb7a33c8..5068f43952c4e 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/type_selection/new_vis_help.tsx
+++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/type_selection/new_vis_help.tsx
@@ -21,7 +21,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import React, { Fragment } from 'react';
import { EuiText, EuiButton } from '@elastic/eui';
import { VisTypeAliasListEntry } from './type_selection';
-import { VisTypeAlias } from '../../../../../../visualizations/public';
+import { VisTypeAlias } from '../../types';
interface Props {
promotedTypes: VisTypeAliasListEntry[];
@@ -33,7 +33,7 @@ export function NewVisHelp(props: Props) {
diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/type_selection/type_selection.tsx b/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/type_selection/type_selection.tsx
similarity index 90%
rename from src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/type_selection/type_selection.tsx
rename to src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/type_selection/type_selection.tsx
index 44da7cc8f2c45..574f5b3cccc99 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/type_selection/type_selection.tsx
+++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/type_selection/type_selection.tsx
@@ -34,13 +34,13 @@ import {
EuiSpacer,
EuiTitle,
} from '@elastic/eui';
-import { VisType } from '../../../legacy_imports';
+
import { memoizeLast } from '../../../../../../visualizations/public/np_ready/public/legacy/memoize';
import { VisTypeAlias } from '../../../../../../visualizations/public';
import { NewVisHelp } from './new_vis_help';
import { VisHelpText } from './vis_help_text';
import { VisTypeIcon } from './vis_type_icon';
-import { TypesStart } from '../../../../../../visualizations/public/np_ready/public/types';
+import { VisType, TypesStart } from '../../types';
export interface VisTypeListEntry extends VisType {
highlighted: boolean;
@@ -85,7 +85,7 @@ class TypeSelection extends React.Component
@@ -107,7 +107,7 @@ class TypeSelection extends React.Component
{query && (
@@ -207,26 +207,26 @@ class TypeSelection extends React.Component !schema.isHiddenType(type));
const importableAndExportableTypes = getImportableAndExportableTypes({ kbnServer, visibleTypes });
@@ -99,7 +100,7 @@ export function savedObjectsMixin(kbnServer, server) {
server.route(createResolveImportErrorsRoute(prereqs, server, importableAndExportableTypes));
server.route(createLogLegacyImportRoute());
- const serializer = new SavedObjectsSerializer(schema);
+ const serializer = kbnServer.newPlatform.start.core.savedObjects.createSerializer();
const createRepository = (callCluster, extraTypes = []) => {
if (typeof callCluster !== 'function') {
@@ -118,10 +119,9 @@ export function savedObjectsMixin(kbnServer, server) {
return new SavedObjectsRepository({
index: config.get('kibana.index'),
- config,
migrator,
mappings,
- schema,
+ typeRegistry,
serializer,
allowedTypes,
callCluster,
diff --git a/src/legacy/server/saved_objects/saved_objects_mixin.test.js b/src/legacy/server/saved_objects/saved_objects_mixin.test.js
index 691878cf66d27..9ca0374b959f6 100644
--- a/src/legacy/server/saved_objects/saved_objects_mixin.test.js
+++ b/src/legacy/server/saved_objects/saved_objects_mixin.test.js
@@ -22,6 +22,14 @@ import { savedObjectsMixin } from './saved_objects_mixin';
import { mockKibanaMigrator } from '../../../core/server/saved_objects/migrations/kibana/kibana_migrator.mock';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { savedObjectsClientProviderMock } from '../../../core/server/saved_objects/service/lib/scoped_client_provider.mock';
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import { convertLegacyTypes } from '../../../core/server/saved_objects/utils';
+import { SavedObjectTypeRegistry } from '../../../core/server';
+import { coreMock } from '../../../core/server/mocks';
+
+const mockConfig = {
+ get: jest.fn().mockReturnValue('anything'),
+};
const savedObjectMappings = [
{
@@ -61,7 +69,30 @@ const savedObjectMappings = [
},
];
-const migrator = mockKibanaMigrator.create({ savedObjectMappings });
+const savedObjectSchemas = {
+ hiddentype: {
+ hidden: true,
+ },
+ doc1: {
+ indexPattern: 'other-index',
+ },
+};
+
+const savedObjectTypes = convertLegacyTypes(
+ {
+ savedObjectMappings,
+ savedObjectSchemas,
+ savedObjectMigrations: {},
+ },
+ mockConfig
+);
+
+const typeRegistry = new SavedObjectTypeRegistry();
+savedObjectTypes.forEach(type => typeRegistry.registerType(type));
+
+const migrator = mockKibanaMigrator.create({
+ types: savedObjectTypes,
+});
describe('Saved Objects Mixin', () => {
let mockKbnServer;
@@ -113,7 +144,17 @@ describe('Saved Objects Mixin', () => {
};
mockKbnServer = {
newPlatform: {
- __internals: { kibanaMigrator: migrator, savedObjectsClientProvider: clientProvider },
+ __internals: {
+ kibanaMigrator: migrator,
+ savedObjectsClientProvider: clientProvider,
+ typeRegistry,
+ },
+ setup: {
+ core: coreMock.createSetup(),
+ },
+ start: {
+ core: coreMock.createStart(),
+ },
},
server: mockServer,
ready: () => {},
@@ -124,14 +165,7 @@ describe('Saved Objects Mixin', () => {
},
uiExports: {
savedObjectMappings,
- savedObjectSchemas: {
- hiddentype: {
- hidden: true,
- },
- doc1: {
- indexPattern: 'other-index',
- },
- },
+ savedObjectSchemas,
},
};
});
diff --git a/src/legacy/ui/public/UI_SYSTEMS.md b/src/legacy/ui/public/UI_SYSTEMS.md
index 37bfbcf92f640..8462b2c8f4144 100644
--- a/src/legacy/ui/public/UI_SYSTEMS.md
+++ b/src/legacy/ui/public/UI_SYSTEMS.md
@@ -5,4 +5,4 @@ In this directory you'll find various UI systems you can use to craft effective
## ui/notify
* [banners](notify/banners/BANNERS.md)
-* [toastNotifications](notify/toasts/TOAST_NOTIFICATIONS.md)
+* [toastNotifications](../../../plugins/kibana_legacy/public/notify/toasts/TOAST_NOTIFICATIONS.md)
diff --git a/src/legacy/ui/public/_index.scss b/src/legacy/ui/public/_index.scss
index e4e58019dda69..e990ba2a46de5 100644
--- a/src/legacy/ui/public/_index.scss
+++ b/src/legacy/ui/public/_index.scss
@@ -10,7 +10,6 @@
@import './accessibility/index';
@import './chrome/index';
-@import './collapsible_sidebar/index';
@import './directives/index';
@import './error_auto_create_index/index';
@import './error_url_overflow/index';
diff --git a/src/legacy/ui/public/accessibility/kbn_accessible_click.js b/src/legacy/ui/public/accessibility/kbn_accessible_click.js
index 35a2fa56af169..a57fbc6be82fd 100644
--- a/src/legacy/ui/public/accessibility/kbn_accessible_click.js
+++ b/src/legacy/ui/public/accessibility/kbn_accessible_click.js
@@ -37,58 +37,7 @@
* Apply this directive to any of these elements to automatically do the above.
*/
-import { accessibleClickKeys, keyCodes } from '@elastic/eui';
import { uiModules } from '../modules';
-
-export function KbnAccessibleClickProvider() {
- return {
- restrict: 'A',
- controller: $element => {
- $element.on('keydown', e => {
- // Prevent a scroll from occurring if the user has hit space.
- if (e.keyCode === keyCodes.SPACE) {
- e.preventDefault();
- }
- });
- },
- link: (scope, element, attrs) => {
- // The whole point of this directive is to hack in functionality that native buttons provide
- // by default.
- const elementType = element.prop('tagName');
-
- if (elementType === 'BUTTON') {
- throw new Error(`kbnAccessibleClick doesn't need to be used on a button.`);
- }
-
- if (elementType === 'A' && attrs.href !== undefined) {
- throw new Error(
- `kbnAccessibleClick doesn't need to be used on a link if it has a href attribute.`
- );
- }
-
- // We're emulating a click action, so we should already have a regular click handler defined.
- if (!attrs.ngClick) {
- throw new Error('kbnAccessibleClick requires ng-click to be defined on its element.');
- }
-
- // If the developer hasn't already specified attributes required for accessibility, add them.
- if (attrs.tabindex === undefined) {
- element.attr('tabindex', '0');
- }
-
- if (attrs.role === undefined) {
- element.attr('role', 'button');
- }
-
- element.on('keyup', e => {
- // Support keyboard accessibility by emulating mouse click on ENTER or SPACE keypress.
- if (accessibleClickKeys[e.keyCode]) {
- // Delegate to the click handler on the element (assumed to be ng-click).
- element.click();
- }
- });
- },
- };
-}
+import { KbnAccessibleClickProvider } from '../../../../plugins/kibana_legacy/public';
uiModules.get('kibana').directive('kbnAccessibleClick', KbnAccessibleClickProvider);
diff --git a/src/legacy/ui/public/agg_response/tabify/_get_columns.ts b/src/legacy/ui/public/agg_response/tabify/_get_columns.ts
index a3127c039049b..4144d5be16012 100644
--- a/src/legacy/ui/public/agg_response/tabify/_get_columns.ts
+++ b/src/legacy/ui/public/agg_response/tabify/_get_columns.ts
@@ -18,15 +18,15 @@
*/
import { groupBy } from 'lodash';
-import { AggConfig } from '../../agg_types';
+import { IAggConfig } from '../../agg_types';
export interface AggColumn {
- aggConfig: AggConfig;
+ aggConfig: IAggConfig;
id: string;
name: string;
}
-const getColumn = (agg: AggConfig, i: number): AggColumn => {
+const getColumn = (agg: IAggConfig, i: number): AggColumn => {
return {
aggConfig: agg,
id: `col-${i}-${agg.id}`,
@@ -40,7 +40,7 @@ const getColumn = (agg: AggConfig, i: number): AggColumn => {
* @param {AggConfigs} aggs - the agg configs object to which the aggregation response correlates
* @param {boolean} minimalColumns - setting to true will only return a column for the last bucket/metric instead of one for each level
*/
-export function tabifyGetColumns(aggs: AggConfig[], minimalColumns: boolean) {
+export function tabifyGetColumns(aggs: IAggConfig[], minimalColumns: boolean) {
// pick the columns
if (minimalColumns) {
return aggs.map((agg, i) => getColumn(agg, i));
diff --git a/src/legacy/ui/public/agg_types/index.ts b/src/legacy/ui/public/agg_types/index.ts
index cf2733b9a9f36..ac5d0bed7ef15 100644
--- a/src/legacy/ui/public/agg_types/index.ts
+++ b/src/legacy/ui/public/agg_types/index.ts
@@ -17,15 +17,69 @@
* under the License.
*/
-export { aggTypes } from './agg_types';
-export { AggParam } from './agg_params';
-export { AggConfig } from './agg_config';
-export { AggConfigs } from './agg_configs';
-export { AggGroupNames, aggGroupNamesMap } from './agg_groups';
-export { FieldParamType } from './param_types';
-export { BUCKET_TYPES } from './buckets/bucket_agg_types';
-export { METRIC_TYPES } from './metrics/metric_agg_types';
-export { ISchemas, Schema, Schemas } from './schemas';
-export { AggType } from './agg_type';
-export { setBounds } from './buckets/date_histogram';
-export { termsAggFilter } from './buckets/terms';
+/**
+ * Nothing to see here!
+ *
+ * Agg Types have moved to the data plugin, and are being
+ * re-exported from ui/agg_types for backwards compatibility.
+ */
+
+import { start as dataStart } from '../../../core_plugins/data/public/legacy';
+
+// runtime contracts
+export const {
+ types: aggTypes,
+ AggConfig,
+ AggConfigs,
+ AggType,
+ aggTypeFieldFilters,
+ FieldParamType,
+ MetricAggType,
+ parentPipelineAggHelper,
+ siblingPipelineAggHelper,
+ setBounds,
+} = dataStart.search.aggs;
+
+// types
+export {
+ IAggConfig,
+ IAggConfigs,
+ IAggType,
+ IFieldParamType,
+ IMetricAggType,
+ AggParam,
+ AggParamOption,
+ BUCKET_TYPES,
+ DateRangeKey,
+ IpRangeKey,
+ ISchemas,
+ METRIC_TYPES,
+ OptionedParamEditorProps,
+ OptionedValueProp,
+} from '../../../core_plugins/data/public';
+
+// static code
+export {
+ AggParamType,
+ AggTypeFilters,
+ aggTypeFilters,
+ AggTypeFieldFilters,
+ AggGroupNames,
+ aggGroupNamesMap,
+ CidrMask,
+ convertDateRangeToString,
+ convertIPRangeToString,
+ intervalOptions,
+ isDateHistogramBucketAggConfig,
+ isStringType,
+ isType,
+ isValidInterval,
+ isValidJson,
+ OptionedParamType,
+ parentPipelineType,
+ propFilter,
+ Schema,
+ Schemas,
+ siblingPipelineType,
+ termsAggFilter,
+} from '../../../core_plugins/data/public';
diff --git a/src/legacy/ui/public/chrome/api/nav.ts b/src/legacy/ui/public/chrome/api/nav.ts
index 771314d9e1481..ae32473e451b7 100644
--- a/src/legacy/ui/public/chrome/api/nav.ts
+++ b/src/legacy/ui/public/chrome/api/nav.ts
@@ -146,7 +146,7 @@ export function initChromeNavApi(chrome: any, internals: NavInternals) {
// link.active and link.lastUrl properties
coreNavLinks
.getAll()
- .filter(link => link.subUrlBase)
+ .filter(link => link.subUrlBase && !link.disableSubUrlTracking)
.forEach(link => {
coreNavLinks.update(link.id, {
subUrlBase: relativeToAbsolute(chrome.addBasePath(link.subUrlBase)),
diff --git a/src/legacy/ui/public/collapsible_sidebar/_index.scss b/src/legacy/ui/public/collapsible_sidebar/_index.scss
deleted file mode 100644
index 84b759f66720e..0000000000000
--- a/src/legacy/ui/public/collapsible_sidebar/_index.scss
+++ /dev/null
@@ -1,3 +0,0 @@
-@import '../styles/_legacy/depth';
-
-@import './collapsible_sidebar';
diff --git a/src/legacy/ui/public/directives/listen/listen.js b/src/legacy/ui/public/directives/listen/listen.js
index 97185e4f602ff..db19471fdb640 100644
--- a/src/legacy/ui/public/directives/listen/listen.js
+++ b/src/legacy/ui/public/directives/listen/listen.js
@@ -18,23 +18,6 @@
*/
import { uiModules } from '../../modules';
-
-export function registerListenEventListener($rootScope) {
- /**
- * Helper that registers an event listener, and removes that listener when
- * the $scope is destroyed.
- *
- * @param {SimpleEmitter} emitter - the event emitter to listen to
- * @param {string} eventName - the event name
- * @param {Function} handler - the event handler
- * @return {undefined}
- */
- $rootScope.constructor.prototype.$listen = function(emitter, eventName, handler) {
- emitter.on(eventName, handler);
- this.$on('$destroy', function() {
- emitter.off(eventName, handler);
- });
- };
-}
+import { registerListenEventListener } from '../../../../../plugins/kibana_legacy/public';
uiModules.get('kibana').run(registerListenEventListener);
diff --git a/src/legacy/ui/public/directives/watch_multi/index.js b/src/legacy/ui/public/directives/watch_multi/index.js
index 3f0f43ce27ed2..800bb503088d4 100644
--- a/src/legacy/ui/public/directives/watch_multi/index.js
+++ b/src/legacy/ui/public/directives/watch_multi/index.js
@@ -17,4 +17,6 @@
* under the License.
*/
-import './watch_multi';
+import { uiModules } from '../../modules';
+import { watchMultiDecorator } from '../../../../../plugins/kibana_legacy/public';
+uiModules.get('kibana').config(watchMultiDecorator);
diff --git a/src/legacy/ui/public/error_url_overflow/__tests__/ie_regex.js b/src/legacy/ui/public/error_url_overflow/__tests__/ie_regex.js
index 3f5a3442b47b3..3d770c13a81aa 100644
--- a/src/legacy/ui/public/error_url_overflow/__tests__/ie_regex.js
+++ b/src/legacy/ui/public/error_url_overflow/__tests__/ie_regex.js
@@ -18,7 +18,7 @@
*/
import expect from '@kbn/expect';
-import { IE_REGEX } from '../url_overflow_service.js';
+import { IE_REGEX } from '../../../../../plugins/kibana_legacy/public';
describe('IE_REGEX', () => {
it('should detect IE 9', () => {
diff --git a/src/legacy/ui/public/error_url_overflow/error_url_overflow.js b/src/legacy/ui/public/error_url_overflow/error_url_overflow.js
index c9b20f41d2b99..223b81fa36fde 100644
--- a/src/legacy/ui/public/error_url_overflow/error_url_overflow.js
+++ b/src/legacy/ui/public/error_url_overflow/error_url_overflow.js
@@ -22,9 +22,9 @@ import uiRoutes from '../routes';
import { KbnUrlProvider } from '../url';
import template from './error_url_overflow.html';
-import { UrlOverflowService } from './url_overflow_service';
+import { UrlOverflowService } from '../../../../plugins/kibana_legacy/public';
-export * from './url_overflow_service';
+export { UrlOverflowService };
uiRoutes.when('/error/url-overflow', {
template,
diff --git a/src/legacy/ui/public/error_url_overflow/index.js b/src/legacy/ui/public/error_url_overflow/index.js
index c5b13182a8288..06a98789349f8 100644
--- a/src/legacy/ui/public/error_url_overflow/index.js
+++ b/src/legacy/ui/public/error_url_overflow/index.js
@@ -18,4 +18,4 @@
*/
import './error_url_overflow';
-export { UrlOverflowService } from './url_overflow_service';
+export { UrlOverflowService } from '../../../../plugins/kibana_legacy/public';
diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/__snapshots__/truncate.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/__snapshots__/truncate.test.js.snap
index c0954491a2a47..729487dfae5d7 100644
--- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/__snapshots__/truncate.test.js.snap
+++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/__snapshots__/truncate.test.js.snap
@@ -21,6 +21,7 @@ exports[`TruncateFormatEditor should render normally 1`] = `
>
diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.js
index fdae8627ead69..9a9b6c954b78d 100644
--- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.js
+++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.js
@@ -38,7 +38,7 @@ export class TruncateFormatEditor extends DefaultFormatEditor {
}
render() {
- const { formatParams } = this.props;
+ const { formatParams, onError } = this.props;
const { error, samples } = this.state;
return (
@@ -55,8 +55,15 @@ export class TruncateFormatEditor extends DefaultFormatEditor {
>
{
- this.onChange({ fieldLength: e.target.value ? Number(e.target.value) : null });
+ if (e.target.checkValidity()) {
+ this.onChange({
+ fieldLength: e.target.value ? Number(e.target.value) : null,
+ });
+ } else {
+ onError(e.target.validationMessage);
+ }
}}
isInvalid={!!error}
/>
diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.test.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.test.js
index e98dd4edca386..7ab6f2a9cbeb0 100644
--- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.test.js
+++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.test.js
@@ -19,6 +19,7 @@
import React from 'react';
import { shallow } from 'enzyme';
+import { EuiFieldNumber } from '@elastic/eui';
import { TruncateFormatEditor } from './truncate';
@@ -34,6 +35,11 @@ const onChange = jest.fn();
const onError = jest.fn();
describe('TruncateFormatEditor', () => {
+ beforeEach(() => {
+ onChange.mockClear();
+ onError.mockClear();
+ });
+
it('should have a formatId', () => {
expect(TruncateFormatEditor.formatId).toEqual('truncate');
});
@@ -50,4 +56,54 @@ describe('TruncateFormatEditor', () => {
);
expect(component).toMatchSnapshot();
});
+
+ it('should fire error, when input is invalid', async () => {
+ const component = shallow(
+
+ );
+ const input = component.find(EuiFieldNumber);
+
+ const changeEvent = {
+ target: {
+ value: '123.3',
+ checkValidity: () => false,
+ validationMessage: 'Error!',
+ },
+ };
+ await input.invoke('onChange')(changeEvent);
+
+ expect(onError).toBeCalledWith(changeEvent.target.validationMessage);
+ expect(onChange).not.toBeCalled();
+ });
+
+ it('should fire change, when input changed and is valid', async () => {
+ const component = shallow(
+
+ );
+ const input = component.find(EuiFieldNumber);
+
+ const changeEvent = {
+ target: {
+ value: '123',
+ checkValidity: () => true,
+ validationMessage: null,
+ },
+ };
+ onError.mockClear();
+ await input.invoke('onChange')(changeEvent);
+ expect(onError).not.toBeCalled();
+ expect(onChange).toBeCalledWith({ fieldLength: 123 });
+ });
});
diff --git a/src/legacy/ui/public/kbn_top_nav/kbn_top_nav.js b/src/legacy/ui/public/kbn_top_nav/kbn_top_nav.js
index 0788afd5f74eb..12c3ca2acc3cd 100644
--- a/src/legacy/ui/public/kbn_top_nav/kbn_top_nav.js
+++ b/src/legacy/ui/public/kbn_top_nav/kbn_top_nav.js
@@ -92,6 +92,7 @@ export const createTopNavHelper = ({ TopNavMenu }) => reactDirective => {
['onClearSavedQuery', { watchDepth: 'reference' }],
['onSaved', { watchDepth: 'reference' }],
['onSavedQueryUpdated', { watchDepth: 'reference' }],
+ ['onSavedQueryIdChange', { watchDepth: 'reference' }],
['indexPatterns', { watchDepth: 'collection' }],
['filters', { watchDepth: 'collection' }],
@@ -109,10 +110,14 @@ export const createTopNavHelper = ({ TopNavMenu }) => reactDirective => {
'screenTitle',
'dateRangeFrom',
'dateRangeTo',
+ 'savedQueryId',
'isRefreshPaused',
'refreshInterval',
'disableAutoFocus',
'showAutoRefreshOnly',
+
+ // temporary flag to use the stateful components
+ 'useDefaultBehaviors',
]);
};
diff --git a/src/legacy/ui/public/legacy_compat/__tests__/xsrf.js b/src/legacy/ui/public/legacy_compat/__tests__/xsrf.js
index 6d2fd2318686a..fc12a18d72823 100644
--- a/src/legacy/ui/public/legacy_compat/__tests__/xsrf.js
+++ b/src/legacy/ui/public/legacy_compat/__tests__/xsrf.js
@@ -22,7 +22,7 @@ import expect from '@kbn/expect';
import sinon from 'sinon';
import ngMock from 'ng_mock';
-import { $setupXsrfRequestInterceptor } from '../angular_config';
+import { $setupXsrfRequestInterceptor } from '../../../../../plugins/kibana_legacy/public';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { version } from '../../../../../core/server/utils/package_json';
diff --git a/src/legacy/ui/public/legacy_compat/index.ts b/src/legacy/ui/public/legacy_compat/index.ts
index ea8932114118e..3b700c8d59399 100644
--- a/src/legacy/ui/public/legacy_compat/index.ts
+++ b/src/legacy/ui/public/legacy_compat/index.ts
@@ -17,5 +17,7 @@
* under the License.
*/
-export { configureAppAngularModule } from './angular_config';
-export { ensureDefaultIndexPattern } from './ensure_default_index_pattern';
+export {
+ configureAppAngularModule,
+ ensureDefaultIndexPattern,
+} from '../../../../plugins/kibana_legacy/public';
diff --git a/src/legacy/ui/public/management/index.d.ts b/src/legacy/ui/public/management/index.d.ts
index 7880e1d5d0295..529efd36623a3 100644
--- a/src/legacy/ui/public/management/index.d.ts
+++ b/src/legacy/ui/public/management/index.d.ts
@@ -18,15 +18,7 @@
*/
declare module 'ui/management' {
- export const PAGE_TITLE_COMPONENT: string;
- export const PAGE_SUBTITLE_COMPONENT: string;
- export const PAGE_FOOTER_COMPONENT: string;
export const SidebarNav: React.FC;
- export function registerSettingsComponent(
- id: string,
- component: string | React.FC,
- allowOverride: boolean
- ): void;
export const management: any; // TODO - properly provide types
export const MANAGEMENT_BREADCRUMB: {
text: string;
diff --git a/src/legacy/ui/public/management/index.js b/src/legacy/ui/public/management/index.js
index b2f1946dbc59c..25d3678c5dbba 100644
--- a/src/legacy/ui/public/management/index.js
+++ b/src/legacy/ui/public/management/index.js
@@ -17,12 +17,6 @@
* under the License.
*/
-export {
- PAGE_TITLE_COMPONENT,
- PAGE_SUBTITLE_COMPONENT,
- PAGE_FOOTER_COMPONENT,
-} from '../../../core_plugins/kibana/public/management/sections/settings/components/default_component_registry';
-export { registerSettingsComponent } from '../../../core_plugins/kibana/public/management/sections/settings/components/component_registry';
export { MANAGEMENT_BREADCRUMB } from './breadcrumbs';
import { npStart } from 'ui/new_platform';
export const management = npStart.plugins.management.legacy;
diff --git a/src/legacy/ui/public/new_platform/__mocks__/helpers.ts b/src/legacy/ui/public/new_platform/__mocks__/helpers.ts
index 439ac9b5713df..6f6b4be86f58d 100644
--- a/src/legacy/ui/public/new_platform/__mocks__/helpers.ts
+++ b/src/legacy/ui/public/new_platform/__mocks__/helpers.ts
@@ -29,6 +29,7 @@ import { managementPluginMock } from '../../../../../plugins/management/public/m
import { usageCollectionPluginMock } from '../../../../../plugins/usage_collection/public/mocks';
import { kibanaLegacyPluginMock } from '../../../../../plugins/kibana_legacy/public/mocks';
import { chartPluginMock } from '../../../../../plugins/charts/public/mocks';
+import { advancedSettingsMock } from '../../../../../plugins/advanced_settings/public/mocks';
/* eslint-enable @kbn/eslint/no-restricted-paths */
export const pluginsMock = {
@@ -41,7 +42,8 @@ export const pluginsMock = {
expressions: expressionsPluginMock.createSetupContract(),
uiActions: uiActionsPluginMock.createSetupContract(),
usageCollection: usageCollectionPluginMock.createSetupContract(),
- kibana_legacy: kibanaLegacyPluginMock.createSetupContract(),
+ advancedSettings: advancedSettingsMock.createSetupContract(),
+ kibanaLegacy: kibanaLegacyPluginMock.createSetupContract(),
}),
createStart: () => ({
data: dataPluginMock.createStartContract(),
@@ -52,7 +54,8 @@ export const pluginsMock = {
expressions: expressionsPluginMock.createStartContract(),
uiActions: uiActionsPluginMock.createStartContract(),
management: managementPluginMock.createStartContract(),
- kibana_legacy: kibanaLegacyPluginMock.createStartContract(),
+ advancedSettings: advancedSettingsMock.createStartContract(),
+ kibanaLegacy: kibanaLegacyPluginMock.createStartContract(),
}),
};
diff --git a/src/legacy/ui/public/new_platform/new_platform.karma_mock.js b/src/legacy/ui/public/new_platform/new_platform.karma_mock.js
index c2c8b5a0fae7a..3cc33504d3daa 100644
--- a/src/legacy/ui/public/new_platform/new_platform.karma_mock.js
+++ b/src/legacy/ui/public/new_platform/new_platform.karma_mock.js
@@ -20,6 +20,7 @@
import sinon from 'sinon';
import { getFieldFormatsRegistry } from '../../../../test_utils/public/stub_field_formats';
import { METRIC_TYPE } from '@kbn/analytics';
+import { ComponentRegistry } from '../../../../../src/plugins/advanced_settings/public/';
const mockObservable = () => {
return {
@@ -58,6 +59,12 @@ const mockCore = {
export const npSetup = {
core: mockCore,
plugins: {
+ advancedSettings: {
+ component: {
+ register: sinon.fake(),
+ componentType: ComponentRegistry.componentType,
+ },
+ },
usageCollection: {
allowTrackUserAgent: sinon.fake(),
reportUiStats: sinon.fake(),
@@ -113,10 +120,10 @@ export const npSetup = {
share: {
register: () => {},
},
- dev_tools: {
+ devTools: {
register: () => {},
},
- kibana_legacy: {
+ kibanaLegacy: {
registerLegacyApp: () => {},
forwardApp: () => {},
config: {
@@ -196,10 +203,10 @@ export const npStart = {
registerRenderer: sinon.fake(),
registerType: sinon.fake(),
},
- dev_tools: {
+ devTools: {
getSortedDevTools: () => [],
},
- kibana_legacy: {
+ kibanaLegacy: {
getApps: () => [],
getForwards: () => [],
config: {
diff --git a/src/legacy/ui/public/new_platform/new_platform.ts b/src/legacy/ui/public/new_platform/new_platform.ts
index 2ade98ec54efd..e300ce4a0caf8 100644
--- a/src/legacy/ui/public/new_platform/new_platform.ts
+++ b/src/legacy/ui/public/new_platform/new_platform.ts
@@ -18,7 +18,7 @@
*/
import { IScope } from 'angular';
-import { IUiActionsStart, IUiActionsSetup } from 'src/plugins/ui_actions/public';
+import { UiActionsStart, UiActionsSetup } from 'src/plugins/ui_actions/public';
import { IEmbeddableStart, IEmbeddableSetup } from 'src/plugins/embeddable/public';
import { LegacyCoreSetup, LegacyCoreStart, App, AppMountDeprecated } from '../../../../core/public';
import { Plugin as DataPlugin } from '../../../../plugins/data/public';
@@ -32,6 +32,10 @@ import { DevToolsSetup, DevToolsStart } from '../../../../plugins/dev_tools/publ
import { KibanaLegacySetup, KibanaLegacyStart } from '../../../../plugins/kibana_legacy/public';
import { HomePublicPluginSetup, HomePublicPluginStart } from '../../../../plugins/home/public';
import { SharePluginSetup, SharePluginStart } from '../../../../plugins/share/public';
+import {
+ AdvancedSettingsSetup,
+ AdvancedSettingsStart,
+} from '../../../../plugins/advanced_settings/public';
import { ManagementSetup, ManagementStart } from '../../../../plugins/management/public';
import { BfetchPublicSetup, BfetchPublicStart } from '../../../../plugins/bfetch/public';
import { UsageCollectionSetup } from '../../../../plugins/usage_collection/public';
@@ -48,12 +52,13 @@ export interface PluginsSetup {
expressions: ReturnType;
home: HomePublicPluginSetup;
inspector: InspectorSetup;
- uiActions: IUiActionsSetup;
+ uiActions: UiActionsSetup;
navigation: NavigationPublicPluginSetup;
- dev_tools: DevToolsSetup;
- kibana_legacy: KibanaLegacySetup;
+ devTools: DevToolsSetup;
+ kibanaLegacy: KibanaLegacySetup;
share: SharePluginSetup;
usageCollection: UsageCollectionSetup;
+ advancedSettings: AdvancedSettingsSetup;
management: ManagementSetup;
}
@@ -65,12 +70,13 @@ export interface PluginsStart {
expressions: ReturnType;
home: HomePublicPluginStart;
inspector: InspectorStart;
- uiActions: IUiActionsStart;
+ uiActions: UiActionsStart;
navigation: NavigationPublicPluginStart;
- dev_tools: DevToolsStart;
- kibana_legacy: KibanaLegacyStart;
+ devTools: DevToolsStart;
+ kibanaLegacy: KibanaLegacyStart;
share: SharePluginStart;
management: ManagementStart;
+ advancedSettings: AdvancedSettingsStart;
}
export const npSetup = {
diff --git a/src/legacy/ui/public/notify/banners/index.js b/src/legacy/ui/public/notify/banners/index.ts
similarity index 100%
rename from src/legacy/ui/public/notify/banners/index.js
rename to src/legacy/ui/public/notify/banners/index.ts
diff --git a/src/legacy/ui/public/notify/fatal_error.ts b/src/legacy/ui/public/notify/fatal_error.ts
index 4c02322bae492..7fa2ae7ac6fe6 100644
--- a/src/legacy/ui/public/notify/fatal_error.ts
+++ b/src/legacy/ui/public/notify/fatal_error.ts
@@ -22,7 +22,7 @@ import {
AngularHttpError,
formatAngularHttpError,
isAngularHttpError,
-} from './lib/format_angular_http_error';
+} from '../../../../plugins/kibana_legacy/public';
export function addFatalErrorCallback(callback: () => void) {
npSetup.core.fatalErrors.get$().subscribe(() => {
diff --git a/src/legacy/ui/public/notify/index.d.ts b/src/legacy/ui/public/notify/index.d.ts
index c76924eb25819..3c1a7ba02db72 100644
--- a/src/legacy/ui/public/notify/index.d.ts
+++ b/src/legacy/ui/public/notify/index.d.ts
@@ -17,5 +17,5 @@
* under the License.
*/
-export { toastNotifications, Toast, ToastInput } from './toasts';
+export { toastNotifications } from './toasts';
export { fatalError } from './fatal_error';
diff --git a/src/legacy/ui/public/notify/index.js b/src/legacy/ui/public/notify/index.js
index 70e6c635d43b9..f7526f3b8f8fd 100644
--- a/src/legacy/ui/public/notify/index.js
+++ b/src/legacy/ui/public/notify/index.js
@@ -19,5 +19,5 @@
export { fatalError, addFatalErrorCallback } from './fatal_error';
export { toastNotifications } from './toasts';
-export { banners } from './banners';
export { addAppRedirectMessageToUrl, showAppRedirectNotification } from './app_redirect';
+export { banners } from './banners';
diff --git a/src/legacy/ui/public/notify/toasts/index.ts b/src/legacy/ui/public/notify/toasts/index.ts
index d305b176e1128..c5e8e3b7ca7a3 100644
--- a/src/legacy/ui/public/notify/toasts/index.ts
+++ b/src/legacy/ui/public/notify/toasts/index.ts
@@ -16,6 +16,5 @@
* specific language governing permissions and limitations
* under the License.
*/
-
+export { ToastNotifications } from './toast_notifications';
export { toastNotifications } from './toasts';
-export { Toast, ToastInput } from './toast_notifications';
diff --git a/src/legacy/ui/public/notify/toasts/toast_notifications.ts b/src/legacy/ui/public/notify/toasts/toast_notifications.ts
index 987717ab17d39..d3ec8edb5d73a 100644
--- a/src/legacy/ui/public/notify/toasts/toast_notifications.ts
+++ b/src/legacy/ui/public/notify/toasts/toast_notifications.ts
@@ -16,40 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-import {
- ErrorToastOptions,
- NotificationsSetup,
- Toast,
- ToastInput,
-} from '../../../../../core/public';
-
-export { Toast, ToastInput };
-
-export class ToastNotifications {
- public list: Toast[] = [];
-
- private onChangeCallback?: () => void;
-
- constructor(private readonly toasts: NotificationsSetup['toasts']) {
- toasts.get$().subscribe(list => {
- this.list = list;
-
- if (this.onChangeCallback) {
- this.onChangeCallback();
- }
- });
- }
-
- public onChange = (callback: () => void) => {
- this.onChangeCallback = callback;
- };
-
- public add = (toastOrTitle: ToastInput) => this.toasts.add(toastOrTitle);
- public remove = (toast: Toast) => this.toasts.remove(toast);
- public addSuccess = (toastOrTitle: ToastInput) => this.toasts.addSuccess(toastOrTitle);
- public addWarning = (toastOrTitle: ToastInput) => this.toasts.addWarning(toastOrTitle);
- public addDanger = (toastOrTitle: ToastInput) => this.toasts.addDanger(toastOrTitle);
- public addError = (error: Error, options: ErrorToastOptions) =>
- this.toasts.addError(error, options);
-}
+/**
+ * ToastNotifications is deprecated! Please use npSetup.core.notifications.toasts instead
+ */
+export { ToastNotifications } from '../../../../../plugins/kibana_legacy/public';
diff --git a/src/legacy/ui/public/notify/toasts/toasts.ts b/src/legacy/ui/public/notify/toasts/toasts.ts
index 8889ee4a6d981..15be7a7891553 100644
--- a/src/legacy/ui/public/notify/toasts/toasts.ts
+++ b/src/legacy/ui/public/notify/toasts/toasts.ts
@@ -19,5 +19,4 @@
import { npSetup } from 'ui/new_platform';
import { ToastNotifications } from './toast_notifications';
-
export const toastNotifications = new ToastNotifications(npSetup.core.notifications.toasts);
diff --git a/src/legacy/ui/public/private/index.d.ts b/src/legacy/ui/public/private/index.d.ts
index d814b31102d59..895dc63939311 100644
--- a/src/legacy/ui/public/private/index.d.ts
+++ b/src/legacy/ui/public/private/index.d.ts
@@ -17,4 +17,4 @@
* under the License.
*/
-export { IPrivate } from './private';
+export { IPrivate } from '../../../../plugins/kibana_legacy/public/utils/private';
diff --git a/src/legacy/ui/public/private/private.js b/src/legacy/ui/public/private/private.js
index 05bd55f4e1bdf..7a0751959417e 100644
--- a/src/legacy/ui/public/private/private.js
+++ b/src/legacy/ui/public/private/private.js
@@ -17,196 +17,7 @@
* under the License.
*/
-import _ from 'lodash';
import { uiModules } from '../modules';
-/**
- * # `Private()`
- * Private module loader, used to merge angular and require js dependency styles
- * by allowing a require.js module to export a single provider function that will
- * create a value used within an angular application. This provider can declare
- * angular dependencies by listing them as arguments, and can be require additional
- * Private modules.
- *
- * ## Define a private module provider:
- * ```js
- * export default function PingProvider($http) {
- * this.ping = function () {
- * return $http.head('/health-check');
- * };
- * };
- * ```
- *
- * ## Require a private module:
- * ```js
- * export default function ServerHealthProvider(Private, Promise) {
- * let ping = Private(require('ui/ping'));
- * return {
- * check: Promise.method(function () {
- * let attempts = 0;
- * return (function attempt() {
- * attempts += 1;
- * return ping.ping()
- * .catch(function (err) {
- * if (attempts < 3) return attempt();
- * })
- * }())
- * .then(function () {
- * return true;
- * })
- * .catch(function () {
- * return false;
- * });
- * })
- * }
- * };
- * ```
- *
- * # `Private.stub(provider, newInstance)`
- * `Private.stub()` replaces the instance of a module with another value. This is all we have needed until now.
- *
- * ```js
- * beforeEach(inject(function ($injector, Private) {
- * Private.stub(
- * // since this module just exports a function, we need to change
- * // what Private returns in order to modify it's behavior
- * require('ui/agg_response/hierarchical/_build_split'),
- * sinon.stub().returns(fakeSplit)
- * );
- * }));
- * ```
- *
- * # `Private.swap(oldProvider, newProvider)`
- * This new method does an 1-for-1 swap of module providers, unlike `stub()` which replaces a modules instance.
- * Pass the module you want to swap out, and the one it should be replaced with, then profit.
- *
- * Note: even though this example shows `swap()` being called in a config
- * function, it can be called from anywhere. It is particularly useful
- * in this scenario though.
- *
- * ```js
- * beforeEach(module('kibana', function (PrivateProvider) {
- * PrivateProvider.swap(
- * function StubbedRedirectProvider($decorate) {
- * // $decorate is a function that will instantiate the original module when called
- * return sinon.spy($decorate());
- * }
- * );
- * }));
- * ```
- *
- * @param {[type]} prov [description]
- */
-
-const nextId = _.partial(_.uniqueId, 'privateProvider#');
-
-function name(fn) {
- return (
- fn.name ||
- fn
- .toString()
- .split('\n')
- .shift()
- );
-}
-
-export function PrivateProvider() {
- const provider = this;
-
- // one cache/swaps per Provider
- const cache = {};
- const swaps = {};
-
- // return the uniq id for this function
- function identify(fn) {
- if (typeof fn !== 'function') {
- throw new TypeError('Expected private module "' + fn + '" to be a function');
- }
-
- if (fn.$$id) return fn.$$id;
- else return (fn.$$id = nextId());
- }
-
- provider.stub = function(fn, instance) {
- cache[identify(fn)] = instance;
- return instance;
- };
-
- provider.swap = function(fn, prov) {
- const id = identify(fn);
- swaps[id] = prov;
- };
-
- provider.$get = [
- '$injector',
- function PrivateFactory($injector) {
- // prevent circular deps by tracking where we came from
- const privPath = [];
- const pathToString = function() {
- return privPath.map(name).join(' -> ');
- };
-
- // call a private provider and return the instance it creates
- function instantiate(prov, locals) {
- if (~privPath.indexOf(prov)) {
- throw new Error(
- 'Circular reference to "' +
- name(prov) +
- '"' +
- ' found while resolving private deps: ' +
- pathToString()
- );
- }
-
- privPath.push(prov);
-
- const context = {};
- let instance = $injector.invoke(prov, context, locals);
- if (!_.isObject(instance)) instance = context;
-
- privPath.pop();
- return instance;
- }
-
- // retrieve an instance from cache or create and store on
- function get(id, prov, $delegateId, $delegateProv) {
- if (cache[id]) return cache[id];
-
- let instance;
-
- if ($delegateId != null && $delegateProv != null) {
- instance = instantiate(prov, {
- $decorate: _.partial(get, $delegateId, $delegateProv),
- });
- } else {
- instance = instantiate(prov);
- }
-
- return (cache[id] = instance);
- }
-
- // main api, get the appropriate instance for a provider
- function Private(prov) {
- let id = identify(prov);
- let $delegateId;
- let $delegateProv;
-
- if (swaps[id]) {
- $delegateId = id;
- $delegateProv = prov;
-
- prov = swaps[$delegateId];
- id = identify(prov);
- }
-
- return get(id, prov, $delegateId, $delegateProv);
- }
-
- Private.stub = provider.stub;
- Private.swap = provider.swap;
-
- return Private;
- },
- ];
-}
+import { PrivateProvider } from '../../../../plugins/kibana_legacy/public';
uiModules.get('kibana/private').provider('Private', PrivateProvider);
diff --git a/src/legacy/ui/public/promises/index.ts b/src/legacy/ui/public/promises/index.ts
new file mode 100644
index 0000000000000..07bb2554c5eda
--- /dev/null
+++ b/src/legacy/ui/public/promises/index.ts
@@ -0,0 +1,28 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { PromiseServiceCreator } from '../../../../plugins/kibana_legacy/public';
+export { createDefer } from './defer';
+// @ts-ignore
+import { uiModules } from '../modules';
+
+const module = uiModules.get('kibana');
+// Provides a tiny subset of the excellent API from
+// bluebird, reimplemented using the $q service
+module.service('Promise', PromiseServiceCreator);
diff --git a/src/legacy/ui/public/saved_objects/_index.scss b/src/legacy/ui/public/saved_objects/_index.scss
index 50a192b6a7b17..89cda29f67744 100644
--- a/src/legacy/ui/public/saved_objects/_index.scss
+++ b/src/legacy/ui/public/saved_objects/_index.scss
@@ -1 +1 @@
-@import '../../../../plugins/kibana_react/public/saved_objects/index';
+@import '../../../../plugins/saved_objects/public/index';
diff --git a/src/legacy/ui/public/saved_objects/components/saved_object_save_modal.tsx b/src/legacy/ui/public/saved_objects/components/saved_object_save_modal.tsx
deleted file mode 100644
index 131f28059cebd..0000000000000
--- a/src/legacy/ui/public/saved_objects/components/saved_object_save_modal.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * @deprecated
- *
- * Do not import this component from here. Import from `src/plugins/kibana_react` instead.
- */
-export { SavedObjectSaveModal } from '../../../../../plugins/kibana_react/public';
diff --git a/src/legacy/ui/public/saved_objects/helpers/parse_search_source.ts b/src/legacy/ui/public/saved_objects/helpers/parse_search_source.ts
index 8c52b7cfa0dbf..b194420fc1cd0 100644
--- a/src/legacy/ui/public/saved_objects/helpers/parse_search_source.ts
+++ b/src/legacy/ui/public/saved_objects/helpers/parse_search_source.ts
@@ -17,7 +17,7 @@
* under the License.
*/
import _ from 'lodash';
-import { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query';
+import { migrateLegacyQuery } from '../../../../../plugins/kibana_legacy/public';
import { SavedObject } from '../types';
import { InvalidJSONProperty } from '../../../../../plugins/kibana_utils/public';
diff --git a/src/legacy/ui/public/styles/_legacy/_index.scss b/src/legacy/ui/public/styles/_legacy/_index.scss
index 106730fecd2b8..a0b1a98b09b7d 100644
--- a/src/legacy/ui/public/styles/_legacy/_index.scss
+++ b/src/legacy/ui/public/styles/_legacy/_index.scss
@@ -1,6 +1,5 @@
// //
// // KIBANA THEME
-@import './depth';
@import './base';
@import './mixins';
diff --git a/src/legacy/ui/public/system_api/__tests__/system_api.js b/src/legacy/ui/public/system_api/__tests__/system_api.js
index 1bb8656502204..822edaa08fdd6 100644
--- a/src/legacy/ui/public/system_api/__tests__/system_api.js
+++ b/src/legacy/ui/public/system_api/__tests__/system_api.js
@@ -18,7 +18,10 @@
*/
import expect from '@kbn/expect';
-import { addSystemApiHeader, isSystemApiRequest } from '../system_api';
+import {
+ addSystemApiHeader,
+ isSystemApiRequest,
+} from '../../../../../plugins/kibana_legacy/public';
describe('system_api', () => {
describe('#addSystemApiHeader', () => {
diff --git a/src/legacy/ui/public/system_api/index.js b/src/legacy/ui/public/system_api/index.js
index 61c5909395aef..6361c0ea6c69a 100644
--- a/src/legacy/ui/public/system_api/index.js
+++ b/src/legacy/ui/public/system_api/index.js
@@ -17,4 +17,4 @@
* under the License.
*/
-export { addSystemApiHeader, isSystemApiRequest } from './system_api';
+export { addSystemApiHeader, isSystemApiRequest } from '../../../../plugins/kibana_legacy/public';
diff --git a/src/legacy/ui/public/time_buckets/time_buckets.js b/src/legacy/ui/public/time_buckets/time_buckets.js
index 50a57d866099e..a611de45fa859 100644
--- a/src/legacy/ui/public/time_buckets/time_buckets.js
+++ b/src/legacy/ui/public/time_buckets/time_buckets.js
@@ -144,7 +144,7 @@ TimeBuckets.prototype.getDuration = function() {
* generated.
*
* Input can be one of the following:
- * - Any object from src/legacy/ui/agg_types/buckets/_interval_options.js
+ * - Any object from src/legacy/ui/agg_types.js
* - "auto"
* - Pass a valid moment unit
* - a moment.duration object.
diff --git a/src/legacy/ui/public/vis/__tests__/_agg_config.js b/src/legacy/ui/public/vis/__tests__/_agg_config.js
index 2ccbaf6c1645e..7dccf3eec18aa 100644
--- a/src/legacy/ui/public/vis/__tests__/_agg_config.js
+++ b/src/legacy/ui/public/vis/__tests__/_agg_config.js
@@ -21,8 +21,8 @@ import sinon from 'sinon';
import expect from '@kbn/expect';
import ngMock from 'ng_mock';
import { Vis } from '../../../../core_plugins/visualizations/public';
-import { AggType } from '../../agg_types/agg_type';
-import { AggConfig } from '../../agg_types/agg_config';
+import { AggType, AggConfig } from '../../agg_types';
+
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
describe('AggConfig', function() {
diff --git a/src/legacy/ui/public/vis/config/editor_config_providers.test.ts b/src/legacy/ui/public/vis/config/editor_config_providers.test.ts
deleted file mode 100644
index 9d93930c09ebc..0000000000000
--- a/src/legacy/ui/public/vis/config/editor_config_providers.test.ts
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { AggConfig } from 'ui/agg_types';
-import { EditorConfigProviderRegistry } from './editor_config_providers';
-import { EditorParamConfig, FixedParam, NumericIntervalParam, TimeIntervalParam } from './types';
-
-jest.mock('ui/new_platform');
-
-describe('EditorConfigProvider', () => {
- let registry: EditorConfigProviderRegistry;
- const indexPattern = {
- id: '1234',
- title: 'logstash-*',
- fields: [
- {
- name: 'response',
- type: 'number',
- esTypes: ['integer'],
- aggregatable: true,
- filterable: true,
- searchable: true,
- },
- ],
- } as any;
-
- beforeEach(() => {
- registry = new EditorConfigProviderRegistry();
- });
-
- it('should call registered providers with given parameters', () => {
- const provider = jest.fn(() => ({}));
- registry.register(provider);
- expect(provider).not.toHaveBeenCalled();
- const aggConfig = {} as AggConfig;
- registry.getConfigForAgg(indexPattern, aggConfig);
- expect(provider).toHaveBeenCalledWith(indexPattern, aggConfig);
- });
-
- it('should call all registered providers with given parameters', () => {
- const provider = jest.fn(() => ({}));
- const provider2 = jest.fn(() => ({}));
- registry.register(provider);
- registry.register(provider2);
- expect(provider).not.toHaveBeenCalled();
- expect(provider2).not.toHaveBeenCalled();
- const aggConfig = {} as AggConfig;
- registry.getConfigForAgg(indexPattern, aggConfig);
- expect(provider).toHaveBeenCalledWith(indexPattern, aggConfig);
- expect(provider2).toHaveBeenCalledWith(indexPattern, aggConfig);
- });
-
- describe('merging configs', () => {
- function singleConfig(paramConfig: EditorParamConfig) {
- return () => ({ singleParam: paramConfig });
- }
-
- function getOutputConfig(reg: EditorConfigProviderRegistry) {
- return reg.getConfigForAgg(indexPattern, {} as AggConfig).singleParam;
- }
-
- it('should have hidden true if at least one config was hidden true', () => {
- registry.register(singleConfig({ hidden: false }));
- registry.register(singleConfig({ hidden: true }));
- registry.register(singleConfig({ hidden: false }));
- const config = getOutputConfig(registry);
- expect(config.hidden).toBe(true);
- });
-
- it('should merge the same fixed values', () => {
- registry.register(singleConfig({ fixedValue: 'foo' }));
- registry.register(singleConfig({ fixedValue: 'foo' }));
- const config = getOutputConfig(registry) as FixedParam;
- expect(config).toHaveProperty('fixedValue');
- expect(config.fixedValue).toBe('foo');
- });
-
- it('should throw having different fixed values', () => {
- registry.register(singleConfig({ fixedValue: 'foo' }));
- registry.register(singleConfig({ fixedValue: 'bar' }));
- expect(() => {
- getOutputConfig(registry);
- }).toThrowError();
- });
-
- it('should allow same base values', () => {
- registry.register(singleConfig({ base: 5 }));
- registry.register(singleConfig({ base: 5 }));
- const config = getOutputConfig(registry) as NumericIntervalParam;
- expect(config).toHaveProperty('base');
- expect(config.base).toBe(5);
- });
-
- it('should merge multiple base values, using least common multiple', () => {
- registry.register(singleConfig({ base: 2 }));
- registry.register(singleConfig({ base: 5 }));
- registry.register(singleConfig({ base: 8 }));
- const config = getOutputConfig(registry) as NumericIntervalParam;
- expect(config).toHaveProperty('base');
- expect(config.base).toBe(40);
- });
-
- it('should throw on combining fixedValue with base', () => {
- registry.register(singleConfig({ fixedValue: 'foo' }));
- registry.register(singleConfig({ base: 5 }));
- expect(() => {
- getOutputConfig(registry);
- }).toThrowError();
- });
-
- it('should allow same timeBase values', () => {
- registry.register(singleConfig({ timeBase: '2h', default: '2h' }));
- registry.register(singleConfig({ timeBase: '2h', default: '2h' }));
- const config = getOutputConfig(registry) as TimeIntervalParam;
- expect(config).toHaveProperty('timeBase');
- expect(config).toHaveProperty('default');
- expect(config.timeBase).toBe('2h');
- expect(config.default).toBe('2h');
- });
-
- it('should merge multiple compatible timeBase values, using least common interval', () => {
- registry.register(singleConfig({ timeBase: '2h', default: '2h' }));
- registry.register(singleConfig({ timeBase: '3h', default: '3h' }));
- registry.register(singleConfig({ timeBase: '4h', default: '4h' }));
- const config = getOutputConfig(registry) as TimeIntervalParam;
- expect(config).toHaveProperty('timeBase');
- expect(config).toHaveProperty('default');
- expect(config.timeBase).toBe('12h');
- expect(config.default).toBe('12h');
- });
-
- it('should throw on combining incompatible timeBase values', () => {
- registry.register(singleConfig({ timeBase: '2h', default: '2h' }));
- registry.register(singleConfig({ timeBase: '1d', default: '1d' }));
- expect(() => {
- getOutputConfig(registry);
- }).toThrowError();
- });
-
- it('should throw on invalid timeBase values', () => {
- registry.register(singleConfig({ timeBase: '2w', default: '2w' }));
- expect(() => {
- getOutputConfig(registry);
- }).toThrowError();
- });
-
- it('should throw if timeBase and default are different', () => {
- registry.register(singleConfig({ timeBase: '1h', default: '2h' }));
- expect(() => {
- getOutputConfig(registry);
- }).toThrowError();
- });
-
- it('should merge hidden together with fixedValue', () => {
- registry.register(singleConfig({ fixedValue: 'foo', hidden: true }));
- registry.register(singleConfig({ fixedValue: 'foo', hidden: false }));
- const config = getOutputConfig(registry) as FixedParam;
- expect(config).toHaveProperty('fixedValue');
- expect(config).toHaveProperty('hidden');
- expect(config.fixedValue).toBe('foo');
- expect(config.hidden).toBe(true);
- });
-
- it('should merge hidden together with base', () => {
- registry.register(singleConfig({ base: 2, hidden: false }));
- registry.register(singleConfig({ base: 13, hidden: false }));
- const config = getOutputConfig(registry) as NumericIntervalParam;
- expect(config).toHaveProperty('base');
- expect(config).toHaveProperty('hidden');
- expect(config.base).toBe(26);
- expect(config.hidden).toBe(false);
- });
-
- it('should merge hidden together with timeBase', () => {
- registry.register(singleConfig({ timeBase: '2h', default: '2h', hidden: false }));
- registry.register(singleConfig({ timeBase: '4h', default: '4h', hidden: false }));
- const config = getOutputConfig(registry) as TimeIntervalParam;
- expect(config).toHaveProperty('timeBase');
- expect(config).toHaveProperty('default');
- expect(config).toHaveProperty('hidden');
- expect(config.timeBase).toBe('4h');
- expect(config.default).toBe('4h');
- expect(config.hidden).toBe(false);
- });
-
- it('should merge helps together into one string', () => {
- registry.register(singleConfig({ help: 'Warning' }));
- registry.register(singleConfig({ help: 'Another help' }));
- const config = getOutputConfig(registry);
- expect(config).toHaveProperty('help');
- expect(config.help).toBe('Warning\n\nAnother help');
- });
- });
-});
diff --git a/src/legacy/ui/public/vis/config/editor_config_providers.ts b/src/legacy/ui/public/vis/config/editor_config_providers.ts
deleted file mode 100644
index 1e82a3ca2762e..0000000000000
--- a/src/legacy/ui/public/vis/config/editor_config_providers.ts
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { IndexPattern } from 'src/plugins/data/public';
-import { AggConfig } from 'ui/agg_types';
-import { parseEsInterval } from '../../../../core_plugins/data/public';
-import {
- TimeIntervalParam,
- EditorConfig,
- EditorParamConfig,
- FixedParam,
- NumericIntervalParam,
-} from './types';
-import { leastCommonInterval, leastCommonMultiple } from '../lib';
-
-type EditorConfigProvider = (indexPattern: IndexPattern, aggConfig: AggConfig) => EditorConfig;
-
-class EditorConfigProviderRegistry {
- private providers: Set = new Set();
-
- public register(configProvider: EditorConfigProvider): void {
- this.providers.add(configProvider);
- }
-
- public getConfigForAgg(indexPattern: IndexPattern, aggConfig: AggConfig): EditorConfig {
- const configs = Array.from(this.providers).map(provider => provider(indexPattern, aggConfig));
- return this.mergeConfigs(configs);
- }
-
- private isTimeBaseParam(config: EditorParamConfig): config is TimeIntervalParam {
- return config.hasOwnProperty('default') && config.hasOwnProperty('timeBase');
- }
-
- private isBaseParam(config: EditorParamConfig): config is NumericIntervalParam {
- return config.hasOwnProperty('base');
- }
-
- private isFixedParam(config: EditorParamConfig): config is FixedParam {
- return config.hasOwnProperty('fixedValue');
- }
-
- private mergeHidden(current: EditorParamConfig, merged: EditorParamConfig): boolean {
- return Boolean(current.hidden || merged.hidden);
- }
-
- private mergeHelp(current: EditorParamConfig, merged: EditorParamConfig): string | undefined {
- if (!current.help) {
- return merged.help;
- }
-
- return merged.help ? `${merged.help}\n\n${current.help}` : current.help;
- }
-
- private mergeFixedAndBase(
- current: EditorParamConfig,
- merged: EditorParamConfig,
- paramName: string
- ): { fixedValue: unknown } | { base: number } | {} {
- if (
- this.isFixedParam(current) &&
- this.isFixedParam(merged) &&
- current.fixedValue !== merged.fixedValue
- ) {
- // In case multiple configurations provided a fixedValue, these must all be the same.
- // If not we'll throw an error.
- throw new Error(`Two EditorConfigProviders provided different fixed values for field ${paramName}:
- ${merged.fixedValue} !== ${current.fixedValue}`);
- }
-
- if (
- (this.isFixedParam(current) && this.isBaseParam(merged)) ||
- (this.isBaseParam(current) && this.isFixedParam(merged))
- ) {
- // In case one config tries to set a fixed value and another setting a base value,
- // we'll throw an error. This could be solved more elegantly, by allowing fixedValues
- // that are the multiple of the specific base value, but since there is no use-case for that
- // right now, this isn't implemented.
- throw new Error(`Tried to provide a fixedValue and a base for param ${paramName}.`);
- }
-
- if (this.isBaseParam(current) && this.isBaseParam(merged)) {
- // In case where both had interval values, just use the least common multiple between both interval
- return {
- base: leastCommonMultiple(current.base, merged.base),
- };
- }
-
- // In this case we haven't had a fixed value of base for that param yet, we use the one specified
- // in the current config
- if (this.isFixedParam(current)) {
- return {
- fixedValue: current.fixedValue,
- };
- }
- if (this.isBaseParam(current)) {
- return {
- base: current.base,
- };
- }
-
- return {};
- }
-
- private mergeTimeBase(
- current: TimeIntervalParam,
- merged: EditorParamConfig,
- paramName: string
- ): { timeBase: string; default: string } {
- if (current.default !== current.timeBase) {
- throw new Error(`Tried to provide differing default and timeBase values for ${paramName}.`);
- }
-
- if (this.isTimeBaseParam(merged)) {
- // In case both had where interval values, just use the least common multiple between both intervals
- const timeBase = leastCommonInterval(current.timeBase, merged.timeBase);
- return {
- default: timeBase,
- timeBase,
- };
- }
-
- // This code is simply here to throw an error in case the `timeBase` is not a valid ES interval
- parseEsInterval(current.timeBase);
- return {
- default: current.timeBase,
- timeBase: current.timeBase,
- };
- }
-
- private mergeConfigs(configs: EditorConfig[]): EditorConfig {
- return configs.reduce((output, conf) => {
- Object.entries(conf).forEach(([paramName, paramConfig]) => {
- if (!output[paramName]) {
- output[paramName] = {};
- }
-
- output[paramName] = {
- hidden: this.mergeHidden(paramConfig, output[paramName]),
- help: this.mergeHelp(paramConfig, output[paramName]),
- ...(this.isTimeBaseParam(paramConfig)
- ? this.mergeTimeBase(paramConfig, output[paramName], paramName)
- : this.mergeFixedAndBase(paramConfig, output[paramName], paramName)),
- };
- });
- return output;
- }, {});
- }
-}
-
-const editorConfigProviders = new EditorConfigProviderRegistry();
-
-export { editorConfigProviders, EditorConfigProviderRegistry };
diff --git a/src/legacy/ui/public/vis/config/types.ts b/src/legacy/ui/public/vis/config/types.ts
deleted file mode 100644
index 61c0ced3cd519..0000000000000
--- a/src/legacy/ui/public/vis/config/types.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * A hidden parameter can be hidden from the UI completely.
- */
-interface Param {
- hidden?: boolean;
- help?: string;
-}
-
-/**
- * A fixed parameter has a fixed value for a specific field.
- * It can optionally also be hidden.
- */
-export type FixedParam = Partial & {
- fixedValue: any;
-};
-
-/**
- * Numeric interval parameters must always be set in the editor to a multiple of
- * the specified base. It can optionally also be hidden.
- */
-export type NumericIntervalParam = Partial & {
- base: number;
-};
-
-/**
- * Time interval parameters must always be set in the editor to a multiple of
- * the specified base. It can optionally also be hidden.
- */
-export type TimeIntervalParam = Partial & {
- default: string;
- timeBase: string;
-};
-
-export type EditorParamConfig = NumericIntervalParam | TimeIntervalParam | FixedParam | Param;
-
-export interface EditorConfig {
- [paramName: string]: EditorParamConfig;
-}
diff --git a/src/legacy/ui/public/visualize/loader/pipeline_helpers/utilities.ts b/src/legacy/ui/public/visualize/loader/pipeline_helpers/utilities.ts
index e763eb1b90791..d8227343159e6 100644
--- a/src/legacy/ui/public/visualize/loader/pipeline_helpers/utilities.ts
+++ b/src/legacy/ui/public/visualize/loader/pipeline_helpers/utilities.ts
@@ -19,15 +19,15 @@
import { i18n } from '@kbn/i18n';
import { identity } from 'lodash';
-import { AggConfig } from 'ui/agg_types';
+import { IAggConfig } from 'ui/agg_types';
import { npStart } from 'ui/new_platform';
import { SerializedFieldFormat } from 'src/plugins/expressions/public';
import { fieldFormats } from '../../../../../../plugins/data/public';
import { Vis } from '../../../../../core_plugins/visualizations/public';
import { tabifyGetColumns } from '../../../agg_response/tabify/_get_columns';
-import { DateRangeKey, convertDateRangeToString } from '../../../agg_types/buckets/date_range';
-import { IpRangeKey, convertIPRangeToString } from '../../../agg_types/buckets/ip_range';
+import { DateRangeKey, convertDateRangeToString } from '../../../agg_types';
+import { IpRangeKey, convertIPRangeToString } from '../../../agg_types';
interface TermsFieldFormatParams {
otherBucketLabel: string;
@@ -62,7 +62,7 @@ const getFieldFormat = (
return new DefaultFieldFormat();
};
-export const createFormat = (agg: AggConfig): SerializedFieldFormat => {
+export const createFormat = (agg: IAggConfig): SerializedFieldFormat => {
const format: SerializedFieldFormat = agg.params.field ? agg.params.field.format.toJSON() : {};
const formats: Record SerializedFieldFormat> = {
date_range: () => ({ id: 'date_range', params: format }),
@@ -106,7 +106,7 @@ export const getFormat: FormatFactory = mapping => {
const format = getFieldFormat(id, mapping.params);
const gte = '\u2265';
const lt = '\u003c';
- return i18n.translate('common.ui.aggTypes.buckets.ranges.rangesFormatMessage', {
+ return i18n.translate('common.ui.aggTypes.rangesFormatMessage', {
defaultMessage: '{gte} {from} and {lt} {to}',
values: {
gte,
@@ -155,7 +155,7 @@ export const getFormat: FormatFactory = mapping => {
}
};
-export const getTableAggs = (vis: Vis): AggConfig[] => {
+export const getTableAggs = (vis: Vis): IAggConfig[] => {
if (!vis.aggs || !vis.aggs.getResponseAggs) {
return [];
}
diff --git a/src/optimize/base_optimizer.js b/src/optimize/base_optimizer.js
index efff7f0aa2b46..d9df2a1955df3 100644
--- a/src/optimize/base_optimizer.js
+++ b/src/optimize/base_optimizer.js
@@ -256,6 +256,7 @@ export default class BaseOptimizer {
profile: this.profile || false,
output: {
+ futureEmitAssets: true, // TODO: remove on webpack 5
path: this.uiBundles.getWorkingDir(),
filename: '[name].bundle.js',
sourceMapFilename: '[file].map',
diff --git a/src/optimize/dynamic_dll_plugin/dll_config_model.js b/src/optimize/dynamic_dll_plugin/dll_config_model.js
index c7ab2fe30dd14..2e74cb6af86d4 100644
--- a/src/optimize/dynamic_dll_plugin/dll_config_model.js
+++ b/src/optimize/dynamic_dll_plugin/dll_config_model.js
@@ -48,6 +48,7 @@ function generateDLL(config) {
entry: dllEntry,
context: dllContext,
output: {
+ futureEmitAssets: true, // TODO: remove on webpack 5
filename: dllBundleFilename,
path: dllOutputPath,
publicPath: dllPublicPath,
@@ -227,36 +228,7 @@ function optimized(config) {
cache: false,
extractComments: false,
terserOptions: {
- compress: {
- // The following is required for dead-code the removal
- // check in React DevTools
- //
- // default
- unused: true,
- dead_code: true,
- conditionals: true,
- evaluate: true,
-
- // changed
- keep_fnames: true,
- keep_infinity: true,
- comparisons: false,
- sequences: false,
- properties: false,
- drop_debugger: false,
- booleans: false,
- loops: false,
- toplevel: false,
- top_retain: false,
- hoist_funs: false,
- if_return: false,
- join_vars: false,
- collapse_vars: false,
- reduce_vars: false,
- warnings: false,
- negate_iife: false,
- side_effects: false,
- },
+ compress: false,
mangle: false,
},
}),
diff --git a/src/plugins/advanced_settings/kibana.json b/src/plugins/advanced_settings/kibana.json
new file mode 100644
index 0000000000000..5fc1e916ae45f
--- /dev/null
+++ b/src/plugins/advanced_settings/kibana.json
@@ -0,0 +1,7 @@
+{
+ "id": "advancedSettings",
+ "version": "kibana",
+ "server": false,
+ "ui": true,
+ "requiredPlugins": []
+}
diff --git a/src/plugins/advanced_settings/public/component_registry/__snapshots__/component_registry.test.tsx.snap b/src/plugins/advanced_settings/public/component_registry/__snapshots__/component_registry.test.tsx.snap
new file mode 100644
index 0000000000000..1d6cc882cb344
--- /dev/null
+++ b/src/plugins/advanced_settings/public/component_registry/__snapshots__/component_registry.test.tsx.snap
@@ -0,0 +1,3 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`ComponentRegistry register should disallow registering a component with a duplicate id 1`] = `"Component with id advanced_settings_page_title is already registered."`;
diff --git a/src/plugins/advanced_settings/public/component_registry/component_registry.test.tsx b/src/plugins/advanced_settings/public/component_registry/component_registry.test.tsx
new file mode 100644
index 0000000000000..3b722e9517fdb
--- /dev/null
+++ b/src/plugins/advanced_settings/public/component_registry/component_registry.test.tsx
@@ -0,0 +1,90 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React from 'react';
+import { ComponentRegistry } from './component_registry';
+
+describe('ComponentRegistry', () => {
+ describe('register', () => {
+ it('should allow a component to be registered', () => {
+ const component = () => ;
+ new ComponentRegistry().setup.register(
+ ComponentRegistry.componentType.PAGE_TITLE_COMPONENT,
+ component
+ );
+ });
+
+ it('should disallow registering a component with a duplicate id', () => {
+ const registry = new ComponentRegistry();
+ const component = () => ;
+ registry.setup.register(ComponentRegistry.componentType.PAGE_TITLE_COMPONENT, component);
+ expect(() =>
+ registry.setup.register(ComponentRegistry.componentType.PAGE_TITLE_COMPONENT, () => (
+
+ ))
+ ).toThrowErrorMatchingSnapshot();
+ });
+
+ it('should allow a component to be overriden', () => {
+ const registry = new ComponentRegistry();
+ const component = () => ;
+ registry.setup.register(ComponentRegistry.componentType.PAGE_TITLE_COMPONENT, component);
+
+ const anotherComponent = () => ;
+ registry.setup.register(
+ ComponentRegistry.componentType.PAGE_TITLE_COMPONENT,
+ anotherComponent,
+ true
+ );
+
+ expect(registry.start.get(ComponentRegistry.componentType.PAGE_TITLE_COMPONENT)).toBe(
+ anotherComponent
+ );
+ });
+ });
+
+ describe('get', () => {
+ it('should allow a component to be retrieved', () => {
+ const registry = new ComponentRegistry();
+ const component = () => ;
+ registry.setup.register(ComponentRegistry.componentType.PAGE_TITLE_COMPONENT, component);
+ expect(registry.start.get(ComponentRegistry.componentType.PAGE_TITLE_COMPONENT)).toBe(
+ component
+ );
+ });
+ });
+
+ it('should set a displayName for the component if one does not exist', () => {
+ const component: React.ComponentType = () => ;
+ const registry = new ComponentRegistry();
+ registry.setup.register(ComponentRegistry.componentType.PAGE_TITLE_COMPONENT, component);
+
+ expect(component.displayName).toEqual(ComponentRegistry.componentType.PAGE_TITLE_COMPONENT);
+ });
+
+ it('should not set a displayName for the component if one already exists', () => {
+ const component: React.ComponentType = () => ;
+ component.displayName = '';
+ const registry = new ComponentRegistry();
+
+ registry.setup.register(ComponentRegistry.componentType.PAGE_TITLE_COMPONENT, component);
+
+ expect(component.displayName).toEqual('');
+ });
+});
diff --git a/src/plugins/advanced_settings/public/component_registry/component_registry.ts b/src/plugins/advanced_settings/public/component_registry/component_registry.ts
new file mode 100644
index 0000000000000..cc61798e84cb7
--- /dev/null
+++ b/src/plugins/advanced_settings/public/component_registry/component_registry.ts
@@ -0,0 +1,91 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { ComponentType } from 'react';
+import { PageTitle } from './page_title';
+import { PageSubtitle } from './page_subtitle';
+import { PageFooter } from './page_footer';
+
+type Id =
+ | 'advanced_settings_page_title'
+ | 'advanced_settings_page_subtitle'
+ | 'advanced_settings_page_footer';
+
+const componentType: { [key: string]: Id } = {
+ PAGE_TITLE_COMPONENT: 'advanced_settings_page_title' as Id,
+ PAGE_SUBTITLE_COMPONENT: 'advanced_settings_page_subtitle' as Id,
+ PAGE_FOOTER_COMPONENT: 'advanced_settings_page_footer' as Id,
+};
+
+type RegistryComponent = ComponentType | undefined>;
+
+export class ComponentRegistry {
+ static readonly componentType = componentType;
+ static readonly defaultRegistry: Record = {
+ advanced_settings_page_title: PageTitle,
+ advanced_settings_page_subtitle: PageSubtitle,
+ advanced_settings_page_footer: PageFooter,
+ };
+
+ registry: { [key in Id]?: RegistryComponent } = {};
+
+ /**
+ * Attempts to register the provided component, with the ability to optionally allow
+ * the component to override an existing one.
+ *
+ * If the intent is to override, then `allowOverride` must be set to true, otherwise an exception is thrown.
+ *
+ * @param {*} id the id of the component to register
+ * @param {*} component the component
+ * @param {*} allowOverride (default: false) - optional flag to allow this component to override a previously registered component
+ */
+ private register(id: Id, component: RegistryComponent, allowOverride = false) {
+ if (!allowOverride && id in this.registry) {
+ throw new Error(`Component with id ${id} is already registered.`);
+ }
+
+ // Setting a display name if one does not already exist.
+ // This enhances the snapshots, as well as the debugging experience.
+ if (!component.displayName) {
+ component.displayName = id;
+ }
+
+ this.registry[id] = component;
+ }
+
+ /**
+ * Retrieve a registered component by its ID.
+ * If the component does not exist, then an exception is thrown.
+ *
+ * @param {*} id the ID of the component to retrieve
+ */
+ private get(id: Id): RegistryComponent {
+ return this.registry[id] || ComponentRegistry.defaultRegistry[id];
+ }
+
+ setup = {
+ componentType: ComponentRegistry.componentType,
+ register: this.register.bind(this),
+ };
+
+ start = {
+ componentType: ComponentRegistry.componentType,
+ get: this.get.bind(this),
+ };
+}
diff --git a/src/legacy/ui/public/promises/index.js b/src/plugins/advanced_settings/public/component_registry/index.ts
similarity index 93%
rename from src/legacy/ui/public/promises/index.js
rename to src/plugins/advanced_settings/public/component_registry/index.ts
index 88fe7520d4967..79c9248e0c2a9 100644
--- a/src/legacy/ui/public/promises/index.js
+++ b/src/plugins/advanced_settings/public/component_registry/index.ts
@@ -17,5 +17,4 @@
* under the License.
*/
-import './promises';
-export { createDefer } from './defer';
+export { ComponentRegistry } from './component_registry';
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_footer/__snapshots__/page_footer.test.tsx.snap b/src/plugins/advanced_settings/public/component_registry/page_footer/__snapshots__/page_footer.test.tsx.snap
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_footer/__snapshots__/page_footer.test.tsx.snap
rename to src/plugins/advanced_settings/public/component_registry/page_footer/__snapshots__/page_footer.test.tsx.snap
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_footer/index.ts b/src/plugins/advanced_settings/public/component_registry/page_footer/index.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_footer/index.ts
rename to src/plugins/advanced_settings/public/component_registry/page_footer/index.ts
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_footer/page_footer.test.tsx b/src/plugins/advanced_settings/public/component_registry/page_footer/page_footer.test.tsx
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_footer/page_footer.test.tsx
rename to src/plugins/advanced_settings/public/component_registry/page_footer/page_footer.test.tsx
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_footer/page_footer.ts b/src/plugins/advanced_settings/public/component_registry/page_footer/page_footer.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_footer/page_footer.ts
rename to src/plugins/advanced_settings/public/component_registry/page_footer/page_footer.ts
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_subtitle/__snapshots__/page_subtitle.test.tsx.snap b/src/plugins/advanced_settings/public/component_registry/page_subtitle/__snapshots__/page_subtitle.test.tsx.snap
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_subtitle/__snapshots__/page_subtitle.test.tsx.snap
rename to src/plugins/advanced_settings/public/component_registry/page_subtitle/__snapshots__/page_subtitle.test.tsx.snap
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_subtitle/index.ts b/src/plugins/advanced_settings/public/component_registry/page_subtitle/index.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_subtitle/index.ts
rename to src/plugins/advanced_settings/public/component_registry/page_subtitle/index.ts
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_subtitle/page_subtitle.test.tsx b/src/plugins/advanced_settings/public/component_registry/page_subtitle/page_subtitle.test.tsx
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_subtitle/page_subtitle.test.tsx
rename to src/plugins/advanced_settings/public/component_registry/page_subtitle/page_subtitle.test.tsx
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_subtitle/page_subtitle.ts b/src/plugins/advanced_settings/public/component_registry/page_subtitle/page_subtitle.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_subtitle/page_subtitle.ts
rename to src/plugins/advanced_settings/public/component_registry/page_subtitle/page_subtitle.ts
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/__snapshots__/page_title.test.tsx.snap b/src/plugins/advanced_settings/public/component_registry/page_title/__snapshots__/page_title.test.tsx.snap
similarity index 85%
rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/__snapshots__/page_title.test.tsx.snap
rename to src/plugins/advanced_settings/public/component_registry/page_title/__snapshots__/page_title.test.tsx.snap
index 8dd4e501067b5..10b799a986b84 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/__snapshots__/page_title.test.tsx.snap
+++ b/src/plugins/advanced_settings/public/component_registry/page_title/__snapshots__/page_title.test.tsx.snap
@@ -7,7 +7,7 @@ exports[`PageTitle should render normally 1`] = `
>
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/index.ts b/src/plugins/advanced_settings/public/component_registry/page_title/index.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/index.ts
rename to src/plugins/advanced_settings/public/component_registry/page_title/index.ts
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/page_title.test.tsx b/src/plugins/advanced_settings/public/component_registry/page_title/page_title.test.tsx
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/page_title.test.tsx
rename to src/plugins/advanced_settings/public/component_registry/page_title/page_title.test.tsx
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/page_title.tsx b/src/plugins/advanced_settings/public/component_registry/page_title/page_title.tsx
similarity index 91%
rename from src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/page_title.tsx
rename to src/plugins/advanced_settings/public/component_registry/page_title/page_title.tsx
index cb807302c2380..18d9c60d331bb 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/settings/components/page_title/page_title.tsx
+++ b/src/plugins/advanced_settings/public/component_registry/page_title/page_title.tsx
@@ -25,7 +25,7 @@ export const PageTitle = () => {
return (
-
+
);
diff --git a/src/plugins/advanced_settings/public/index.ts b/src/plugins/advanced_settings/public/index.ts
new file mode 100644
index 0000000000000..13be36e671f75
--- /dev/null
+++ b/src/plugins/advanced_settings/public/index.ts
@@ -0,0 +1,27 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { PluginInitializerContext } from 'kibana/public';
+import { AdvancedSettingsPlugin } from './plugin';
+export { AdvancedSettingsSetup, AdvancedSettingsStart } from './types';
+export { ComponentRegistry } from './component_registry';
+
+export function plugin(initializerContext: PluginInitializerContext) {
+ return new AdvancedSettingsPlugin();
+}
diff --git a/src/legacy/ui/public/notify/filters/markdown.js b/src/plugins/advanced_settings/public/mocks.ts
similarity index 70%
rename from src/legacy/ui/public/notify/filters/markdown.js
rename to src/plugins/advanced_settings/public/mocks.ts
index 9ab7470b4a1c9..e147f57101aae 100644
--- a/src/legacy/ui/public/notify/filters/markdown.js
+++ b/src/plugins/advanced_settings/public/mocks.ts
@@ -17,15 +17,17 @@
* under the License.
*/
-import MarkdownIt from 'markdown-it';
-import { uiModules } from 'ui/modules';
-import 'angular-sanitize';
+import { ComponentRegistry } from './component_registry';
-const markdownIt = new MarkdownIt({
- html: false,
- linkify: true,
-});
+const register = jest.fn();
+const get = jest.fn();
+const componentType = ComponentRegistry.componentType;
-uiModules.get('kibana', ['ngSanitize']).filter('markdown', function($sanitize) {
- return md => (md ? $sanitize(markdownIt.render(md)) : '');
-});
+export const advancedSettingsMock = {
+ createSetupContract() {
+ return { register, componentType };
+ },
+ createStartContract() {
+ return { get, componentType };
+ },
+};
diff --git a/src/plugins/advanced_settings/public/plugin.ts b/src/plugins/advanced_settings/public/plugin.ts
new file mode 100644
index 0000000000000..692e515ca4e5e
--- /dev/null
+++ b/src/plugins/advanced_settings/public/plugin.ts
@@ -0,0 +1,39 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
+import { ComponentRegistry } from './component_registry';
+import { AdvancedSettingsSetup, AdvancedSettingsStart } from './types';
+
+const component = new ComponentRegistry();
+
+export class AdvancedSettingsPlugin
+ implements Plugin {
+ public setup(core: CoreSetup) {
+ return {
+ component: component.setup,
+ };
+ }
+
+ public start(core: CoreStart) {
+ return {
+ component: component.start,
+ };
+ }
+}
diff --git a/src/legacy/ui/public/promises/promises.d.ts b/src/plugins/advanced_settings/public/types.ts
similarity index 78%
rename from src/legacy/ui/public/promises/promises.d.ts
rename to src/plugins/advanced_settings/public/types.ts
index 84d81b39ec37d..a9b965c3c22de 100644
--- a/src/legacy/ui/public/promises/promises.d.ts
+++ b/src/plugins/advanced_settings/public/types.ts
@@ -17,9 +17,11 @@
* under the License.
*/
-export interface PromiseService {
- resolve: (value: T | PromiseLike) => ng.IPromise;
+import { ComponentRegistry } from './component_registry';
- // TODO: add additional typing
- [key: string]: any;
+export interface AdvancedSettingsSetup {
+ component: ComponentRegistry['setup'];
+}
+export interface AdvancedSettingsStart {
+ component: ComponentRegistry['start'];
}
diff --git a/src/plugins/console/kibana.json b/src/plugins/console/kibana.json
index 18f7eb06e98ed..57de385ba565c 100644
--- a/src/plugins/console/kibana.json
+++ b/src/plugins/console/kibana.json
@@ -3,6 +3,6 @@
"version": "kibana",
"server": true,
"ui": true,
- "requiredPlugins": ["dev_tools", "home"],
+ "requiredPlugins": ["devTools", "home"],
"optionalPlugins": ["usageCollection"]
}
diff --git a/src/plugins/console/public/application/components/index.ts b/src/plugins/console/public/application/components/index.ts
index eccde899a2640..d9a8aa9328b73 100644
--- a/src/plugins/console/public/application/components/index.ts
+++ b/src/plugins/console/public/application/components/index.ts
@@ -17,6 +17,7 @@
* under the License.
*/
+export { NetworkRequestStatusBar } from './network_request_status_bar';
export { SomethingWentWrongCallout } from './something_went_wrong_callout';
export { TopNavMenuItem, TopNavMenu } from './top_nav_menu';
export { ConsoleMenu } from './console_menu';
diff --git a/src/plugins/kibana_react/public/saved_objects/index.ts b/src/plugins/console/public/application/components/network_request_status_bar/index.ts
similarity index 90%
rename from src/plugins/kibana_react/public/saved_objects/index.ts
rename to src/plugins/console/public/application/components/network_request_status_bar/index.ts
index ade80d2cd2a92..ce214c1cdfffa 100644
--- a/src/plugins/kibana_react/public/saved_objects/index.ts
+++ b/src/plugins/console/public/application/components/network_request_status_bar/index.ts
@@ -17,5 +17,4 @@
* under the License.
*/
-export * from './saved_object_finder';
-export * from './saved_object_save_modal';
+export { NetworkRequestStatusBar } from './network_request_status_bar';
diff --git a/src/plugins/console/public/application/components/network_request_status_bar/network_request_status_bar.tsx b/src/plugins/console/public/application/components/network_request_status_bar/network_request_status_bar.tsx
new file mode 100644
index 0000000000000..6915ff15f374d
--- /dev/null
+++ b/src/plugins/console/public/application/components/network_request_status_bar/network_request_status_bar.tsx
@@ -0,0 +1,133 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { i18n } from '@kbn/i18n';
+import React, { FunctionComponent } from 'react';
+import { EuiFlexGroup, EuiFlexItem, EuiBadge, EuiText, EuiToolTip } from '@elastic/eui';
+
+export interface Props {
+ requestInProgress: boolean;
+ requestResult?: {
+ // Status code of the request, e.g., 200
+ statusCode: number;
+
+ // Status text of the request, e.g., OK
+ statusText: string;
+
+ // Method of the request, e.g., GET
+ method: string;
+
+ // The path of endpoint that was called, e.g., /_search
+ endpoint: string;
+
+ // The time, in milliseconds, that the last request took
+ timeElapsedMs: number;
+ };
+}
+
+const mapStatusCodeToBadgeColor = (statusCode: number) => {
+ if (statusCode <= 199) {
+ return 'default';
+ }
+
+ if (statusCode <= 299) {
+ return 'secondary';
+ }
+
+ if (statusCode <= 399) {
+ return 'primary';
+ }
+
+ if (statusCode <= 499) {
+ return 'warning';
+ }
+
+ return 'danger';
+};
+
+export const NetworkRequestStatusBar: FunctionComponent = ({
+ requestInProgress,
+ requestResult,
+}) => {
+ let content: React.ReactNode = null;
+
+ if (requestInProgress) {
+ content = (
+
+
+ {i18n.translate('console.requestInProgressBadgeText', {
+ defaultMessage: 'Request in progress',
+ })}
+
+
+ );
+ } else if (requestResult) {
+ const { endpoint, method, statusCode, statusText, timeElapsedMs } = requestResult;
+
+ content = (
+ <>
+
+ {`${method} ${
+ endpoint.startsWith('/') ? endpoint : '/' + endpoint
+ }`}
+ }
+ >
+
+ {/* Use to ensure that no matter the width we don't allow line breaks */}
+ {statusCode} - {statusText}
+
+
+
+
+
+ {i18n.translate('console.requestTimeElapasedBadgeTooltipContent', {
+ defaultMessage: 'Time Elapsed',
+ })}
+
+ }
+ >
+
+
+ {timeElapsedMs} {'ms'}
+
+
+
+
+ >
+ );
+ }
+
+ return (
+
+ {content}
+
+ );
+};
diff --git a/src/plugins/console/public/application/containers/editor/editor.tsx b/src/plugins/console/public/application/containers/editor/editor.tsx
index 5c7fe293651fb..0bfe837f2cd90 100644
--- a/src/plugins/console/public/application/containers/editor/editor.tsx
+++ b/src/plugins/console/public/application/containers/editor/editor.tsx
@@ -17,14 +17,15 @@
* under the License.
*/
-import React, { useCallback } from 'react';
+import React, { useCallback, memo } from 'react';
import { debounce } from 'lodash';
+import { EuiProgress } from '@elastic/eui';
import { EditorContentSpinner } from '../../components';
import { Panel, PanelsContainer } from '../../../../../kibana_react/public';
import { Editor as EditorUI, EditorOutput } from './legacy/console_editor';
import { StorageKeys } from '../../../services';
-import { useEditorReadContext, useServicesContext } from '../../contexts';
+import { useEditorReadContext, useServicesContext, useRequestReadContext } from '../../contexts';
const INITIAL_PANEL_WIDTH = 50;
const PANEL_MIN_WIDTH = '100px';
@@ -33,12 +34,13 @@ interface Props {
loading: boolean;
}
-export const Editor = ({ loading }: Props) => {
+export const Editor = memo(({ loading }: Props) => {
const {
services: { storage },
} = useServicesContext();
const { currentTextObject } = useEditorReadContext();
+ const { requestInFlight } = useRequestReadContext();
const [firstPanelWidth, secondPanelWidth] = storage.get(StorageKeys.WIDTH, [
INITIAL_PANEL_WIDTH,
@@ -55,23 +57,30 @@ export const Editor = ({ loading }: Props) => {
if (!currentTextObject) return null;
return (
-
-
- {loading ? (
-
- ) : (
-
- )}
-
-
- {loading ? : }
-
-
+ <>
+ {requestInFlight ? (
+
+
+
+ ) : null}
+
+
+ {loading ? (
+
+ ) : (
+
+ )}
+
+
+ {loading ? : }
+
+
+ >
);
-};
+});
diff --git a/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.tsx b/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.tsx
index 759e3dbafb39c..b3e966ddffa4c 100644
--- a/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.tsx
+++ b/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.tsx
@@ -211,14 +211,14 @@ function EditorUI({ initialTextValue }: EditorProps) {