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

Add right panel with Room information #365

Merged
merged 91 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from 84 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
c7ba472
Add view and vm for RoomInformation
MidhunSureshR May 23, 2021
c7fd0fa
Allow details to be child of room
MidhunSureshR May 23, 2021
986271d
Add code to toggle RoomInformation panel
MidhunSureshR May 23, 2021
e39572b
Create RoomInformationView on toggle
MidhunSureshR May 23, 2021
96959a3
Put name of property in emitChange
MidhunSureshR May 23, 2021
439910f
Handle case when path.get() may be null
MidhunSureshR May 23, 2021
98d8d44
Allow details to be child of rooms
MidhunSureshR May 23, 2021
7e38c3e
Remove right panel on grid update if needed
MidhunSureshR May 23, 2021
ddaa9b4
Dispose vm preemptively
MidhunSureshR May 24, 2021
c3333f5
Extract method
MidhunSureshR May 24, 2021
9a605cc
Remove unnecessary check
MidhunSureshR May 24, 2021
0d11f85
Add CSS to display sidebar to the right
MidhunSureshR May 24, 2021
191eb09
Fallback to canonical alias if no names found
MidhunSureshR May 24, 2021
0ea2843
Add background for sidebar
MidhunSureshR May 25, 2021
6f1b77b
Add room avatar to RoomInfoView
MidhunSureshR May 25, 2021
aece82d
Make room avatar larger in RoomInfoView
MidhunSureshR May 25, 2021
d502a7f
Make display name bold
MidhunSureshR May 25, 2021
a23e2c3
Better styling
MidhunSureshR May 25, 2021
0a4f8af
Create method to add sidebar element
MidhunSureshR May 26, 2021
653fcbb
Add method to create avatar section
MidhunSureshR May 26, 2021
ee29d7f
Bring in icon assets
MidhunSureshR May 26, 2021
f42553f
Add avatar size for design
MidhunSureshR May 26, 2021
c96abc8
Add css to place items appropriately
MidhunSureshR May 26, 2021
b0535b5
Add styling for RoomInfoView
MidhunSureshR May 26, 2021
91f083a
Add close button to RoomInfoView
MidhunSureshR May 26, 2021
c65e26e
Position the close button to right end
MidhunSureshR May 26, 2021
20a250d
Style close button
MidhunSureshR May 26, 2021
37367cd
Make close button close the view
MidhunSureshR May 26, 2021
ecd5505
Bring in info icon
MidhunSureshR May 26, 2021
4edc58e
Add button in Room header to open details
MidhunSureshR May 26, 2021
b5480b0
Style open button
MidhunSureshR May 26, 2021
9ac415f
Show panel when first visit contains /details
MidhunSureshR May 26, 2021
eab6ca3
Make side-bar responsive
MidhunSureshR May 26, 2021
d782c9e
Justify content to flex-end instead
MidhunSureshR May 26, 2021
2dcec63
Info icon should open/close view alternatively
MidhunSureshR May 27, 2021
02d79b5
Prefer canonical alias over room_id if available
MidhunSureshR May 28, 2021
426d077
Keep RoomInfoView open across room/grid changes
MidhunSureshR May 31, 2021
1e96b58
Add link support to menu
MidhunSureshR May 31, 2021
00dbd3d
Add menu entry to launch RoomInfoView
MidhunSureshR May 31, 2021
040c744
Style links and buttons similarly in menu
MidhunSureshR Jun 1, 2021
f1fe17f
Make font-size equal to that of room-header
MidhunSureshR Jun 1, 2021
d3d65d8
Put sidebar rows into container
MidhunSureshR Jun 1, 2021
3273682
Do not show room id instead of canonical alias
MidhunSureshR Jun 1, 2021
8d254c9
Undo formatting/stylistic changes
MidhunSureshR Jun 3, 2021
a3271fb
Fix Menu: Use t instead of tag to get events
MidhunSureshR Jun 3, 2021
98ef6f4
Use optionWithButton
MidhunSureshR Jun 3, 2021
65bd744
Make menu-items uniform
MidhunSureshR Jun 3, 2021
9074caf
Change Room Details --> Room details
MidhunSureshR Jun 3, 2021
986f04a
Move Room details menu entry to top
MidhunSureshR Jun 3, 2021
a3587a8
Use internationalization for user facing strings
MidhunSureshR Jun 3, 2021
04933ac
Add missing checks
MidhunSureshR Jun 3, 2021
7f922af
Reduce duplication in code
MidhunSureshR Jun 3, 2021
a4bcb21
Move details handling to separate function
MidhunSureshR Jun 4, 2021
37e052c
details do not need to be child of rooms
MidhunSureshR Jun 4, 2021
b2448e1
Calculate path when button is clicked
MidhunSureshR Jun 4, 2021
5b74038
Check value of details everywhere
MidhunSureshR Jun 4, 2021
0d63ce9
Change SideBarActive --> right-shown
MidhunSureshR Jun 4, 2021
4c96294
Modify setters in MenuOption to support chaining
MidhunSureshR Jun 4, 2021
4700009
Add new test for parseUrlPath
MidhunSureshR Jun 4, 2021
c6f3b1f
Do not use private props from room summary
MidhunSureshR Jun 4, 2021
0406584
Remove unused getter
MidhunSureshR Jun 4, 2021
fcc2afb
Do not compute link in getter
MidhunSureshR Jun 4, 2021
eb870cf
Use url instead of link
MidhunSureshR Jun 4, 2021
7fbcf89
Remove unncessary empty line
MidhunSureshR Jun 4, 2021
332fbdd
Move variable to scope of conditional
MidhunSureshR Jun 4, 2021
008f360
Remove link support from Menu
MidhunSureshR Jun 4, 2021
efd37d8
Update on changes to vm
MidhunSureshR Jun 6, 2021
f917730
Stick to naming convention for css/html classes
MidhunSureshR Jun 6, 2021
f3f1436
Rename room info to room details everywhere
MidhunSureshR Jun 6, 2021
2c0176f
Remove unwanted width
MidhunSureshR Jun 6, 2021
6086d15
Make value multiple of 4
MidhunSureshR Jun 6, 2021
95512b5
Remove margin from top
MidhunSureshR Jun 6, 2021
fa67c5e
Refactor function
MidhunSureshR Jun 7, 2021
4005d70
Increase height to make element more centered
MidhunSureshR Jun 7, 2021
dd9a19b
Make formatting consistent
MidhunSureshR Jun 7, 2021
0c5d118
Add rule to warn on wrong formatting
MidhunSureshR Jun 7, 2021
b2f2d51
Make formatting consistent with the codebase
MidhunSureshR Jun 7, 2021
e2443a8
Undo spillover from earlier formatting havoc
MidhunSureshR Jun 7, 2021
e10b455
Rename method
MidhunSureshR Jun 14, 2021
7b811aa
Remove space after brace in two places
MidhunSureshR Jun 14, 2021
88a1e34
Unsubscribe on dispose
MidhunSureshR Jun 14, 2021
e50b503
Undo lint config change
MidhunSureshR Jun 14, 2021
97e484b
Rename toggle --> open
MidhunSureshR Jun 15, 2021
4f05d9a
Make navigation changes in one go
MidhunSureshR Jun 15, 2021
1772fc0
Remove text(..)
MidhunSureshR Jun 15, 2021
5e4db2f
Change font size
MidhunSureshR Jun 15, 2021
e161f61
Remove selector list
MidhunSureshR Jun 15, 2021
e2fd90b
Remove Segment import
MidhunSureshR Jun 24, 2021
a273b25
Remove css assumption
MidhunSureshR Jun 24, 2021
eb35f46
Make sure room does exist before creating vm
MidhunSureshR Jun 24, 2021
09aba78
Merge branch 'master' into room-info
bwindels Jun 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ module.exports = {
"no-console": "off",
"no-empty": "off",
"no-prototype-builtins": "off",
"no-unused-vars": "warn",
"no-unused-vars": "warn"
}
};
24 changes: 23 additions & 1 deletion src/domain/navigation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function allowsChild(parent, child) {
// downside of the approach: both of these will control which tile is selected
return type === "room" || type === "empty-grid-tile";
case "room":
return type === "lightbox";
return type === "lightbox" || type === "details";
bwindels marked this conversation as resolved.
Show resolved Hide resolved
default:
return false;
}
Expand Down Expand Up @@ -113,6 +113,9 @@ export function parseUrlPath(urlPath, currentNavPath, defaultSessionId) {
segments.push(roomsSegmentWithRoom(rooms, roomId, currentNavPath));
}
segments.push(new Segment("room", roomId));
if (currentNavPath.get("details")?.value) {
bwindels marked this conversation as resolved.
Show resolved Hide resolved
segments.push(new Segment("details"));
}
} else if (type === "last-session") {
let sessionSegment = currentNavPath.get("session");
if (typeof sessionSegment?.value !== "string" && defaultSessionId) {
Expand Down Expand Up @@ -254,6 +257,25 @@ export function tests() {
assert.equal(segments[2].type, "room");
assert.equal(segments[2].value, "a");
},
"parse open-room action changing focus to an existing room with details open": assert => {
const nav = new Navigation(allowsChild);
const path = nav.pathFrom([
new Segment("session", 1),
new Segment("rooms", ["a", "b", "c"]),
new Segment("room", "b"),
new Segment("details", true)
]);
const segments = parseUrlPath("/session/1/open-room/a", path);
assert.equal(segments.length, 4);
assert.equal(segments[0].type, "session");
assert.equal(segments[0].value, "1");
assert.equal(segments[1].type, "rooms");
assert.deepEqual(segments[1].value, ["a", "b", "c"]);
assert.equal(segments[2].type, "room");
assert.equal(segments[2].value, "a");
assert.equal(segments[3].type, "details");
assert.equal(segments[3].value, true);
},
"parse open-room action setting a room in an empty tile": assert => {
const nav = new Navigation(allowsChild);
const path = nav.pathFrom([
Expand Down
15 changes: 13 additions & 2 deletions src/domain/session/RoomGridViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,23 @@ export class RoomGridViewModel extends ViewModel {
return this._height;
}

_switchToRoom(roomId) {
const detailsShown = !!this.navigation.path.get("details")?.value;
let path = this.navigation.path.until("rooms");
path = path.with(new Segment("room", roomId));
if (detailsShown) {
path = path.with(new Segment("details", true));
}
this.navigation.applyPath(path);
}

focusTile(index) {
if (index === this._selectedIndex) {
return;
}
const vmo = this._viewModelsObservables[index];
if (vmo) {
this.navigation.push("room", vmo.id);
this._switchToRoom(vmo.id);
} else {
this.navigation.push("empty-grid-tile", index);
}
Expand Down Expand Up @@ -146,7 +156,7 @@ export class RoomGridViewModel extends ViewModel {
this.emitChange();
viewModel?.focus();
}

/** called from SessionViewModel */
releaseRoomViewModel(roomId) {
const index = this._viewModelsObservables.findIndex(vmo => vmo && vmo.id === roomId);
Expand Down Expand Up @@ -179,6 +189,7 @@ export class RoomGridViewModel extends ViewModel {

import {createNavigation} from "../navigation/index.js";
import {ObservableValue} from "../../observable/ObservableValue.js";
import { Segment } from "../navigation/Navigation.js";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: only the imports needed for the tests should be below here, the others up at the top. You can also avoid the import by doing this.navigation.segment(...) fwiw.


export function tests() {
class RoomVMMock {
Expand Down
30 changes: 28 additions & 2 deletions src/domain/session/SessionViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.

import {LeftPanelViewModel} from "./leftpanel/LeftPanelViewModel.js";
import {RoomViewModel} from "./room/RoomViewModel.js";
import {RoomDetailsViewModel} from "./rightpanel/RoomDetailsViewModel.js";
import {UnknownRoomViewModel} from "./room/UnknownRoomViewModel.js";
import {InviteViewModel} from "./room/InviteViewModel.js";
import {LightboxViewModel} from "./room/LightboxViewModel.js";
Expand Down Expand Up @@ -62,6 +63,7 @@ export class SessionViewModel extends ViewModel {
if (!this._gridViewModel) {
this._updateRoom(roomId);
}
this._updateRoomDetails();
}));
if (!this._gridViewModel) {
this._updateRoom(currentRoomId.get());
Expand All @@ -78,6 +80,10 @@ export class SessionViewModel extends ViewModel {
this._updateLightbox(eventId);
}));
this._updateLightbox(lightbox.get());

const details = this.navigation.observe("details");
this.track(details.subscribe(() => this._updateRoomDetails()));
this._updateRoomDetails();
}

get id() {
Expand Down Expand Up @@ -112,6 +118,10 @@ export class SessionViewModel extends ViewModel {
return this._roomViewModelObservable?.get();
}

get roomDetailsViewModel() {
return this._roomDetailsViewModel;
}

_updateGrid(roomIds) {
const changed = !(this._gridViewModel && roomIds);
const currentRoomId = this.navigation.path.get("room");
Expand Down Expand Up @@ -230,8 +240,7 @@ export class SessionViewModel extends ViewModel {
this._lightboxViewModel = this.disposeTracked(this._lightboxViewModel);
}
if (eventId) {
const roomId = this.navigation.path.get("room").value;
const room = this._sessionContainer.session.rooms.get(roomId);
const room = this._roomFromNavigation();
this._lightboxViewModel = this.track(new LightboxViewModel(this.childOptions({eventId, room})));
}
this.emitChange("lightboxViewModel");
Expand All @@ -240,4 +249,21 @@ export class SessionViewModel extends ViewModel {
get lightboxViewModel() {
return this._lightboxViewModel;
}

_roomFromNavigation() {
const roomId = this.navigation.path.get("room")?.value;
const room = this._sessionContainer.session.rooms.get(roomId);
return room;
}

_updateRoomDetails() {
this._roomDetailsViewModel = this.disposeTracked(this._roomDetailsViewModel);
const enable = !!this.navigation.path.get("details")?.value;
if (enable) {
const room = this._roomFromNavigation();
this._roomDetailsViewModel = this.track(new RoomDetailsViewModel(this.childOptions({room})));
}
this.emitChange("roomDetailsViewModel");
}

}
16 changes: 10 additions & 6 deletions src/domain/session/leftpanel/LeftPanelViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,30 @@ export class LeftPanelViewModel extends ViewModel {
}
}

_pathForDetails(path) {
const details = this.navigation.path.get("details");
return details?.value ? path.with(details) : path;
}

toggleGrid() {
const room = this.navigation.path.get("room");
let path = this.navigation.path.until("session");
if (this.gridEnabled) {
let path = this.navigation.path.until("session");
const room = this.navigation.path.get("room");
if (room) {
path = path.with(room);
path = this._pathForDetails(path);
}
this.navigation.applyPath(path);
} else {
let path = this.navigation.path.until("session");
const room = this.navigation.path.get("room");
if (room) {
path = path.with(this.navigation.segment("rooms", [room.value]));
path = path.with(room);
path = this._pathForDetails(path);
} else {
path = path.with(this.navigation.segment("rooms", []));
path = path.with(this.navigation.segment("empty-grid-tile", 0));
}
this.navigation.applyPath(path);
}
this.navigation.applyPath(path);
}

get tileViewModels() {
Expand Down
61 changes: 61 additions & 0 deletions src/domain/session/rightpanel/RoomDetailsViewModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import {ViewModel} from "../../ViewModel.js";
import {avatarInitials, getIdentifierColorNumber, getAvatarHttpUrl} from "../../avatar.js";

export class RoomDetailsViewModel extends ViewModel {
constructor(options) {
super(options);
this._room = options.room;
this._onRoomChange = this._onRoomChange.bind(this);
this._room.on("change", this._onRoomChange);
}

get roomId() {
return this._room.id;
}

get canonicalAlias() {
return this._room.canonicalAlias;
}

get name() {
return this._room.name;
}

get isEncrypted() {
return !!this._room.isEncrypted;
}

get memberCount() {
return this._room.joinedMemberCount;
}

get avatarLetter() {
return avatarInitials(this.name);
}

get avatarColorNumber() {
return getIdentifierColorNumber(this.roomId)
}

avatarUrl(size) {
return getAvatarHttpUrl(this._room.avatarUrl, size, this.platform, this._room.mediaRepository);
}

get avatarTitle() {
return this.name;
}

_onRoomChange() {
this.emitChange();
}

closePanel() {
const path = this.navigation.path.until("room");
this.navigation.applyPath(path);
}

dispose() {
super.dispose();
this._room.off("change", this._onRoomChange);
}
}
10 changes: 8 additions & 2 deletions src/domain/session/room/RoomViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,16 @@ export class RoomViewModel extends ViewModel {
console.error(err.stack);
}
}

get composerViewModel() {
return this._composerVM;
}

openDetailsPanel() {
let path = this.navigation.path.until("room");
path = path.with(this.navigation.segment("details", true));
this.navigation.applyPath(path);
}
}

class ComposerViewModel extends ViewModel {
Expand Down Expand Up @@ -383,4 +389,4 @@ class ArchivedViewModel extends ViewModel {
get kind() {
return "archived";
}
}
}
8 changes: 8 additions & 0 deletions src/matrix/room/BaseRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,14 @@ export class BaseRoom extends EventEmitter {
return this.membership === "leave";
}

get canonicalAlias() {
return this._summary.data.canonicalAlias;
}

get joinedMemberCount() {
return this._summary.data.joinCount;
}

get mediaRepository() {
return this._mediaRepository;
}
Expand Down
8 changes: 8 additions & 0 deletions src/platform/web/ui/css/avatar.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ limitations under the License.
font-size: calc(var(--avatar-size) * 0.6);
}

.hydrogen .avatar.size-52 {
--avatar-size: 52px;
width: var(--avatar-size);
height: var(--avatar-size);
line-height: var(--avatar-size);
font-size: calc(var(--avatar-size) * 0.6);
}

.hydrogen .avatar.size-30 {
--avatar-size: 30px;
width: var(--avatar-size);
Expand Down
22 changes: 21 additions & 1 deletion src/platform/web/ui/css/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ main {
min-width: 0;
}

.right-shown{
grid-template:
"status status status" auto
"left middle right" 1fr /
300px 1fr 300px;
}

/* resize and reposition session view to account for mobile Safari which shifts
the layout viewport up without resizing it when the keyboard shows */
.hydrogen.ios .SessionView {
Expand All @@ -65,7 +72,7 @@ the layout viewport up without resizing it when the keyboard shows */
.middle .close-middle { display: none; }
/* mobile layout */
@media screen and (max-width: 800px) {
.SessionView:not(.middle-shown) {
.SessionView:not(.middle-shown, .right-shown) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

selector lists in :not are not supported in IE apparently. Can you write this out?

grid-template:
"status" auto
"left" 1fr /
Expand All @@ -79,8 +86,16 @@ the layout viewport up without resizing it when the keyboard shows */
1fr;
}

.SessionView.right-shown{
grid-template:
"status" auto
"right" 1fr /
1fr;
}

.SessionView:not(.middle-shown) .room-placeholder { display: none; }
.SessionView.middle-shown .LeftPanel { display: none; }
.SessionView.right-shown .middle { display: none; }

/* show back button */
.middle .close-middle { display: block !important; }
Expand Down Expand Up @@ -179,6 +194,11 @@ the layout viewport up without resizing it when the keyboard shows */
z-index: 2;
}

.menu .menu-item{
box-sizing: border-box;
width: 100%;
}

.Settings {
display: flex;
flex-direction: column;
Expand Down
1 change: 1 addition & 0 deletions src/platform/web/ui/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
@import url('layout.css');
@import url('login.css');
@import url('left-panel.css');
@import url('right-panel.css');
@import url('room.css');
@import url('timeline.css');
@import url('avatar.css');
Expand Down