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

Commit 3d52c82

Browse files
authored
Revert "Release Sign in with QR out of labs (#10066)"
This reverts commit 5123d7e.
1 parent a3a2a0f commit 3d52c82

File tree

9 files changed

+66
-12
lines changed

9 files changed

+66
-12
lines changed

src/components/views/settings/devices/LoginWithQRSection.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type { IServerVersions } from "matrix-js-sdk/src/matrix";
2020
import { _t } from "../../../../languageHandler";
2121
import AccessibleButton from "../../elements/AccessibleButton";
2222
import SettingsSubsection from "../shared/SettingsSubsection";
23+
import SettingsStore from "../../../../settings/SettingsStore";
2324

2425
interface IProps {
2526
onShowQr: () => void;
@@ -32,10 +33,12 @@ export default class LoginWithQRSection extends React.Component<IProps> {
3233
}
3334

3435
public render(): JSX.Element | null {
35-
// Needs server support for MSC3882 and MSC3886:
3636
const msc3882Supported = !!this.props.versions?.unstable_features?.["org.matrix.msc3882"];
3737
const msc3886Supported = !!this.props.versions?.unstable_features?.["org.matrix.msc3886"];
38-
const offerShowQr = msc3882Supported && msc3886Supported;
38+
39+
// Needs to be enabled as a feature + server support MSC3886 or have a default rendezvous server configured:
40+
const offerShowQr =
41+
SettingsStore.getValue("feature_qr_signin_reciprocate_show") && msc3882Supported && msc3886Supported; // We don't support configuration of a fallback at the moment so we just check the MSCs
3942

4043
// don't show anything if no method is available
4144
if (!offerShowQr) {

src/components/views/settings/tabs/user/SecurityUserSettingsTab.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
381381
}
382382

383383
const useNewSessionManager = SettingsStore.getValue("feature_new_device_manager");
384+
const showQrCodeEnabled = SettingsStore.getValue("feature_qr_signin_reciprocate_show");
384385
const devicesSection = useNewSessionManager ? null : (
385386
<>
386387
<div className="mx_SettingsTab_heading">{_t("Where you're signed in")}</div>
@@ -393,13 +394,15 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
393394
</span>
394395
<DevicesPanel />
395396
</div>
396-
<LoginWithQRSection onShowQr={this.onShowQRClicked} versions={this.state.versions} />
397+
{showQrCodeEnabled ? (
398+
<LoginWithQRSection onShowQr={this.onShowQRClicked} versions={this.state.versions} />
399+
) : null}
397400
</>
398401
);
399402

400403
const client = MatrixClientPeg.get();
401404

402-
if (this.state.showLoginWithQR) {
405+
if (showQrCodeEnabled && this.state.showLoginWithQR) {
403406
return (
404407
<div className="mx_SettingsTab mx_SecurityUserSettingsTab">
405408
<LoginWithQR

src/components/views/settings/tabs/user/SessionManagerTab.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { deleteDevicesWithInteractiveAuth } from "../../devices/deleteDevices";
3434
import SettingsTab from "../SettingsTab";
3535
import LoginWithQRSection from "../../devices/LoginWithQRSection";
3636
import LoginWithQR, { Mode } from "../../../auth/LoginWithQR";
37+
import SettingsStore from "../../../../../settings/SettingsStore";
3738
import { useAsyncMemo } from "../../../../../hooks/useAsyncMemo";
3839
import QuestionDialog from "../../../dialogs/QuestionDialog";
3940
import { FilterVariation } from "../../devices/filter";
@@ -211,6 +212,8 @@ const SessionManagerTab: React.FC = () => {
211212

212213
const [signInWithQrMode, setSignInWithQrMode] = useState<Mode | null>();
213214

215+
const showQrCodeEnabled = SettingsStore.getValue("feature_qr_signin_reciprocate_show");
216+
214217
const onQrFinish = useCallback(() => {
215218
setSignInWithQrMode(null);
216219
}, [setSignInWithQrMode]);
@@ -219,7 +222,7 @@ const SessionManagerTab: React.FC = () => {
219222
setSignInWithQrMode(Mode.Show);
220223
}, [setSignInWithQrMode]);
221224

222-
if (signInWithQrMode) {
225+
if (showQrCodeEnabled && signInWithQrMode) {
223226
return <LoginWithQR mode={signInWithQrMode} onFinished={onQrFinish} client={matrixClient} />;
224227
}
225228

@@ -279,7 +282,7 @@ const SessionManagerTab: React.FC = () => {
279282
/>
280283
</SettingsSubsection>
281284
)}
282-
<LoginWithQRSection onShowQr={onShowQrClicked} versions={clientVersions} />
285+
{showQrCodeEnabled ? <LoginWithQRSection onShowQr={onShowQrClicked} versions={clientVersions} /> : null}
283286
</SettingsTab>
284287
);
285288
};

src/i18n/strings/en_EN.json

+1
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,7 @@
977977
"New session manager": "New session manager",
978978
"Have greater visibility and control over all your sessions.": "Have greater visibility and control over all your sessions.",
979979
"Our new sessions manager provides better visibility of all your sessions, and greater control over them including the ability to remotely toggle push notifications.": "Our new sessions manager provides better visibility of all your sessions, and greater control over them including the ability to remotely toggle push notifications.",
980+
"Allow a QR code to be shown in session manager to sign in another device (requires compatible homeserver)": "Allow a QR code to be shown in session manager to sign in another device (requires compatible homeserver)",
980981
"Rust cryptography implementation": "Rust cryptography implementation",
981982
"Under active development. Can currently only be enabled via config.json": "Under active development. Can currently only be enabled via config.json",
982983
"Font size": "Font size",

src/settings/Settings.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,16 @@ export const SETTINGS: { [setting: string]: ISetting } = {
496496
),
497497
},
498498
},
499+
"feature_qr_signin_reciprocate_show": {
500+
isFeature: true,
501+
labsGroup: LabGroup.Experimental,
502+
supportedLevels: LEVELS_FEATURE,
503+
displayName: _td(
504+
"Allow a QR code to be shown in session manager to sign in another device " +
505+
"(requires compatible homeserver)",
506+
),
507+
default: false,
508+
},
499509
"feature_rust_crypto": {
500510
// use the rust matrix-sdk-crypto-js for crypto.
501511
isFeature: true,

test/components/views/settings/devices/LoginWithQRSection-test.tsx

+12-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import React from "react";
2121

2222
import LoginWithQRSection from "../../../../../src/components/views/settings/devices/LoginWithQRSection";
2323
import { MatrixClientPeg } from "../../../../../src/MatrixClientPeg";
24+
import { SettingLevel } from "../../../../../src/settings/SettingLevel";
25+
import SettingsStore from "../../../../../src/settings/SettingsStore";
2426

2527
function makeClient() {
2628
return mocked({
@@ -65,14 +67,22 @@ describe("<LoginWithQRSection />", () => {
6567
expect(container).toMatchSnapshot();
6668
});
6769

68-
it("only MSC3882 enabled", async () => {
70+
it("feature enabled", async () => {
71+
await SettingsStore.setValue("feature_qr_signin_reciprocate_show", null, SettingLevel.DEVICE, true);
72+
const { container } = render(getComponent());
73+
expect(container).toMatchSnapshot();
74+
});
75+
76+
it("only feature + MSC3882 enabled", async () => {
77+
await SettingsStore.setValue("feature_qr_signin_reciprocate_show", null, SettingLevel.DEVICE, true);
6978
const { container } = render(getComponent({ versions: makeVersions({ "org.matrix.msc3882": true }) }));
7079
expect(container).toMatchSnapshot();
7180
});
7281
});
7382

7483
describe("should render panel", () => {
75-
it("MSC3882 + MSC3886", async () => {
84+
it("enabled by feature + MSC3882 + MSC3886", async () => {
85+
await SettingsStore.setValue("feature_qr_signin_reciprocate_show", null, SettingLevel.DEVICE, true);
7686
const { container } = render(
7787
getComponent({
7888
versions: makeVersions({

test/components/views/settings/devices/__snapshots__/LoginWithQRSection-test.tsx.snap

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`<LoginWithQRSection /> should not render feature enabled 1`] = `<div />`;
4+
35
exports[`<LoginWithQRSection /> should not render no support at all 1`] = `<div />`;
46

5-
exports[`<LoginWithQRSection /> should not render only MSC3882 enabled 1`] = `<div />`;
7+
exports[`<LoginWithQRSection /> should not render only feature + MSC3882 enabled 1`] = `<div />`;
68

7-
exports[`<LoginWithQRSection /> should render panel MSC3882 + MSC3886 1`] = `
9+
exports[`<LoginWithQRSection /> should render panel enabled by feature + MSC3882 + MSC3886 1`] = `
810
<div>
911
<div
1012
class="mx_SettingsSubsection"

test/components/views/settings/tabs/user/SecurityUserSettingsTab-test.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,17 @@ describe("<SecurityUserSettingsTab />", () => {
7979
expect(queryByTestId("devices-section")).toBeFalsy();
8080
});
8181

82-
it("renders qr code login section", async () => {
82+
it("does not render qr code login section when disabled", () => {
83+
settingsValueSpy.mockReturnValue(false);
84+
const { queryByText } = render(getComponent());
85+
86+
expect(settingsValueSpy).toHaveBeenCalledWith("feature_qr_signin_reciprocate_show");
87+
88+
expect(queryByText("Sign in with QR code")).toBeFalsy();
89+
});
90+
91+
it("renders qr code login section when enabled", async () => {
92+
settingsValueSpy.mockImplementation((settingName) => settingName === "feature_qr_signin_reciprocate_show");
8393
const { getByText } = render(getComponent());
8494

8595
// wait for versions call to settle
@@ -89,6 +99,7 @@ describe("<SecurityUserSettingsTab />", () => {
8999
});
90100

91101
it("enters qr code login section when show QR code button clicked", async () => {
102+
settingsValueSpy.mockImplementation((settingName) => settingName === "feature_qr_signin_reciprocate_show");
92103
const { getByText, getByTestId } = render(getComponent());
93104
// wait for versions call to settle
94105
await flushPromises();

test/components/views/settings/tabs/user/SessionManagerTab-test.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,17 @@ describe("<SessionManagerTab />", () => {
13481348
});
13491349
});
13501350

1351-
it("renders qr code login section", async () => {
1351+
it("does not render qr code login section when disabled", () => {
1352+
settingsValueSpy.mockReturnValue(false);
1353+
const { queryByText } = render(getComponent());
1354+
1355+
expect(settingsValueSpy).toHaveBeenCalledWith("feature_qr_signin_reciprocate_show");
1356+
1357+
expect(queryByText("Sign in with QR code")).toBeFalsy();
1358+
});
1359+
1360+
it("renders qr code login section when enabled", async () => {
1361+
settingsValueSpy.mockImplementation((settingName) => settingName === "feature_qr_signin_reciprocate_show");
13521362
const { getByText } = render(getComponent());
13531363

13541364
// wait for versions call to settle
@@ -1358,6 +1368,7 @@ describe("<SessionManagerTab />", () => {
13581368
});
13591369

13601370
it("enters qr code login section when show QR code button clicked", async () => {
1371+
settingsValueSpy.mockImplementation((settingName) => settingName === "feature_qr_signin_reciprocate_show");
13611372
const { getByText, getByTestId } = render(getComponent());
13621373
// wait for versions call to settle
13631374
await flushPromises();

0 commit comments

Comments
 (0)