[Maps] Disable add layer button when flyout is open (#54932)
This commit is contained in:
parent
773b0ed15d
commit
003d6e9eed
|
@ -65,6 +65,7 @@ exports[`LayerControl is rendered 1`] = `
|
|||
data-test-subj="addLayerButton"
|
||||
fill={true}
|
||||
fullWidth={true}
|
||||
isDisabled={true}
|
||||
onClick={[Function]}
|
||||
>
|
||||
<FormattedMessage
|
||||
|
|
|
@ -8,7 +8,11 @@ import { connect } from 'react-redux';
|
|||
import { LayerControl } from './view';
|
||||
import { FLYOUT_STATE } from '../../../reducers/ui';
|
||||
import { updateFlyout, setIsLayerTOCOpen } from '../../../actions/ui_actions';
|
||||
import { getIsReadOnly, getIsLayerTOCOpen } from '../../../selectors/ui_selectors';
|
||||
import {
|
||||
getIsReadOnly,
|
||||
getIsLayerTOCOpen,
|
||||
getFlyoutDisplay,
|
||||
} from '../../../selectors/ui_selectors';
|
||||
import { getLayerList } from '../../../selectors/map_selectors';
|
||||
|
||||
function mapStateToProps(state = {}) {
|
||||
|
@ -16,6 +20,7 @@ function mapStateToProps(state = {}) {
|
|||
isReadOnly: getIsReadOnly(state),
|
||||
isLayerTOCOpen: getIsLayerTOCOpen(state),
|
||||
layerList: getLayerList(state),
|
||||
isAddButtonActive: getFlyoutDisplay(state) === FLYOUT_STATE.NONE,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ export function LayerControl({
|
|||
closeLayerTOC,
|
||||
openLayerTOC,
|
||||
layerList,
|
||||
isAddButtonActive,
|
||||
}) {
|
||||
if (!isLayerTOCOpen) {
|
||||
const hasErrors = layerList.some(layer => {
|
||||
|
@ -85,6 +86,7 @@ export function LayerControl({
|
|||
<Fragment>
|
||||
<EuiSpacer size="s" />
|
||||
<EuiButton
|
||||
isDisabled={!isAddButtonActive}
|
||||
className="mapLayerControl__addLayerButton"
|
||||
fill
|
||||
fullWidth
|
||||
|
|
|
@ -28,7 +28,7 @@ export default function({ getPageObjects }) {
|
|||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await PageObjects.maps.cancelLayerAdd();
|
||||
await PageObjects.maps.closeOrCancelLayer();
|
||||
});
|
||||
|
||||
it('should add GeoJSON file to map', async () => {
|
||||
|
|
|
@ -45,7 +45,7 @@ export default function({ getService, getPageObjects }) {
|
|||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await PageObjects.maps.cancelLayerAdd();
|
||||
await PageObjects.maps.closeOrCancelLayer();
|
||||
await PageObjects.maps.waitForLayerAddPanelClosed();
|
||||
});
|
||||
|
||||
|
|
|
@ -388,6 +388,27 @@ export function GisPageProvider({ getService, getPageObjects }) {
|
|||
}
|
||||
}
|
||||
|
||||
async closeOrCancelLayer(layerName) {
|
||||
log.debug(`Close or cancel layer add`);
|
||||
const cancelExists = await testSubjects.exists('layerAddCancelButton');
|
||||
const closeExists = await testSubjects.exists('layerPanelCancelButton');
|
||||
if (cancelExists) {
|
||||
log.debug(`Cancel layer add.`);
|
||||
await testSubjects.click('layerAddCancelButton');
|
||||
} else if (closeExists) {
|
||||
log.debug(`Close layer add.`);
|
||||
await testSubjects.click('layerPanelCancelButton');
|
||||
} else {
|
||||
log.debug(`No need to close or cancel.`);
|
||||
return;
|
||||
}
|
||||
|
||||
await this.waitForLayerAddPanelClosed();
|
||||
if (layerName) {
|
||||
await this.waitForLayerDeleted(layerName);
|
||||
}
|
||||
}
|
||||
|
||||
async importFileButtonEnabled() {
|
||||
log.debug(`Check "Import file" button enabled`);
|
||||
const importFileButton = await testSubjects.find('importFileButton');
|
||||
|
|
Loading…
Reference in a new issue