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

Commit 3684c77

Browse files
Kerryandybalaam
Kerry
andauthored
Hide account deactivation for externally managed accounts (#11445)
* util for account url * test cases * disable multi session selection on device list * remove sign out all from context menus when oidc-aware * comment * remove unused param * typo * dont show account deactivation for externally managed accounts * Update snapshots - field ID changed --------- Co-authored-by: Andy Balaam <[email protected]>
1 parent 23196d4 commit 3684c77

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,8 @@ export default class GeneralUserSettingsTab extends React.Component<IProps, ISta
527527
const supportsMultiLanguageSpellCheck = plaf?.supportsSpellCheckSettings();
528528

529529
let accountManagementSection: JSX.Element | undefined;
530-
if (SettingsStore.getValue(UIFeature.Deactivate)) {
530+
const isAccountManagedExternally = !!this.state.externalAccountManagementUrl;
531+
if (SettingsStore.getValue(UIFeature.Deactivate) && !isAccountManagedExternally) {
531532
accountManagementSection = this.renderManagementSection();
532533
}
533534

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,23 @@ describe("<GeneralUserSettingsTab />", () => {
163163
expect(screen.queryByText("Deactivate account")).not.toBeInTheDocument();
164164
expect(SettingsStore.getValue).toHaveBeenCalledWith(UIFeature.Deactivate);
165165
});
166+
it("should not render section when account is managed externally", async () => {
167+
jest.spyOn(SettingsStore, "getValue").mockImplementation(
168+
(settingName) => settingName === UIFeature.Deactivate,
169+
);
170+
// account is managed externally when we have delegated auth configured
171+
mockClient.getClientWellKnown.mockReturnValue({
172+
[M_AUTHENTICATION.name]: {
173+
issuer: "https://issuer.org",
174+
account: "https://issuer.org/account",
175+
},
176+
});
177+
render(getComponent());
178+
179+
await flushPromises();
180+
181+
expect(screen.queryByText("Deactivate account")).not.toBeInTheDocument();
182+
});
166183
it("should render section when account deactivation feature is enabled", () => {
167184
jest.spyOn(SettingsStore, "getValue").mockImplementation(
168185
(settingName) => settingName === UIFeature.Deactivate,

test/components/views/settings/tabs/user/__snapshots__/GeneralUserSettingsTab-test.tsx.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ exports[`<GeneralUserSettingsTab /> 3pids should display 3pid email addresses an
4242
>
4343
<input
4444
autocomplete="email"
45-
id="mx_Field_57"
45+
id="mx_Field_61"
4646
label="Email Address"
4747
placeholder="Email Address"
4848
type="text"
4949
value=""
5050
/>
5151
<label
52-
for="mx_Field_57"
52+
for="mx_Field_61"
5353
>
5454
Email Address
5555
</label>
@@ -150,14 +150,14 @@ exports[`<GeneralUserSettingsTab /> 3pids should display 3pid email addresses an
150150
</span>
151151
<input
152152
autocomplete="tel-national"
153-
id="mx_Field_58"
153+
id="mx_Field_62"
154154
label="Phone Number"
155155
placeholder="Phone Number"
156156
type="text"
157157
value=""
158158
/>
159159
<label
160-
for="mx_Field_58"
160+
for="mx_Field_62"
161161
>
162162
Phone Number
163163
</label>

0 commit comments

Comments
 (0)