Skip to content

Commit

Permalink
[Maps] Disable edit features if editing already enabled for layer (el…
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Caldwell committed Jun 24, 2021
1 parent c0122f7 commit e1ef2ea
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 1 deletion.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ export class TOCEntry extends Component<Props, State> {
openLayerSettings={this._openLayerPanelWithCheck}
isEditButtonDisabled={this.props.isEditButtonDisabled}
supportsFitToBounds={this.state.supportsFitToBounds}
editModeActiveForLayer={this.props.editModeActiveForLayer}
/>

{this._renderQuickActions()}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const defaultProps = {
enableShapeEditing: () => {},
enablePointEditing: () => {},
openLayerSettings: () => {},
editModeActiveForLayer: false,
};

describe('TOCEntryActionsPopover', () => {
Expand Down Expand Up @@ -100,4 +101,17 @@ describe('TOCEntryActionsPopover', () => {

expect(component).toMatchSnapshot();
});

test('should disable Edit features when edit mode active for layer', async () => {
const component = shallow(
<TOCEntryActionsPopover {...defaultProps} editModeActiveForLayer={true} />
);

// Ensure all promises resolve
await new Promise((resolve) => process.nextTick(resolve));
// Ensure the state changes are reflected
component.update();

expect(component).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface Props {
removeLayer: (layerId: string) => void;
supportsFitToBounds: boolean;
toggleVisible: (layerId: string) => void;
editModeActiveForLayer: boolean;
}

interface State {
Expand Down Expand Up @@ -170,7 +171,7 @@ export class TOCEntryActionsPopover extends Component<Props, State> {
defaultMessage:
'Edit features only supported for document layers without clustering, joins, or time filtering',
}),
disabled: !this.state.isFeatureEditingEnabled,
disabled: !this.state.isFeatureEditingEnabled || this.props.editModeActiveForLayer,
onClick: async () => {
this._closePopover();
const supportedShapeTypes = await (this.props.layer.getSource() as ESSearchSource).getSupportedShapeTypes();
Expand Down

0 comments on commit e1ef2ea

Please sign in to comment.