Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 973c2ac

Browse files
committed
Move map attribution to top right
Signed-off-by: Michael Weimann <[email protected]>
1 parent 5f8aeca commit 973c2ac

File tree

8 files changed

+71
-13
lines changed

8 files changed

+71
-13
lines changed

src/utils/location/map.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ export const createMap = (
3636
style: styleUrl,
3737
zoom: 15,
3838
interactive,
39+
attributionControl: false,
3940
});
41+
map.addControl(new maplibregl.AttributionControl(), 'top-right');
4042

4143
map.on('error', (e) => {
4244
logger.error(

test/components/views/beacon/BeaconViewDialog-test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ describe('<BeaconViewDialog />', () => {
8989
const getComponent = (props = {}) =>
9090
mount(<BeaconViewDialog {...defaultProps} {...props} />);
9191

92+
beforeAll(() => {
93+
maplibregl.AttributionControl = jest.fn();
94+
});
95+
9296
beforeEach(() => {
9397
jest.spyOn(OwnBeaconStore.instance, 'getLiveBeaconIds').mockRestore();
9498

test/components/views/location/LocationViewDialog-test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import React from 'react';
1818
import { mount } from 'enzyme';
1919
import { RoomMember } from 'matrix-js-sdk/src/matrix';
2020
import { LocationAssetType } from 'matrix-js-sdk/src/@types/location';
21+
import maplibregl from 'maplibre-gl';
2122

2223
import LocationViewDialog from '../../../../src/components/views/location/LocationViewDialog';
2324
import { TILE_SERVER_WK_KEY } from '../../../../src/utils/WellKnownUtils';
@@ -41,6 +42,10 @@ describe('<LocationViewDialog />', () => {
4142
const getComponent = (props = {}) =>
4243
mount(<LocationViewDialog {...defaultProps} {...props} />);
4344

45+
beforeAll(() => {
46+
maplibregl.AttributionControl = jest.fn();
47+
});
48+
4449
it('renders map correctly', () => {
4550
const component = getComponent();
4651
expect(component.find('Map')).toMatchSnapshot();

test/components/views/location/Map-test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ describe('<Map />', () => {
4444
wrappingComponentProps: { value: matrixClient },
4545
});
4646

47+
beforeAll(() => {
48+
maplibregl.AttributionControl = jest.fn();
49+
});
50+
4751
beforeEach(() => {
4852
jest.clearAllMocks();
4953
matrixClient.getClientWellKnown.mockReturnValue({

test/components/views/location/__snapshots__/LocationViewDialog-test.tsx.snap

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,20 @@ exports[`<LocationViewDialog /> renders map correctly 1`] = `
2323
},
2424
"_eventsCount": 1,
2525
"_maxListeners": undefined,
26-
"addControl": [MockFunction],
26+
"addControl": [MockFunction] {
27+
"calls": Array [
28+
Array [
29+
mockConstructor {},
30+
"top-right",
31+
],
32+
],
33+
"results": Array [
34+
Object {
35+
"type": "return",
36+
"value": undefined,
37+
},
38+
],
39+
},
2740
"fitBounds": [MockFunction],
2841
"removeControl": [MockFunction],
2942
"setCenter": [MockFunction] {
@@ -78,7 +91,20 @@ exports[`<LocationViewDialog /> renders map correctly 1`] = `
7891
},
7992
"_eventsCount": 1,
8093
"_maxListeners": undefined,
81-
"addControl": [MockFunction],
94+
"addControl": [MockFunction] {
95+
"calls": Array [
96+
Array [
97+
mockConstructor {},
98+
"top-right",
99+
],
100+
],
101+
"results": Array [
102+
Object {
103+
"type": "return",
104+
"value": undefined,
105+
},
106+
],
107+
},
82108
"fitBounds": [MockFunction],
83109
"removeControl": [MockFunction],
84110
"setCenter": [MockFunction] {

test/components/views/messages/MBeaconBody-test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ describe('<MBeaconBody />', () => {
7979
});
8080

8181
const modalSpy = jest.spyOn(Modal, 'createTrackedDialog').mockReturnValue(undefined);
82+
83+
beforeAll(() => {
84+
maplibregl.AttributionControl = jest.fn();
85+
});
86+
8287
beforeEach(() => {
8388
jest.clearAllMocks();
8489
});

test/components/views/messages/MLocationBody-test.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ describe("MLocationBody", () => {
5656
wrappingComponent: MatrixClientContext.Provider,
5757
wrappingComponentProps: { value: mockClient },
5858
});
59+
60+
beforeAll(() => {
61+
maplibregl.AttributionControl = jest.fn();
62+
});
63+
64+
beforeEach(() => {
65+
jest.clearAllMocks();
66+
});
67+
5968
describe('with error', () => {
6069
let sdkConfigSpy;
6170

test/components/views/messages/__snapshots__/MLocationBody-test.tsx.snap

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,20 @@ exports[`MLocationBody <MLocationBody> without error renders map correctly 1`] =
124124
},
125125
"_eventsCount": 1,
126126
"_maxListeners": undefined,
127-
"addControl": [MockFunction],
127+
"addControl": [MockFunction] {
128+
"calls": Array [
129+
Array [
130+
mockConstructor {},
131+
"top-right",
132+
],
133+
],
134+
"results": Array [
135+
Object {
136+
"type": "return",
137+
"value": undefined,
138+
},
139+
],
140+
},
128141
"fitBounds": [MockFunction],
129142
"removeControl": [MockFunction],
130143
"setCenter": [MockFunction] {
@@ -135,22 +148,12 @@ exports[`MLocationBody <MLocationBody> without error renders map correctly 1`] =
135148
"lon": -0.1276,
136149
},
137150
],
138-
Array [
139-
Object {
140-
"lat": 51.5076,
141-
"lon": -0.1276,
142-
},
143-
],
144151
],
145152
"results": Array [
146153
Object {
147154
"type": "return",
148155
"value": undefined,
149156
},
150-
Object {
151-
"type": "return",
152-
"value": undefined,
153-
},
154157
],
155158
},
156159
"setStyle": [MockFunction],

0 commit comments

Comments
 (0)