Merge pull request #5527 from matrix-org/travis/widget-nav

Wire up MSC2931 widget navigation
This commit is contained in:
Travis Ralston 2021-01-18 09:09:32 -07:00 committed by GitHub
commit 83fb698bbc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 5 deletions

View file

@ -82,7 +82,7 @@
"linkifyjs": "^2.1.9", "linkifyjs": "^2.1.9",
"lodash": "^4.17.19", "lodash": "^4.17.19",
"matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop", "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop",
"matrix-widget-api": "^0.1.0-beta.10", "matrix-widget-api": "0.1.0-beta.11",
"minimist": "^1.2.5", "minimist": "^1.2.5",
"pako": "^1.0.11", "pako": "^1.0.11",
"parse5": "^5.1.1", "parse5": "^5.1.1",

View file

@ -584,6 +584,7 @@
"Send stickers into this room": "Send stickers into this room", "Send stickers into this room": "Send stickers into this room",
"Send stickers into your active room": "Send stickers into your active room", "Send stickers into your active room": "Send stickers into your active room",
"Change which room you're viewing": "Change which room you're viewing", "Change which room you're viewing": "Change which room you're viewing",
"Change which room, message, or user you're viewing": "Change which room, message, or user you're viewing",
"Change the topic of this room": "Change the topic of this room", "Change the topic of this room": "Change the topic of this room",
"See when the topic changes in this room": "See when the topic changes in this room", "See when the topic changes in this room": "See when the topic changes in this room",
"Change the topic of your active room": "Change the topic of your active room", "Change the topic of your active room": "Change the topic of your active room",

View file

@ -20,9 +20,16 @@ export enum ElementWidgetActions {
ClientReady = "im.vector.ready", ClientReady = "im.vector.ready",
HangupCall = "im.vector.hangup", HangupCall = "im.vector.hangup",
OpenIntegrationManager = "integration_manager_open", OpenIntegrationManager = "integration_manager_open",
/**
* @deprecated Use MSC2931 instead
*/
ViewRoom = "io.element.view_room", ViewRoom = "io.element.view_room",
} }
/**
* @deprecated Use MSC2931 instead
*/
export interface IViewRoomApiRequest extends IWidgetApiRequest { export interface IViewRoomApiRequest extends IWidgetApiRequest {
data: { data: {
room_id: string; // eslint-disable-line camelcase room_id: string; // eslint-disable-line camelcase

View file

@ -15,5 +15,8 @@
*/ */
export enum ElementWidgetCapabilities { export enum ElementWidgetCapabilities {
/**
* @deprecated Use MSC2931 instead.
*/
CanChangeViewedRoom = "io.element.view_room", CanChangeViewedRoom = "io.element.view_room",
} }

View file

@ -43,6 +43,7 @@ import { EventType } from "matrix-js-sdk/src/@types/event";
import { CHAT_EFFECTS } from "../../effects"; import { CHAT_EFFECTS } from "../../effects";
import { containsEmoji } from "../../effects/utils"; import { containsEmoji } from "../../effects/utils";
import dis from "../../dispatcher/dispatcher"; import dis from "../../dispatcher/dispatcher";
import {tryTransformPermalinkToLocalHref} from "../../utils/permalinks/Permalinks";
// TODO: Purge this from the universe // TODO: Purge this from the universe
@ -171,4 +172,12 @@ export class StopGapWidgetDriver extends WidgetDriver {
}, },
}); });
} }
public async navigate(uri: string): Promise<void> {
const localUri = tryTransformPermalinkToLocalHref(uri);
if (!localUri || localUri === uri) { // parse failure can lead to an unmodified URL
throw new Error("Failed to transform URI");
}
window.location.hash = localUri; // it'll just be a fragment
}
} }

View file

@ -60,6 +60,9 @@ export class CapabilityText {
[ElementWidgetCapabilities.CanChangeViewedRoom]: { [ElementWidgetCapabilities.CanChangeViewedRoom]: {
[GENERIC_WIDGET_KIND]: _td("Change which room you're viewing"), [GENERIC_WIDGET_KIND]: _td("Change which room you're viewing"),
}, },
[MatrixCapabilities.MSC2931Navigate]: {
[GENERIC_WIDGET_KIND]: _td("Change which room, message, or user you're viewing"),
},
}; };
private static stateSendRecvCaps: ISendRecvStaticCapText = { private static stateSendRecvCaps: ISendRecvStaticCapText = {

View file

@ -1809,6 +1809,11 @@
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag== integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==
"@types/events@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==
"@types/fbemitter@*": "@types/fbemitter@*":
version "2.0.32" version "2.0.32"
resolved "https://registry.yarnpkg.com/@types/fbemitter/-/fbemitter-2.0.32.tgz#8ed204da0f54e9c8eaec31b1eec91e25132d082c" resolved "https://registry.yarnpkg.com/@types/fbemitter/-/fbemitter-2.0.32.tgz#8ed204da0f54e9c8eaec31b1eec91e25132d082c"
@ -6580,11 +6585,12 @@ matrix-react-test-utils@^0.2.2:
resolved "https://registry.yarnpkg.com/matrix-react-test-utils/-/matrix-react-test-utils-0.2.2.tgz#c87144d3b910c7edc544a6699d13c7c2bf02f853" resolved "https://registry.yarnpkg.com/matrix-react-test-utils/-/matrix-react-test-utils-0.2.2.tgz#c87144d3b910c7edc544a6699d13c7c2bf02f853"
integrity sha512-49+7gfV6smvBIVbeloql+37IeWMTD+fiywalwCqk8Dnz53zAFjKSltB3rmWHso1uecLtQEcPtCijfhzcLXAxTQ== integrity sha512-49+7gfV6smvBIVbeloql+37IeWMTD+fiywalwCqk8Dnz53zAFjKSltB3rmWHso1uecLtQEcPtCijfhzcLXAxTQ==
matrix-widget-api@^0.1.0-beta.10: matrix-widget-api@0.1.0-beta.11:
version "0.1.0-beta.10" version "0.1.0-beta.11"
resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-0.1.0-beta.10.tgz#2e4d658d90ff3152c5567089b4ddd21fb44ec1dd" resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-0.1.0-beta.11.tgz#3658e244bf82eebea36e64475ebfce86b778b476"
integrity sha512-yX2UURjM1zVp7snPiOFcH9+FDBdHfAdt5HEAyDUHGJ7w/F2zOtcK/y0dMlZ1+XhxY7Wv0IBZH0US8X/ioJRX1A== integrity sha512-RxIghopRKTQdmYMJzZg/QR+wcPcKe9S1pZZ31zN/M1LKsvTLThBYdMcP1idKh7MkhpO9eCdCVjJOMJTrqxNzbQ==
dependencies: dependencies:
"@types/events" "^3.0.0"
events "^3.2.0" events "^3.2.0"
mdast-util-compact@^1.0.0: mdast-util-compact@^1.0.0: