diff --git a/src/components/views/rooms/RoomList.tsx b/src/components/views/rooms/RoomList.tsx index cf1b99a7178..5df43fb556f 100644 --- a/src/components/views/rooms/RoomList.tsx +++ b/src/components/views/rooms/RoomList.tsx @@ -163,7 +163,7 @@ const DmAuxButton: React.FC = ({ tabIndex, dispatcher = default }} /> )} - {showInviteUsers && ( + {showInviteUsers && SettingsStore.getValue(UIFeature.ShowInviteToSpaceFromPeoplePlus) && ( = ({ tabIndex, dispatcher = default isExpanded={menuDisplayed} ref={handle} /> - {contextMenu} ); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index a18d26e892a..25cfa2b2242 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -81,6 +81,11 @@ "monday_friday": "Monday - Friday", "opening_hours": "08.00 - 16.00", "support_phone": "Phone +4790532454" + }, + "user_menu" : { + "administration_portal": "Administration portal", + "signing_order": "Signing orders", + "login_account": "Account & Login" } }, "a11y": { diff --git a/src/i18n/strings/nb_NO.json b/src/i18n/strings/nb_NO.json index 6cfedaa265e..3257a34baa6 100644 --- a/src/i18n/strings/nb_NO.json +++ b/src/i18n/strings/nb_NO.json @@ -81,6 +81,11 @@ "support_phone": "Telefon", "monday_friday": "Mandag - Fredag", "08.00_16.00": "08.00 - 16.00" + }, + "user_menu" : { + "administration_portal": "Administrasjonsportal", + "signing_order": "Signeringsordre", + "login_account": "Konto og innlogging" } }, "%(duration)sd": "%(duration)sd", diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index 307dc8af88f..94aab9222c5 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -1507,6 +1507,10 @@ export const SETTINGS: { [setting: string]: ISetting } = { supportedLevels: LEVELS_UI_FEATURE, default: true, }, + [UIFeature.ShowInviteToSpaceFromPeoplePlus]: { + 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. diff --git a/src/settings/UIFeature.ts b/src/settings/UIFeature.ts index 022002d7e4e..540932d87e3 100644 --- a/src/settings/UIFeature.ts +++ b/src/settings/UIFeature.ts @@ -100,6 +100,7 @@ export const enum UIFeature { ShowSendMessageToUserLink = "UIFeature.showSendMessageToUserLink", SendInviteLinkPrompt = "UIFeature.sendInviteLinkPrompt", HelpShowMatrixDisclosurePolicyAndLinks = "UIFeature.helpShowMatrixDisclosurePolicyAndLinks", + ShowInviteToSpaceFromPeoplePlus = "UIFeature.showInviteToSpaceFromPeoplePlus", SettingShowMessageSearch = "UIFeature.settingShowMessageSearch", } diff --git a/test/components/views/rooms/RoomList-test.tsx b/test/components/views/rooms/RoomList-test.tsx index 499414edd62..82b4a200d0f 100644 --- a/test/components/views/rooms/RoomList-test.tsx +++ b/test/components/views/rooms/RoomList-test.tsx @@ -51,7 +51,6 @@ DMRoomMap.sharedInstance = { getUserIdForRoomId, getDMRoomsForUserId }; describe("UIFeature tests", () => { stubClient(); - //const client = MatrixClientPeg.safeGet(); const store = SpaceStore.instance; function getComponent(props: Partial> = {}): JSX.Element { @@ -383,3 +382,68 @@ describe("RoomList", () => { }); }); }); + +describe("UIFeature tests part 2", () => { + stubClient(); + const store = SpaceStore.instance; + + function getComponent(props: Partial> = {}): JSX.Element { + return ( + + ); + } + beforeEach(() => { + store.setActiveSpace(MetaSpace.Home); + mocked(shouldShowComponent).mockImplementation((feature) => true); + }); + describe("UIFeature.showInviteToSpaceFromPeoplePlus", () => { + stubClient(); + const client = MatrixClientPeg.safeGet(); + const store = SpaceStore.instance; + let rooms: Room[]; + const mkSpaceForRooms = (spaceId: string, children: string[] = []) => mkSpace(client, spaceId, rooms, children); + + const space1 = "!verjispace1:server"; + + beforeEach(async () => { + rooms = []; + mkSpaceForRooms(space1); + mocked(client).getRoom.mockImplementation((roomId) => rooms.find((room) => room.roomId === roomId) || null); + await testUtils.setupAsyncStoreWithClient(store, client); + + store.setActiveSpace(space1); + }); + it("UIFeature.showInviteToSpaceFromPeoplePlus = true: renders 'Invite to space'-button", async () => { + jest.spyOn(SettingsStore, "getValue").mockImplementation((name: string) => { + if (name == UIFeature.ShowInviteToSpaceFromPeoplePlus) return true; + return false; + }); + render(getComponent()); + const peoplePlusButton = screen.getByLabelText("Add people"); + await userEvent.click(peoplePlusButton); + + expect(screen.getByLabelText("Invite to space")).toBeInTheDocument(); + }); + + it("UIFeature.showInviteToSpaceFromPeoplePlus = false: does not render 'Invite to space'-button", async () => { + jest.spyOn(SettingsStore, "getValue").mockImplementation((name: string) => { + if (name == UIFeature.ShowInviteToSpaceFromPeoplePlus) return false; + return false; + }); + render(getComponent()); + const peoplePlusButton = screen.getByLabelText("Add people"); + await userEvent.click(peoplePlusButton); + + expect(screen.queryByLabelText("Invite to space")).not.toBeInTheDocument(); + }); + }); +});