Show URL when hovering over links
This commit is contained in:
parent
e4f961f2f0
commit
e4e40ec7c0
32
src/browser/components/HoveringURL.jsx
Normal file
32
src/browser/components/HoveringURL.jsx
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
const React = require('react');
|
||||||
|
|
||||||
|
const divStyle = {
|
||||||
|
backgroundColor: 'whitesmoke',
|
||||||
|
position: 'absolute',
|
||||||
|
bottom: 0,
|
||||||
|
paddingLeft: 4,
|
||||||
|
paddingRight: 16,
|
||||||
|
borderTopRightRadius: 4
|
||||||
|
};
|
||||||
|
|
||||||
|
const spanStyle = {
|
||||||
|
color: 'gray'
|
||||||
|
};
|
||||||
|
|
||||||
|
class HoveringURL extends React.Component {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div style={divStyle}>
|
||||||
|
<span style={spanStyle}>
|
||||||
|
{this.props.targetURL}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HoveringURL.propTypes = {
|
||||||
|
targetURL: React.PropTypes.string
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = HoveringURL;
|
|
@ -7,6 +7,7 @@ const url = require('url');
|
||||||
const LoginModal = require('./LoginModal.jsx');
|
const LoginModal = require('./LoginModal.jsx');
|
||||||
const MattermostView = require('./MattermostView.jsx');
|
const MattermostView = require('./MattermostView.jsx');
|
||||||
const TabBar = require('./TabBar.jsx');
|
const TabBar = require('./TabBar.jsx');
|
||||||
|
const HoveringURL = require('./HoveringURL.jsx');
|
||||||
|
|
||||||
const MainPage = React.createClass({
|
const MainPage = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
@ -22,7 +23,8 @@ const MainPage = React.createClass({
|
||||||
mentionCounts: new Array(this.props.teams.length),
|
mentionCounts: new Array(this.props.teams.length),
|
||||||
unreadAtActive: new Array(this.props.teams.length),
|
unreadAtActive: new Array(this.props.teams.length),
|
||||||
mentionAtActiveCounts: new Array(this.props.teams.length),
|
mentionAtActiveCounts: new Array(this.props.teams.length),
|
||||||
loginQueue: []
|
loginQueue: [],
|
||||||
|
targetURL: ''
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -196,6 +198,9 @@ const MainPage = React.createClass({
|
||||||
loginQueue.shift();
|
loginQueue.shift();
|
||||||
this.setState({loginQueue});
|
this.setState({loginQueue});
|
||||||
},
|
},
|
||||||
|
handleTargetURLChange(targetURL) {
|
||||||
|
this.setState({targetURL});
|
||||||
|
},
|
||||||
render() {
|
render() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
@ -234,6 +239,7 @@ const MainPage = React.createClass({
|
||||||
src={team.url}
|
src={team.url}
|
||||||
name={team.name}
|
name={team.name}
|
||||||
disablewebsecurity={this.props.disablewebsecurity}
|
disablewebsecurity={this.props.disablewebsecurity}
|
||||||
|
onTargetURLChange={self.handleTargetURLChange}
|
||||||
onUnreadCountChange={handleUnreadCountChange}
|
onUnreadCountChange={handleUnreadCountChange}
|
||||||
onNotificationClick={handleNotificationClick}
|
onNotificationClick={handleNotificationClick}
|
||||||
ref={id}
|
ref={id}
|
||||||
|
@ -268,6 +274,7 @@ const MainPage = React.createClass({
|
||||||
{ tabsRow }
|
{ tabsRow }
|
||||||
{ viewsRow }
|
{ viewsRow }
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<HoveringURL targetURL={this.state.targetURL}/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ const MattermostView = React.createClass({
|
||||||
disablewebsecurity: React.PropTypes.bool,
|
disablewebsecurity: React.PropTypes.bool,
|
||||||
name: React.PropTypes.string,
|
name: React.PropTypes.string,
|
||||||
id: React.PropTypes.string,
|
id: React.PropTypes.string,
|
||||||
|
onTargetURLChange: React.PropTypes.func,
|
||||||
onUnreadCountChange: React.PropTypes.func,
|
onUnreadCountChange: React.PropTypes.func,
|
||||||
src: React.PropTypes.string,
|
src: React.PropTypes.string,
|
||||||
style: React.PropTypes.object
|
style: React.PropTypes.object
|
||||||
|
@ -108,6 +109,12 @@ const MattermostView = React.createClass({
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
webview.addEventListener('update-target-url', (event) => {
|
||||||
|
if (self.props.onTargetURLChange) {
|
||||||
|
self.props.onTargetURLChange(event.url);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
webview.addEventListener('ipc-message', (event) => {
|
webview.addEventListener('ipc-message', (event) => {
|
||||||
switch (event.channel) {
|
switch (event.channel) {
|
||||||
case 'onUnreadCountChange':
|
case 'onUnreadCountChange':
|
||||||
|
|
Loading…
Reference in a new issue