From 0f0e89d394ce8a78482b41b6b5518d140d8b589d Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Wed, 25 Apr 2018 12:49:30 +0100 Subject: [PATCH] Add a button to 'pop out' widgets in to their own tab. --- res/img/button-new-window.svg | 12 ++++++ src/components/views/elements/AppTile.js | 37 ++++++++++++++----- .../views/elements/TintableSvgButton.js | 7 +++- src/i18n/strings/en_EN.json | 1 + 4 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 res/img/button-new-window.svg diff --git a/res/img/button-new-window.svg b/res/img/button-new-window.svg new file mode 100644 index 0000000000..dd1225e798 --- /dev/null +++ b/res/img/button-new-window.svg @@ -0,0 +1,12 @@ + + + + + + diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index 41be5738af..d3c66aaa4f 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -54,6 +54,7 @@ export default class AppTile extends React.Component { this._onInitialLoad = this._onInitialLoad.bind(this); this._grantWidgetPermission = this._grantWidgetPermission.bind(this); this._revokeWidgetPermission = this._revokeWidgetPermission.bind(this); + this._onPopoutWidgetClick = this._onPopoutWidgetClick.bind(this); } /** @@ -499,6 +500,13 @@ export default class AppTile extends React.Component { } } + _onPopoutWidgetClick(e) { + // Using Object.assign workaround as the following opens in a new window instead of a new tab. + // window.open(this._getSafeUrl(), '_blank', 'noopener=yes,noreferrer=yes'); + Object.assign(document.createElement('a'), + { target: '_blank', href: this._getSafeUrl(), rel: 'noopener noreferrer'}).click(); + } + render() { let appTileBody; @@ -581,6 +589,7 @@ export default class AppTile extends React.Component { // Picture snapshot - only show button when apps are maximised. const showPictureSnapshotButton = this._hasCapability('screenshot') && this.props.show; const showPictureSnapshotIcon = 'img/camera_green.svg'; + const popoutWidgetIcon = 'img/button-new-window.svg'; const windowStateIcon = (this.props.show ? 'img/minimize.svg' : 'img/maximize.svg'); return ( @@ -599,15 +608,25 @@ export default class AppTile extends React.Component { { this.props.showTitle && this._getTileTitle() } - { /* Snapshot widget */ } - { showPictureSnapshotButton && } + { /* Popout widget */ } + + + { /* Snapshot widget */ } + { showPictureSnapshotButton && } { /* Edit widget */ } { showEditButton && - + /> ); } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 297f3756cd..d818f8bb02 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -100,6 +100,7 @@ "You need to be logged in.": "You need to be logged in.", "You need to be able to invite users to do that.": "You need to be able to invite users to do that.", "Unable to create widget.": "Unable to create widget.", + "Popout widget": "Popout widget", "Missing roomId.": "Missing roomId.", "Failed to send request.": "Failed to send request.", "This room is not recognised.": "This room is not recognised.",