diff --git a/res/css/structures/_SpaceRoomView.scss b/res/css/structures/_SpaceRoomView.scss index 945de01eba..d6dca8b675 100644 --- a/res/css/structures/_SpaceRoomView.scss +++ b/res/css/structures/_SpaceRoomView.scss @@ -212,9 +212,10 @@ $SpaceRoomViewInnerWidth: 428px; } } - > .mx_BaseAvatar_image, - > .mx_BaseAvatar > .mx_BaseAvatar_image { - border-radius: 12px; + > .mx_RoomAvatar_isSpaceRoom { + &.mx_BaseAvatar_image, .mx_BaseAvatar_image { + border-radius: 12px; + } } h1.mx_SpaceRoomView_preview_name { diff --git a/res/css/views/settings/tabs/user/_PreferencesUserSettingsTab.scss b/res/css/views/settings/tabs/user/_PreferencesUserSettingsTab.scss index 4cdfa0b40f..d6f4064e35 100644 --- a/res/css/views/settings/tabs/user/_PreferencesUserSettingsTab.scss +++ b/res/css/views/settings/tabs/user/_PreferencesUserSettingsTab.scss @@ -21,6 +21,10 @@ limitations under the License. .mx_SettingsTab_section { margin-bottom: 30px; + + > details + .mx_SettingsFlag { + margin-top: 20px; + } } .mx_PreferencesUserSettingsTab_CommunityMigrator { diff --git a/res/img/betas/.gitkeep b/res/img/betas/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/res/img/betas/spaces.png b/res/img/betas/spaces.png deleted file mode 100644 index f4cfa90b4e..0000000000 Binary files a/res/img/betas/spaces.png and /dev/null differ diff --git a/src/components/structures/GroupFilterPanel.js b/src/components/structures/GroupFilterPanel.js index 5d1be64f25..a72790b928 100644 --- a/src/components/structures/GroupFilterPanel.js +++ b/src/components/structures/GroupFilterPanel.js @@ -122,19 +122,13 @@ class GroupFilterPanel extends React.Component { mx_GroupFilterPanel_items_selected: itemsSelected, }); - let betaDot; - if (SettingsStore.getBetaInfo("feature_spaces") && !localStorage.getItem("mx_seenSpacesBeta")) { - betaDot =
; - } - let createButton = ( - { betaDot } - + className="mx_TagTile mx_TagTile_plus" + /> ); if (SettingsStore.getValue("feature_communities_v2_prototypes")) { diff --git a/src/components/structures/LegacyCommunityPreview.tsx b/src/components/structures/LegacyCommunityPreview.tsx new file mode 100644 index 0000000000..92aea8bb7d --- /dev/null +++ b/src/components/structures/LegacyCommunityPreview.tsx @@ -0,0 +1,116 @@ +/* +Copyright 2021 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 React, { useContext } from "react"; + +import MatrixClientContext from "../../contexts/MatrixClientContext"; +import { _t } from "../../languageHandler"; +import AccessibleButton from "../views/elements/AccessibleButton"; +import ErrorBoundary from "../views/elements/ErrorBoundary"; +import { IGroupSummary } from "../views/dialogs/CreateSpaceFromCommunityDialog"; +import { useAsyncMemo } from "../../hooks/useAsyncMemo"; +import Spinner from "../views/elements/Spinner"; +import GroupAvatar from "../views/avatars/GroupAvatar"; +import { linkifyElement } from "../../HtmlUtils"; +import defaultDispatcher from "../../dispatcher/dispatcher"; +import { Action } from "../../dispatcher/actions"; +import { UserTab } from "../views/dialogs/UserSettingsDialog"; +import MainSplit from './MainSplit'; + +interface IProps { + groupId: string; +} + +const onSwapClick = () => { + defaultDispatcher.dispatch({ + action: Action.ViewUserSettings, + initialTabId: UserTab.Preferences, + }); +}; + +// XXX: temporary community migration component, reuses SpaceRoomView & SpacePreview classes for simplicity +const LegacyCommunityPreview = ({ groupId }: IProps) => { + const cli = useContext(MatrixClientContext); + + const groupSummary = useAsyncMemo(() => cli.getGroupSummary(groupId), [cli, groupId]); + + if (!groupSummary) { + return
+ +
+ +
+
+
; + } + + let visibilitySection: JSX.Element; + if (groupSummary.profile.is_public) { + visibilitySection = + { _t("Public community") } + ; + } else { + visibilitySection = + { _t("Private community") } + ; + } + + return
+ + +
+ +

+ { groupSummary.profile.name } +

+
+ { visibilitySection } +
+
e && linkifyElement(e)}> + { groupSummary.profile.short_description } +
+
+ { groupSummary.user?.membership === "join" + ? _t("To view %(communityName)s, swap to communities in your preferences", { + communityName: groupSummary.profile.name, + }, { + a: sub => ( + { sub } + ), + }) + : _t("To join %(communityName)s, swap to communities in your preferences", { + communityName: groupSummary.profile.name, + }, { + a: sub => ( + { sub } + ), + }) + } +
+
+
+
+
; +}; + +export default LegacyCommunityPreview; diff --git a/src/components/structures/LoggedInView.tsx b/src/components/structures/LoggedInView.tsx index d496c4ad21..551e690e51 100644 --- a/src/components/structures/LoggedInView.tsx +++ b/src/components/structures/LoggedInView.tsx @@ -64,6 +64,7 @@ import MyGroups from "./MyGroups"; import UserView from "./UserView"; import GroupView from "./GroupView"; import SpaceStore from "../../stores/SpaceStore"; +import LegacyCommunityPreview from "./LegacyCommunityPreview"; // We need to fetch each pinned message individually (if we don't already have it) // so each pinned message may trigger a request. Limit the number per room for sanity. @@ -593,11 +594,15 @@ class LoggedInView extends React.Component { pageElement = ; break; case PageTypes.GroupView: - pageElement = ; + if (SpaceStore.spacesEnabled) { + pageElement = ; + } else { + pageElement = ; + } break; } diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index 60c78b5f9e..76c90be009 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -1796,11 +1796,6 @@ export default class MatrixChat extends React.PureComponent { subAction: params.action, }); } else if (screen.indexOf('group/') === 0) { - if (SpaceStore.spacesEnabled) { - dis.dispatch({ action: "view_home_page" }); - return; - } - const groupId = screen.substring(6); // TODO: Check valid group ID diff --git a/src/components/structures/MyGroups.js b/src/components/structures/MyGroups.js index dab18c4161..cebbe30e0a 100644 --- a/src/components/structures/MyGroups.js +++ b/src/components/structures/MyGroups.js @@ -138,7 +138,6 @@ export default class MyGroups extends React.Component {
*/ } -
{ contentHeader } { content } diff --git a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx index 21c3ab24ec..27758a5205 100644 --- a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx +++ b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx @@ -145,7 +145,7 @@ export default class PreferencesUserSettingsTab extends React.Component { - return ; + return ; }); } @@ -348,7 +348,7 @@ export default class PreferencesUserSettingsTab extends React.Component{ _t("If a community isn't shown you may not have permission to convert it.") }

