PLT-4343 Fixes for mobile main menu (#4148)

* Fixed mobile app link in the main menu to be displayed on mobile browsers

* Fixed doubled up dividers in mobile menu

* Added scrolling to mobile main menu
Этот коммит содержится в:
Harrison Healey
2016-10-04 14:38:19 -04:00
коммит произвёл GitHub
родитель b9dc759449
Коммит 816a738d28
10 изменённых файлов: 20 добавлений и 12 удалений

Просмотреть файл

@@ -30,7 +30,7 @@ export function executeCommand(channelId, message, suggest, success, error) {
msg = msg.substring(0, msg.indexOf(' ')).toLowerCase() + msg.substring(msg.indexOf(' '), msg.length); msg = msg.substring(0, msg.indexOf(' ')).toLowerCase() + msg.substring(msg.indexOf(' '), msg.length);
if (message.indexOf('/shortcuts') !== -1) { if (message.indexOf('/shortcuts') !== -1) {
if (UserAgent.isMobileApp()) { if (UserAgent.isMobile()) {
const err = {message: Utils.localizeMessage('create_post.shortcutsNotSupported', 'Keyboard shortcuts are not supported on your device')}; const err = {message: Utils.localizeMessage('create_post.shortcutsNotSupported', 'Keyboard shortcuts are not supported on your device')};
error(err); error(err);
return; return;

Просмотреть файл

@@ -169,7 +169,7 @@ export default class CreateComment extends React.Component {
} }
commentMsgKeyPress(e) { commentMsgKeyPress(e) {
if (!UserAgent.isMobileApp() && ((this.state.ctrlSend && e.ctrlKey) || !this.state.ctrlSend)) { if (!UserAgent.isMobile() && ((this.state.ctrlSend && e.ctrlKey) || !this.state.ctrlSend)) {
if (e.which === KeyCodes.ENTER && !e.shiftKey && !e.altKey) { if (e.which === KeyCodes.ENTER && !e.shiftKey && !e.altKey) {
e.preventDefault(); e.preventDefault();
ReactDOM.findDOMNode(this.refs.textbox).blur(); ReactDOM.findDOMNode(this.refs.textbox).blur();

Просмотреть файл

@@ -199,7 +199,7 @@ export default class CreatePost extends React.Component {
} }
postMsgKeyPress(e) { postMsgKeyPress(e) {
if (!UserAgent.isMobileApp() && ((this.state.ctrlSend && e.ctrlKey) || !this.state.ctrlSend)) { if (!UserAgent.isMobile() && ((this.state.ctrlSend && e.ctrlKey) || !this.state.ctrlSend)) {
if (e.which === KeyCodes.ENTER && !e.shiftKey && !e.altKey) { if (e.which === KeyCodes.ENTER && !e.shiftKey && !e.altKey) {
e.preventDefault(); e.preventDefault();
ReactDOM.findDOMNode(this.refs.textbox).blur(); ReactDOM.findDOMNode(this.refs.textbox).blur();

Просмотреть файл

@@ -95,7 +95,7 @@ export default class EditPostModal extends React.Component {
} }
handleEditKeyPress(e) { handleEditKeyPress(e) {
if (!UserAgent.isMobileApp() && !this.state.ctrlSend && e.which === KeyCodes.ENTER && !e.shiftKey && !e.altKey) { if (!UserAgent.isMobile() && !this.state.ctrlSend && e.which === KeyCodes.ENTER && !e.shiftKey && !e.altKey) {
e.preventDefault(); e.preventDefault();
ReactDOM.findDOMNode(this.refs.editbox).blur(); ReactDOM.findDOMNode(this.refs.editbox).blur();
this.handleEdit(); this.handleEdit();

Просмотреть файл

@@ -37,7 +37,7 @@ export default class FilteredChannelList extends React.Component {
componentDidMount() { componentDidMount() {
// only focus the search box on desktop so that we don't cause the keyboard to open on mobile // only focus the search box on desktop so that we don't cause the keyboard to open on mobile
if (!UserAgent.isMobileApp()) { if (!UserAgent.isMobile()) {
ReactDOM.findDOMNode(this.refs.filter).focus(); ReactDOM.findDOMNode(this.refs.filter).focus();
} }
} }

Просмотреть файл

@@ -62,7 +62,7 @@ class FilteredUserList extends React.Component {
componentDidMount() { componentDidMount() {
// only focus the search box on desktop so that we don't cause the keyboard to open on mobile // only focus the search box on desktop so that we don't cause the keyboard to open on mobile
if (!UserAgent.isMobileApp()) { if (!UserAgent.isMobile()) {
ReactDOM.findDOMNode(this.refs.filter).focus(); ReactDOM.findDOMNode(this.refs.filter).focus();
} }
} }

Просмотреть файл

@@ -221,6 +221,10 @@
.divider { .divider {
border-top: 1px solid transparent; border-top: 1px solid transparent;
margin: 0.5em 0; margin: 0.5em 0;
& + .divider {
display: none;
}
} }
.team__header { .team__header {
@@ -302,10 +306,6 @@
.admin-navbar-dropdown__icon { .admin-navbar-dropdown__icon {
fill: $white; fill: $white;
} }
.divider + .divider {
display: none;
}
} }
.user__picture { .user__picture {

Просмотреть файл

@@ -5,6 +5,7 @@
border-right: $border-gray; border-right: $border-gray;
display: none; display: none;
height: 100%; height: 100%;
overflow: auto;
padding: 0 0 2em; padding: 0 0 2em;
position: absolute; position: absolute;
right: 0; right: 0;

Просмотреть файл

@@ -911,7 +911,7 @@ export function getSuggestedCommands(command, suggestionId, component) {
(data) => { (data) => {
var matches = []; var matches = [];
data.forEach((cmd) => { data.forEach((cmd) => {
if (cmd.trigger !== 'shortcuts' || !UserAgent.isMobileApp()) { if (cmd.trigger !== 'shortcuts' || !UserAgent.isMobile()) {
if (('/' + cmd.trigger).indexOf(command) === 0) { if (('/' + cmd.trigger).indexOf(command) === 0) {
const s = '/' + cmd.trigger; const s = '/' + cmd.trigger;
let hint = ''; let hint = '';

Просмотреть файл

@@ -77,8 +77,15 @@ export function isAndroidWeb() {
return isAndroidChrome(); return isAndroidChrome();
} }
// Returns true if and only if the user is using a Mattermost mobile app. This will return false if the user is using the
// web browser on a mobile device.
export function isMobileApp() { export function isMobileApp() {
return isAndroid() || isIos(); return userAgent.indexOf('iPhone') !== -1 && userAgent.indexOf('Safari') === -1 && userAgent.indexOf('CriOS') === -1;
}
// Returns true if and only if the user is using Mattermost from either the mobile app or the web browser on a mobile device.
export function isMobile() {
return isIos() || isAndroid();
} }
export function isFirefox() { export function isFirefox() {