Skip to content

Commit

Permalink
Merge branch 'master' into add-alert-mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine committed May 11, 2020
2 parents 88dd778 + be79023 commit 722e229
Show file tree
Hide file tree
Showing 54 changed files with 815 additions and 632 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
fields?: {
[subfield: string]: {
type: string;
ignore_above?: number;
};
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface SavedObjectsCoreFieldMapping
| Property | Type | Description |
| --- | --- | --- |
| [enabled](./kibana-plugin-core-server.savedobjectscorefieldmapping.enabled.md) | <code>boolean</code> | |
| [fields](./kibana-plugin-core-server.savedobjectscorefieldmapping.fields.md) | <code>{</code><br/><code> [subfield: string]: {</code><br/><code> type: string;</code><br/><code> };</code><br/><code> }</code> | |
| [fields](./kibana-plugin-core-server.savedobjectscorefieldmapping.fields.md) | <code>{</code><br/><code> [subfield: string]: {</code><br/><code> type: string;</code><br/><code> ignore_above?: number;</code><br/><code> };</code><br/><code> }</code> | |
| [index](./kibana-plugin-core-server.savedobjectscorefieldmapping.index.md) | <code>boolean</code> | |
| [null\_value](./kibana-plugin-core-server.savedobjectscorefieldmapping.null_value.md) | <code>number &#124; boolean &#124; string</code> | |
| [type](./kibana-plugin-core-server.savedobjectscorefieldmapping.type.md) | <code>string</code> | |
Expand Down
1 change: 1 addition & 0 deletions src/core/server/saved_objects/mappings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export interface SavedObjectsCoreFieldMapping {
fields?: {
[subfield: string]: {
type: string;
ignore_above?: number;
};
};
}
Expand Down
1 change: 1 addition & 0 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1884,6 +1884,7 @@ export interface SavedObjectsCoreFieldMapping {
fields?: {
[subfield: string]: {
type: string;
ignore_above?: number;
};
};
// (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,18 @@ interface TabsProps extends Pick<RouteComponentProps, 'history' | 'location'> {
};
}

const searchAriaLabel = i18n.translate('kbn.management.editIndexPattern.fields.searchAria', {
defaultMessage: 'Search fields',
});

const filterAriaLabel = i18n.translate('kbn.management.editIndexPattern.fields.filterAria', {
defaultMessage: 'Filter',
defaultMessage: 'Filter field types',
});

const filterPlaceholder = i18n.translate(
'kbn.management.editIndexPattern.fields.filterPlaceholder',
{
defaultMessage: 'Filter',
defaultMessage: 'Search',
}
);

