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

Commit d710061

Browse files
committed
Merge branch 'hughns/graduate-qr-signin-from-labs' of https://github.com/matrix-org/matrix-react-sdk into hughns/graduate-qr-signin-from-labs
2 parents 98d85bb + 9b12f9d commit d710061

File tree

61 files changed

+1846
-990
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1846
-990
lines changed

cypress/e2e/spaces/spaces.spec.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
/// <reference types="cypress" />
1818

1919
import type { MatrixClient } from "matrix-js-sdk/src/client";
20+
import type { Preset } from "matrix-js-sdk/src/@types/partials";
2021
import type { ICreateRoomOpts } from "matrix-js-sdk/src/@types/requests";
2122
import { HomeserverInstance } from "../../plugins/utils/homeserver";
2223
import Chainable = Cypress.Chainable;
@@ -32,7 +33,7 @@ function openSpaceContextMenu(spaceName: string): Chainable<JQuery> {
3233
return cy.get(".mx_SpacePanel_contextMenu");
3334
}
3435

35-
function spaceCreateOptions(spaceName: string): ICreateRoomOpts {
36+
function spaceCreateOptions(spaceName: string, roomIds: string[] = []): ICreateRoomOpts {
3637
return {
3738
creation_content: {
3839
type: "m.space",
@@ -44,6 +45,7 @@ function spaceCreateOptions(spaceName: string): ICreateRoomOpts {
4445
name: spaceName,
4546
},
4647
},
48+
...roomIds.map(spaceChildInitialState),
4749
],
4850
};
4951
}
@@ -283,4 +285,29 @@ describe("Spaces", () => {
283285
cy.checkA11y(undefined, axeOptions);
284286
cy.get(".mx_SpacePanel").percySnapshotElement("Space panel expanded", { widths: [258] });
285287
});
288+
289+
it("should not soft crash when joining a room from space hierarchy which has a link in its topic", () => {
290+
cy.getBot(homeserver, { displayName: "BotBob" }).then({ timeout: 10000 }, async (bot) => {
291+
const { room_id: roomId } = await bot.createRoom({
292+
preset: "public_chat" as Preset,
293+
name: "Test Room",
294+
topic: "This is a topic https://github.com/matrix-org/matrix-react-sdk/pull/10060 with a link",
295+
});
296+
const { room_id: spaceId } = await bot.createRoom(spaceCreateOptions("Test Space", [roomId]));
297+
await bot.invite(spaceId, user.userId);
298+
});
299+
300+
cy.getSpacePanelButton("Test Space").should("exist");
301+
cy.wait(500); // without this we can end up clicking too quickly and it ends up having no effect
302+
cy.viewSpaceByName("Test Space");
303+
cy.contains(".mx_AccessibleButton", "Accept").click();
304+
305+
cy.contains(".mx_SpaceHierarchy_roomTile.mx_AccessibleButton", "Test Room").within(() => {
306+
cy.contains("Join").should("exist").realHover().click();
307+
cy.contains("View", { timeout: 5000 }).should("exist").click();
308+
});
309+
310+
// Assert we get shown the new room intro, and thus not the soft crash screen
311+
cy.get(".mx_NewRoomIntro").should("exist");
312+
});
286313
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"jszip": "^3.7.0",
8787
"katex": "^0.16.0",
8888
"linkify-element": "4.0.0-beta.4",
89+
"linkify-react": "4.0.0-beta.4",
8990
"linkify-string": "4.0.0-beta.4",
9091
"linkifyjs": "4.0.0-beta.4",
9192
"lodash": "^4.17.20",

