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

Rm/1962 hierarchy ux 6 #62

Merged
merged 4 commits into from
Jun 26, 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
32 changes: 30 additions & 2 deletions src/components/views/rooms/RoomList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ const DmAuxButton: React.FC<IAuxButtonProps> = ({ tabIndex, dispatcher = default
return SpaceStore.instance.activeSpaceRoom;
});

let showStartChatPlusMenuForMetaSpace = true;
if (!SettingsStore.getValue(UIFeature.ShowStartChatPlusMenuForMetaSpace)) {
switch (SpaceStore.instance.activeSpace) {
case MetaSpace.Home:
case MetaSpace.Favourites:
case MetaSpace.People:
showStartChatPlusMenuForMetaSpace = false;
break;

default:
break;
}
}

const showCreateRooms = shouldShowComponent(UIComponent.CreateRooms);
const showInviteUsers = shouldShowComponent(UIComponent.InviteUsers);

Expand Down Expand Up @@ -183,7 +197,7 @@ const DmAuxButton: React.FC<IAuxButtonProps> = ({ tabIndex, dispatcher = default
{contextMenu}
</>
);
} else if (!activeSpace && showCreateRooms) {
} else if (showStartChatPlusMenuForMetaSpace && !activeSpace && showCreateRooms) {
return (
<AccessibleButton
tabIndex={tabIndex}
Expand Down Expand Up @@ -352,7 +366,21 @@ const UntaggedAuxButton: React.FC<IAuxButtonProps> = ({ tabIndex }) => {
);
}

if (showCreateRoom || showExploreRooms) {
let ShowAddRoomPlusMenuForMetaSpace = true;
if (!SettingsStore.getValue(UIFeature.ShowAddRoomPlusMenuForMetaSpace)) {
switch (SpaceStore.instance.activeSpace) {
case MetaSpace.Home:
case MetaSpace.Favourites:
case MetaSpace.People:
ShowAddRoomPlusMenuForMetaSpace = false;
break;

default:
break;
}
}

if (ShowAddRoomPlusMenuForMetaSpace && (showCreateRoom || showExploreRooms)) {
return (
<>
<ContextMenuTooltipButton
Expand Down
16 changes: 15 additions & 1 deletion src/components/views/rooms/RoomListHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,20 @@ const RoomListHeader: React.FC<IProps> = ({ onVisibilityChange }) => {
}
}

let showPlusMenuForMetaSpace = true;
if (!SettingsStore.getValue(UIFeature.ShowPlusMenuForMetaSpace)) {
switch (spaceKey) {
case MetaSpace.Home:
case MetaSpace.Favourites:
case MetaSpace.People:
showPlusMenuForMetaSpace = false;
break;

default:
break;
}
}

return (
<aside className="mx_RoomListHeader" aria-label={_t("room|context_menu|title")}>
{contextMenuButton}
Expand All @@ -419,7 +433,7 @@ const RoomListHeader: React.FC<IProps> = ({ onVisibilityChange }) => {
<InlineSpinner />
</Tooltip>
) : null}
{canShowPlusMenu && (
{showPlusMenuForMetaSpace && canShowPlusMenu && (
<ContextMenuTooltipButton
ref={plusMenuHandle}
onClick={openPlusMenu}
Expand Down
12 changes: 12 additions & 0 deletions src/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,18 @@ export const SETTINGS: { [setting: string]: ISetting } = {
supportedLevels: LEVELS_UI_FEATURE,
default: true,
},
[UIFeature.ShowPlusMenuForMetaSpace]: {
supportedLevels: LEVELS_UI_FEATURE,
default: true,
},
[UIFeature.ShowStartChatPlusMenuForMetaSpace]: {
supportedLevels: LEVELS_UI_FEATURE,
default: true,
},
[UIFeature.ShowAddRoomPlusMenuForMetaSpace]: {
supportedLevels: LEVELS_UI_FEATURE,
default: true,
},
[UIFeature.ShowExploreRoomsButton]: {
supportedLevels: LEVELS_UI_FEATURE,
default: true,
Expand Down
3 changes: 3 additions & 0 deletions src/settings/UIFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export const enum UIFeature {
TimelineEnableRelativeDates = "UIFeature.timelineEnableRelativeDates",
BulkUnverifiedSessionsReminder = "UIFeature.BulkUnverifiedSessionsReminder",
ShowCreateSpaceButton = "UIFeature.showCreateSpaceButton",
ShowPlusMenuForMetaSpace = "UIFeature.showPlusMenuForMetaSpace",
ShowStartChatPlusMenuForMetaSpace = "UIFeature.showStartChatPlusMenuForMetaSpace",
ShowAddRoomPlusMenuForMetaSpace = "UIFeature.showAddRoomPlusMenuForMetaSpace",
ShowExploreRoomsButton = "UIFeature.showExploreRoomsButton",
ShowAddWidgetsInRoomInfo = "UIFeature.showAddWidgetsInRoomInfo",
AddExistingRoomToSpace = "UIFeature.addExistingRoomToSpace",
Expand Down
48 changes: 48 additions & 0 deletions test/components/views/rooms/RoomList-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,52 @@ describe("RoomList", () => {
});
});
});

describe("UIFeature.showStartChatPlusMenuForMetaSpace", () => {
beforeEach(() => {
store.setActiveSpace(MetaSpace.Home);
});

it("UIFeature.showStartChatPlusMenuForMetaSpace = true: renders 'Start Chat' plus-button", () => {
jest.spyOn(SettingsStore, "getValue").mockImplementation((val) => {
return val === UIFeature.ShowStartChatPlusMenuForMetaSpace ? true : "default";
});
render(getComponent());

expect(screen.getByLabelText("Start chat")).toBeInTheDocument();
});

it("UIFeature.showStartChatPlusMenuForMetaSpace = false: does not render 'Start Chat' plus-button", () => {
jest.spyOn(SettingsStore, "getValue").mockImplementation((val) => {
return val === UIFeature.ShowStartChatPlusMenuForMetaSpace ? false : "default";
});
render(getComponent());

expect(screen.queryByLabelText("Start chat")).not.toBeInTheDocument();
});
});

describe("UIFeature.showAddRoomPlusMenuForMetaSpace", () => {
beforeEach(() => {
store.setActiveSpace(MetaSpace.Home);
});

it("UIFeature.showAddRoomPlusMenuForMetaSpace = true: renders 'Add room' plus-button", () => {
jest.spyOn(SettingsStore, "getValue").mockImplementation((val) => {
return val === UIFeature.ShowAddRoomPlusMenuForMetaSpace ? true : "default";
});
render(getComponent());

expect(screen.getByLabelText("Add room")).toBeInTheDocument();
});

it("UIFeature.showAddRoomPlusMenuForMetaSpace = false: does not render 'Add room' plus-button", () => {
jest.spyOn(SettingsStore, "getValue").mockImplementation((val) => {
return val === UIFeature.ShowAddRoomPlusMenuForMetaSpace ? false : "default";
});
render(getComponent());

expect(screen.queryByLabelText("Add room")).not.toBeInTheDocument();
});
});
});
Loading