diff --git a/CHANGELOG.md b/CHANGELOG.md index 478dc7c5..bd9bb1c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,4 +19,5 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Infrastructure ### Documentation ### Maintenance +* Deprecated maps multi data source display [#651](https://github.com/opensearch-project/dashboards-maps/pull/651) ### Refactoring diff --git a/opensearch_dashboards.json b/opensearch_dashboards.json index 1c6b783e..e8abd481 100644 --- a/opensearch_dashboards.json +++ b/opensearch_dashboards.json @@ -5,5 +5,5 @@ "server": true, "ui": true, "requiredPlugins": ["regionMap", "opensearchDashboardsReact", "opensearchDashboardsUtils", "navigation", "savedObjects", "data", "embeddable", "visualizations"], - "optionalPlugins": ["home", "dataSource", "dataSourceManagement"] + "optionalPlugins": ["home"] } diff --git a/public/components/layer_control_panel/layer_control_panel.tsx b/public/components/layer_control_panel/layer_control_panel.tsx index 44be9bd9..993fc0b2 100644 --- a/public/components/layer_control_panel/layer_control_panel.tsx +++ b/public/components/layer_control_panel/layer_control_panel.tsx @@ -29,7 +29,7 @@ import { IndexPattern } from '../../../../../src/plugins/data/public'; import { AddLayerPanel } from '../add_layer_panel'; import { LayerConfigPanel } from '../layer_config'; import { MapLayerSpecification } from '../../model/mapLayerType'; -import { DASHBOARDS_MAPS_LAYER_TYPE, LAYER_ICON_TYPE_MAP } from '../../../common'; +import { LAYER_ICON_TYPE_MAP } from '../../../common'; import { useOpenSearchDashboards } from '../../../../../src/plugins/opensearch_dashboards_react/public'; import { MapServices } from '../../types'; import { MapState } from '../../model/mapState'; @@ -49,7 +49,6 @@ interface Props { selectedLayerConfig: MapLayerSpecification | undefined; setSelectedLayerConfig: (layerConfig: MapLayerSpecification | undefined) => void; setIsUpdatingLayerRender: (isUpdatingLayerRender: boolean) => void; - setDataSourceRefIds: (dataSourceRefIds: string[]) => void; } export const LayerControlPanel = memo( @@ -57,14 +56,11 @@ export const LayerControlPanel = memo( maplibreRef, setLayers, layers, - layersIndexPatterns, - setLayersIndexPatterns, zoom, isReadOnlyMode, selectedLayerConfig, setSelectedLayerConfig, setIsUpdatingLayerRender, - setDataSourceRefIds, }: Props) => { const { services } = useOpenSearchDashboards(); @@ -209,39 +205,12 @@ export const LayerControlPanel = memo( setIsDeleteLayerModalVisible(true); }; - const removeDataLayerDataSource = (layer: MapLayerSpecification) => { - if (layer.type === DASHBOARDS_MAPS_LAYER_TYPE.DOCUMENTS) { - const indexPatternId = layer.source.indexPatternId; - const indexPattern = layersIndexPatterns.find((idp) => idp.id === indexPatternId); - if (indexPattern) { - const indexPatternClone = [...layersIndexPatterns]; - const index = indexPatternClone.findIndex((idp) => idp.id === indexPatternId); - if (index > -1) { - indexPatternClone.splice(index, 1); - setLayersIndexPatterns(indexPatternClone); - } - // remove duplicate dataSourceRefIds - const updatedDataSourceRefIds : string[] = []; - indexPatternClone.forEach((ip) => { - if (ip.dataSourceRef && !updatedDataSourceRefIds.includes(ip.dataSourceRef.id)) { - updatedDataSourceRefIds.push(ip.dataSourceRef.id); - } else if (!ip.dataSourceRef && !updatedDataSourceRefIds.includes('')) { - updatedDataSourceRefIds.push(''); - } - }); - - setDataSourceRefIds(updatedDataSourceRefIds); - } - } - }; - const onDeleteLayerConfirm = () => { if (selectedDeleteLayer) { removeLayers(maplibreRef.current!, selectedDeleteLayer.id, true); removeLayer(selectedDeleteLayer.id); setIsDeleteLayerModalVisible(false); setSelectedDeleteLayer(undefined); - removeDataLayerDataSource(selectedDeleteLayer); } }; diff --git a/public/components/map_container/map_container.tsx b/public/components/map_container/map_container.tsx index e819ddfa..8fc7f120 100644 --- a/public/components/map_container/map_container.tsx +++ b/public/components/map_container/map_container.tsx @@ -46,8 +46,6 @@ interface MapContainerProps { isUpdatingLayerRender: boolean; setIsUpdatingLayerRender: (isUpdatingLayerRender: boolean) => void; addSpatialFilter: (shape: ShapeFilter, label: string | null, relation: GeoShapeRelation) => void; - dataSourceRefIds: string[]; - setDataSourceRefIds: (refIds: string[]) => void; } export class MapsServiceError extends Error { @@ -69,7 +67,6 @@ export const MapContainer = ({ isUpdatingLayerRender, setIsUpdatingLayerRender, addSpatialFilter, - setDataSourceRefIds, }: MapContainerProps) => { const { services } = useOpenSearchDashboards(); @@ -248,16 +245,6 @@ export const MapContainer = ({ ); const cloneLayersIndexPatterns = [...layersIndexPatterns, newIndexPattern]; setLayersIndexPatterns(cloneLayersIndexPatterns); - const updatedDataSourceRefIds: string[] = []; - cloneLayersIndexPatterns.forEach((ip) => { - if (ip.dataSourceRef && !updatedDataSourceRefIds.includes(ip.dataSourceRef.id)) { - updatedDataSourceRefIds.push(ip.dataSourceRef.id); - } else if (!ip.dataSourceRef && !updatedDataSourceRefIds.includes('')) { - // If index pattern of the layer doesn't have reference to a data source, it is using local cluster - updatedDataSourceRefIds.push(''); - } - }); - setDataSourceRefIds(updatedDataSourceRefIds); } }; @@ -284,7 +271,6 @@ export const MapContainer = ({ selectedLayerConfig={selectedLayerConfig} setSelectedLayerConfig={setSelectedLayerConfig} setIsUpdatingLayerRender={setIsUpdatingLayerRender} - setDataSourceRefIds={setDataSourceRefIds} /> )} {mounted && tooltipState === TOOLTIP_STATE.DISPLAY_FEATURES && maplibreRef.current && ( diff --git a/public/components/map_page/map_page.tsx b/public/components/map_page/map_page.tsx index 997c8806..2762e530 100644 --- a/public/components/map_page/map_page.tsx +++ b/public/components/map_page/map_page.tsx @@ -59,8 +59,6 @@ export const MapComponent = ({ mapIdFromSavedObject, dashboardProps }: MapCompon const [mapState, setMapState] = useState(getInitialMapState()); const [isUpdatingLayerRender, setIsUpdatingLayerRender] = useState(true); const isReadOnlyMode = !!dashboardProps; - const [dataSourceRefIds, setDataSourceRefIds] = useState([]); - const [dataLoadReady, setDataLoadReady] = useState(false); useEffect(() => { if (mapIdFromSavedObject) { @@ -71,39 +69,21 @@ export const MapComponent = ({ mapIdFromSavedObject, dashboardProps }: MapCompon setMapState(savedMapState); setLayers(layerList); const savedIndexPatterns: IndexPattern[] = []; - const remoteDataSourceIds: string[] = []; - - const fetchDataLayer = async () => { - const requests = layerList - .filter((layer) => layer.type === DASHBOARDS_MAPS_LAYER_TYPE.DOCUMENTS) - .map((layer) => services.data.indexPatterns.get(layer.source.indexPatternId)); - - const resp = await Promise.all(requests); - resp.forEach((response: IndexPattern) => { - savedIndexPatterns.push(response); - if (response.dataSourceRef && !dataSourceRefIds.includes(response.dataSourceRef.id)) { - remoteDataSourceIds.push(response.dataSourceRef.id); - } else if (!response.dataSourceRef && !remoteDataSourceIds.includes('')) { - // If index pattern of the layer doesn't have reference to a data source, it is using local cluster - remoteDataSourceIds.push(''); - } - }); - - setLayers(layerList); - setLayersIndexPatterns(savedIndexPatterns); - setDataSourceRefIds(remoteDataSourceIds); - setDataLoadReady(true); - }; - - fetchDataLayer(); + layerList.forEach(async (layer: MapLayerSpecification) => { + if (layer.type === DASHBOARDS_MAPS_LAYER_TYPE.DOCUMENTS) { + const indexPatternId = layer.source.indexPatternId; + const indexPattern = await services.data.indexPatterns.get(indexPatternId); + savedIndexPatterns.push(indexPattern); + } + }); + setLayersIndexPatterns(savedIndexPatterns); }); } else { const initialDefaultLayer: MapLayerSpecification = getLayerConfigMap()[ OPENSEARCH_MAP_LAYER.type - ] as MapLayerSpecification; + ] as MapLayerSpecification; initialDefaultLayer.name = MAP_LAYER_DEFAULT_NAME; setLayers([initialDefaultLayer]); - setDataLoadReady(true); } // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -135,21 +115,18 @@ export const MapComponent = ({ mapIdFromSavedObject, dashboardProps }: MapCompon return (
- {isReadOnlyMode - ? null - : dataLoadReady && ( - - )} + {isReadOnlyMode ? null : ( + + )} {!isReadOnlyMode && !!mapState.spatialMetaFilters?.length && (
@@ -173,8 +150,6 @@ export const MapComponent = ({ mapIdFromSavedObject, dashboardProps }: MapCompon isUpdatingLayerRender={isUpdatingLayerRender} setIsUpdatingLayerRender={setIsUpdatingLayerRender} addSpatialFilter={addSpatialFilter} - dataSourceRefIds={dataSourceRefIds} - setDataSourceRefIds={setDataSourceRefIds} />
); diff --git a/public/components/map_top_nav/top_nav_menu.tsx b/public/components/map_top_nav/top_nav_menu.tsx index 3fd13f20..d6519d94 100644 --- a/public/components/map_top_nav/top_nav_menu.tsx +++ b/public/components/map_top_nav/top_nav_menu.tsx @@ -26,7 +26,6 @@ interface MapTopNavMenuProps { setMapState: (mapState: MapState) => void; originatingApp?: string; setIsUpdatingLayerRender: (isUpdatingLayerRender: boolean) => void; - dataSourceRefIds: string[]; } export const MapTopNavMenu = ({ @@ -38,7 +37,6 @@ export const MapTopNavMenu = ({ mapState, setMapState, setIsUpdatingLayerRender, - dataSourceRefIds, }: MapTopNavMenuProps) => { const { services } = useOpenSearchDashboards(); const { @@ -50,9 +48,6 @@ export const MapTopNavMenu = ({ application: { navigateToApp }, embeddable, scopedHistory, - dataSourceManagement, - savedObjects: { client: savedObjectsClient }, - notifications, } = services; const [title, setTitle] = useState(''); @@ -137,42 +132,27 @@ export const MapTopNavMenu = ({ }); }, [services, mapIdFromUrl, layers, title, description, mapState, originatingApp]); - const dataSourceManagementEnabled: boolean = !!dataSourceManagement; - return ( // @ts-ignore - <> - - + ); }; diff --git a/public/components/maps_list/maps_list.tsx b/public/components/maps_list/maps_list.tsx index 29a9c20f..335c081a 100644 --- a/public/components/maps_list/maps_list.tsx +++ b/public/components/maps_list/maps_list.tsx @@ -22,7 +22,6 @@ import { MapSavedObjectAttributes } from '../../../common/map_saved_object_attri import { MapServices } from '../../types'; import { getMapsLandingBreadcrumbs } from '../../utils/breadcrumbs'; import { APP_PATH, MAPS_APP_ID } from '../../../common'; -import { DataSourceAggregatedViewConfig } from '../../../../../src/plugins/data_source_management/public'; export const MapsList = () => { const { @@ -31,8 +30,6 @@ export const MapsList = () => { savedObjects: { client: savedObjectsClient }, application: { navigateToApp }, chrome: { docTitle, setBreadcrumbs }, - dataSourceManagement, - setActionMenu, }, } = useOpenSearchDashboards(); @@ -116,7 +113,6 @@ export const MapsList = () => { ]} /> ); - const dataSourceManagementEnabled: boolean = !!dataSourceManagement; return ( @@ -124,21 +120,6 @@ export const MapsList = () => { - {dataSourceManagementEnabled && (() => { - const DataSourcesMenu = dataSourceManagement.ui.getDataSourceMenu(); - return ( - - ); - })()} (), }; - const dataSourceManagentEnabled: boolean = !!dataSourceManagement; // Register an application into the side navigation menu core.application.register({ id: MAPS_APP_ID, @@ -93,12 +92,10 @@ export class CustomImportMapPlugin scopedHistory: params.history, uiSettings: coreStart.uiSettings, mapConfig, - dataSourceManagement, - setActionMenu: params.setHeaderActionMenu, }; params.element.classList.add('mapAppContainer'); // Render the application - return renderApp(params, services, dataSourceManagentEnabled); + return renderApp(params, services); }, }); diff --git a/public/types.ts b/public/types.ts index 8376ae84..8d57c75a 100644 --- a/public/types.ts +++ b/public/types.ts @@ -9,7 +9,6 @@ import { SavedObjectsClient, ToastsStart, ScopedHistory, - MountPoint, } from '../../../src/core/public'; import { NavigationPublicPluginStart } from '../../../src/plugins/navigation/public'; import { DataPublicPluginSetup, DataPublicPluginStart } from '../../../src/plugins/data/public'; @@ -17,7 +16,6 @@ import { RegionMapPluginSetup } from '../../../src/plugins/region_map/public'; import { EmbeddableSetup, EmbeddableStart } from '../../../src/plugins/embeddable/public'; import { VisualizationsSetup } from '../../../src/plugins/visualizations/public'; import { ConfigSchema } from '../common/config'; -import { DataSourceManagementPluginSetup } from '../../../src/plugins/data_source_management/public'; export interface AppPluginStartDependencies { navigation: NavigationPublicPluginStart; @@ -43,8 +41,6 @@ export interface MapServices extends CoreStart { chrome: CoreStart['chrome']; uiSettings: CoreStart['uiSettings']; mapConfig: ConfigSchema; - dataSourceManagement: DataSourceManagementPluginSetup; - setActionMenu: (menuMount: MountPoint | undefined) => void; } // eslint-disable-next-line @typescript-eslint/no-empty-interface @@ -58,5 +54,4 @@ export interface AppPluginSetupDependencies { embeddable: EmbeddableSetup; visualizations: VisualizationsSetup; data: DataPublicPluginSetup; - dataSourceManagement: DataSourceManagementPluginSetup; }