Merge pull request #241 from Razzeee/Change-title
Change window title to the one thats set from the platform for the current channel
This commit is contained in:
@@ -9,6 +9,7 @@ Release date: TBD
|
|||||||
### Improvements
|
### Improvements
|
||||||
|
|
||||||
#### All platforms
|
#### All platforms
|
||||||
|
- Show current channel/team in window title
|
||||||
- Changed display of unread messages on the team tabbar, they are now shown as bold text
|
- Changed display of unread messages on the team tabbar, they are now shown as bold text
|
||||||
- Reload only the selected tab and keep its URL on "Reload" and "Clear Cache and Reload".
|
- Reload only the selected tab and keep its URL on "Reload" and "Clear Cache and Reload".
|
||||||
- Disabled `eval()` function for security improvements.
|
- Disabled `eval()` function for security improvements.
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Mattermost</title>
|
|
||||||
<link rel="stylesheet" href="modules/bootstrap/css/bootstrap.min.css">
|
<link rel="stylesheet" href="modules/bootstrap/css/bootstrap.min.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@@ -94,6 +94,11 @@ var MainPage = React.createClass({
|
|||||||
key: newKey
|
key: newKey
|
||||||
});
|
});
|
||||||
this.handleOnTeamFocused(key);
|
this.handleOnTeamFocused(key);
|
||||||
|
|
||||||
|
var webview = document.getElementById('mattermostView' + key);
|
||||||
|
ipcRenderer.send('update-title', {
|
||||||
|
title: webview.getTitle()
|
||||||
|
});
|
||||||
},
|
},
|
||||||
handleUnreadCountChange: function(index, unreadCount, mentionCount, isUnread, isMentioned) {
|
handleUnreadCountChange: function(index, unreadCount, mentionCount, isUnread, isMentioned) {
|
||||||
var unreadCounts = this.state.unreadCounts;
|
var unreadCounts = this.state.unreadCounts;
|
||||||
@@ -196,8 +201,9 @@ var MainPage = React.createClass({
|
|||||||
thisObj.handleSelect(index);
|
thisObj.handleSelect(index);
|
||||||
}
|
}
|
||||||
var id = 'mattermostView' + index;
|
var id = 'mattermostView' + index;
|
||||||
return (<MattermostView key={ id } id={ id } style={ thisObj.visibleStyle(thisObj.state.key === index) } src={ team.url } name={ team.name } onUnreadCountChange={ handleUnreadCountChange }
|
var is_active = thisObj.state.key === index;
|
||||||
onNotificationClick={ handleNotificationClick } ref={ id } />)
|
return (<MattermostView key={ id } id={ id } style={ thisObj.visibleStyle(is_active) } src={ team.url } name={ team.name } onUnreadCountChange={ handleUnreadCountChange }
|
||||||
|
onNotificationClick={ handleNotificationClick } ref={ id } active={ is_active } />)
|
||||||
});
|
});
|
||||||
var views_row = (<Row>
|
var views_row = (<Row>
|
||||||
{ views }
|
{ views }
|
||||||
@@ -403,6 +409,14 @@ var MattermostView = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
webview.addEventListener('page-title-updated', function(event) {
|
||||||
|
if (thisObj.props.active) {
|
||||||
|
ipcRenderer.send('update-title', {
|
||||||
|
title: event.title
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
webview.addEventListener('console-message', (e) => {
|
webview.addEventListener('console-message', (e) => {
|
||||||
const message = `[${this.props.name}] ${e.message}`;
|
const message = `[${this.props.name}] ${e.message}`;
|
||||||
switch (e.level) {
|
switch (e.level) {
|
||||||
|
@@ -229,6 +229,11 @@ app.on('ready', function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.on('update-title', function(event, arg) {
|
||||||
|
mainWindow.setTitle(arg.title);
|
||||||
|
});
|
||||||
|
|
||||||
if (shouldShowTrayIcon()) {
|
if (shouldShowTrayIcon()) {
|
||||||
// set up tray icon
|
// set up tray icon
|
||||||
trayIcon = new Tray(trayImages.normal);
|
trayIcon = new Tray(trayImages.normal);
|
||||||
|
@@ -1,5 +1,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Mattermost Desktop testing html</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>window.open() test</h1>
|
<h1>window.open() test</h1>
|
||||||
<p>
|
<p>
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const path = require('path');
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const http = require('http');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
const env = require('../../modules/environment');
|
const env = require('../../modules/environment');
|
||||||
|
|
||||||
@@ -19,6 +20,17 @@ describe('browser/index.html', function() {
|
|||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const serverPort = 8181;
|
||||||
|
|
||||||
|
before(function() {
|
||||||
|
this.server = http.createServer(function(req, res) {
|
||||||
|
res.writeHead(200, {
|
||||||
|
'Content-Type': 'text/html'
|
||||||
|
});
|
||||||
|
res.end(fs.readFileSync(path.resolve(env.sourceRootDir, 'test/modules/test.html'), 'utf-8'));
|
||||||
|
}).listen(serverPort, '127.0.0.1');
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
fs.writeFileSync(env.configFilePath, JSON.stringify(config));
|
fs.writeFileSync(env.configFilePath, JSON.stringify(config));
|
||||||
this.app = env.getSpectronApp();
|
this.app = env.getSpectronApp();
|
||||||
@@ -31,6 +43,10 @@ describe('browser/index.html', function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
after(function(done) {
|
||||||
|
this.server.close(done);
|
||||||
|
})
|
||||||
|
|
||||||
it('should NOT show tabs when there is one team', function() {
|
it('should NOT show tabs when there is one team', function() {
|
||||||
fs.writeFileSync(env.configFilePath, JSON.stringify({
|
fs.writeFileSync(env.configFilePath, JSON.stringify({
|
||||||
url: env.mattermostURL
|
url: env.mattermostURL
|
||||||
@@ -78,4 +94,81 @@ describe('browser/index.html', function() {
|
|||||||
.waitForVisible('#mattermostView0-fail', 20000)
|
.waitForVisible('#mattermostView0-fail', 20000)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should set window title by using webview\'s one', function() {
|
||||||
|
fs.writeFileSync(env.configFilePath, JSON.stringify({
|
||||||
|
version: 1,
|
||||||
|
teams: [{
|
||||||
|
name: 'title_test',
|
||||||
|
url: `http://localhost:${serverPort}`
|
||||||
|
}]
|
||||||
|
}));
|
||||||
|
return this.app.restart().then(() => {
|
||||||
|
return this.app.client.waitUntilWindowLoaded().pause(500);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return this.app.browserWindow.getTitle().should.eventually.equal('Mattermost Desktop testing html');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update window title when the activated tab\'s title is updated', function() {
|
||||||
|
fs.writeFileSync(env.configFilePath, JSON.stringify({
|
||||||
|
version: 1,
|
||||||
|
teams: [{
|
||||||
|
name: 'title_test_0',
|
||||||
|
url: `http://localhost:${serverPort}`
|
||||||
|
}, {
|
||||||
|
name: 'title_test_1',
|
||||||
|
url: `http://localhost:${serverPort}`
|
||||||
|
}]
|
||||||
|
}));
|
||||||
|
return this.app.restart().then(() => {
|
||||||
|
return this.app.client.waitUntilWindowLoaded().pause(500);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return this.app.client
|
||||||
|
.windowByIndex(1)
|
||||||
|
.execute(function() {
|
||||||
|
document.title = 'Title 0';
|
||||||
|
})
|
||||||
|
.windowByIndex(0)
|
||||||
|
.browserWindow.getTitle().should.eventually.equal('Title 0')
|
||||||
|
.windowByIndex(2)
|
||||||
|
.execute(function() {
|
||||||
|
document.title = 'Title 1';
|
||||||
|
})
|
||||||
|
.windowByIndex(0)
|
||||||
|
.browserWindow.getTitle().should.eventually.equal('Title 0')
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update window title when a tab is selected', function() {
|
||||||
|
fs.writeFileSync(env.configFilePath, JSON.stringify({
|
||||||
|
version: 1,
|
||||||
|
teams: [{
|
||||||
|
name: 'title_test_0',
|
||||||
|
url: `http://localhost:${serverPort}`
|
||||||
|
}, {
|
||||||
|
name: 'title_test_1',
|
||||||
|
url: `http://localhost:${serverPort}`
|
||||||
|
}]
|
||||||
|
}));
|
||||||
|
return this.app.restart().then(() => {
|
||||||
|
return this.app.client
|
||||||
|
.waitUntilWindowLoaded()
|
||||||
|
.pause(500)
|
||||||
|
.windowByIndex(1)
|
||||||
|
.execute(function() {
|
||||||
|
document.title = 'Title 0';
|
||||||
|
})
|
||||||
|
.windowByIndex(2)
|
||||||
|
.execute(function() {
|
||||||
|
document.title = 'Title 1';
|
||||||
|
})
|
||||||
|
.windowByIndex(0)
|
||||||
|
.browserWindow.getTitle().should.eventually.equal('Title 0')
|
||||||
|
.click('#teamTabItem1')
|
||||||
|
.browserWindow.getTitle().should.eventually.equal('Title 1');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user