Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1873 Remove possibility for user to send message room|persons #60

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/views/right_panel/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ export const UserOptionsSection: React.FC<{
<div className="mx_UserInfo_container">
<h3>{_t("common|options")}</h3>
<div>
{directMessageButton}
{SettingsStore.getValue(UIFeature.ShowSendMessageToUserLink) && directMessageButton}
{readReceiptButton}
{/* If you donw want users to send a room link, disable flag in settings.tsx */}
{SettingsStore.getValue(UIFeature.UserInfoShareLinkToUserButton) && shareUserButton}
Expand Down
4 changes: 4 additions & 0 deletions src/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,10 @@ export const SETTINGS: { [setting: string]: ISetting } = {
supportedLevels: LEVELS_UI_FEATURE,
default: true,
},
[UIFeature.ShowSendMessageToUserLink]: {
supportedLevels: LEVELS_UI_FEATURE,
default: true,
},

// Electron-specific settings, they are stored by Electron and set/read over an IPC.
// We store them over there are they are necessary to know before the renderer process launches.
Expand Down
1 change: 1 addition & 0 deletions src/settings/UIFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export const enum UIFeature {
SpacesEnabled = "UIFeature.spacesEnabled",
MultipleCallsInRoom = "UIFeature.multipleCallsInRoom",
ShowSpaceLandingPageDetails = "UIFeature.showSpaceLandingPageDetails",
ShowSendMessageToUserLink = "UIFeature.showSendMessageToUserLink",
}

export enum UIComponent {
Expand Down
15 changes: 14 additions & 1 deletion test/components/views/right_panel/UserInfo-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import { DirectoryMember, startDmOnFirstMessage } from "../../../../src/utils/di
import { clearAllModals, flushPromises } from "../../../test-utils";
import ErrorDialog from "../../../../src/components/views/dialogs/ErrorDialog";
import { shouldShowComponent } from "../../../../src/customisations/helpers/UIComponents";
import { UIComponent } from "../../../../src/settings/UIFeature";
import { UIComponent, UIFeature } from "../../../../src/settings/UIFeature";
import SettingsStore from "../../../../src/settings/SettingsStore";

jest.mock("../../../../src/utils/direct-messages", () => ({
Expand Down Expand Up @@ -177,6 +177,7 @@ beforeEach(() => {

jest.spyOn(MatrixClientPeg, "get").mockReturnValue(mockClient);
jest.spyOn(MatrixClientPeg, "safeGet").mockReturnValue(mockClient);
jest.spyOn(SettingsStore, "getValue").mockReturnValue(true);
});

describe("<UserInfo />", () => {
Expand Down Expand Up @@ -342,6 +343,18 @@ describe("<UserInfo />", () => {

screen.getByRole("button", { name: "Message" });
});
it("does not renders the message button when feature is false", () => {
jest.spyOn(SettingsStore, "getValue").mockImplementation((name: string) => {
if (name == UIFeature.ShowSendMessageToUserLink) return false;
});
render(
<MatrixClientContext.Provider value={mockClient}>
<UserInfo {...defaultProps} />
</MatrixClientContext.Provider>,
);

expect(screen.queryByText("button")).toBeNull();
});

it("hides the message button if the visibility customisation hides all create room features", () => {
mocked(shouldShowComponent).withImplementation(
Expand Down
Loading