[Maps] show edit link when map embeddabed in dashboard (#36188) (#36238)

* [Maps] show edit link when map embeddabed in dashboard

* move functional tests to dashboard_security test suite
This commit is contained in:
Nathan Reese 2019-05-07 16:16:03 -06:00 committed by GitHub
parent 9801e5631e
commit 515d6836aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 137 additions and 4 deletions

View file

@ -42,9 +42,10 @@ export class MapEmbeddable extends Embeddable {
embeddableConfig,
savedMap,
editUrl,
editable,
indexPatterns = []
}) {
super({ title: savedMap.title, editUrl, indexPatterns });
super({ title: savedMap.title, editUrl, editable, indexPatterns });
this._onEmbeddableStateChanged = onEmbeddableStateChanged;
this._embeddableConfig = _.cloneDeep(embeddableConfig);

View file

@ -14,6 +14,7 @@ import { createMapPath, MAP_SAVED_OBJECT_TYPE, APP_ICON } from '../../common/con
import { createMapStore } from '../store/store';
import { addLayerWithoutDataSync } from '../actions/store_actions';
import { getQueryableUniqueIndexPatternIds } from '../selectors/map_selectors';
import { capabilities } from 'ui/capabilities';
export class MapEmbeddableFactory extends EmbeddableFactory {
@ -63,11 +64,14 @@ export class MapEmbeddableFactory extends EmbeddableFactory {
const indexPatterns = await this._getIndexPatterns(savedMap.layerListJSON);
const editable = capabilities.get().maps.save;
return new MapEmbeddable({
onEmbeddableStateChanged,
embeddableConfig: panelMetadata.embeddableConfig,
savedMap,
editUrl: chrome.addBasePath(createMapPath(panelMetadata.id)),
editable,
indexPatterns,
});
}

View file

@ -22,7 +22,7 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
const testSubjects = getService('testSubjects');
const globalNav = getService('globalNav');
describe('security', () => {
describe('dashboard security', () => {
before(async () => {
await esArchiver.load('dashboard/feature_controls/security');
await esArchiver.loadIfNeeded('logstash_functional');
@ -38,7 +38,7 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
await PageObjects.security.forceLogout();
});
describe('global dashboard all privileges', () => {
describe('global dashboard all privileges, no embeddable application privileges', () => {
before(async () => {
await security.role.create('global_dashboard_all_role', {
elasticsearch: {
@ -129,9 +129,15 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
await PageObjects.share.openShareMenuItem('Permalinks');
await PageObjects.share.createShortUrlExistOrFail();
});
it(`does not allow a map to be edited`, async () => {
await PageObjects.dashboard.gotoDashboardEditMode('dashboard with map');
await panelActions.openContextMenu();
await panelActions.expectMissingEditPanelAction();
});
});
describe('global dashboard & visualize all privileges', () => {
describe('global dashboard & embeddable all privileges', () => {
before(async () => {
await security.role.create('global_dashboard_visualize_all_role', {
elasticsearch: {
@ -142,6 +148,7 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
feature: {
dashboard: ['all'],
visualize: ['all'],
maps: ['all'],
},
spaces: ['*'],
},
@ -174,6 +181,13 @@ export default function({ getPageObjects, getService }: KibanaFunctionalTestDefa
await panelActions.openContextMenu();
await panelActions.expectExistsEditPanelAction();
});
it(`allows a map to be edited`, async () => {
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.gotoDashboardEditMode('dashboard with map');
await panelActions.openContextMenu();
await panelActions.expectExistsEditPanelAction();
});
});
describe('global dashboard read-only privileges', () => {

View file

@ -83,3 +83,89 @@
}
}
}
{
"type": "doc",
"value": {
"index": ".kibana",
"type": "doc",
"id": "map:0b849ed0-70f5-11e9-8625-9580c4904684",
"source": {
"map": {
"title" : "just a map",
"description" : "",
"mapStateJSON" : "{\"zoom\":0.8,\"center\":{\"lon\":0,\"lat\":0},\"timeFilters\":{\"from\":\"now-15m\",\"to\":\"now\"},\"refreshConfig\":{\"isPaused\":false,\"interval\":0},\"query\":{\"query\":\"\",\"language\":\"kuery\"}}",
"layerListJSON" : "[{\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"id\":\"road_map\"},\"id\":\"c7bdee60-5267-459e-83d6-b53acf1b9e67\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":1,\"visible\":true,\"applyGlobalQuery\":true,\"style\":{\"type\":\"TILE\",\"properties\":{}},\"type\":\"TILE\"}]",
"uiStateJSON" : "{\"isLayerTOCOpen\":true}",
"bounds" : {
"type" : "polygon",
"coordinates" : [
[
[
-180,
85.05113
],
[
-180,
-85.05113
],
[
180,
-85.05113
],
[
180,
85.05113
],
[
-180,
85.05113
]
]
]
}
},
"type": "map",
"references" : [ ],
"migrationVersion" : {
"map" : "7.1.0"
},
"updated_at" : "2019-05-07T18:22:17.405Z"
}
}
}
{
"type": "doc",
"value": {
"index": ".kibana",
"type": "doc",
"id": "dashboard:1c1a87f0-70f5-11e9-8625-9580c4904684",
"source": {
"dashboard": {
"title" : "dashboard with map",
"hits" : 0,
"description" : "",
"panelsJSON" : "[{\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":15,\"i\":\"1\"},\"version\":\"8.0.0\",\"panelIndex\":\"1\",\"embeddableConfig\":{\"mapCenter\":{\"lat\":0,\"lon\":0,\"zoom\":0.8},\"isLayerTOCOpen\":true},\"panelRefName\":\"panel_0\"}]",
"optionsJSON" : "{\"useMargins\":true,\"hidePanelTitles\":false}",
"version" : 1,
"timeRestore" : false,
"kibanaSavedObjectMeta" : {
"searchSourceJSON" : "{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}"
}
},
"type": "dashboard",
"references" : [
{
"name" : "panel_0",
"type" : "map",
"id" : "0b849ed0-70f5-11e9-8625-9580c4904684"
}
],
"migrationVersion" : {
"dashboard" : "7.0.0"
},
"updated_at" : "2019-05-07T18:22:45.231Z"
}
}
}

View file

@ -279,9 +279,37 @@
}
}
},
"migrationVersion": {
"dynamic": "true",
"properties": {
"index-pattern": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
}
}
},
"namespace": {
"type": "keyword"
},
"references": {
"type": "nested",
"properties": {
"name": {
"type": "keyword"
},
"type": {
"type": "keyword"
},
"id": {
"type": "keyword"
}
}
},
"search": {
"properties": {
"columns": {