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

Commit 4751c52

Browse files
authored
Refactor the various email/phone management UI into a single component (#12884)
* Refactor the various email/phone management UI into a single component These were basically the same component copied & pasted 3 times and tweaked to match the behaviour of each case. This de-dupes them into one component. This all could really benefit from playwright tests, but would require setting up a dummy ID server in the playwright tests. This is all legacy pre-MAS stuff so its questionable whether its worth the effort. * Basic test, remove old tests * Use different text to confirm remove & put headers back although the two texts are both 'Remove' in practice * Remove string This was never triggered anyway with sydent & synapse because they don't seem to agree on what error to return. In any case, I think it makes more sense for it to be consistent with the email path, ie. using a dialog. * Avoid nested forms * Snapshots * More snapshots * Test the hs side * Snapshots * Test IS bind/revoke * Test remove can be cancelled * Test unvalidated cases & fix phone error * Reset state between tests * Import useState directly * One more direct React import
1 parent de898d1 commit 4751c52

File tree

21 files changed

+1390
-1980
lines changed

21 files changed

+1390
-1980
lines changed

res/css/_components.pcss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
@import "./components/views/messages/shared/_MediaProcessingError.pcss";
3838
@import "./components/views/pips/_WidgetPip.pcss";
3939
@import "./components/views/polls/_PollOption.pcss";
40-
@import "./components/views/settings/_EmailAddressesPhoneNumbers.pcss";
40+
@import "./components/views/settings/_AddRemoveThreepids.pcss";
4141
@import "./components/views/settings/devices/_CurrentDeviceSection.pcss";
4242
@import "./components/views/settings/devices/_DeviceDetailHeading.pcss";
4343
@import "./components/views/settings/devices/_DeviceDetails.pcss";

res/css/components/views/settings/_EmailAddressesPhoneNumbers.pcss renamed to res/css/components/views/settings/_AddRemoveThreepids.pcss

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,29 @@ limitations under the License.
2121
* tab sensibly and before I can refactor these components.
2222
*/
2323

24-
.mx_EmailAddressesPhoneNumbers_discovery_existing {
24+
.mx_AddRemoveThreepids_existing {
2525
display: flex;
2626
align-items: center;
2727
}
2828

29-
.mx_EmailAddressesPhoneNumbers_discovery_existing_address,
30-
.mx_EmailAddressesPhoneNumbers_discovery_existing_promptText {
29+
.mx_AddRemoveThreepids_existing_address,
30+
.mx_AddRemoveThreepids_existing_promptText {
3131
flex: 1;
3232
margin-right: 10px;
3333
}
3434

35-
.mx_EmailAddressesPhoneNumbers_discovery_existing_button {
35+
.mx_AddRemoveThreepids_existing_button {
3636
margin-left: 5px;
3737
}
38+
39+
.mx_EmailAddressesPhoneNumbers_verify {
40+
display: flex;
41+
}
42+
43+
.mx_EmailAddressesPhoneNumbers_existing_button {
44+
justify-content: right;
45+
}
46+
47+
.mx_EmailAddressesPhoneNumbers_verify_instructions {
48+
flex: 1;
49+
}

src/AddThreepid.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,7 @@ export default class AddThreepid {
271271
* with a "message" property which contains a human-readable message detailing why
272272
* the request failed.
273273
*/
274-
public async haveMsisdnToken(
275-
msisdnToken: string,
276-
): Promise<[success?: boolean, result?: IAuthData | Error | null] | undefined> {
274+
public async haveMsisdnToken(msisdnToken: string): Promise<[success?: boolean, result?: IAuthData | Error | null]> {
277275
const authClient = new IdentityAuthClient();
278276

279277
if (this.submitUrl) {
@@ -301,13 +299,14 @@ export default class AddThreepid {
301299
id_server: getIdServerDomain(this.matrixClient),
302300
id_access_token: await authClient.getAccessToken(),
303301
});
302+
return [true];
304303
} else {
305304
try {
306305
await this.makeAddThreepidOnlyRequest();
307306

308307
// The spec has always required this to use UI auth but synapse briefly
309308
// implemented it without, so this may just succeed and that's OK.
310-
return;
309+
return [true];
311310
} catch (err) {
312311
if (!(err instanceof MatrixError) || err.httpStatus !== 401 || !err.data || !err.data.flows) {
313312
// doesn't look like an interactive-auth failure

0 commit comments

Comments
 (0)