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, style: styleUrl,
zoom: 15, zoom: 15,
interactive, interactive,
attributionControl: false,
}); });
map.addControl(new maplibregl.AttributionControl(), 'top-right');
map.on('error', (e) => { map.on('error', (e) => {
logger.error( logger.error(

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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