Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Transfer by Dialpad #6217

Merged
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6d07d5d
Add ability to transfer by dial pad
dbkr Jun 10, 2021
a85420b
Re-arrange buttons as per transfer dialog design
dbkr Jun 11, 2021
2cc6bce
Much theming & visual of transfer window dial pad
dbkr Jun 18, 2021
a91c859
Merge remote-tracking branch 'origin/develop' into dbkr/transfer_by_d…
dbkr Jun 18, 2021
df35844
Somehow lost react braces
dbkr Jun 18, 2021
84e9ed6
Add tab icons
dbkr Jun 18, 2021
b97a166
Put delete button back, fix layout
dbkr Jun 18, 2021
7327058
Remove duplicated height setting
dbkr Jun 18, 2021
ed4313f
Fix other Dialpad usage
dbkr Jun 18, 2021
e67a803
missed return
dbkr Jun 21, 2021
ab95fcb
use currentTarget over target
dbkr Jun 21, 2021
f4ee7bb
Inherit width & height
dbkr Jun 21, 2021
65eb9c9
Make dispatcher actions camel case like the others
dbkr Jun 21, 2021
d012e9c
Use unit-less 0
dbkr Jun 21, 2021
284aec8
Design feedback
dbkr Jun 21, 2021
c829cb9
Use flexbox to layout buttons
dbkr Jun 22, 2021
fc7a306
Remove top margin on input to move dial pad up
dbkr Jun 22, 2021
a636e5e
shift the dial pad up a bit more
dbkr Jun 22, 2021
c93e973
Disable input once a selection is made
dbkr Jun 22, 2021
f8e5fb5
Merge remote-tracking branch 'origin/develop' into dbkr/transfer_by_d…
dbkr Jun 23, 2021
10a900b
Change drop shadow to 1px border
dbkr Jun 23, 2021
fb4806b
Merge remote-tracking branch 'origin/develop' into dbkr/transfer_by_d…
dbkr Jun 23, 2021
0d8dd74
Reduce bottom padding
dbkr Jun 23, 2021
9e3b861
Merge remote-tracking branch 'origin/develop' into dbkr/transfer_by_d…
dbkr Jun 24, 2021
91bc871
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
anoadragon453 Jul 1, 2021
b3afaad
lint fixes
anoadragon453 Jul 1, 2021
12e360b
Not all semicolons are created necessary
anoadragon453 Jul 1, 2021
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
107 changes: 85 additions & 22 deletions res/css/structures/_TabbedView.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2017 Travis Ralston
Copyright 2019 New Vector Ltd
Copyright 2021 The Matrix.org Foundation C.I.C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -20,19 +21,99 @@ limitations under the License.
padding: 0 0 0 16px;
display: flex;
flex-direction: column;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin-top: 8px;
}

.mx_TabbedView_tabsOnLeft {
flex-direction: column;
position: absolute;

.mx_TabbedView_tabLabels {
width: 170px;
max-width: 170px;
position: fixed;
}

.mx_TabbedView_tabPanel {
margin-left: 240px; // 170px sidebar + 70px padding
flex-direction: column;
}

.mx_TabbedView_tabLabel_active {
background-color: $tab-label-active-bg-color;
color: $tab-label-active-fg-color;
}

.mx_TabbedView_tabLabel_active .mx_TabbedView_maskedIcon::before {
background-color: $tab-label-active-icon-bg-color;
}

.mx_TabbedView_maskedIcon {
width: 16px;
height: 16px;
margin-left: 8px;
margin-right: 16px;
}

.mx_TabbedView_maskedIcon::before {
mask-size: 16px;
width: 16px;
height: 16px;
}
}

.mx_TabbedView_tabsOnTop {
flex-direction: column;

.mx_TabbedView_tabLabels {
display: flex;
}

.mx_TabbedView_tabLabel {
padding-left: 0px;
padding-right: 52px;

.mx_TabbedView_tabLabel_text {
font-size: 15px;
color: $tertiary-fg-color;
}
}

.mx_TabbedView_tabPanel {
flex-direction: row;
}

.mx_TabbedView_tabLabel_active {
color: $accent-color;
.mx_TabbedView_tabLabel_text {
color: $accent-color;
}
}

.mx_TabbedView_tabLabel_active .mx_TabbedView_maskedIcon::before {
background-color: $accent-color;
}

.mx_TabbedView_maskedIcon {
width: 22px;
height: 22px;
margin-left: 0px;
margin-right: 8px;
}

.mx_TabbedView_maskedIcon::before {
mask-size: 22px;
width: 22px;
height: 22px;
dbkr marked this conversation as resolved.
Show resolved Hide resolved
}
}