Expand Down Expand Up @@ -108,7 +112,7 @@ export function Tabs({ config, indexPattern, fields, services, history, location
value={fieldFilter}
onChange={e => setFieldFilter(e.target.value)}
data-test-subj="indexPatternFieldFilter"
aria-label={filterAriaLabel}
aria-label={searchAriaLabel}
/>
</EuiFlexItem>
{type === TAB_INDEXED_FIELDS && indexedFieldTypes.length > 0 && (
Expand All @@ -118,6 +122,7 @@ export function Tabs({ config, indexPattern, fields, services, history, location
value={indexedFieldTypeFilter}
onChange={e => setIndexedFieldTypeFilter(e.target.value)}
data-test-subj="indexedFieldTypeFilterDropdown"
aria-label={filterAriaLabel}
/>
</EuiFlexItem>
)}
Expand Down
30 changes: 0 additions & 30 deletions src/legacy/core_plugins/ui_metric/index.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/legacy/core_plugins/ui_metric/package.json

This file was deleted.

21 changes: 0 additions & 21 deletions src/legacy/core_plugins/ui_metric/public/index.ts

This file was deleted.

This file was deleted.

44 changes: 0 additions & 44 deletions src/plugins/usage_collection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,41 +126,6 @@ export function registerMyPluginUsageCollector(
}
```

### Migrating to NP from Legacy Plugins

Pass `usageCollection` to the setup NP plugin setup function under plugins. Inside the `setup` function call the `registerCollector` like what you'd do in the NP example above.

```js
// index.js
export const myPlugin = (kibana: any) => {
return new kibana.Plugin({
init: async function (server) {
const { usageCollection } = server.newPlatform.setup.plugins;
const plugins = {
usageCollection,
};
plugin(initializerContext).setup(core, plugins);
}
});
}
```

### Legacy Plugins

Typically, a plugin will create the collector object and register it with the Telemetry service from the `init` method of the plugin definition, or a helper module called from `init`.

```js
// index.js
export const myPlugin = (kibana: any) => {
return new kibana.Plugin({
init: async function (server) {
const { usageCollection } = server.newPlatform.setup.plugins;
registerMyPluginUsageCollector(usageCollection);
}
});
}
```

## Update the telemetry payload and telemetry cluster field mappings

There is a module in the telemetry service that creates the payload of data that gets sent up to the telemetry cluster.
Expand Down Expand Up @@ -239,15 +204,6 @@ To track a user interaction, use the `reportUiStats` method exposed by the plugi
}
```
Alternatively, in the Legacy world you can still import the `createUiStatsReporter` helper function from UI Metric app:
```js
import { createUiStatsReporter, METRIC_TYPE } from 'relative/path/to/src/legacy/core_plugins/ui_metric/public';
const trackMetric = createUiStatsReporter(`<AppName>`);
trackMetric(METRIC_TYPE.CLICK, `<EventName>`);
trackMetric('click', `<EventName>`);
```
Metric Types:
- `METRIC_TYPE.CLICK` for tracking clicks `trackMetric(METRIC_TYPE.CLICK, 'my_button_clicked');`
Expand Down
25 changes: 8 additions & 17 deletions test/accessibility/apps/management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,12 @@
import { FtrProviderContext } from '../ftr_provider_context';

export default function({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['common', 'settings']);
const PageObjects = getPageObjects(['common', 'settings', 'header']);
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const testSubjects = getService('testSubjects');
const a11y = getService('a11y');

// describe('Management', () => {
// before(async () => {
// await esArchiver.loadIfNeeded('logstash_functional');
// await kibanaServer.uiSettings.update({
// defaultIndex: 'logstash-*',
// });
// await PageObjects.common.navigateToApp('settings');
// });

// FLAKY: https://github.com/elastic/kibana/issues/60470
describe.skip('Management', () => {
describe('Management', () => {
before(async () => {
await esArchiver.load('discover');
await esArchiver.loadIfNeeded('logstash_functional');
Expand All @@ -57,23 +46,25 @@ export default function({ getService, getPageObjects }: FtrProviderContext) {

it('Single indexpattern view', async () => {
await PageObjects.settings.clickIndexPatternLogstash();
await PageObjects.header.waitUntilLoadingHasFinished();
await a11y.testAppSnapshot();
});

it('Create Index pattern wizard', async () => {
it('Open create index pattern wizard', async () => {
await PageObjects.settings.clickKibanaIndexPatterns();
await (await testSubjects.find('createIndexPatternButton')).click();
await PageObjects.settings.clickAddNewIndexPatternButton();
await PageObjects.header.waitUntilLoadingHasFinished();
await a11y.testAppSnapshot();
});

// index patterns page
// We are navigating back to index pattern page to test field formatters
it('Navigate back to logstash index page', async () => {
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
await a11y.testAppSnapshot();
});

// Issue: https://github.com/elastic/kibana/issues/60030
// Will be enabling this and field formatters after this issue is addressed: https://github.com/elastic/kibana/issues/60030
it.skip('Edit field type', async () => {
await PageObjects.settings.clickEditFieldFormat();
await a11y.testAppSnapshot();
Expand Down
34 changes: 1 addition & 33 deletions x-pack/legacy/plugins/maps/server/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,10 @@ import { emsBoundariesSpecProvider } from './tutorials/ems';

export class MapPlugin {
setup(core, plugins, __LEGACY) {
const { featuresPlugin, home, licensing, usageCollection, mapsLegacy } = plugins;
const { home, licensing, usageCollection, mapsLegacy } = plugins;
let routesInitialized = false;
const mapConfig = mapsLegacy.config;

featuresPlugin.registerFeature({
id: APP_ID,
name: i18n.translate('xpack.maps.featureRegistry.mapsFeatureName', {
defaultMessage: 'Maps',
}),
order: 600,
icon: APP_ICON,
navLinkId: APP_ID,
app: [APP_ID, 'kibana'],
catalogue: [APP_ID],
privileges: {
all: {
app: [APP_ID, 'kibana'],
catalogue: [APP_ID],
savedObject: {
all: [MAP_SAVED_OBJECT_TYPE, 'query'],
read: ['index-pattern'],
},
ui: ['save', 'show', 'saveQuery'],
},
read: {
app: [APP_ID, 'kibana'],
catalogue: [APP_ID],
savedObject: {
all: [],
read: [MAP_SAVED_OBJECT_TYPE, 'index-pattern', 'query'],
},
ui: ['show'],
},
},
});

licensing.license$.subscribe(license => {
const { state } = license.check('maps', 'basic');
if (state === 'valid' && !routesInitialized) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ export function setupXPackMain(server) {

server.ext('onPreResponse', (request, h) => injectXPackInfoSignature(info, request, h));

const { registerFeature, getFeatures } = server.newPlatform.setup.plugins.features;
server.expose('registerFeature', registerFeature);
const { getFeatures } = server.newPlatform.setup.plugins.features;
server.expose('getFeatures', getFeatures);

const setPluginStatus = () => {
Expand Down
1 change: 0 additions & 1 deletion x-pack/legacy/plugins/xpack_main/server/xpack_main.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ export { XPackFeature } from './lib/xpack_info';
export interface XPackMainPlugin {
info: XPackInfo;
getFeatures(): Feature[];
registerFeature(feature: FeatureConfig): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -236,28 +236,33 @@ const getWaterfallItems = (items: TraceAPIResponse['trace']['items']) =>
}
});

/**
* Changes the parent_id of items based on the child.id property.
* Solves the problem of Inferred spans that are created as child of trace spans
* when it actually should be its parent.
* @param waterfallItems
*/
const reparentSpans = (waterfallItems: IWaterfallItem[]) => {
function reparentSpans(waterfallItems: IWaterfallItem[]) {
// find children that needs to be re-parented and map them to their correct parent id
const childIdToParentIdMapping = Object.fromEntries(
flatten(
waterfallItems.map(waterfallItem => {
if (waterfallItem.docType === 'span') {
const childIds = waterfallItem.doc.child?.id ?? [];
return childIds.map(id => [id, waterfallItem.id]);
}
return [];
})
)
);

// update parent id for children that needs it or return unchanged
return waterfallItems.map(waterfallItem => {
if (waterfallItem.docType === 'span') {
const childId = waterfallItem.doc.child?.id;
if (childId) {
childId.forEach(id => {
const item = waterfallItems.find(_item => _item.id === id);
if (item) {
item.parentId = waterfallItem.id;
}
});
}
const newParentId = childIdToParentIdMapping[waterfallItem.id];
if (newParentId) {
return {
...waterfallItem,
parentId: newParentId
};
}

return waterfallItem;
});
};
}

const getChildrenGroupedByParentId = (waterfallItems: IWaterfallItem[]) =>
groupBy(waterfallItems, item => (item.parentId ? item.parentId : ROOT_ID));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2027,7 +2027,7 @@ export const inferredSpans = {
id: '41226ae63af4f235',
type: 'unknown'
},
child: { ids: ['8d80de06aa11a6fc'] }
child: { id: ['8d80de06aa11a6fc'] }
},
{
container: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export const defaultShapeParameters = {
ignore_z_value: true,
};

describe('Mappings editor: shape datatype', () => {
// That test is being flaky and is under work to be fixed
// Skipping it for now.
describe.skip('Mappings editor: shape datatype', () => {
let testBed: MappingsEditorTestBed;

/**
Expand Down
Loading

0 comments on commit 722e229

Please sign in to comment.