Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit ed2ee70

Browse files
authored
Merge pull request #6899 from KalleStruik/19245-improve-styling-of-search-initialization-errors
Improve the styling of search initialization errors.
2 parents 548290b + bebf7e8 commit ed2ee70

File tree

7 files changed

+39
-37
lines changed

7 files changed

+39
-37
lines changed

res/css/_components.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
@import "./views/elements/_AddressSelector.scss";
144144
@import "./views/elements/_AddressTile.scss";
145145
@import "./views/elements/_CopyableText.scss";
146-
@import "./views/elements/_DesktopBuildsNotice.scss";
146+
@import "./views/elements/_SearchWarning.scss";
147147
@import "./views/elements/_DesktopCapturerSourcePicker.scss";
148148
@import "./views/elements/_DialPadBackspaceButton.scss";
149149
@import "./views/elements/_DirectorySearchBox.scss";

res/css/views/elements/_DesktopBuildsNotice.scss renamed to res/css/views/elements/_SearchWarning.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
.mx_DesktopBuildsNotice {
17+
.mx_SearchWarning {
1818
text-align: center;
1919
padding: 0 16px;
2020

src/components/structures/FilePanel.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { logger } from "matrix-js-sdk/src/logger";
2727
import { MatrixClientPeg } from '../../MatrixClientPeg';
2828
import EventIndexPeg from "../../indexing/EventIndexPeg";
2929
import { _t } from '../../languageHandler';
30-
import DesktopBuildsNotice, { WarningKind } from "../views/elements/DesktopBuildsNotice";
30+
import SearchWarning, { WarningKind } from "../views/elements/SearchWarning";
3131
import BaseCard from "../views/right_panel/BaseCard";
3232
import ResizeNotifier from '../../utils/ResizeNotifier';
3333
import TimelinePanel from "./TimelinePanel";
@@ -275,7 +275,7 @@ class FilePanel extends React.Component<IProps, IState> {
275275
sensor={this.card.current}
276276
onMeasurement={this.onMeasurement}
277277
/>
278-
<DesktopBuildsNotice isRoomEncrypted={isRoomEncrypted} kind={WarningKind.Files} />
278+
<SearchWarning isRoomEncrypted={isRoomEncrypted} kind={WarningKind.Files} />
279279
<TimelinePanel
280280
manageReadReceipts={false}
281281
manageReadMarkers={false}

src/components/views/elements/DesktopBuildsNotice.tsx renamed to src/components/views/elements/SearchWarning.tsx

+21-19
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,30 @@ interface IProps {
3535
kind: WarningKind;
3636
}
3737

38-
export default function DesktopBuildsNotice({ isRoomEncrypted, kind }: IProps) {
38+
export default function SearchWarning({ isRoomEncrypted, kind }: IProps) {
3939
if (!isRoomEncrypted) return null;
4040
if (EventIndexPeg.get()) return null;
4141

4242
if (EventIndexPeg.error) {
43-
return <>
44-
{ _t("Message search initialisation failed, check <a>your settings</a> for more information", {}, {
45-
a: sub => (
46-
<AccessibleButton
47-
kind="link_inline"
48-
onClick={(evt) => {
49-
evt.preventDefault();
50-
dis.dispatch({
51-
action: Action.ViewUserSettings,
52-
initialTabId: UserTab.Security,
53-
});
54-
}}
55-
>
56-
{ sub }
57-
</AccessibleButton>),
58-
}) }
59-
</>;
43+
return (
44+
<div className="mx_SearchWarning">
45+
{ _t("Message search initialisation failed, check <a>your settings</a> for more information", {}, {
46+
a: sub => (
47+
<AccessibleButton
48+
kind="link_inline"
49+
onClick={(evt) => {
50+
evt.preventDefault();
51+
dis.dispatch({
52+
action: Action.ViewUserSettings,
53+
initialTabId: UserTab.Security,
54+
});
55+
}}
56+
>
57+
{ sub }
58+
</AccessibleButton>),
59+
}) }
60+
</div>
61+
);
6062
}
6163

6264
const brand = SdkConfig.get("brand");
@@ -97,7 +99,7 @@ export default function DesktopBuildsNotice({ isRoomEncrypted, kind }: IProps) {
9799
}
98100

99101
return (
100-
<div className="mx_DesktopBuildsNotice">
102+
<div className="mx_SearchWarning">
101103
{ logo }
102104
<span>{ text }</span>
103105
</div>

src/components/views/rooms/SearchBar.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import classNames from "classnames";
2020

2121
import AccessibleButton from "../elements/AccessibleButton";
2222
import { _t } from '../../../languageHandler';
23-
import DesktopBuildsNotice, { WarningKind } from "../elements/DesktopBuildsNotice";
2423
import { PosthogScreenTracker } from '../../../PosthogTrackers';
2524
import { getKeyBindingsManager } from "../../../KeyBindingsManager";
2625
import { KeyBindingAction } from "../../../accessibility/KeyboardShortcuts";
26+
import SearchWarning, { WarningKind } from "../elements/SearchWarning";
2727

2828
interface IProps {
2929
onCancelClick: () => void;
@@ -127,7 +127,7 @@ export default class SearchBar extends React.Component<IProps, IState> {
127127
</div>
128128
<AccessibleButton className="mx_SearchBar_cancel" onClick={this.props.onCancelClick} />
129129
</div>
130-
<DesktopBuildsNotice isRoomEncrypted={this.props.isRoomEncrypted} kind={WarningKind.Search} />
130+
<SearchWarning isRoomEncrypted={this.props.isRoomEncrypted} kind={WarningKind.Search} />
131131
</>
132132
);
133133
}

src/i18n/strings/en_EN.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -2249,11 +2249,6 @@
22492249
"Error - Mixed content": "Error - Mixed content",
22502250
"Popout widget": "Popout widget",
22512251
"Copy": "Copy",
2252-
"Message search initialisation failed, check <a>your settings</a> for more information": "Message search initialisation failed, check <a>your settings</a> for more information",
2253-
"Use the <a>Desktop app</a> to see all encrypted files": "Use the <a>Desktop app</a> to see all encrypted files",
2254-
"Use the <a>Desktop app</a> to search encrypted messages": "Use the <a>Desktop app</a> to search encrypted messages",
2255-
"This version of %(brand)s does not support viewing some encrypted files": "This version of %(brand)s does not support viewing some encrypted files",
2256-
"This version of %(brand)s does not support searching encrypted messages": "This version of %(brand)s does not support searching encrypted messages",
22572252
"Share entire screen": "Share entire screen",
22582253
"Application window": "Application window",
22592254
"Share content": "Share content",
@@ -2380,6 +2375,11 @@
23802375
"%(count)s members including %(commaSeparatedMembers)s|one": "%(commaSeparatedMembers)s",
23812376
"%(count)s people you know have already joined|other": "%(count)s people you know have already joined",
23822377
"%(count)s people you know have already joined|one": "%(count)s person you know has already joined",
2378+
"Message search initialisation failed, check <a>your settings</a> for more information": "Message search initialisation failed, check <a>your settings</a> for more information",
2379+
"Use the <a>Desktop app</a> to see all encrypted files": "Use the <a>Desktop app</a> to see all encrypted files",
2380+
"Use the <a>Desktop app</a> to search encrypted messages": "Use the <a>Desktop app</a> to search encrypted messages",
2381+
"This version of %(brand)s does not support viewing some encrypted files": "This version of %(brand)s does not support viewing some encrypted files",
2382+
"This version of %(brand)s does not support searching encrypted messages": "This version of %(brand)s does not support searching encrypted messages",
23832383
"Server Options": "Server Options",
23842384
"You can use the custom server options to sign into other Matrix servers by specifying a different homeserver URL. This allows you to use %(brand)s with an existing Matrix account on a different homeserver.": "You can use the custom server options to sign into other Matrix servers by specifying a different homeserver URL. This allows you to use %(brand)s with an existing Matrix account on a different homeserver.",
23852385
"Join millions for free on the largest public server": "Join millions for free on the largest public server",

test/components/views/rooms/SearchBar-test.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
import React from 'react';
1818
import { mount } from "enzyme";
1919

20-
import DesktopBuildsNotice from "../../../../src/components/views/elements/DesktopBuildsNotice";
20+
import SearchWarning from "../../../../src/components/views/elements/SearchWarning";
2121
import { PosthogScreenTracker } from "../../../../src/PosthogTrackers";
2222
import SearchBar, { SearchScope } from "../../../../src/components/views/rooms/SearchBar";
2323
import { KeyBindingAction } from "../../../../src/accessibility/KeyboardShortcuts";
@@ -39,8 +39,8 @@ jest.mock("../../../../src/KeyBindingsManager", () => ({
3939
{ getAccessibilityAction: jest.fn(() => mockCurrentEvent) })),
4040
}));
4141

42-
/** mock out DesktopBuildsNotice component so it doesn't affect the result of our test */
43-
jest.mock('../../../../src/components/views/elements/DesktopBuildsNotice', () => ({
42+
/** mock out SearchWarning component so it doesn't affect the result of our test */
43+
jest.mock('../../../../src/components/views/elements/SearchWarning', () => ({
4444
__esModule: true,
4545
WarningKind: {
4646
get Search() { // eslint-disable-line @typescript-eslint/naming-convention
@@ -73,13 +73,13 @@ describe("SearchBar", () => {
7373

7474
it("must render child components and pass necessary props", () => {
7575
const postHogScreenTracker = wrapper.find(PosthogScreenTracker);
76-
const desktopBuildNotice = wrapper.find(DesktopBuildsNotice);
76+
const searchWarning = wrapper.find(SearchWarning);
7777

7878
expect(postHogScreenTracker.length).toBe(1);
79-
expect(desktopBuildNotice.length).toBe(1);
79+
expect(searchWarning.length).toBe(1);
8080
expect(postHogScreenTracker.props().screenName).toEqual("RoomSearch");
81-
expect(desktopBuildNotice.props().isRoomEncrypted).toEqual(searchProps.isRoomEncrypted);
82-
expect(desktopBuildNotice.props().kind).toEqual(mockWarningKind);
81+
expect(searchWarning.props().isRoomEncrypted).toEqual(searchProps.isRoomEncrypted);
82+
expect(searchWarning.props().kind).toEqual(mockWarningKind);
8383
});
8484

8585
it("must not search when input value is empty", () => {

0 commit comments

Comments
 (0)