diff --git a/x-pack/legacy/plugins/maps/public/actions/ui_actions.d.ts b/x-pack/legacy/plugins/maps/public/actions/ui_actions.d.ts
index 203520e2d0a1d..680a6b6ea9adc 100644
--- a/x-pack/legacy/plugins/maps/public/actions/ui_actions.d.ts
+++ b/x-pack/legacy/plugins/maps/public/actions/ui_actions.d.ts
@@ -5,6 +5,7 @@
*/
import { AnyAction } from 'redux';
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { FLYOUT_STATE } from '../../../../../plugins/maps/public/reducers/ui';
export function updateFlyout(display: FLYOUT_STATE): AnyAction;
diff --git a/x-pack/legacy/plugins/maps/public/actions/ui_actions.js b/x-pack/legacy/plugins/maps/public/actions/ui_actions.js
index 33ab2fd74122a..6022aa30f441b 100644
--- a/x-pack/legacy/plugins/maps/public/actions/ui_actions.js
+++ b/x-pack/legacy/plugins/maps/public/actions/ui_actions.js
@@ -19,6 +19,10 @@ import {
} from '../../../../../plugins/maps/public/actions/ui_actions';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
export * from '../../../../../plugins/maps/public/actions/ui_actions';
+import { getFlyoutDisplay } from '../selectors/ui_selectors';
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import { FLYOUT_STATE } from '../../../../../plugins/maps/public/reducers/ui';
+import { setSelectedLayer, trackMapSettings } from './map_actions';
export function exitFullScreen() {
return {
@@ -33,6 +37,17 @@ export function updateFlyout(display) {
display,
};
}
+export function openMapSettings() {
+ return (dispatch, getState) => {
+ const flyoutDisplay = getFlyoutDisplay(getState());
+ if (flyoutDisplay === FLYOUT_STATE.MAP_SETTINGS_PANEL) {
+ return;
+ }
+ dispatch(setSelectedLayer(null));
+ dispatch(trackMapSettings());
+ dispatch(updateFlyout(FLYOUT_STATE.MAP_SETTINGS_PANEL));
+ };
+}
export function closeSetView() {
return {
type: CLOSE_SET_VIEW,
diff --git a/x-pack/legacy/plugins/maps/public/angular/map_controller.js b/x-pack/legacy/plugins/maps/public/angular/map_controller.js
index 503a8d67da62a..cf29a22077398 100644
--- a/x-pack/legacy/plugins/maps/public/angular/map_controller.js
+++ b/x-pack/legacy/plugins/maps/public/angular/map_controller.js
@@ -50,8 +50,9 @@ import {
setReadOnly,
setIsLayerTOCOpen,
setOpenTOCDetails,
+ openMapSettings,
} from '../actions/ui_actions';
-import { getIsFullScreen } from '../selectors/ui_selectors';
+import { getIsFullScreen, getFlyoutDisplay } from '../selectors/ui_selectors';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { copyPersistentState } from '../../../../../plugins/maps/public/reducers/util';
import {
@@ -447,6 +448,7 @@ app.controller(
$scope.isFullScreen = false;
$scope.isSaveDisabled = false;
+ $scope.isOpenSettingsDisabled = false;
function handleStoreChanges(store) {
const nextIsFullScreen = getIsFullScreen(store.getState());
if (nextIsFullScreen !== $scope.isFullScreen) {
@@ -468,6 +470,14 @@ app.controller(
$scope.isSaveDisabled = nextIsSaveDisabled;
});
}
+
+ const flyoutDisplay = getFlyoutDisplay(store.getState());
+ const nextIsOpenSettingsDisabled = flyoutDisplay !== FLYOUT_STATE.NONE;
+ if (nextIsOpenSettingsDisabled !== $scope.isOpenSettingsDisabled) {
+ $scope.$evalAsync(() => {
+ $scope.isOpenSettingsDisabled = nextIsOpenSettingsDisabled;
+ });
+ }
}
$scope.$on('$destroy', () => {
@@ -645,6 +655,22 @@ app.controller(
},
]
: []),
+ {
+ id: 'mapSettings',
+ label: i18n.translate('xpack.maps.mapController.openSettingsButtonLabel', {
+ defaultMessage: `Settings`,
+ }),
+ description: i18n.translate('xpack.maps.mapController.openSettingsDescription', {
+ defaultMessage: `Open settings`,
+ }),
+ testId: 'openSettingsButton',
+ disableButton() {
+ return $scope.isOpenSettingsDisabled;
+ },
+ run() {
+ store.dispatch(openMapSettings());
+ },
+ },
];
}
);
diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/__snapshots__/view.test.js.snap b/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/__snapshots__/view.test.js.snap
index 1a7d72b8abca2..0af4eb0793f03 100644
--- a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/__snapshots__/view.test.js.snap
+++ b/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/__snapshots__/view.test.js.snap
@@ -31,25 +31,6 @@ exports[`LayerControl is rendered 1`] = `
-
-
-
-
-
@@ -238,25 +219,6 @@ exports[`LayerControl should disable buttons when flyout is open 1`] = `
-
-
-
-
-
diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/index.js b/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/index.js
index 5e42457f6342d..2235627808df5 100644
--- a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/index.js
+++ b/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/index.js
@@ -9,7 +9,7 @@ import { LayerControl } from './view';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { FLYOUT_STATE } from '../../../../../../../plugins/maps/public/reducers/ui';
import { updateFlyout, setIsLayerTOCOpen } from '../../../actions/ui_actions';
-import { setSelectedLayer, trackMapSettings } from '../../../actions/map_actions';
+import { setSelectedLayer } from '../../../actions/map_actions';
import {
getIsReadOnly,
getIsLayerTOCOpen,
@@ -38,11 +38,6 @@ function mapDispatchToProps(dispatch) {
openLayerTOC: () => {
dispatch(setIsLayerTOCOpen(true));
},
- openMapSettings: async () => {
- await dispatch(setSelectedLayer(null));
- dispatch(trackMapSettings());
- dispatch(updateFlyout(FLYOUT_STATE.MAP_SETTINGS_PANEL));
- },
};
}
diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/view.js b/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/view.js
index b2610c1465750..180dc2e3933c3 100644
--- a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/view.js
+++ b/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/view.js
@@ -58,7 +58,6 @@ export function LayerControl({
openLayerTOC,
layerList,
isFlyoutOpen,
- openMapSettings,
}) {
if (!isLayerTOCOpen) {
const hasErrors = layerList.some(layer => {
@@ -81,12 +80,7 @@ export function LayerControl({
);
}
- const openMapSettingsLabel = i18n.translate('xpack.maps.layerControl.openMapSettingsLabel', {
- defaultMessage: 'Edit map settings',
- });
-
let addLayer;
- let mapSettingsBtn;
if (!isReadOnly) {
addLayer = (
@@ -106,21 +100,6 @@ export function LayerControl({
);
- mapSettingsBtn = (
-
-
-
-
-
- );
}
return (
@@ -147,7 +126,6 @@ export function LayerControl({
- {mapSettingsBtn}
{},
closeLayerTOC: () => {},
openLayerTOC: () => {},
- openMapSettings: () => {},
isLayerTOCOpen: true,
layerList: [],
isFlyoutOpen: false,