Move map attribution to top right (#8621)

Signed-off-by: Michael Weimann <michaelw@matrix.org>

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Weimann 2022-05-23 12:19:59 +02:00 committed by GitHub
parent 764b307e63
commit 1535ff0d6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 71 additions and 13 deletions

View File

@ -36,7 +36,9 @@ export const createMap = (
style: styleUrl,
zoom: 15,
interactive,
attributionControl: false,
});
map.addControl(new maplibregl.AttributionControl(), 'top-right');
map.on('error', (e) => {
logger.error(

View File

@ -89,6 +89,10 @@ describe('<BeaconViewDialog />', () => {
const getComponent = (props = {}) =>
mount(<BeaconViewDialog {...defaultProps} {...props} />);
beforeAll(() => {
maplibregl.AttributionControl = jest.fn();
});
beforeEach(() => {
jest.spyOn(OwnBeaconStore.instance, 'getLiveBeaconIds').mockRestore();

View File

@ -18,6 +18,7 @@ import React from 'react';
import { mount } from 'enzyme';
import { RoomMember } from 'matrix-js-sdk/src/matrix';
import { LocationAssetType } from 'matrix-js-sdk/src/@types/location';
import maplibregl from 'maplibre-gl';
import LocationViewDialog from '../../../../src/components/views/location/LocationViewDialog';
import { TILE_SERVER_WK_KEY } from '../../../../src/utils/WellKnownUtils';
@ -41,6 +42,10 @@ describe('<LocationViewDialog />', () => {
const getComponent = (props = {}) =>
mount(<LocationViewDialog {...defaultProps} {...props} />);
beforeAll(() => {
maplibregl.AttributionControl = jest.fn();
});
it('renders map correctly', () => {
const component = getComponent();
expect(component.find('Map')).toMatchSnapshot();

View File

@ -44,6 +44,10 @@ describe('<Map />', () => {
wrappingComponentProps: { value: matrixClient },
});
beforeAll(() => {
maplibregl.AttributionControl = jest.fn();
});
beforeEach(() => {
jest.clearAllMocks();
matrixClient.getClientWellKnown.mockReturnValue({

View File

@ -23,7 +23,20 @@ exports[`<LocationViewDialog /> renders map correctly 1`] = `
},
"_eventsCount": 1,
"_maxListeners": undefined,
"addControl": [MockFunction],
"addControl": [MockFunction] {
"calls": Array [
Array [
mockConstructor {},
"top-right",
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
],
},
"fitBounds": [MockFunction],
"removeControl": [MockFunction],
"setCenter": [MockFunction] {
@ -78,7 +91,20 @@ exports[`<LocationViewDialog /> renders map correctly 1`] = `
},
"_eventsCount": 1,
"_maxListeners": undefined,
"addControl": [MockFunction],
"addControl": [MockFunction] {
"calls": Array [
Array [
mockConstructor {},
"top-right",
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
],
},
"fitBounds": [MockFunction],
"removeControl": [MockFunction],
"setCenter": [MockFunction] {

View File

@ -79,6 +79,11 @@ describe('<MBeaconBody />', () => {
});
const modalSpy = jest.spyOn(Modal, 'createTrackedDialog').mockReturnValue(undefined);
beforeAll(() => {
maplibregl.AttributionControl = jest.fn();
});
beforeEach(() => {
jest.clearAllMocks();
});

View File

@ -56,6 +56,15 @@ describe("MLocationBody", () => {
wrappingComponent: MatrixClientContext.Provider,
wrappingComponentProps: { value: mockClient },
});
beforeAll(() => {
maplibregl.AttributionControl = jest.fn();
});
beforeEach(() => {
jest.clearAllMocks();
});
describe('with error', () => {
let sdkConfigSpy;

View File

@ -124,7 +124,20 @@ exports[`MLocationBody <MLocationBody> without error renders map correctly 1`] =
},
"_eventsCount": 1,
"_maxListeners": undefined,
"addControl": [MockFunction],
"addControl": [MockFunction] {
"calls": Array [
Array [
mockConstructor {},
"top-right",
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
],
},
"fitBounds": [MockFunction],
"removeControl": [MockFunction],
"setCenter": [MockFunction] {
@ -135,22 +148,12 @@ exports[`MLocationBody <MLocationBody> without error renders map correctly 1`] =
"lon": -0.1276,
},
],
Array [
Object {
"lat": 51.5076,
"lon": -0.1276,
},
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
},
"setStyle": [MockFunction],