Skip to content

Commit

Permalink
Merge branch 'master' into elastic#60333
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Apr 2, 2020
2 parents 845261d + a06e33e commit b892dfe
Show file tree
Hide file tree
Showing 85 changed files with 1,092 additions and 1,037 deletions.
9 changes: 0 additions & 9 deletions .github/paths-labeller.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
---
- "Team:AppArch":
- "src/plugins/bfetch/**/*.*"
- "src/plugins/dashboard_embeddable_container/**/*.*"
- "src/plugins/data/**/*.*"
- "src/plugins/embeddable/**/*.*"
- "src/plugins/expressions/**/*.*"
- "src/plugins/inspector/**/*.*"
- "src/plugins/ui_actions/**/*.*"
- "src/plugins/visualizations/**/*.*"
- "Feature:Embedding":
- "src/plugins/embeddable/**/*.*"
- "src/plugins/dashboard_embeddable_container/**/*.*"
Expand Down
1 change: 0 additions & 1 deletion kibana.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import * as LegacyKibanaServer from './src/legacy/server/kbn_server';
*/
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Legacy {
export type IndexPatternsService = LegacyKibanaServer.IndexPatternsService;
export type KibanaConfig = LegacyKibanaServer.KibanaConfig;
export type Request = LegacyKibanaServer.Request;
export type ResponseToolkit = LegacyKibanaServer.ResponseToolkit;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { IAggConfigs, IAggConfig } from 'src/plugins/data/public';
import { DefaultEditorAggGroup, DefaultEditorAggGroupProps } from './agg_group';
import { DefaultEditorAgg } from './agg';
import { DefaultEditorAggAdd } from './agg_add';
import { Schema } from '../schemas';
import { ISchemas, Schemas } from '../schemas';
import { EditorVisState } from './sidebar/state/reducers';

jest.mock('@elastic/eui', () => ({
Expand All @@ -47,6 +47,7 @@ jest.mock('./agg_add', () => ({
describe('DefaultEditorAgg component', () => {
let defaultProps: DefaultEditorAggGroupProps;
let aggs: IAggConfigs;
let schemas: ISchemas;
let setTouched: jest.Mock;
let setValidity: jest.Mock;
let reorderAggs: jest.Mock;
Expand All @@ -55,6 +56,18 @@ describe('DefaultEditorAgg component', () => {
setTouched = jest.fn();
setValidity = jest.fn();
reorderAggs = jest.fn();
schemas = new Schemas([
{
name: 'metrics',
group: 'metrics',
max: 1,
},
{
name: 'buckets',
group: 'buckets',
max: 1,
},
]);

aggs = {
aggs: [
Expand Down Expand Up @@ -95,18 +108,7 @@ describe('DefaultEditorAgg component', () => {
state: {
data: { aggs },
} as EditorVisState,
schemas: [
{
name: 'metrics',
group: 'metrics',
max: 1,
} as Schema,
{
name: 'buckets',
group: 'buckets',
max: 1,
} as Schema,
],
schemas: schemas.metrics,
setTouched,
setValidity,
reorderAggs,
Expand All @@ -133,6 +135,7 @@ describe('DefaultEditorAgg component', () => {

it('should last bucket has truthy isLastBucket prop', () => {
defaultProps.groupName = 'buckets';
defaultProps.schemas = schemas.buckets;
const comp = mount(<DefaultEditorAggGroup {...defaultProps} />);
const lastAgg = comp.find(DefaultEditorAgg).last();

Expand All @@ -154,6 +157,8 @@ describe('DefaultEditorAgg component', () => {

it('should show add button when schemas count is less than max', () => {
defaultProps.groupName = 'buckets';
defaultProps.schemas = schemas.buckets;
defaultProps.schemas[0].max = 2;
const comp = shallow(<DefaultEditorAggGroup {...defaultProps} />);

expect(comp.find(DefaultEditorAggAdd).exists()).toBeTruthy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
getEnabledMetricAggsCount,
} from './agg_group_helper';
import { aggGroupReducer, initAggsState, AGGS_ACTION_KEYS } from './agg_group_state';
import { Schema, getSchemasByGroup } from '../schemas';
import { Schema } from '../schemas';
import { TimeRange } from '../../../../../plugins/data/public';

export interface DefaultEditorAggGroupProps extends DefaultEditorAggCommonProps {
Expand Down Expand Up @@ -73,7 +73,7 @@ function DefaultEditorAggGroup({
}: DefaultEditorAggGroupProps) {
const groupNameLabel = (search.aggs.aggGroupNamesMap() as any)[groupName];
// e.g. buckets can have no aggs
const schemaNames = getSchemasByGroup(schemas, groupName).map(s => s.name);
const schemaNames = schemas.map(s => s.name);
const group: IAggConfig[] = useMemo(
() =>
state.data.aggs!.aggs.filter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ import { DefaultEditorAggCommonProps } from '../agg_common_props';
import { SidebarTitle } from './sidebar_title';
import { PersistedState } from '../../../../../../plugins/visualizations/public';
import { SavedSearch } from '../../../../../../plugins/discover/public';
import { AggGroupNames } from '../../../../../../plugins/data/public';
import { getSchemasByGroup } from '../../schemas';
import { Schema } from '../../schemas';
import { TimeRange } from '../../../../../../plugins/data/public';

interface DefaultEditorSideBarProps {
Expand Down Expand Up @@ -66,9 +65,7 @@ function DefaultEditorSideBar({
const responseAggs = useMemo(() => (state.data.aggs ? state.data.aggs.getResponseAggs() : []), [
state.data.aggs,
]);
const metricSchemas = getSchemasByGroup(vis.type.schemas.all || [], AggGroupNames.Metrics).map(
s => s.name
);
const metricSchemas = (vis.type.schemas.metrics || []).map((s: Schema) => s.name);
const metricAggs = useMemo(
() => responseAggs.filter(agg => metricSchemas.includes(get(agg, 'schema'))),
[responseAggs, metricSchemas]
Expand Down
30 changes: 8 additions & 22 deletions src/legacy/core_plugins/vis_default_editor/public/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
* under the License.
*/

import _ from 'lodash';
import _, { defaults } from 'lodash';

import { Optional } from '@kbn/utility-types';

import { IndexedArray } from 'ui/indexed_array';
import { AggGroupNames, AggParam, IAggGroupNames } from '../../../../plugins/data/public';

export interface ISchemas {
Expand All @@ -45,9 +44,10 @@ export interface Schema {
aggSettings?: any;
}

export class Schemas {
// @ts-ignore
all: IndexedArray<Schema>;
export class Schemas implements ISchemas {
all: Schema[] = [];
[AggGroupNames.Buckets]: Schema[] = [];
[AggGroupNames.Metrics]: Schema[] = [];

constructor(
schemas: Array<
Expand All @@ -70,7 +70,7 @@ export class Schemas {
] as AggParam[];
}

_.defaults(schema, {
defaults(schema, {
min: 0,
max: Infinity,
group: AggGroupNames.Buckets,
Expand All @@ -83,22 +83,12 @@ export class Schemas {
return schema as Schema;
})
.tap((fullSchemas: Schema[]) => {
this.all = new IndexedArray({
index: ['name'],
group: ['group'],
immutable: true,
initialSet: fullSchemas,
});
this.all = fullSchemas;
})
.groupBy('group')
.forOwn((group, groupName) => {
// @ts-ignore
this[groupName] = new IndexedArray({
index: ['name'],
immutable: true,
// @ts-ignore
initialSet: group,
});
this[groupName] = group;
})
.commit();
}
Expand All @@ -107,7 +97,3 @@ export class Schemas {
export const getSchemaByName = (schemas: Schema[], schemaName?: string) => {
return schemas.find(s => s.name === schemaName) || ({} as Schema);
};

export const getSchemasByGroup = (schemas: Schema[], schemaGroup?: string) => {
return schemas.filter(s => s.group === schemaGroup);
};
25 changes: 0 additions & 25 deletions src/legacy/server/index_patterns/index.ts

This file was deleted.

56 changes: 0 additions & 56 deletions src/legacy/server/index_patterns/mixin.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/legacy/server/kbn_server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import { LegacyConfig, ILegacyService, ILegacyInternals } from '../../core/serve
import { ApmOssPlugin } from '../core_plugins/apm_oss';
import { CallClusterWithRequest, ElasticsearchPlugin } from '../core_plugins/elasticsearch';
import { UsageCollectionSetup } from '../../plugins/usage_collection/server';
import { IndexPatternsServiceFactory } from './index_patterns';
import { Capabilities } from '../../core/server';
import { UiSettingsServiceFactoryOptions } from '../../legacy/ui/ui_settings/ui_settings_service_factory';
import { HomeServerPluginSetup } from '../../plugins/home/server';
Expand All @@ -68,7 +67,6 @@ declare module 'hapi' {

interface Server {
config: () => KibanaConfig;
indexPatternsServiceFactory: IndexPatternsServiceFactory;
savedObjects: SavedObjectsLegacyService;
injectUiAppVars: (pluginName: string, getAppVars: () => { [key: string]: any }) => void;
getHiddenUiAppById(appId: string): UiApp;
Expand Down Expand Up @@ -175,5 +173,4 @@ export default class KbnServer {
export { Server, Request, ResponseToolkit } from 'hapi';

// Re-export commonly accessed api types.
export { IndexPatternsFetcher as IndexPatternsService } from './index_patterns';
export { SavedObjectsLegacyService, SavedObjectsClient } from 'src/core/server';
2 changes: 0 additions & 2 deletions src/legacy/server/kbn_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import pidMixin from './pid';
import configCompleteMixin from './config/complete';
import optimizeMixin from '../../optimize';
import * as Plugins from './plugins';
import { indexPatternsMixin } from './index_patterns';
import { savedObjectsMixin } from './saved_objects/saved_objects_mixin';
import { capabilitiesMixin } from './capabilities';
import { serverExtensionsMixin } from './server_extensions';
Expand Down Expand Up @@ -114,7 +113,6 @@ export default class KbnServer {

// setup this.uiBundles
uiMixin,
indexPatternsMixin,

// setup saved object routes
savedObjectsMixin,
Expand Down
5 changes: 0 additions & 5 deletions src/legacy/server/saved_objects/saved_objects_mixin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@ describe('Saved Objects Mixin', () => {
get: stubConfig,
};
},
indexPatternsServiceFactory: () => {
return {
getFieldsForWildcard: jest.fn(),
};
},
plugins: {
elasticsearch: {
getCluster: () => {
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/home/public/application/components/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
EuiPageBody,
EuiScreenReaderOnly,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import { Welcome } from './welcome';
import { getServices } from '../kibana_services';
Expand Down Expand Up @@ -69,6 +70,9 @@ export class Home extends Component {
componentDidMount() {
this._isMounted = true;
this.fetchIsNewKibanaInstance();

const homeTitle = i18n.translate('home.breadcrumbs.homeTitle', { defaultMessage: 'Home' });
getServices().chrome.setBreadcrumbs([{ text: homeTitle }]);
}

fetchIsNewKibanaInstance = async () => {
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/home/public/application/components/home.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jest.mock('../kibana_services', () => ({
getBasePath: () => 'path',
tutorialVariables: () => ({}),
homeConfig: { disableWelcomeScreen: false },
chrome: {
setBreadcrumbs: () => {},
},
}),
}));

Expand Down
Loading

0 comments on commit b892dfe

Please sign in to comment.