+
- { /* Minimise widget */ }
- { showMinimiseButton && }
- { /* Maximise widget */ }
- { showMaximiseButton && }
- { /* Title */ }
{ this.props.showTitle && this._getTileTitle() }
- { /* Popout widget */ }
{ this.props.showPopout && }
- { /* Context menu */ }
{ ;
}
}
+
+export const getPersistKey = (appId: string) => 'widget_' + appId;
diff --git a/src/components/views/elements/PersistentApp.js b/src/components/views/elements/PersistentApp.js
index a3e413151a..5edf0bb5b5 100644
--- a/src/components/views/elements/PersistentApp.js
+++ b/src/components/views/elements/PersistentApp.js
@@ -74,13 +74,10 @@ export default class PersistentApp extends React.Component {
fullWidth={true}
room={persistentWidgetInRoom}
userId={MatrixClientPeg.get().credentials.userId}
- show={true}
creatorUserId={app.creatorUserId}
widgetPageTitle={WidgetUtils.getWidgetDataTitle(app)}
waitForIframeLoad={app.waitForIframeLoad}
whitelistCapabilities={capWhitelist}
- showDelete={false}
- showMinimise={false}
miniMode={true}
showMenubar={false}
/>;
diff --git a/src/components/views/right_panel/WidgetCard.tsx b/src/components/views/right_panel/WidgetCard.tsx
index 230e71c000..ec30d6c53b 100644
--- a/src/components/views/right_panel/WidgetCard.tsx
+++ b/src/components/views/right_panel/WidgetCard.tsx
@@ -62,67 +62,22 @@ const WidgetCard: React.FC = ({ room, widgetId, onClose }) => {
// Don't render anything as we are about to transition
if (!app || isPinned) return null;
- const header =
- { WidgetUtils.getWidgetName(app) }
- ;
-
- const canModify = WidgetUtils.canUserModifyWidgets(room.roomId);
-
let contextMenu;
if (menuDisplayed) {
const rect = handle.current.getBoundingClientRect();
contextMenu = (
);
}
- const onPinClick = () => {
- WidgetStore.instance.pinWidget(app.id);
- };
-
- const onEditClick = () => {
- WidgetUtils.editWidget(room, app);
- };
-
- let editButton;
- if (canModify) {
- editButton =
- { _t("Edit") }
- ;
- }
-
- const pinButtonClasses = canModify ? "" : "mx_WidgetCard_widePinButton";
-
- let pinButton;
- if (WidgetStore.instance.canPin(app.id)) {
- pinButton =
- { _t("Pin to room") }
- ;
- } else {
- pinButton =
- { _t("Pin to room") }
- ;
- }
-
- const footer =
- { editButton }
- { pinButton }
+ const header =
+ { WidgetUtils.getWidgetName(app) }
= ({ room, widgetId, onClose }) => {
isExpanded={menuDisplayed}
label={_t("Options")}
/>
-
{ contextMenu }
;
return {
- e.preventDefault();
- this._launchManageIntegrations();
- };
-
render() {
+ if (!this.props.showApps) return ;
+
const apps = this.state.apps.map((app, index, arr) => {
const capWhitelist = WidgetUtils.getCapWhitelistForAppTypeInRoomId(app.type, this.props.room.roomId);
@@ -133,7 +119,6 @@ export default class AppsDrawer extends React.Component {
fullWidth={arr.length < 2}
room={this.props.room}
userId={this.props.userId}
- show={this.props.showApps}
creatorUserId={app.creatorUserId}
widgetPageTitle={WidgetUtils.getWidgetDataTitle(app)}
waitForIframeLoad={app.waitForIframeLoad}
@@ -145,21 +130,6 @@ export default class AppsDrawer extends React.Component {
return ;
}
- let addWidget;
- if (this.props.showApps &&
- this._canUserModify()
- ) {
- addWidget =
- [+] { _t('Add a widget') }
- ;
- }
-
let spinner;
if (
apps.length === 0 && WidgetEchoStore.roomHasPendingWidgets(
@@ -191,7 +161,6 @@ export default class AppsDrawer extends React.Component {
{ apps }
{ spinner }
- { this._canUserModify() && addWidget }
);
}
diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js
index 1a116838ac..8eb8276630 100644
--- a/src/components/views/rooms/RoomHeader.js
+++ b/src/components/views/rooms/RoomHeader.js
@@ -42,6 +42,8 @@ export default class RoomHeader extends React.Component {
onLeaveClick: PropTypes.func,
onCancelClick: PropTypes.func,
e2eStatus: PropTypes.string,
+ onAppsClick: PropTypes.func,
+ appsShown: PropTypes.bool,
};
static defaultProps = {
@@ -230,6 +232,17 @@ export default class RoomHeader extends React.Component {
title={_t("Forget room")} />;
}
+ let appsButton;
+ if (this.props.onAppsClick) {
+ appsButton =
+
;
+ }
+
let searchButton;
if (this.props.onSearchClick && this.props.inRoom) {
searchButton =
@@ -243,6 +256,7 @@ export default class RoomHeader extends React.Component {
{ pinnedEventsButton }
{ forgetButton }
+ { appsButton }
{ searchButton }
;
diff --git a/src/components/views/rooms/Stickerpicker.js b/src/components/views/rooms/Stickerpicker.js
index 2faa0fea27..ae7ed48898 100644
--- a/src/components/views/rooms/Stickerpicker.js
+++ b/src/components/views/rooms/Stickerpicker.js
@@ -272,13 +272,10 @@ export default class Stickerpicker extends React.Component {
userId={MatrixClientPeg.get().credentials.userId}
creatorUserId={stickerpickerWidget.sender || MatrixClientPeg.get().credentials.userId}
waitForIframeLoad={true}
- show={true}
showMenubar={true}
onEditClick={this._launchManageIntegrations}
onDeleteClick={this._removeStickerpickerWidgets}
showTitle={false}
- showMinimise={true}
- showDelete={false}
showCancel={false}
showPopout={false}
onMinimiseClick={this._onHideStickersClick}
diff --git a/src/dispatcher/actions.ts b/src/dispatcher/actions.ts
index 26d585b76e..6fb71df30d 100644
--- a/src/dispatcher/actions.ts
+++ b/src/dispatcher/actions.ts
@@ -94,14 +94,4 @@ export enum Action {
* Trigged after the phase of the right panel is set. Should be used with AfterRightPanelPhaseChangePayload.
*/
AfterRightPanelPhaseChange = "after_right_panel_phase_change",
-
- /**
- * Requests that the AppTile deletes the widget. Should be used with the AppTileActionPayload.
- */
- AppTileDelete = "appTile_delete",
-
- /**
- * Requests that the AppTile revokes the widget. Should be used with the AppTileActionPayload.
- */
- AppTileRevoke = "appTile_revoke",
}
diff --git a/src/dispatcher/payloads/AppTileActionPayload.ts b/src/dispatcher/payloads/AppTileActionPayload.ts
deleted file mode 100644
index 3cdb0f8c1f..0000000000
--- a/src/dispatcher/payloads/AppTileActionPayload.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-Copyright 2020 The Matrix.org Foundation C.I.C.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-import { ActionPayload } from "../payloads";
-import { Action } from "../actions";
-
-export interface AppTileActionPayload extends ActionPayload {
- action: Action.AppTileDelete | Action.AppTileRevoke;
- widgetId: string;
-}
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index 0b68c9dd19..b01edad821 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -1104,6 +1104,8 @@
"(~%(count)s results)|one": "(~%(count)s result)",
"Join Room": "Join Room",
"Forget room": "Forget room",
+ "Hide Widgets": "Hide Widgets",
+ "Show Widgets": "Show Widgets",
"Search": "Search",
"Invites": "Invites",
"Favourites": "Favourites",
@@ -1358,9 +1360,6 @@
"You cancelled verification.": "You cancelled verification.",
"Verification cancelled": "Verification cancelled",
"Compare emoji": "Compare emoji",
- "Edit": "Edit",
- "Pin to room": "Pin to room",
- "You can only pin 2 widgets at a time": "You can only pin 2 widgets at a time",
"Sunday": "Sunday",
"Monday": "Monday",
"Tuesday": "Tuesday",
@@ -1379,6 +1378,7 @@
"Error decrypting audio": "Error decrypting audio",
"React": "React",
"Reply": "Reply",
+ "Edit": "Edit",
"Message Actions": "Message Actions",
"Attachment": "Attachment",
"Error decrypting attachment": "Error decrypting attachment",
@@ -1476,8 +1476,6 @@
"Delete widget": "Delete widget",
"Failed to remove widget": "Failed to remove widget",
"An error ocurred whilst trying to remove the widget from the room": "An error ocurred whilst trying to remove the widget from the room",
- "Minimize widget": "Minimize widget",
- "Maximize widget": "Maximize widget",
"Popout widget": "Popout widget",
"More options": "More options",
"Use the
Desktop app to see all encrypted files": "Use the
Desktop app to see all encrypted files",
diff --git a/src/utils/WidgetUtils.js b/src/utils/WidgetUtils.js
index 6cc95efb25..67a0eacc8c 100644
--- a/src/utils/WidgetUtils.js
+++ b/src/utils/WidgetUtils.js
@@ -494,4 +494,16 @@ export default class WidgetUtils {
IntegrationManagers.sharedInstance().getPrimaryManager().open(room, 'type_' + app.type, app.id);
}
}
+
+ static isManagedByManager(app) {
+ if (WidgetUtils.isScalarUrl(app.url)) {
+ const managers = IntegrationManagers.sharedInstance();
+ if (managers.hasManager()) {
+ // TODO: Pick the right manager for the widget
+ const defaultManager = managers.getPrimaryManager();
+ return WidgetUtils.isScalarUrl(defaultManager.apiUrl);
+ }
+ }
+ return false;
+ }
}