From 10ab8d616baeacbd95f41300382baaa8963fa5fd Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 5 Oct 2022 11:12:07 -0600 Subject: [PATCH 1/2] Delete the remainder of groups Fixes https://github.com/vector-im/element-web/issues/22770 Continues https://github.com/matrix-org/matrix-react-sdk/pull/8027 --- src/IConfigOptions.ts | 3 -- src/PageTypes.ts | 1 - src/PosthogTrackers.ts | 1 - src/SdkConfig.ts | 1 - src/components/structures/LegacyGroupView.tsx | 51 ------------------- src/components/structures/LoggedInView.tsx | 7 --- src/components/structures/MatrixChat.tsx | 21 -------- src/group_helpers.tsx | 45 ---------------- src/linkify-matrix.ts | 28 ---------- .../permalinks/ElementPermalinkConstructor.ts | 8 --- .../MatrixSchemePermalinkConstructor.ts | 4 -- .../MatrixToPermalinkConstructor.ts | 6 --- src/utils/permalinks/PermalinkConstructor.ts | 18 ++----- src/utils/permalinks/Permalinks.ts | 10 ---- 14 files changed, 4 insertions(+), 200 deletions(-) delete mode 100644 src/components/structures/LegacyGroupView.tsx delete mode 100644 src/group_helpers.tsx diff --git a/src/IConfigOptions.ts b/src/IConfigOptions.ts index b877cb90af5..a6f7d0cdb4d 100644 --- a/src/IConfigOptions.ts +++ b/src/IConfigOptions.ts @@ -179,9 +179,6 @@ export interface IConfigOptions { sync_timeline_limit?: number; dangerously_allow_unsafe_and_insecure_passwords?: boolean; // developer option - - // XXX: Undocumented URL for the "Learn more about spaces" link in the "Communities don't exist" messaging. - spaces_learn_more_url?: string; } export interface ISsoRedirectOptions { diff --git a/src/PageTypes.ts b/src/PageTypes.ts index fb0424f6e05..1e181b4e3f1 100644 --- a/src/PageTypes.ts +++ b/src/PageTypes.ts @@ -20,7 +20,6 @@ enum PageType { HomePage = "home_page", RoomView = "room_view", UserView = "user_view", - LegacyGroupView = "legacy_group_view", } export default PageType; diff --git a/src/PosthogTrackers.ts b/src/PosthogTrackers.ts index 0422f0bf9b6..4814daa6f47 100644 --- a/src/PosthogTrackers.ts +++ b/src/PosthogTrackers.ts @@ -41,7 +41,6 @@ const loggedInPageTypeMap: Record = { [PageType.HomePage]: "Home", [PageType.RoomView]: "Room", [PageType.UserView]: "User", - [PageType.LegacyGroupView]: "Group", }; export default class PosthogTrackers { diff --git a/src/SdkConfig.ts b/src/SdkConfig.ts index 7a869827235..14fd0694d02 100644 --- a/src/SdkConfig.ts +++ b/src/SdkConfig.ts @@ -44,7 +44,6 @@ export const DEFAULTS: IConfigOptions = { logo: require("../res/img/element-desktop-logo.svg").default, url: "https://element.io/get-started", }, - spaces_learn_more_url: "https://element.io/blog/spaces-blast-out-of-beta/", }; export default class SdkConfig { diff --git a/src/components/structures/LegacyGroupView.tsx b/src/components/structures/LegacyGroupView.tsx deleted file mode 100644 index 236c4f6ecde..00000000000 --- a/src/components/structures/LegacyGroupView.tsx +++ /dev/null @@ -1,51 +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 * as React from "react"; - -import AutoHideScrollbar from './AutoHideScrollbar'; -import { _t } from "../../languageHandler"; -import SdkConfig, { DEFAULTS } from "../../SdkConfig"; - -interface IProps { - groupId: string; -} - -const LegacyGroupView: React.FC = ({ groupId }) => { - // XXX: Stealing classes from the HomePage component for CSS simplicity. - // XXX: Inline CSS because this is all temporary - const learnMoreUrl = SdkConfig.get().spaces_learn_more_url ?? DEFAULTS.spaces_learn_more_url; - return -
-

{ _t("That link is no longer supported") }

-

- { _t( - "You're trying to access a community link (%(groupId)s).
" + - "Communities are no longer supported and have been replaced by spaces." + - "Learn more about spaces here.", - { groupId }, - { - br: () =>
, - br2: () =>
, - a: (sub) => { sub }, - }, - ) } -

-
-
; -}; - -export default LegacyGroupView; diff --git a/src/components/structures/LoggedInView.tsx b/src/components/structures/LoggedInView.tsx index 6c8aad5f71e..872c69c01d2 100644 --- a/src/components/structures/LoggedInView.tsx +++ b/src/components/structures/LoggedInView.tsx @@ -67,7 +67,6 @@ import RightPanelStore from '../../stores/right-panel/RightPanelStore'; import { TimelineRenderingType } from "../../contexts/RoomContext"; import { KeyBindingAction } from "../../accessibility/KeyboardShortcuts"; import { SwitchSpacePayload } from "../../dispatcher/payloads/SwitchSpacePayload"; -import LegacyGroupView from "./LegacyGroupView"; import { IConfigOptions } from "../../IConfigOptions"; import LeftPanelLiveShareWarning from '../views/beacon/LeftPanelLiveShareWarning'; import { UserOnboardingPage } from '../views/user-onboarding/UserOnboardingPage'; @@ -103,8 +102,6 @@ interface IProps { justRegistered?: boolean; roomJustCreatedOpts?: IOpts; forceTimeline?: boolean; // see props on MatrixChat - - currentGroupId?: string; } interface IState { @@ -641,10 +638,6 @@ class LoggedInView extends React.Component { case PageTypes.UserView: pageElement = ; break; - - case PageTypes.LegacyGroupView: - pageElement = ; - break; } const wrapperClasses = classNames({ diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index 1d24e1da087..6dd2820aa17 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -188,8 +188,6 @@ interface IState { currentRoomId?: string; // If we're trying to just view a user ID (i.e. /user URL), this is it currentUserId?: string; - // Group ID for legacy "communities don't exist" page - currentGroupId?: string; // this is persisted as mx_lhs_size, loaded in LoggedInView collapseLhs: boolean; // Parameters used in the registration dance with the IS @@ -679,9 +677,6 @@ export default class MatrixChat extends React.PureComponent { } break; } - case 'view_legacy_group': - this.viewLegacyGroup(payload.groupId); - break; case Action.ViewUserSettings: { const tabPayload = payload as OpenToTabPayload; Modal.createDialog(UserSettingsDialog, @@ -1023,16 +1018,6 @@ export default class MatrixChat extends React.PureComponent { }); } - private viewLegacyGroup(groupId: string) { - this.setStateForNewView({ - view: Views.LOGGED_IN, - currentRoomId: null, - currentGroupId: groupId, - }); - this.notifyNewScreen('group/' + groupId); - this.setPage(PageType.LegacyGroupView); - } - private async createRoom(defaultPublic = false, defaultName?: string, type?: RoomType) { const modal = Modal.createDialog(CreateRoomDialog, { type, @@ -1803,12 +1788,6 @@ export default class MatrixChat extends React.PureComponent { userId: userId, subAction: params.action, }); - } else if (screen.indexOf('group/') === 0) { - const groupId = screen.substring(6); - dis.dispatch({ - action: 'view_legacy_group', - groupId: groupId, - }); } else { logger.info("Ignoring showScreen for '%s'", screen); } diff --git a/src/group_helpers.tsx b/src/group_helpers.tsx deleted file mode 100644 index 9e5a96aa193..00000000000 --- a/src/group_helpers.tsx +++ /dev/null @@ -1,45 +0,0 @@ -/* -Copyright 2022 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 * as React from "react"; - -import Modal from "./Modal"; -import QuestionDialog from "./components/views/dialogs/QuestionDialog"; -import { _t } from "./languageHandler"; -import SdkConfig, { DEFAULTS } from "./SdkConfig"; - -export function showGroupReplacedWithSpacesDialog(groupId: string) { - const learnMoreUrl = SdkConfig.get().spaces_learn_more_url ?? DEFAULTS.spaces_learn_more_url; - Modal.createDialog(QuestionDialog, { - title: _t("That link is no longer supported"), - description: <> -

- { _t( - "You're trying to access a community link (%(groupId)s).
" + - "Communities are no longer supported and have been replaced by spaces." + - "Learn more about spaces here.", - { groupId }, - { - br: () =>
, - br2: () =>
, - a: (sub) => { sub }, - }, - ) } -

- , - hasCancelButton: false, - }); -} diff --git a/src/linkify-matrix.ts b/src/linkify-matrix.ts index 896784cb454..f2df222eec1 100644 --- a/src/linkify-matrix.ts +++ b/src/linkify-matrix.ts @@ -30,13 +30,11 @@ import dis from './dispatcher/dispatcher'; import { Action } from './dispatcher/actions'; import { ViewUserPayload } from './dispatcher/payloads/ViewUserPayload'; import { ViewRoomPayload } from "./dispatcher/payloads/ViewRoomPayload"; -import { showGroupReplacedWithSpacesDialog } from "./group_helpers"; export enum Type { URL = "url", UserId = "userid", RoomAlias = "roomalias", - GroupId = "groupid", } // Linkify stuff doesn't type scanner/parser/utils properly :/ @@ -115,11 +113,6 @@ function onUserClick(event: MouseEvent, userId: string) { }); } -function onGroupClick(event: MouseEvent, groupId: string) { - event.preventDefault(); - showGroupReplacedWithSpacesDialog(groupId); -} - function onAliasClick(event: MouseEvent, roomAlias: string) { event.preventDefault(); dis.dispatch({ @@ -192,15 +185,6 @@ export const options = { onAliasClick(e, alias); }, }; - - case Type.GroupId: - return { - // @ts-ignore see https://linkify.js.org/docs/options.html - click: function(e: MouseEvent) { - const groupId = parsePermalink(href).groupId; - onGroupClick(e, groupId); - }, - }; } }, @@ -208,7 +192,6 @@ export const options = { switch (type) { case Type.RoomAlias: case Type.UserId: - case Type.GroupId: default: { return tryTransformEntityToPermalink(href); } @@ -255,17 +238,6 @@ registerPlugin(Type.RoomAlias, ({ scanner, parser, utils }) => { }); }); -registerPlugin(Type.GroupId, ({ scanner, parser, utils }) => { - const token = scanner.tokens.PLUS as '+'; - matrixOpaqueIdLinkifyParser({ - scanner, - parser, - utils, - token, - name: Type.GroupId, - }); -}); - registerPlugin(Type.UserId, ({ scanner, parser, utils }) => { const token = scanner.tokens.AT as '@'; matrixOpaqueIdLinkifyParser({ diff --git a/src/utils/permalinks/ElementPermalinkConstructor.ts b/src/utils/permalinks/ElementPermalinkConstructor.ts index 01525081a60..d66c3ae031c 100644 --- a/src/utils/permalinks/ElementPermalinkConstructor.ts +++ b/src/utils/permalinks/ElementPermalinkConstructor.ts @@ -43,17 +43,11 @@ export default class ElementPermalinkConstructor extends PermalinkConstructor { return `${this.elementUrl}/#/user/${userId}`; } - forGroup(groupId: string): string { - return `${this.elementUrl}/#/group/${groupId}`; - } - forEntity(entityId: string): string { if (entityId[0] === '!' || entityId[0] === '#') { return this.forRoom(entityId); } else if (entityId[0] === '@') { return this.forUser(entityId); - } else if (entityId[0] === '+') { - return this.forGroup(entityId); } else throw new Error("Unrecognized entity"); } @@ -107,8 +101,6 @@ export default class ElementPermalinkConstructor extends PermalinkConstructor { const eventId = parts.length > 2 ? parts.slice(2).join('/') : ""; const via = query.split(/&?via=/).filter(p => !!p); return PermalinkParts.forEvent(entity, eventId, via); - } else if (entityType === 'group') { - return PermalinkParts.forGroup(entity); } else { throw new Error("Unknown entity type in permalink"); } diff --git a/src/utils/permalinks/MatrixSchemePermalinkConstructor.ts b/src/utils/permalinks/MatrixSchemePermalinkConstructor.ts index 70622af7c27..904fbb89397 100644 --- a/src/utils/permalinks/MatrixSchemePermalinkConstructor.ts +++ b/src/utils/permalinks/MatrixSchemePermalinkConstructor.ts @@ -51,10 +51,6 @@ export default class MatrixSchemePermalinkConstructor extends PermalinkConstruct return `matrix:${this.encodeEntity(userId)}`; } - forGroup(groupId: string): string { - throw new Error("Deliberately not implemented"); - } - forEntity(entityId: string): string { return `matrix:${this.encodeEntity(entityId)}`; } diff --git a/src/utils/permalinks/MatrixToPermalinkConstructor.ts b/src/utils/permalinks/MatrixToPermalinkConstructor.ts index ab2de5959a0..3a57fc443f9 100644 --- a/src/utils/permalinks/MatrixToPermalinkConstructor.ts +++ b/src/utils/permalinks/MatrixToPermalinkConstructor.ts @@ -39,10 +39,6 @@ export default class MatrixToPermalinkConstructor extends PermalinkConstructor { return `${baseUrl}/#/${userId}`; } - forGroup(groupId: string): string { - return `${baseUrl}/#/${groupId}`; - } - forEntity(entityId: string): string { return `${baseUrl}/#/${entityId}`; } @@ -82,8 +78,6 @@ export default class MatrixToPermalinkConstructor extends PermalinkConstructor { const via = query.split(/&?via=/g).filter(p => !!p); return PermalinkParts.forEvent(entity, eventId, via); - } else if (entity[0] === '+') { - return PermalinkParts.forGroup(entity); } else { throw new Error("Unknown entity type in permalink"); } diff --git a/src/utils/permalinks/PermalinkConstructor.ts b/src/utils/permalinks/PermalinkConstructor.ts index 158df895e2e..f259094095f 100644 --- a/src/utils/permalinks/PermalinkConstructor.ts +++ b/src/utils/permalinks/PermalinkConstructor.ts @@ -27,10 +27,6 @@ export default class PermalinkConstructor { throw new Error("Not implemented"); } - forGroup(groupId: string): string { - throw new Error("Not implemented"); - } - forUser(userId: string): string { throw new Error("Not implemented"); } @@ -55,30 +51,24 @@ export class PermalinkParts { eventId: string; userId: string; viaServers: string[]; - groupId: string; - constructor(roomIdOrAlias: string, eventId: string, userId: string, groupId: string, viaServers: string[]) { + constructor(roomIdOrAlias: string, eventId: string, userId: string, viaServers: string[]) { this.roomIdOrAlias = roomIdOrAlias; this.eventId = eventId; this.userId = userId; - this.groupId = groupId; this.viaServers = viaServers; } static forUser(userId: string): PermalinkParts { - return new PermalinkParts(null, null, userId, null, null); - } - - static forGroup(groupId: string): PermalinkParts { - return new PermalinkParts(null, null, null, groupId, null); + return new PermalinkParts(null, null, userId, null); } static forRoom(roomIdOrAlias: string, viaServers: string[] = []): PermalinkParts { - return new PermalinkParts(roomIdOrAlias, null, null, null, viaServers); + return new PermalinkParts(roomIdOrAlias, null, null, viaServers); } static forEvent(roomId: string, eventId: string, viaServers: string[] = []): PermalinkParts { - return new PermalinkParts(roomId, eventId, null, null, viaServers); + return new PermalinkParts(roomId, eventId, null, viaServers); } get primaryEntityId(): string { diff --git a/src/utils/permalinks/Permalinks.ts b/src/utils/permalinks/Permalinks.ts index c7c7de9c534..ce2f8aeb1d3 100644 --- a/src/utils/permalinks/Permalinks.ts +++ b/src/utils/permalinks/Permalinks.ts @@ -295,10 +295,6 @@ export function makeRoomPermalink(roomId: string): string { return permalinkCreator.forShareableRoom(); } -export function makeGroupPermalink(groupId: string): string { - return getPermalinkConstructor().forGroup(groupId); -} - export function isPermalinkHost(host: string): boolean { // Always check if the permalink is a spec permalink (callers are likely to call // parsePermalink after this function). @@ -319,7 +315,6 @@ export function tryTransformEntityToPermalink(entity: string): string { // Check to see if it is a bare entity for starters if (entity[0] === '#' || entity[0] === '!') return makeRoomPermalink(entity); if (entity[0] === '@') return makeUserPermalink(entity); - if (entity[0] === '+') return makeGroupPermalink(entity); if (entity.slice(0, 7) === "matrix:") { try { @@ -332,8 +327,6 @@ export function tryTransformEntityToPermalink(entity: string): string { pl += new MatrixToPermalinkConstructor().encodeServerCandidates(permalinkParts.viaServers); } return pl; - } else if (permalinkParts.groupId) { - return matrixtoBaseUrl + `/#/${permalinkParts.groupId}`; } else if (permalinkParts.userId) { return matrixtoBaseUrl + `/#/${permalinkParts.userId}`; } @@ -381,8 +374,6 @@ export function tryTransformPermalinkToLocalHref(permalink: string): string { } } else if (permalinkParts.userId) { permalink = `#/user/${permalinkParts.userId}`; - } else if (permalinkParts.groupId) { - permalink = `#/group/${permalinkParts.groupId}`; } // else not a valid permalink for our purposes - do not handle } } catch (e) { @@ -410,7 +401,6 @@ export function getPrimaryPermalinkEntity(permalink: string): string { if (!permalinkParts) return null; // not processable if (permalinkParts.userId) return permalinkParts.userId; if (permalinkParts.roomIdOrAlias) return permalinkParts.roomIdOrAlias; - if (permalinkParts.groupId) return permalinkParts.groupId; } catch (e) { // no entity - not a permalink } From 2c78740433bc19dff000471b2118da1e105cfb9f Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 5 Oct 2022 11:14:50 -0600 Subject: [PATCH 2/2] Don't need the strings either --- src/i18n/strings/en_EN.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 03d5517c84e..2fc9052b43a 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -52,8 +52,6 @@ "%(value)sh": "%(value)sh", "%(value)sm": "%(value)sm", "%(value)ss": "%(value)ss", - "That link is no longer supported": "That link is no longer supported", - "You're trying to access a community link (%(groupId)s).
Communities are no longer supported and have been replaced by spaces.Learn more about spaces here.": "You're trying to access a community link (%(groupId)s).
Communities are no longer supported and have been replaced by spaces.Learn more about spaces here.", "Identity server has no terms of service": "Identity server has no terms of service", "This action requires accessing the default identity server to validate an email address or phone number, but the server does not have any terms of service.": "This action requires accessing the default identity server to validate an email address or phone number, but the server does not have any terms of service.", "Only continue if you trust the owner of the server.": "Only continue if you trust the owner of the server.",