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 <andy.balaam@matrix.org>
pull/28217/head
Kerry 2023-08-22 23:51:16 +12:00 committed by GitHub
parent 23196d49e1
commit 3684c77cfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 5 deletions

View File

@ -527,7 +527,8 @@ export default class GeneralUserSettingsTab extends React.Component<IProps, ISta
const supportsMultiLanguageSpellCheck = plaf?.supportsSpellCheckSettings(); const supportsMultiLanguageSpellCheck = plaf?.supportsSpellCheckSettings();
let accountManagementSection: JSX.Element | undefined; let accountManagementSection: JSX.Element | undefined;
if (SettingsStore.getValue(UIFeature.Deactivate)) { const isAccountManagedExternally = !!this.state.externalAccountManagementUrl;
if (SettingsStore.getValue(UIFeature.Deactivate) && !isAccountManagedExternally) {
accountManagementSection = this.renderManagementSection(); accountManagementSection = this.renderManagementSection();
} }

View File

@ -163,6 +163,23 @@ describe("<GeneralUserSettingsTab />", () => {
expect(screen.queryByText("Deactivate account")).not.toBeInTheDocument(); expect(screen.queryByText("Deactivate account")).not.toBeInTheDocument();
expect(SettingsStore.getValue).toHaveBeenCalledWith(UIFeature.Deactivate); expect(SettingsStore.getValue).toHaveBeenCalledWith(UIFeature.Deactivate);
}); });
it("should not render section when account is managed externally", async () => {
jest.spyOn(SettingsStore, "getValue").mockImplementation(
(settingName) => settingName === UIFeature.Deactivate,
);
// account is managed externally when we have delegated auth configured
mockClient.getClientWellKnown.mockReturnValue({
[M_AUTHENTICATION.name]: {
issuer: "https://issuer.org",
account: "https://issuer.org/account",
},
});
render(getComponent());
await flushPromises();
expect(screen.queryByText("Deactivate account")).not.toBeInTheDocument();
});
it("should render section when account deactivation feature is enabled", () => { it("should render section when account deactivation feature is enabled", () => {
jest.spyOn(SettingsStore, "getValue").mockImplementation( jest.spyOn(SettingsStore, "getValue").mockImplementation(
(settingName) => settingName === UIFeature.Deactivate, (settingName) => settingName === UIFeature.Deactivate,

View File

@ -42,14 +42,14 @@ exports[`<GeneralUserSettingsTab /> 3pids should display 3pid email addresses an
> >
<input <input
autocomplete="email" autocomplete="email"
id="mx_Field_57" id="mx_Field_61"
label="Email Address" label="Email Address"
placeholder="Email Address" placeholder="Email Address"
type="text" type="text"
value="" value=""
/> />
<label <label
for="mx_Field_57" for="mx_Field_61"
> >
Email Address Email Address
</label> </label>
@ -150,14 +150,14 @@ exports[`<GeneralUserSettingsTab /> 3pids should display 3pid email addresses an
</span> </span>
<input <input
autocomplete="tel-national" autocomplete="tel-national"
id="mx_Field_58" id="mx_Field_62"
label="Phone Number" label="Phone Number"
placeholder="Phone Number" placeholder="Phone Number"
type="text" type="text"
value="" value=""
/> />
<label <label
for="mx_Field_58" for="mx_Field_62"
> >
Phone Number Phone Number
</label> </label>