Skip to content

Commit

Permalink
[Maps] nest security layers in layer group (#144055)
Browse files Browse the repository at this point in the history
* [Maps] nest security layers in layer group

* update security layers

* [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

* [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix'

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
nreese and kibanamachine authored Oct 27, 2022
1 parent 9ae3880 commit a21ed37
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('createLayerDescriptor', () => {
label: 'apm-*-transaction* | Source Point',
maxZoom: 24,
minZoom: 0,
parent: '12345',
disableTooltips: false,
sourceDescriptor: {
applyGlobalQuery: true,
Expand Down Expand Up @@ -119,6 +120,7 @@ describe('createLayerDescriptor', () => {
label: 'apm-*-transaction* | Destination point',
maxZoom: 24,
minZoom: 0,
parent: '12345',
disableTooltips: false,
sourceDescriptor: {
applyGlobalQuery: true,
Expand Down Expand Up @@ -196,6 +198,7 @@ describe('createLayerDescriptor', () => {
label: 'apm-*-transaction* | Line',
maxZoom: 24,
minZoom: 0,
parent: '12345',
disableTooltips: false,
sourceDescriptor: {
applyGlobalQuery: true,
Expand Down Expand Up @@ -248,6 +251,13 @@ describe('createLayerDescriptor', () => {
type: 'GEOJSON_VECTOR',
visible: true,
},
{
id: '12345',
label: 'apm-*-transaction*',
sourceDescriptor: null,
type: 'LAYER_GROUP',
visible: true,
},
]);
});

Expand All @@ -262,6 +272,7 @@ describe('createLayerDescriptor', () => {
label: 'filebeat-* | Source Point',
maxZoom: 24,
minZoom: 0,
parent: '12345',
disableTooltips: false,
sourceDescriptor: {
applyGlobalQuery: true,
Expand Down Expand Up @@ -339,6 +350,7 @@ describe('createLayerDescriptor', () => {
label: 'filebeat-* | Destination point',
maxZoom: 24,
minZoom: 0,
parent: '12345',
disableTooltips: false,
sourceDescriptor: {
applyGlobalQuery: true,
Expand Down Expand Up @@ -410,6 +422,7 @@ describe('createLayerDescriptor', () => {
label: 'filebeat-* | Line',
maxZoom: 24,
minZoom: 0,
parent: '12345',
disableTooltips: false,
sourceDescriptor: {
applyGlobalQuery: true,
Expand Down Expand Up @@ -462,6 +475,13 @@ describe('createLayerDescriptor', () => {
type: 'GEOJSON_VECTOR',
visible: true,
},
{
id: '12345',
label: 'filebeat-*',
sourceDescriptor: null,
type: 'LAYER_GROUP',
visible: true,
},
]);
});

Expand All @@ -476,6 +496,7 @@ describe('createLayerDescriptor', () => {
label: 'traces-apm-opbean-node | Source Point',
maxZoom: 24,
minZoom: 0,
parent: '12345',
disableTooltips: false,
sourceDescriptor: {
applyGlobalQuery: true,
Expand Down Expand Up @@ -553,6 +574,7 @@ describe('createLayerDescriptor', () => {
label: 'traces-apm-opbean-node | Destination point',
maxZoom: 24,
minZoom: 0,
parent: '12345',
disableTooltips: false,
sourceDescriptor: {
applyGlobalQuery: true,
Expand Down Expand Up @@ -624,6 +646,7 @@ describe('createLayerDescriptor', () => {
label: 'traces-apm-opbean-node | Line',
maxZoom: 24,
minZoom: 0,
parent: '12345',
disableTooltips: false,
sourceDescriptor: {
applyGlobalQuery: true,
Expand Down Expand Up @@ -676,6 +699,13 @@ describe('createLayerDescriptor', () => {
type: 'GEOJSON_VECTOR',
visible: true,
},
{
id: '12345',
label: 'traces-apm-opbean-node',
sourceDescriptor: null,
type: 'LAYER_GROUP',
visible: true,
},
]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
VECTOR_STYLES,
} from '../../../../../../common/constants';
import { GeoJsonVectorLayer } from '../../../vector_layer';
import { LayerGroup } from '../../../layer_group';
import { VectorStyle } from '../../../../styles/vector/vector_style';
import { ESSearchSource } from '../../../../sources/es_search_source';
import { ESPewPewSource } from '../../../../sources/es_pew_pew_source';
Expand All @@ -48,7 +49,11 @@ function getDestinationField(indexPatternTitle: string) {
return isApmIndex(indexPatternTitle) ? 'server.geo.location' : 'destination.geo.location';
}

function createSourceLayerDescriptor(indexPatternId: string, indexPatternTitle: string) {
function createSourceLayerDescriptor(
indexPatternId: string,
indexPatternTitle: string,
parentId: string
) {
const sourceDescriptor = ESSearchSource.createDescriptor({
indexPatternId,
geoField: getSourceField(indexPatternTitle),
Expand Down Expand Up @@ -96,12 +101,17 @@ function createSourceLayerDescriptor(indexPatternId: string, indexPatternTitle:
defaultMessage: '{indexPatternTitle} | Source Point',
values: { indexPatternTitle },
}),
parent: parentId,
sourceDescriptor,
style: VectorStyle.createDescriptor(styleProperties),
});
}

function createDestinationLayerDescriptor(indexPatternId: string, indexPatternTitle: string) {
function createDestinationLayerDescriptor(
indexPatternId: string,
indexPatternTitle: string,
parentId: string
) {
const sourceDescriptor = ESSearchSource.createDescriptor({
indexPatternId,
geoField: getDestinationField(indexPatternTitle),
Expand Down Expand Up @@ -149,12 +159,17 @@ function createDestinationLayerDescriptor(indexPatternId: string, indexPatternTi
defaultMessage: '{indexPatternTitle} | Destination point',
values: { indexPatternTitle },
}),
parent: parentId,
sourceDescriptor,
style: VectorStyle.createDescriptor(styleProperties),
});
}

function createLineLayerDescriptor(indexPatternId: string, indexPatternTitle: string) {
function createLineLayerDescriptor(
indexPatternId: string,
indexPatternTitle: string,
parentId: string
) {
const sourceDescriptor = ESPewPewSource.createDescriptor({
indexPatternId,
sourceGeoField: getSourceField(indexPatternTitle),
Expand Down Expand Up @@ -195,6 +210,7 @@ function createLineLayerDescriptor(indexPatternId: string, indexPatternTitle: st
defaultMessage: '{indexPatternTitle} | Line',
values: { indexPatternTitle },
}),
parent: parentId,
sourceDescriptor,
style: VectorStyle.createDescriptor(styleProperties),
});
Expand All @@ -204,9 +220,11 @@ export function createSecurityLayerDescriptors(
indexPatternId: string,
indexPatternTitle: string
): LayerDescriptor[] {
const layerGroupDescriptor = LayerGroup.createDescriptor({ label: indexPatternTitle });
return [
createSourceLayerDescriptor(indexPatternId, indexPatternTitle),
createDestinationLayerDescriptor(indexPatternId, indexPatternTitle),
createLineLayerDescriptor(indexPatternId, indexPatternTitle),
createSourceLayerDescriptor(indexPatternId, indexPatternTitle, layerGroupDescriptor.id),
createDestinationLayerDescriptor(indexPatternId, indexPatternTitle, layerGroupDescriptor.id),
createLineLayerDescriptor(indexPatternId, indexPatternTitle, layerGroupDescriptor.id),
layerGroupDescriptor,
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ export const mockAPMIndexPatternIds: IndexPatternMapping[] = [
{ title: 'traces-apm*,logs-apm*,metrics-apm*,apm-*', id: '8c7323ac-97ad-4b53-ac0a-40f8f691a918' },
];

export const mockLayerGroup = {
id: 'uuid.v4()',
label: 'filebeat-*',
sourceDescriptor: null,
type: LAYER_TYPE.LAYER_GROUP,
visible: true,
};

export const mockSourceLayer = {
sourceDescriptor: {
id: 'uuid.v4()',
Expand Down Expand Up @@ -64,6 +72,7 @@ export const mockSourceLayer = {
},
},
id: 'uuid.v4()',
parent: 'uuid.v4()',
label: `filebeat-* | Source Point`,
minZoom: 0,
maxZoom: 24,
Expand Down Expand Up @@ -121,6 +130,7 @@ export const mockDestinationLayer = {
},
},
id: 'uuid.v4()',
parent: 'uuid.v4()',
label: `filebeat-* | Destination Point`,
minZoom: 0,
maxZoom: 24,
Expand Down Expand Up @@ -176,6 +186,7 @@ export const mockClientLayer = {
},
},
id: 'uuid.v4()',
parent: 'uuid.v4()',
label: `apm-* | Client Point`,
minZoom: 0,
maxZoom: 24,
Expand Down Expand Up @@ -238,6 +249,7 @@ export const mockServerLayer = {
},
},
id: 'uuid.v4()',
parent: 'uuid.v4()',
label: `apm-* | Server Point`,
minZoom: 0,
maxZoom: 24,
Expand Down Expand Up @@ -307,6 +319,7 @@ export const mockLineLayer = {
},
},
id: 'uuid.v4()',
parent: 'uuid.v4()',
label: `filebeat-* | Line`,
minZoom: 0,
maxZoom: 24,
Expand Down Expand Up @@ -371,6 +384,7 @@ export const mockClientServerLineLayer = {
},
},
id: 'uuid.v4()',
parent: 'uuid.v4()',
label: `apm-* | Line`,
minZoom: 0,
maxZoom: 24,
Expand Down Expand Up @@ -399,6 +413,7 @@ export const mockLayerList = [
mockLineLayer,
mockDestinationLayer,
mockSourceLayer,
mockLayerGroup,
];

export const mockLayerListDouble = [
Expand All @@ -416,9 +431,11 @@ export const mockLayerListDouble = [
mockLineLayer,
mockDestinationLayer,
mockSourceLayer,
mockLayerGroup,
mockLineLayer,
mockDestinationLayer,
mockSourceLayer,
mockLayerGroup,
];

export const mockLayerListMixed = [
Expand All @@ -436,12 +453,21 @@ export const mockLayerListMixed = [
mockLineLayer,
mockDestinationLayer,
mockSourceLayer,
mockLayerGroup,
mockClientServerLineLayer,
mockServerLayer,
mockClientLayer,
{
...mockLayerGroup,
label: 'apm-*',
},
mockApmDataStreamClientServerLineLayer,
mockApmDataStreamServerLayer,
mockApmDataStreamClientLayer,
{
...mockLayerGroup,
label: 'traces-apm*,logs-apm*,metrics-apm*,apm-*',
},
];

export const mockAPMIndexPattern: IndexPatternSavedObject = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
mockLayerList,
mockLayerListDouble,
mockLayerListMixed,
mockLayerGroup,
mockLineLayer,
mockServerLayer,
mockSourceLayer,
Expand Down Expand Up @@ -50,6 +51,7 @@ describe('map_config', () => {
const layerList = getSourceLayer(
mockIndexPatternIds[0].title,
mockIndexPatternIds[0].id,
mockLayerGroup.id,
lmc.default.source
);
expect(layerList).toStrictEqual(mockSourceLayer);
Expand All @@ -59,6 +61,7 @@ describe('map_config', () => {
const layerList = getSourceLayer(
mockAPMIndexPatternIds[0].title,
mockAPMIndexPatternIds[0].id,
mockLayerGroup.id,
lmc[mockAPMIndexPatternIds[0].title].source
);
expect(layerList).toStrictEqual(mockClientLayer);
Expand All @@ -70,6 +73,7 @@ describe('map_config', () => {
const layerList = getDestinationLayer(
mockIndexPatternIds[0].title,
mockIndexPatternIds[0].id,
mockLayerGroup.id,
lmc.default.destination
);
expect(layerList).toStrictEqual(mockDestinationLayer);
Expand All @@ -79,6 +83,7 @@ describe('map_config', () => {
const layerList = getDestinationLayer(
mockAPMIndexPatternIds[0].title,
mockAPMIndexPatternIds[0].id,
mockLayerGroup.id,
lmc[mockAPMIndexPatternIds[0].title].destination
);
expect(layerList).toStrictEqual(mockServerLayer);
Expand All @@ -90,6 +95,7 @@ describe('map_config', () => {
const layerList = getLineLayer(
mockIndexPatternIds[0].title,
mockIndexPatternIds[0].id,
mockLayerGroup.id,
lmc.default
);
expect(layerList).toStrictEqual(mockLineLayer);
Expand All @@ -99,6 +105,7 @@ describe('map_config', () => {
const layerList = getLineLayer(
mockAPMIndexPatternIds[0].title,
mockAPMIndexPatternIds[0].id,
mockLayerGroup.id,
lmc[mockAPMIndexPatternIds[0].title]
);
expect(layerList).toStrictEqual(mockClientServerLineLayer);
Expand Down
Loading

0 comments on commit a21ed37

Please sign in to comment.