[Maps] Disable add layer button when flyout is open (#54932)

This commit is contained in:
Thomas Neirynck 2020-01-22 13:22:22 -05:00 committed by GitHub
parent 773b0ed15d
commit 003d6e9eed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 3 deletions

View file

@ -65,6 +65,7 @@ exports[`LayerControl is rendered 1`] = `
data-test-subj="addLayerButton"
fill={true}
fullWidth={true}
isDisabled={true}
onClick={[Function]}
>
<FormattedMessage

View file

@ -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,
};
}

View file

@ -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

View file

@ -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 () => {

View file

@ -45,7 +45,7 @@ export default function({ getService, getPageObjects }) {
});
afterEach(async () => {
await PageObjects.maps.cancelLayerAdd();
await PageObjects.maps.closeOrCancelLayer();
await PageObjects.maps.waitForLayerAddPanelClosed();
});

View file

@ -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');