res/css/_components.pcss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
@import "./components/views/beacon/_ShareLatestLocation.pcss";
1818
@import "./components/views/beacon/_StyledLiveBeaconIcon.pcss";
1919
@import "./components/views/context_menus/_KebabContextMenu.pcss";
20+
@import "./components/views/dialogs/polls/_PollListItem.pcss";
2021
@import "./components/views/elements/_FilterDropdown.pcss";
2122
@import "./components/views/elements/_LearnMore.pcss";
2223
@import "./components/views/location/_EnableLiveShare.pcss";
@@ -161,6 +162,8 @@
161162
@import "./views/dialogs/_UserSettingsDialog.pcss";
162163
@import "./views/dialogs/_VerifyEMailDialog.pcss";
163164
@import "./views/dialogs/_WidgetCapabilitiesPromptDialog.pcss";
165+
@import "./views/dialogs/polls/_PollHistoryDialog.pcss";
166+
@import "./views/dialogs/polls/_PollHistoryList.pcss";
164167
@import "./views/dialogs/security/_AccessSecretStorageDialog.pcss";
165168
@import "./views/dialogs/security/_CreateCrossSigningDialog.pcss";
166169
@import "./views/dialogs/security/_CreateKeyBackupDialog.pcss";
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
Copyright 2023 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
.mx_PollListItem {
18+
width: 100%;
19+
display: grid;
20+
justify-content: left;
21+
align-items: center;
22+
grid-gap: $spacing-8;
23+
grid-template-columns: auto auto auto;
24+
grid-template-rows: auto;
25+
26+
color: $primary-content;
27+
}
28+
29+
.mx_PollListItem_icon {
30+
height: 14px;
31+
width: 14px;
32+
color: $quaternary-content;
33+
padding-left: $spacing-8;
34+
}
35+
36+
.mx_PollListItem_question {
37+
white-space: nowrap;
38+
overflow: hidden;
39+
text-overflow: ellipsis;
40+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Copyright 2023 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
.mx_PollHistoryDialog_content {
18+
height: 600px;
19+
width: 100%;
20+
21+
display: flex;
22+
flex-direction: column;
23+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
Copyright 2023 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
.mx_PollHistoryList {
18+
display: flex;
19+
flex-direction: column;
20+
flex: 1 1 auto;
21+
max-height: 100%;
22+
}
23+
24+
.mx_PollHistoryList_list {
25+
overflow: auto;
26+
list-style: none;
27+
margin-block: 0;
28+
padding-inline: 0;
29+
flex: 1 1 0;
30+
align-content: flex-start;
31+
display: grid;
32+
grid-gap: $spacing-20;
33+
padding-right: $spacing-64;
34+
margin: $spacing-32 0;
35+
}
36+
37+
.mx_PollHistoryList_noResults {
38+
height: 100%;
39+
width: 100%;
40+
display: flex;
41+
align-items: center;
42+
justify-content: center;
43+
color: $secondary-content;
44+
}

res/css/views/messages/_MPollBody.pcss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,16 @@ limitations under the License.
150150
}
151151

152152
.mx_MPollBody_totalVotes {
153+
display: flex;
154+
flex-direction: inline;
155+
justify-content: start;
153156
color: $secondary-content;
154157
font-size: $font-12px;
158+
159+
.mx_Spinner {
160+
flex: 0;
161+
margin-left: $spacing-8;
162+
}
155163
}
156164
}
157165

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ sonar.exclusions=__mocks__,docs
1010

1111
sonar.typescript.tsconfigPath=./tsconfig.json
1212
sonar.javascript.lcov.reportPaths=coverage/lcov.info
13-
sonar.coverage.exclusions=test/**/*,cypress/**/*
13+
sonar.coverage.exclusions=test/**/*,cypress/**/*,src/components/views/dialogs/devtools/**/*
1414
sonar.testExecutionReportPaths=coverage/jest-sonar-report.xml

src/DateUtils.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,16 @@ export function formatPreciseDuration(durationMs: number): string {
269269
}
270270
return _t("%(value)ss", { value: seconds });
271271
}
272+
273+
/**
274+
* Formats a timestamp to a short date
275+
* (eg 25/12/22 in uk locale)
276+
* localised by system locale
277+
* @param timestamp - epoch timestamp
278+
* @returns {string} formattedDate
279+
*/
280+
export const formatLocalDateShort = (timestamp: number): string =>
281+
new Intl.DateTimeFormat(
282+
undefined, // locales
283+
{ day: "2-digit", month: "2-digit", year: "2-digit" },
284+
).format(timestamp);

src/HtmlUtils.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@ See the License for the specific language governing permissions and
1717
limitations under the License.
1818
*/
1919

20-
import React, { ReactNode } from "react";
20+
import React, { ReactElement, ReactNode } from "react";
2121
import sanitizeHtml from "sanitize-html";
2222
import cheerio from "cheerio";
2323
import classNames from "classnames";
2424
import EMOJIBASE_REGEX from "emojibase-regex";
25-
import { split } from "lodash";
25+
import { merge, split } from "lodash";
2626
import katex from "katex";
2727
import { decode } from "html-entities";
2828
import { IContent } from "matrix-js-sdk/src/models/event";
2929
import { Optional } from "matrix-events-sdk";
30+
import _Linkify from "linkify-react";
3031

3132
import {
3233
_linkifyElement,
@@ -682,6 +683,15 @@ export function topicToHtml(
682683
);
683684
}
684685

686+
/* Wrapper around linkify-react merging in our default linkify options */
687+
export function Linkify({ as, options, children }: React.ComponentProps<typeof _Linkify>): ReactElement {
688+
return (
689+
<_Linkify as={as} options={merge({}, linkifyMatrixOptions, options)}>
690+
{children}
691+
</_Linkify>
692+
);
693+
}
694+
685695
/**
686696
* Linkifies the given string. This is a wrapper around 'linkifyjs/string'.
687697
*

0 commit comments

Comments
 (0)