search: Improve text about searching public channels.

We use different text for guest users, specifying that they can
only search in channels they can view.
The issue description suggests the same for spectators, but
we already use different text for them.

The search-operators help overlay is also updated with the same.

Fixes #30902
This commit is contained in:
Kislay Verma
2024-07-16 23:50:30 +05:30
committed by Tim Abbott
parent ed5d291781
commit de430f541c
5 changed files with 36 additions and 9 deletions

View File

@@ -12,8 +12,10 @@ import {$t, $t_html} from "./i18n";
import * as keydown_util from "./keydown_util"; import * as keydown_util from "./keydown_util";
import * as markdown from "./markdown"; import * as markdown from "./markdown";
import * as overlays from "./overlays"; import * as overlays from "./overlays";
import {page_params} from "./page_params";
import * as rendered_markdown from "./rendered_markdown"; import * as rendered_markdown from "./rendered_markdown";
import * as scroll_util from "./scroll_util"; import * as scroll_util from "./scroll_util";
import {current_user} from "./state_data";
import {user_settings} from "./user_settings"; import {user_settings} from "./user_settings";
import * as util from "./util"; import * as util from "./util";
@@ -277,7 +279,11 @@ export function set_up_toggler(): void {
}); });
$(".informational-overlays .overlay-body").append($markdown_help); $(".informational-overlays .overlay-body").append($markdown_help);
const $search_operators = $(render_search_operator()); const $search_operators = $(
render_search_operator({
can_access_all_public_channels: !page_params.is_spectator && !current_user.is_guest,
}),
);
$(".informational-overlays .overlay-body").append($search_operators); $(".informational-overlays .overlay-body").append($search_operators);
const $keyboard_shortcuts = $(render_keyboard_shortcut()); const $keyboard_shortcuts = $(render_keyboard_shortcut());

View File

@@ -11,7 +11,7 @@ import * as narrow_state from "./narrow_state";
import {page_params} from "./page_params"; import {page_params} from "./page_params";
import * as people from "./people"; import * as people from "./people";
import type {User} from "./people"; import type {User} from "./people";
import type {NarrowTerm} from "./state_data"; import {type NarrowTerm, current_user} from "./state_data";
import * as stream_data from "./stream_data"; import * as stream_data from "./stream_data";
import * as stream_topic_history from "./stream_topic_history"; import * as stream_topic_history from "./stream_topic_history";
import * as stream_topic_history_util from "./stream_topic_history_util"; import * as stream_topic_history_util from "./stream_topic_history_util";
@@ -625,10 +625,16 @@ function get_channels_filter_suggestions(last: NarrowTerm, terms: NarrowTerm[]):
if (last.operator === "search" && common.phrase_match(last.operand, "streams")) { if (last.operator === "search" && common.phrase_match(last.operand, "streams")) {
search_string = "streams:public"; search_string = "streams:public";
} }
let description_html;
if (page_params.is_spectator || current_user.is_guest) {
description_html = "All public channels that you can view";
} else {
description_html = "All public channels";
}
const suggestions: SuggestionAndIncompatiblePatterns[] = [ const suggestions: SuggestionAndIncompatiblePatterns[] = [
{ {
search_string, search_string,
description_html: "All public channels in organization", description_html,
is_people: false, is_people: false,
incompatible_patterns: [ incompatible_patterns: [
{operator: "is", operand: "dm"}, {operator: "is", operand: "dm"},

View File

@@ -192,7 +192,11 @@ function initialize_compose_box() {
} }
function initialize_message_feed_errors() { function initialize_message_feed_errors() {
$("#message_feed_errors_container").html(render_message_feed_errors()); $("#message_feed_errors_container").html(
render_message_feed_errors({
is_guest: current_user.is_guest,
}),
);
} }
export function initialize_kitchen_sink_stuff() { export function initialize_kitchen_sink_stuff() {

View File

@@ -20,10 +20,17 @@
{{/tr}} {{/tr}}
   
<span> <span>
{{#tr}} {{#if is_guest}}
Consider <z-link>searching all public channels</z-link>. {{#tr}}
{{#*inline "z-link"}}<a class="search-shared-history" href="">{{> @partial-block}}</a>{{/inline}} Consider <z-link>searching all public channels that you can view</z-link>.
{{/tr}} {{#*inline "z-link"}}<a class="search-shared-history" href="">{{> @partial-block}}</a>{{/inline}}
{{/tr}}
{{else}}
{{#tr}}
Consider <z-link>searching all public channels</z-link>.
{{#*inline "z-link"}}<a class="search-shared-history" href="">{{> @partial-block}}</a>{{/inline}}
{{/tr}}
{{/if}}
</span> </span>
</p> </p>
</div> </div>

View File

@@ -63,7 +63,11 @@
<tr> <tr>
<td class="operator">channels:public</td> <td class="operator">channels:public</td>
<td class="definition"> <td class="definition">
{{t 'Search all public channels in the organization.'}} {{#if can_access_all_public_channels }}
{{t 'Search all public channels.'}}
{{else}}
{{t 'Search all public channels that you can view.'}}
{{/if}}
</td> </td>
</tr> </tr>
<tr> <tr>