Add button to remove all stickerpacks

This commit is contained in:
Richard Lewis 2018-02-05 11:49:44 +00:00
parent 34de3729fe
commit 992c4771f4

View file

@ -33,12 +33,13 @@ export default class Stickerpack extends React.Component {
this.onHideStickersClick = this.onHideStickersClick.bind(this); this.onHideStickersClick = this.onHideStickersClick.bind(this);
this.onFinished = this.onFinished.bind(this); this.onFinished = this.onFinished.bind(this);
this._launchManageIntegrations = this._launchManageIntegrations.bind(this); this._launchManageIntegrations = this._launchManageIntegrations.bind(this);
this._removeStickerpackWidgets = this._removeStickerpackWidgets.bind(this);
this.defaultStickersContent = ( this.defaultStickersContent = (
<div className='mx_Stickers_contentPlaceholder'> <div className='mx_Stickers_contentPlaceholder'>
<p>You don't currently have any stickerpacks enabled</p> <p>{_t("You don't currently have any stickerpacks enabled")}</p>
<p>Click <a href=''>here</a> to add some!</p> <p>{_t("Click")} <span className='mx_Stickers_addLink' onClick={this._launchManageIntegrations} > { _t("here") } </span>{_t("to add some!")}</p>
<img src='img/stickerpack-placeholder.png' alt='Add a stickerpack' /> <img src='img/stickerpack-placeholder.png' alt={_t('Add a stickerpack')} />
</div> </div>
); );
this.popoverWidth = 300; this.popoverWidth = 300;
@ -50,6 +51,11 @@ export default class Stickerpack extends React.Component {
}; };
} }
_removeStickerpackWidgets() {
console.warn('Removing stickerpack widgets');
Widgets.removeStickerpackWidgets()
}
componentDidMount() { componentDidMount() {
this.scalarClient = null; this.scalarClient = null;
if (SdkConfig.get().integrations_ui_url && SdkConfig.get().integrations_rest_url) { if (SdkConfig.get().integrations_ui_url && SdkConfig.get().integrations_rest_url) {
@ -91,6 +97,14 @@ export default class Stickerpack extends React.Component {
width: this.popoverWidth, width: this.popoverWidth,
}} }}
> >
<div
style={{
'float': 'right',
'fontSize': 'smaller',
'cursor': 'pointer',
}}
onClick={this._removeStickerpackWidgets()}
>X</div>
<AppTile <AppTile
id={stickerpackWidget.id} id={stickerpackWidget.id}
url={stickerpackWidget.content.url} url={stickerpackWidget.content.url}
@ -121,7 +135,7 @@ export default class Stickerpack extends React.Component {
); );
} else { } else {
// Default content to show if stickerpack widget not added // Default content to show if stickerpack widget not added
stickersContent = <p>Click here to add your first sitckerpack</p>; stickersContent = this.defaultStickersContent;
} }
this.setState({stickersContent}); this.setState({stickersContent});
} }