Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: Add no-results className to full page search toggle #1055

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions assets/javascripts/discourse/components/ai-full-page-search.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import didUpdate from "@ember/render-modifiers/modifiers/did-update";
import { service } from "@ember/service";
import DToggleSwitch from "discourse/components/d-toggle-switch";
import { SEARCH_TYPE_DEFAULT } from "discourse/controllers/full-page-search";
import concatClass from "discourse/helpers/concat-class";
import { ajax } from "discourse/lib/ajax";
import { isValidSearchTerm, translateResults } from "discourse/lib/search";
import icon from "discourse-common/helpers/d-icon";
Expand Down Expand Up @@ -107,6 +108,18 @@ export default class AiFullPageSearch extends Component {
}
}

get settled() {
return (
this.validSearchOrder &&
!this.searching &&
this.searchTerm === this.initialSearchTerm
);
}

get noResults() {
return this.settled && this.AiResults.length === 0;
}

get searchTerm() {
if (this.initialSearchTerm !== this.args.searchTerm) {
this.initialSearchTerm = undefined;
Expand All @@ -123,6 +136,16 @@ export default class AiFullPageSearch extends Component {
);
}

get searchClass() {
if (!this.validSearchOrder) {
return "unavailable";
} else if (this.searching) {
return "in-progress";
} else if (this.noResults) {
return "no-results";
}
}

get tooltipText() {
return i18n(
`discourse_ai.embeddings.semantic_search_tooltips.${
Expand Down Expand Up @@ -197,9 +220,7 @@ export default class AiFullPageSearch extends Component {
<div class="semantic-search__container search-results" role="region">
<div class="semantic-search__results">
<div
class="semantic-search__searching
{{if this.searching 'in-progress'}}
{{unless this.validSearchOrder 'unavailable'}}"
class={{concatClass "semantic-search__searching" this.searchClass}}
>
<DToggleSwitch
disabled={{this.disableToggleSwitch}}
Expand Down
Loading