mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-06-29 19:12:15 +00:00
DEV: Conditionally show AI results toggle based on sort order (#652)
This commit is contained in:
parent
834fea672f
commit
02a50a29f8
@ -24,11 +24,14 @@ export default class SemanticSearch extends Component {
|
|||||||
@tracked searching = false;
|
@tracked searching = false;
|
||||||
@tracked AIResults = [];
|
@tracked AIResults = [];
|
||||||
@tracked showingAIResults = false;
|
@tracked showingAIResults = false;
|
||||||
@tracked preventAISearch = false;
|
|
||||||
initialSearchTerm = this.args.outletArgs.search;
|
initialSearchTerm = this.args.outletArgs.search;
|
||||||
|
|
||||||
get disableToggleSwitch() {
|
get disableToggleSwitch() {
|
||||||
if (this.searching || this.AIResults.length === 0 || this.preventAISearch) {
|
if (
|
||||||
|
this.searching ||
|
||||||
|
this.AIResults.length === 0 ||
|
||||||
|
this.args.outletArgs.sortOrder !== 0
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,11 +56,6 @@ export default class SemanticSearch extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search disabled for sort order:
|
|
||||||
if (this.preventAISearch) {
|
|
||||||
return I18n.t("discourse_ai.embeddings.semantic_search_disabled_sort");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search loading:
|
// Search loading:
|
||||||
if (this.searching) {
|
if (this.searching) {
|
||||||
return I18n.t("discourse_ai.embeddings.semantic_search_loading");
|
return I18n.t("discourse_ai.embeddings.semantic_search_loading");
|
||||||
@ -88,7 +86,8 @@ export default class SemanticSearch extends Component {
|
|||||||
get searchEnabled() {
|
get searchEnabled() {
|
||||||
return (
|
return (
|
||||||
this.args.outletArgs.type === SEARCH_TYPE_DEFAULT &&
|
this.args.outletArgs.type === SEARCH_TYPE_DEFAULT &&
|
||||||
isValidSearchTerm(this.searchTerm, this.siteSettings)
|
isValidSearchTerm(this.searchTerm, this.siteSettings) &&
|
||||||
|
this.args.outletArgs.sortOrder === 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,15 +113,6 @@ export default class SemanticSearch extends Component {
|
|||||||
if (!this.searchEnabled) {
|
if (!this.searchEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (
|
|
||||||
this.searchPreferencesManager?.sortOrder !== undefined &&
|
|
||||||
this.searchPreferencesManager?.sortOrder !== 0
|
|
||||||
) {
|
|
||||||
this.preventAISearch = true;
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
this.preventAISearch = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.initialSearchTerm && !this.searching) {
|
if (this.initialSearchTerm && !this.searching) {
|
||||||
return this.performHyDESearch();
|
return this.performHyDESearch();
|
||||||
|
@ -295,7 +295,6 @@ en:
|
|||||||
embeddings:
|
embeddings:
|
||||||
semantic_search: "Topics (Semantic)"
|
semantic_search: "Topics (Semantic)"
|
||||||
semantic_search_loading: "Searching for more results using AI"
|
semantic_search_loading: "Searching for more results using AI"
|
||||||
semantic_search_disabled_sort: "AI Search disabled for this sort order, sort by Relevance to enable."
|
|
||||||
semantic_search_results:
|
semantic_search_results:
|
||||||
toggle: "Showing %{count} results found using AI"
|
toggle: "Showing %{count} results found using AI"
|
||||||
toggle_hidden: "Hiding %{count} results found using AI"
|
toggle_hidden: "Hiding %{count} results found using AI"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user