From ca40d71ca82717cc651f2d9c9181fed2066371ee Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Mon, 13 Apr 2020 16:05:27 -0600 Subject: [PATCH] Remove last angular bindings to gis map saved object loader --- .../services/gis_map_saved_object_loader.js | 11 ++--------- .../public/embeddable/map_embeddable_factory.ts | 4 ++-- x-pack/legacy/plugins/maps/public/routes.js | 15 ++++++++++----- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/x-pack/legacy/plugins/maps/public/angular/services/gis_map_saved_object_loader.js b/x-pack/legacy/plugins/maps/public/angular/services/gis_map_saved_object_loader.js index 70d1e2e7537cb..e4dccf07cc9ed 100644 --- a/x-pack/legacy/plugins/maps/public/angular/services/gis_map_saved_object_loader.js +++ b/x-pack/legacy/plugins/maps/public/angular/services/gis_map_saved_object_loader.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ +import _ from 'lodash'; import { createSavedGisMapClass } from './saved_gis_map'; -import { uiModules } from 'ui/modules'; import { SavedObjectLoader } from '../../../../../../../src/plugins/saved_objects/public'; import { getCoreChrome, @@ -15,7 +15,7 @@ import { getData, } from '../../kibana_services'; -export function getMapsSavedObjectLoader() { +export const getMapsSavedObjectLoader = _.once(function() { const services = { savedObjectsClient: getSavedObjectsClient(), indexPatterns: getIndexPatternService(), @@ -26,11 +26,4 @@ export function getMapsSavedObjectLoader() { const SavedGisMap = createSavedGisMapClass(services); return new SavedObjectLoader(SavedGisMap, getSavedObjectsClient(), getCoreChrome()); -} - -const module = uiModules.get('app/maps'); - -// This is the only thing that gets injected into controllers -module.service('gisMapSavedObjectLoader', function() { - return getMapsSavedObjectLoader(); }); diff --git a/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.ts b/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.ts index e3add828db0a2..93529c165464b 100644 --- a/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.ts +++ b/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.ts @@ -10,7 +10,7 @@ import { npSetup, npStart } from 'ui/new_platform'; import { IIndexPattern } from 'src/plugins/data/public'; import { getMapsSavedObjectLoader } from '../angular/services/gis_map_saved_object_loader'; import { MapEmbeddable, MapEmbeddableInput } from './map_embeddable'; -import { getIndexPatternService, getHttp, getMapsCapabilties } from '../kibana_services'; +import { getIndexPatternService, getHttp, getMapsCapabilities } from '../kibana_services'; import { EmbeddableFactoryDefinition, IContainer, @@ -49,7 +49,7 @@ export class MapEmbeddableFactory implements EmbeddableFactoryDefinition { } async isEditable() { - return getMapsCapabilties().save as boolean; + return getMapsCapabilities().save as boolean; } // Not supported yet for maps types. diff --git a/x-pack/legacy/plugins/maps/public/routes.js b/x-pack/legacy/plugins/maps/public/routes.js index bf3b2d4dcc185..26d0232fc78a7 100644 --- a/x-pack/legacy/plugins/maps/public/routes.js +++ b/x-pack/legacy/plugins/maps/public/routes.js @@ -9,13 +9,14 @@ import routes from 'ui/routes'; import listingTemplate from './angular/listing_ng_wrapper.html'; import mapTemplate from './angular/map.html'; import { getSavedObjectsClient, getCoreChrome, getMapsCapabilities } from './kibana_services'; +import { getMapsSavedObjectLoader } from './angular/services/gis_map_saved_object_loader'; routes.enable(); routes .defaults(/.*/, { - badge: uiCapabilities => { - if (uiCapabilities.maps.save) { + badge: () => { + if (getMapsCapabilities().save) { return undefined; } @@ -32,7 +33,8 @@ routes }) .when('/', { template: listingTemplate, - controller($scope, gisMapSavedObjectLoader, config) { + controller($scope, config) { + const gisMapSavedObjectLoader = getMapsSavedObjectLoader(); $scope.listingLimit = config.get('savedObjects:listingLimit'); $scope.find = search => { return gisMapSavedObjectLoader.find(search, $scope.listingLimit); @@ -60,7 +62,9 @@ routes template: mapTemplate, controller: 'GisMapController', resolve: { - map: function(gisMapSavedObjectLoader, redirectWhenMissing) { + map: function(redirectWhenMissing, $scope, config) { + const gisMapSavedObjectLoader = getMapsSavedObjectLoader(); + $scope.listingLimit = config.get('savedObjects:listingLimit'); return gisMapSavedObjectLoader.get().catch( redirectWhenMissing({ map: '/', @@ -73,7 +77,8 @@ routes template: mapTemplate, controller: 'GisMapController', resolve: { - map: function(gisMapSavedObjectLoader, redirectWhenMissing, $route) { + map: function(redirectWhenMissing, $route) { + const gisMapSavedObjectLoader = getMapsSavedObjectLoader(); const id = $route.current.params.id; return gisMapSavedObjectLoader .get(id)