.mx_TabbedView_tabLabels {
width: 170px;
max-width: 170px;
color: $tab-label-fg-color;
position: fixed;
}

.mx_TabbedView_tabLabel {
Expand All @@ -46,43 +127,25 @@ limitations under the License.
position: relative;
}

.mx_TabbedView_tabLabel_active {
background-color: $tab-label-active-bg-color;
color: $tab-label-active-fg-color;
}

.mx_TabbedView_maskedIcon {
margin-left: 8px;
margin-right: 16px;
width: 16px;
height: 16px;
display: inline-block;
}

.mx_TabbedView_maskedIcon::before {
display: inline-block;
background-color: $tab-label-icon-bg-color;
mask-repeat: no-repeat;
mask-size: 16px;
width: 16px;
height: 16px;
mask-position: center;
content: '';
}

.mx_TabbedView_tabLabel_active .mx_TabbedView_maskedIcon::before {
background-color: $tab-label-active-icon-bg-color;
}

.mx_TabbedView_tabLabel_text {
vertical-align: middle;
}

.mx_TabbedView_tabPanel {
margin-left: 240px; // 170px sidebar + 70px padding
flex-grow: 1;
display: flex;
flex-direction: column;
min-height: 0; // firefox
}

Expand Down
52 changes: 49 additions & 3 deletions res/css/views/dialogs/_InviteDialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,31 @@ limitations under the License.
}
}

.mx_InviteDialog {
.mx_InviteDialog_other {
// Prevent the dialog from jumping around randomly when elements change.
height: 600px;
padding-left: 20px; // the design wants some padding on the left
display: flex;

.mx_InviteDialog_userSections {
height: calc(100% - 115px); // mx_InviteDialog's height minus some for the upper and lower elements
}
}

.mx_InviteDialog_content {
height: calc(100% - 36px); // full height minus the size of the header
}

.mx_InviteDialog_transfer {
width: 496px;
height: 466px;
flex-direction: column;

.mx_InviteDialog_content {
flex-direction: column;

.mx_TabbedView {
height: calc(100% - 40px);
}
overflow: hidden;
}
}
Expand All @@ -302,7 +319,6 @@ limitations under the License.
margin-top: 4px;
overflow-y: auto;
padding: 0 45px 4px 0;
height: calc(100% - 115px); // mx_InviteDialog's height minus some for the upper and lower elements
}

.mx_InviteDialog_hasFooter .mx_InviteDialog_userSections {
Expand All @@ -316,3 +332,33 @@ limitations under the License.
.mx_InviteDialog_helpText .mx_AccessibleButton_kind_link {
padding: 0;
}

.mx_InviteDialog_dialPad .mx_InviteDialog_dialPadField {
border-top: 0px;
border-left: 0px;
border-right: 0px;
border-radius: 0px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably out of scope for this review, but we might want to introduce a StyleLint rule that forces unit-less 0.
It's what I usually see in CSS codebases

Copy link
Member Author

Choose a reason for hiding this comment

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

oh yeah - have changed these, but yep, we could probably add a rule


input {
font-size: 18px;
font-weight: 600;
}
}

.mx_InviteDialog_dialPad {
width: 224px;
margin-left: auto;
margin-right: auto;
}

.mx_InviteDialog_transferButton {
float: right;
}

.mx_InviteDialog_userDirectoryIcon::before {
mask-image: url('$(res)/img/voip/tab-userdirectory.svg');
}

.mx_InviteDialog_dialPadIcon::before {
mask-image: url('$(res)/img/voip/tab-dialpad.svg');
}
2 changes: 2 additions & 0 deletions res/css/views/voip/_DialPad.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ limitations under the License.
text-align: center;
vertical-align: middle;
line-height: 40px;
margin-left: auto;
margin-right: auto;
}

