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

Commit b2c26e6

Browse files
authored
Merge pull request #1920 from matrix-org/rxl881/refreshWidget
Add a "reload widget" button.
2 parents 6288e9b + 9753326 commit b2c26e6

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

res/img/button-refresh.svg

Lines changed: 12 additions & 0 deletions
Loading

src/components/views/elements/AppTile.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export default class AppTile extends React.Component {
5555
this._grantWidgetPermission = this._grantWidgetPermission.bind(this);
5656
this._revokeWidgetPermission = this._revokeWidgetPermission.bind(this);
5757
this._onPopoutWidgetClick = this._onPopoutWidgetClick.bind(this);
58+
this._onReloadWidgetClick = this._onReloadWidgetClick.bind(this);
5859
}
5960

6061
/**
@@ -533,6 +534,11 @@ export default class AppTile extends React.Component {
533534
{ target: '_blank', href: this._getSafeUrl(), rel: 'noopener noreferrer'}).click();
534535
}
535536

537+
_onReloadWidgetClick(e) {
538+
// Reload iframe in this way to avoid cross-origin restrictions
539+
this.refs.appFrame.src = this.refs.appFrame.src;
540+
}
541+
536542
render() {
537543
let appTileBody;
538544

@@ -620,6 +626,7 @@ export default class AppTile extends React.Component {
620626
const showPictureSnapshotButton = this._hasCapability('m.capability.screenshot') && this.props.show;
621627
const showPictureSnapshotIcon = 'img/camera_green.svg';
622628
const popoutWidgetIcon = 'img/button-new-window.svg';
629+
const reloadWidgetIcon = 'img/button-refresh.svg';
623630
const windowStateIcon = (this.props.show ? 'img/minimize.svg' : 'img/maximize.svg');
624631

625632
return (
@@ -638,6 +645,16 @@ export default class AppTile extends React.Component {
638645
{ this.props.showTitle && this._getTileTitle() }
639646
</span>
640647
<span className="mx_AppTileMenuBarWidgets">
648+
{ /* Reload widget */ }
649+
{ this.props.showReload && <TintableSvgButton
650+
src={reloadWidgetIcon}
651+
className="mx_AppTileMenuBarWidget mx_AppTileMenuBarWidgetPadding"
652+
title={_t('Reload widget')}
653+
onClick={this._onReloadWidgetClick}
654+
width="10"
655+
height="10"
656+
/> }
657+
641658
{ /* Popout widget */ }
642659
{ this.props.showPopout && <TintableSvgButton
643660
src={popoutWidgetIcon}
@@ -721,6 +738,11 @@ AppTile.propTypes = {
721738
showDelete: PropTypes.bool,
722739
// Optionally hide the popout widget icon
723740
showPopout: PropTypes.bool,
741+
// Optionally show the reload widget icon
742+
// This is not currently intended for use with production widgets. However
743+
// it can be useful when developing persistent widgets in order to avoid
744+
// having to reload all of riot to get new widget content.
745+
showReload: PropTypes.bool,
724746
// Widget capabilities to allow by default (without user confirmation)
725747
// NOTE -- Use with caution. This is intended to aid better integration / UX
726748
// basic widget capabilities, e.g. injecting sticker message events.
@@ -740,6 +762,7 @@ AppTile.defaultProps = {
740762
showMinimise: true,
741763
showDelete: true,
742764
showPopout: true,
765+
showReload: false,
743766
handleMinimisePointerEvents: false,
744767
whitelistCapabilities: [],
745768
userWidget: false,

src/i18n/strings/en_EN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"You need to be logged in.": "You need to be logged in.",
105105
"You need to be able to invite users to do that.": "You need to be able to invite users to do that.",
106106
"Unable to create widget.": "Unable to create widget.",
107+
"Reload widget": "Reload widget",
107108
"Missing roomId.": "Missing roomId.",
108109
"Failed to send request.": "Failed to send request.",
109110
"This room is not recognised.": "This room is not recognised.",

0 commit comments

Comments
 (0)