Skip to content

Commit

Permalink
Merge branch 'eik/hide_labs_and_sharedinvites' of https://github.com/…
Browse files Browse the repository at this point in the history
…verji/matrix-react-sdk into eik/hide_labs_and_sharedinvites
  • Loading branch information
eiksta committed Aug 30, 2024
2 parents e046f67 + 266d729 commit a113ffe
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/components/views/rooms/RoomList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const DmAuxButton: React.FC<IAuxButtonProps> = ({ tabIndex, dispatcher = default
}}
/>
)}
{showInviteUsers && (
{showInviteUsers && SettingsStore.getValue(UIFeature.ShowInviteToSpaceFromPeoplePlus) && (
<IconizedContextMenuOption
label={_t("action|invite_to_space")}
iconClassName="mx_RoomList_iconInvite"
Expand Down Expand Up @@ -193,7 +193,6 @@ const DmAuxButton: React.FC<IAuxButtonProps> = ({ tabIndex, dispatcher = default
isExpanded={menuDisplayed}
ref={handle}
/>

{contextMenu}
</>
);
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/strings/nb_NO.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions src/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/settings/UIFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export const enum UIFeature {
ShowSendMessageToUserLink = "UIFeature.showSendMessageToUserLink",
SendInviteLinkPrompt = "UIFeature.sendInviteLinkPrompt",
HelpShowMatrixDisclosurePolicyAndLinks = "UIFeature.helpShowMatrixDisclosurePolicyAndLinks",
ShowInviteToSpaceFromPeoplePlus = "UIFeature.showInviteToSpaceFromPeoplePlus",
SettingShowMessageSearch = "UIFeature.settingShowMessageSearch",
}

Expand Down
66 changes: 65 additions & 1 deletion test/components/views/rooms/RoomList-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ DMRoomMap.sharedInstance = { getUserIdForRoomId, getDMRoomsForUserId };

describe("UIFeature tests", () => {
stubClient();
//const client = MatrixClientPeg.safeGet();
const store = SpaceStore.instance;

function getComponent(props: Partial<ComponentProps<typeof RoomList>> = {}): JSX.Element {
Expand Down Expand Up @@ -383,3 +382,68 @@ describe("RoomList", () => {
});
});
});

describe("UIFeature tests part 2", () => {
stubClient();
const store = SpaceStore.instance;

function getComponent(props: Partial<ComponentProps<typeof RoomList>> = {}): JSX.Element {
return (
<RoomList
onKeyDown={jest.fn()}
onFocus={jest.fn()}
onBlur={jest.fn()}
onResize={jest.fn()}
resizeNotifier={new ResizeNotifier()}
isMinimized={false}
activeSpace={MetaSpace.Home}
{...props}
/>
);
}
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();
});
});
});

0 comments on commit a113ffe

Please sign in to comment.