diff --git a/res/css/_components.scss b/res/css/_components.scss index 54e7436886..4c83dd7a31 100644 --- a/res/css/_components.scss +++ b/res/css/_components.scss @@ -100,6 +100,7 @@ @import "./views/elements/_AccessibleButton.scss"; @import "./views/elements/_AddressSelector.scss"; @import "./views/elements/_AddressTile.scss"; +@import "./views/elements/_DesktopBuildsNotice.scss"; @import "./views/elements/_DirectorySearchBox.scss"; @import "./views/elements/_Dropdown.scss"; @import "./views/elements/_EditableItemList.scss"; diff --git a/res/css/views/elements/_DesktopBuildsNotice.scss b/res/css/views/elements/_DesktopBuildsNotice.scss new file mode 100644 index 0000000000..3672595bf1 --- /dev/null +++ b/res/css/views/elements/_DesktopBuildsNotice.scss @@ -0,0 +1,28 @@ +/* +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. +*/ + +.mx_DesktopBuildsNotice { + text-align: center; + padding: 0 16px; + + > * { + vertical-align: middle; + } + + > img { + margin-right: 8px; + } +} diff --git a/res/css/views/rooms/_SearchBar.scss b/res/css/views/rooms/_SearchBar.scss index fecc8d78d8..d9f730a8b6 100644 --- a/res/css/views/rooms/_SearchBar.scss +++ b/res/css/views/rooms/_SearchBar.scss @@ -68,3 +68,4 @@ limitations under the License. cursor: pointer; } } + diff --git a/res/img/element-desktop-logo.svg b/res/img/element-desktop-logo.svg new file mode 100644 index 0000000000..2031733ce3 --- /dev/null +++ b/res/img/element-desktop-logo.svg @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SdkConfig.ts b/src/SdkConfig.ts index b914aaaf6d..7d7caa2d24 100644 --- a/src/SdkConfig.ts +++ b/src/SdkConfig.ts @@ -33,6 +33,11 @@ export const DEFAULTS: ConfigOptions = { // Default conference domain preferredDomain: "jitsi.riot.im", }, + desktopBuilds: { + available: true, + logo: require("../res/img/element-desktop-logo.svg"), + url: "https://element.io/get-started", + }, }; export default class SdkConfig { diff --git a/src/components/structures/FilePanel.js b/src/components/structures/FilePanel.js index 6d618d0b9d..4836b0f554 100644 --- a/src/components/structures/FilePanel.js +++ b/src/components/structures/FilePanel.js @@ -25,6 +25,7 @@ import EventIndexPeg from "../../indexing/EventIndexPeg"; import { _t } from '../../languageHandler'; import BaseCard from "../views/right_panel/BaseCard"; import {RightPanelPhases} from "../../stores/RightPanelStorePhases"; +import DesktopBuildsNotice, {WarningKind} from "../views/elements/DesktopBuildsNotice"; /* * Component which shows the filtered file using a TimelinePanel @@ -222,6 +223,8 @@ class FilePanel extends React.Component {

{_t('Attach files from chat or just drag and drop them anywhere in a room.')}

); + const isRoomEncrypted = this.noRoom ? false : MatrixClientPeg.get().isRoomEncrypted(this.props.roomId); + if (this.state.timelineSet) { // console.log("rendering TimelinePanel for timelineSet " + this.state.timelineSet.room.roomId + " " + // "(" + this.state.timelineSet._timelines.join(", ") + ")" + " with key " + this.props.roomId); @@ -232,6 +235,7 @@ class FilePanel extends React.Component { previousPhase={RightPanelPhases.RoomSummary} withoutScrollContainer > + { searchInProgress={this.state.searchInProgress} onCancelClick={this.onCancelSearchClick} onSearch={this.onSearch} + isRoomEncrypted={this.context.isRoomEncrypted(this.state.room.roomId)} />; } else if (showRoomUpgradeBar) { aux = ; diff --git a/src/components/views/elements/DesktopBuildsNotice.tsx b/src/components/views/elements/DesktopBuildsNotice.tsx new file mode 100644 index 0000000000..688d0669da --- /dev/null +++ b/src/components/views/elements/DesktopBuildsNotice.tsx @@ -0,0 +1,77 @@ +/* +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 EventIndexPeg from "../../../indexing/EventIndexPeg"; +import { _t } from "../../../languageHandler"; +import SdkConfig from "../../../SdkConfig"; +import React from "react"; + +export enum WarningKind { + Files, + Search, +} + +interface IProps { + isRoomEncrypted: boolean; + kind: WarningKind; +} + +export default function DesktopBuildsNotice({isRoomEncrypted, kind}: IProps) { + if (!isRoomEncrypted) return null; + if (EventIndexPeg.get()) return null; + + const {desktopBuilds, brand} = SdkConfig.get(); + + let text = null; + let logo = null; + if (desktopBuilds.available) { + logo = ; + switch(kind) { + case WarningKind.Files: + text = _t("Use the Desktop app to see encrypted files", {}, { + a: sub => ({sub}), + }); + break; + case WarningKind.Search: + text = _t("Use the Desktop app to search encrypted messages", {}, { + a: sub => ({sub}), + }); + break; + } + } else { + switch(kind) { + case WarningKind.Files: + text = _t("This version of %(brand)s does not support viewing encrypted files", {brand}); + break; + case WarningKind.Search: + text = _t("This version of %(brand)s does not support searching encrypted messages", {brand}); + break; + } + } + + // for safety + if (!text) { + console.warn("Unknown desktop builds warning kind: ", kind); + return null; + } + + return ( +
+ {logo} + {text} +
+ ); +} diff --git a/src/components/views/rooms/SearchBar.js b/src/components/views/rooms/SearchBar.js index 767f5a35f5..4bf97aac10 100644 --- a/src/components/views/rooms/SearchBar.js +++ b/src/components/views/rooms/SearchBar.js @@ -1,5 +1,6 @@ /* Copyright 2015, 2016 OpenMarket Ltd +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. @@ -19,6 +20,9 @@ import AccessibleButton from "../elements/AccessibleButton"; import classNames from "classnames"; import { _t } from '../../../languageHandler'; import {Key} from "../../../Keyboard"; +import SdkConfig from "../../../SdkConfig"; +import EventIndexPeg from "../../../indexing/EventIndexPeg"; +import DesktopBuildsNotice, {WarningKind} from "../elements/DesktopBuildsNotice"; export default class SearchBar extends React.Component { constructor(props) { @@ -72,21 +76,24 @@ export default class SearchBar extends React.Component { }); return ( -
-
- - {_t("This Room")} - - - {_t("All Rooms")} - + <> +
+
+ + {_t("This Room")} + + + {_t("All Rooms")} + +
+
+ + +
+
-
- - -
- -
+ + ); } } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index b2b4e01202..d4053f4418 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1493,6 +1493,10 @@ "Maximize apps": "Maximize apps", "Popout widget": "Popout widget", "More options": "More options", + "Use the Desktop app to see encrypted files": "Use the Desktop app to see encrypted files", + "Use the Desktop app to search encrypted messages": "Use the Desktop app to search encrypted messages", + "This version of %(brand)s does not support viewing encrypted files": "This version of %(brand)s does not support viewing encrypted files", + "This version of %(brand)s does not support searching encrypted messages": "This version of %(brand)s does not support searching encrypted messages", "Join": "Join", "No results": "No results", "Please create a new issue on GitHub so that we can investigate this bug.": "Please create a new issue on GitHub so that we can investigate this bug.",