- { this.renderGroup(PreferencesUserSettingsTab.COMMUNITIES_SETTINGS) } + { this.renderGroup(PreferencesUserSettingsTab.COMMUNITIES_SETTINGS, SettingLevel.DEVICE) }
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 6fff4a5393..a3e7ee74f5 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -796,15 +796,6 @@ "%(senderName)s: %(stickerName)s": "%(senderName)s: %(stickerName)s", "Change notification settings": "Change notification settings", "Report to moderators prototype. In rooms that support moderation, the `report` button will let you report abuse to room moderators": "Report to moderators prototype. In rooms that support moderation, the `report` button will let you report abuse to room moderators", - "Spaces prototype. Incompatible with Communities, Communities v2 and Custom Tags. Requires compatible homeserver for some features.": "Spaces prototype. Incompatible with Communities, Communities v2 and Custom Tags. Requires compatible homeserver for some features.", - "Spaces": "Spaces", - "Spaces are a new way to group rooms and people.": "Spaces are a new way to group rooms and people.", - "If you leave, %(brand)s will reload with Spaces disabled. Communities and custom tags will be visible again.": "If you leave, %(brand)s will reload with Spaces disabled. Communities and custom tags will be visible again.", - "Beta available for web, desktop and Android. Thank you for trying the beta.": "Beta available for web, desktop and Android. Thank you for trying the beta.", - "%(brand)s will reload with Spaces enabled. Communities and custom tags will be hidden.": "%(brand)s will reload with Spaces enabled. Communities and custom tags will be hidden.", - "You can leave the beta any time from settings or tapping on a beta badge, like the one above.": "You can leave the beta any time from settings or tapping on a beta badge, like the one above.", - "Beta available for web, desktop and Android. Some features may be unavailable on your homeserver.": "Beta available for web, desktop and Android. Some features may be unavailable on your homeserver.", - "Your feedback will help make spaces better. The more detail you can go into, the better.": "Your feedback will help make spaces better. The more detail you can go into, the better.", "Show options to enable 'Do not disturb' mode": "Show options to enable 'Do not disturb' mode", "Render LaTeX maths in messages": "Render LaTeX maths in messages", "Communities v2 prototypes. Requires compatible homeserver. Highly experimental - use with caution.": "Communities v2 prototypes. Requires compatible homeserver. Highly experimental - use with caution.", @@ -879,6 +870,8 @@ "Show chat effects (animations when receiving e.g. confetti)": "Show chat effects (animations when receiving e.g. confetti)", "Show all rooms in Home": "Show all rooms in Home", "All rooms you're in will appear in Home.": "All rooms you're in will appear in Home.", + "Display Communities instead of Spaces": "Display Communities instead of Spaces", + "Temporarily show communities instead of Spaces. Support for this will be removed in the near future. This will reload Element": "Temporarily show communities instead of Spaces. Support for this will be removed in the near future. This will reload Element", "Collecting app version information": "Collecting app version information", "Collecting logs": "Collecting logs", "Uploading logs": "Uploading logs", @@ -1027,6 +1020,7 @@ "e.g. my-space": "e.g. my-space", "Address": "Address", "Create a space": "Create a space", + "Spaces are a new way to group rooms and people.": "Spaces are a new way to group rooms and people.", "What kind of Space do you want to create?": "What kind of Space do you want to create?", "You can change this later.": "You can change this later.", "Public": "Public", @@ -1343,6 +1337,7 @@ "Show tray icon and minimize window to it on close": "Show tray icon and minimize window to it on close", "Preferences": "Preferences", "Room list": "Room list", + "Spaces": "Spaces", "Communities": "Communities", "Communities have been archived to make way for Spaces but you can convert your communities into Spaces below. Converting will ensure your conversations get the latest features.": "Communities have been archived to make way for Spaces but you can convert your communities into Spaces below. Converting will ensure your conversations get the latest features.", "Show my Communities": "Show my Communities", @@ -2758,6 +2753,10 @@ "Create a Group Chat": "Create a Group Chat", "Upgrade to %(hostSignupBrand)s": "Upgrade to %(hostSignupBrand)s", "Open dial pad": "Open dial pad", + "Public community": "Public community", + "Private community": "Private community", + "To view %(communityName)s, swap to communities in your preferences": "To view %(communityName)s, swap to communities in your preferences", + "To join %(communityName)s, swap to communities in your preferences": "To join %(communityName)s, swap to communities in your preferences", "Failed to reject invitation": "Failed to reject invitation", "Cannot create rooms in this community": "Cannot create rooms in this community", "You do not have permission to create rooms in this community.": "You do not have permission to create rooms in this community.", @@ -2788,7 +2787,6 @@ "Error whilst fetching joined communities": "Error whilst fetching joined communities", "Create a new community": "Create a new community", "Create a community to group together users and rooms! Build a custom homepage to mark out your space in the Matrix universe.": "Create a community to group together users and rooms! Build a custom homepage to mark out your space in the Matrix universe.", - "Communities are changing to Spaces": "Communities are changing to Spaces", "You’re all caught up": "You’re all caught up", "You have no visible notifications.": "You have no visible notifications.", "%(brand)s failed to get the protocol list from the homeserver. The homeserver may be too old to support third party networks.": "%(brand)s failed to get the protocol list from the homeserver. The homeserver may be too old to support third party networks.", diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index d170f8d357..6d980d30cd 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -145,44 +145,6 @@ export const SETTINGS: {[setting: string]: ISetting} = { supportedLevels: LEVELS_FEATURE, default: false, }, - "feature_spaces": { - isFeature: true, - displayName: _td("Spaces prototype. Incompatible with Communities, Communities v2 and Custom Tags. " + - "Requires compatible homeserver for some features."), - supportedLevels: LEVELS_FEATURE, - default: false, - controller: new ReloadOnChangeController(), - betaInfo: { - title: _td("Spaces"), - caption: _td("Spaces are a new way to group rooms and people."), - disclaimer: (enabled) => { - if (enabled) { - return <> -

{ _t("If you leave, %(brand)s will reload with Spaces disabled. " + - "Communities and custom tags will be visible again.", { - brand: SdkConfig.get().brand, - }) }

-

{ _t("Beta available for web, desktop and Android. Thank you for trying the beta.") }

- ; - } - - return <> -

{ _t("%(brand)s will reload with Spaces enabled. " + - "Communities and custom tags will be hidden.", { - brand: SdkConfig.get().brand, - }) }

- { _t("You can leave the beta any time from settings or tapping on a beta badge, " + - "like the one above.") } -

{ _t("Beta available for web, desktop and Android. " + - "Some features may be unavailable on your homeserver.") }

- ; - }, - image: require("../../res/img/betas/spaces.png"), - feedbackSubheading: _td("Your feedback will help make spaces better. " + - "The more detail you can go into, the better."), - feedbackLabel: "spaces-feedback", - }, - }, "feature_dnd": { isFeature: true, displayName: _td("Show options to enable 'Do not disturb' mode"), @@ -203,7 +165,7 @@ export const SETTINGS: {[setting: string]: ISetting} = { ), supportedLevels: LEVELS_FEATURE, default: false, - controller: new IncompatibleController("feature_spaces"), + controller: new IncompatibleController("showCommunitiesInsteadOfSpaces", false, false), }, "feature_pinning": { isFeature: true, @@ -223,7 +185,7 @@ export const SETTINGS: {[setting: string]: ISetting} = { displayName: _td("Group & filter rooms by custom tags (refresh to apply changes)"), supportedLevels: LEVELS_FEATURE, default: false, - controller: new IncompatibleController("feature_spaces"), + controller: new IncompatibleController("showCommunitiesInsteadOfSpaces", false, false), }, "feature_state_counters": { isFeature: true, @@ -769,6 +731,14 @@ export const SETTINGS: {[setting: string]: ISetting} = { supportedLevels: LEVELS_ACCOUNT_SETTINGS, default: false, }, + "showCommunitiesInsteadOfSpaces": { + displayName: _td("Display Communities instead of Spaces"), + description: _td("Temporarily show communities instead of Spaces. " + + "Support for this will be removed in the near future. This will reload Element"), + supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG, + default: false, + controller: new ReloadOnChangeController(), + }, [UIFeature.RoomHistorySettings]: { supportedLevels: LEVELS_UI_FEATURE, default: true, @@ -832,7 +802,7 @@ export const SETTINGS: {[setting: string]: ISetting} = { [UIFeature.Communities]: { supportedLevels: LEVELS_UI_FEATURE, default: true, - controller: new IncompatibleController("feature_spaces"), + controller: new IncompatibleController("showCommunitiesInsteadOfSpaces", false, false), }, [UIFeature.AdvancedSettings]: { supportedLevels: LEVELS_UI_FEATURE, diff --git a/src/settings/controllers/IncompatibleController.ts b/src/settings/controllers/IncompatibleController.ts index c48ce0a60b..3a7d6ab7d7 100644 --- a/src/settings/controllers/IncompatibleController.ts +++ b/src/settings/controllers/IncompatibleController.ts @@ -24,7 +24,11 @@ import SettingsStore from "../SettingsStore"; * labs flags. */ export default class IncompatibleController extends SettingController { - public constructor(private settingName: string, private forcedValue = false) { + public constructor( + private settingName: string, + private forcedValue = false, + private incompatibleValue: any = true, + ) { super(); } @@ -34,13 +38,13 @@ export default class IncompatibleController extends SettingController { calculatedValue: any, calculatedAtLevel: SettingLevel, ): any { - if (this.incompatibleSettingEnabled) { + if (this.incompatibleSetting) { return this.forcedValue; } return null; // no override } - public get incompatibleSettingEnabled(): boolean { - return SettingsStore.getValue(this.settingName); + public get incompatibleSetting(): boolean { + return SettingsStore.getValue(this.settingName) === this.incompatibleValue; } } diff --git a/src/stores/SpaceStore.tsx b/src/stores/SpaceStore.tsx index da18646d0f..5c0267f0ec 100644 --- a/src/stores/SpaceStore.tsx +++ b/src/stores/SpaceStore.tsx @@ -71,7 +71,7 @@ export interface ISuggestedRoom extends ISpaceSummaryRoom { const MAX_SUGGESTED_ROOMS = 20; // This setting causes the page to reload and can be costly if read frequently, so read it here only -const spacesEnabled = SettingsStore.getValue("feature_spaces"); +const spacesEnabled = !SettingsStore.getValue("showCommunitiesInsteadOfSpaces"); const getSpaceContextKey = (space?: Room) => `mx_space_context_${space?.roomId || "HOME_SPACE"}`; @@ -764,7 +764,8 @@ export class SpaceStoreClass extends AsyncStoreWithClient { // restore selected state from last session if any and still valid const lastSpaceId = window.localStorage.getItem(ACTIVE_SPACE_LS_KEY); if (lastSpaceId) { - this.setActiveSpace(this.matrixClient.getRoom(lastSpaceId)); + // only context switch if our view is looking at a room, rather than e.g a community + this.setActiveSpace(this.matrixClient.getRoom(lastSpaceId), !!RoomViewStore.getRoomId()); } }