2024-03-08 11:02:50 -05:00
|
|
|
import Component from "@glimmer/component";
|
2024-11-19 05:57:40 -05:00
|
|
|
import { service } from "@ember/service";
|
2024-03-08 11:02:50 -05:00
|
|
|
import { isValidSearchTerm } from "discourse/lib/search";
|
|
|
|
import i18n from "discourse-common/helpers/i18n";
|
|
|
|
|
|
|
|
export default class AiQuickSearchInfo extends Component {
|
|
|
|
@service search;
|
|
|
|
@service siteSettings;
|
|
|
|
@service quickSearch;
|
|
|
|
|
|
|
|
get termTooShort() {
|
|
|
|
// We check the validity again here because the input may have changed
|
|
|
|
// since the last time we checked, so we may want to stop showing the error
|
|
|
|
const validity = !isValidSearchTerm(
|
|
|
|
this.search.activeGlobalSearchTerm,
|
|
|
|
this.siteSettings
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
validity &&
|
|
|
|
this.quickSearch.invalidTerm &&
|
|
|
|
this.search.activeGlobalSearchTerm?.length > 0
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
<template>
|
|
|
|
{{#if this.termTooShort}}
|
|
|
|
<div class="no-results">{{i18n "search.too_short"}}</div>
|
|
|
|
{{/if}}
|
|
|
|
</template>
|
|
|
|
}
|