.mx_DialPad_deleteButton, .mx_DialPad_dialButton {
Expand Down
3 changes: 3 additions & 0 deletions res/img/voip/tab-dialpad.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions res/img/voip/tab-userdirectory.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 49 additions & 1 deletion src/CallHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ export default class CallHandler extends EventEmitter {
}

private setCallListeners(call: MatrixCall) {
let mappedRoomId = CallHandler.sharedInstance().roomIdForCall(call);
let mappedRoomId = this.roomIdForCall(call);

call.on(CallEvent.Error, (err: CallError) => {
if (!this.matchesCallForThisRoom(call)) return;
Expand Down Expand Up @@ -871,6 +871,12 @@ export default class CallHandler extends EventEmitter {
case Action.DialNumber:
this.dialNumber(payload.number);
break;
case Action.TransferCallToMatrixID:
this.startTransferToMatrixID(payload.call, payload.destination, payload.consultFirst);
break;
case Action.TransferCallToPhoneNumber:
this.startTransferToPhoneNumber(payload.call, payload.destination, payload.consultFirst);
break;
}
}

Expand Down Expand Up @@ -905,6 +911,48 @@ export default class CallHandler extends EventEmitter {
});
}

private async startTransferToPhoneNumber(call: MatrixCall, destination: string, consultFirst: boolean) {
const results = await this.pstnLookup(destination);
if (!results || results.length === 0 || !results[0].userid) {
Modal.createTrackedDialog('', '', ErrorDialog, {
title: _t("Unable to transfer call"),
description: _t("There was an error looking up the phone number"),
});
return;
}

await this.startTransferToMatrixID(call, results[0].userid, consultFirst);
}

private async startTransferToMatrixID(call: MatrixCall, destination: string, consultFirst: boolean) {
if (consultFirst) {
const dmRoomId = await ensureDMExists(MatrixClientPeg.get(), destination);

dis.dispatch({
action: 'place_call',
type: call.type,
room_id: dmRoomId,
transferee: call,
});
dis.dispatch({
action: 'view_room',
room_id: dmRoomId,
should_peek: false,
joining: false,
});
} else {
try {
await call.transfer(destination);
} catch (e) {
console.log("Failed to transfer call", e);
Modal.createTrackedDialog('Failed to transfer call', '', ErrorDialog, {
title: _t('Transfer Failed'),
description: _t('Failed to transfer call'),
});
}
}
}

setActiveCallRoomId(activeCallRoomId: string) {
logger.info("Setting call in room " + activeCallRoomId + " active");

Expand Down
21 changes: 20 additions & 1 deletion src/components/structures/TabbedView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {_t} from '../../languageHandler';
import * as sdk from "../../index";
import AutoHideScrollbar from './AutoHideScrollbar';
import {replaceableComponent} from "../../utils/replaceableComponent";
import classNames from "classnames";

/**
* Represents a tab for the TabbedView.
Expand All @@ -37,9 +38,16 @@ export class Tab {
}
}

export enum TabLocation {
LEFT = 'left',
TOP = 'top',
}

interface IProps {
tabs: Tab[];
initialTabId?: string;
tabLocation: TabLocation;
onChange?: (tabId: string) => void;
}

interface IState {
Expand All @@ -62,6 +70,10 @@ export default class TabbedView extends React.Component<IProps, IState> {
};
}

static defaultProps = {
tabLocation: TabLocation.LEFT,
}

private _getActiveTabIndex() {
if (!this.state || !this.state.activeTabIndex) return 0;
return this.state.activeTabIndex;
Expand All @@ -75,6 +87,7 @@ export default class TabbedView extends React.Component<IProps, IState> {
private _setActiveTab(tab: Tab) {
const idx = this.props.tabs.indexOf(tab);
if (idx !== -1) {
if (this.props.onChange) this.props.onChange(tab.id);
this.setState({activeTabIndex: idx});
} else {
console.error("Could not find tab " + tab.label + " in tabs");
Expand Down Expand Up @@ -121,8 +134,14 @@ export default class TabbedView extends React.Component<IProps, IState> {
const labels = this.props.tabs.map(tab => this._renderTabLabel(tab));
const panel = this._renderTabPanel(this.props.tabs[this._getActiveTabIndex()]);

const tabbedViewClasses = classNames({
'mx_TabbedView': true,
'mx_TabbedView_tabsOnLeft': this.props.tabLocation == TabLocation.LEFT,
'mx_TabbedView_tabsOnTop': this.props.tabLocation == TabLocation.TOP,
});

return (
<div className="mx_TabbedView">
<div className={tabbedViewClasses}>
<div className="mx_TabbedView_tabLabels">
{labels}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/context_menus/DialpadContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class DialpadContextMenu extends React.Component<IProps, IState>
</div>
<div className="mx_DialPadContextMenu_horizSep" />
<div className="mx_DialPadContextMenu_dialPad">
<Dialpad onDigitPress={this.onDigitPress} hasDialAndDelete={false} />
<Dialpad onDigitPress={this.onDigitPress} hasDial={false} hasDelete={false} />
</div>
</ContextMenu>;
}
Expand Down
Loading