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

Features: Add searching by URL in quick launch #4321

Closed
Closed
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions docs/configs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ You can use the 'Quick Launch' feature to search services, perform a web search
There are a few optional settings for the Quick Launch feature:

- `searchDescriptions`: which lets you control whether item descriptions are included in searches. This is false by default. When enabled, results that match the item name will be placed above those that only match the description.
- `searchUrls`: which lets you control whether item URLs are included in searches. This is false by default. When enabled, results that match the item name will be placed above those that only match URLs. When used with `searchDescriptions`, items which match descriptions will show higher than those that match only URLs.
- `hideInternetSearch`: disable automatically including the currently-selected web search (e.g. from the widget) as a Quick Launch option. This is false by default, enabling the feature.
- `showSearchSuggestions`: show search suggestions for the internet search. If this is not specified then the setting will be inherited from the search widget. If it is not specified there either, it will default to false. For custom providers the `suggestionUrl` needs to be set in order for this to work.
- `provider`: search engine provider. If none is specified it will try to use the provider set for the Search Widget, if neither are present then internet search will be disabled.
Expand All @@ -386,6 +387,7 @@ There are a few optional settings for the Quick Launch feature:
```yaml
quicklaunch:
searchDescriptions: true
searchUrls: true
hideInternetSearch: true
showSearchSuggestions: true
hideVisitURL: true
Expand Down
13 changes: 9 additions & 4 deletions src/components/quicklaunch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea
const { t } = useTranslation();

const { settings } = useContext(SettingsContext);
const { searchDescriptions = false, hideVisitURL = false } = settings?.quicklaunch ?? {};
const { searchDescriptions = false, searchUrls = false, hideVisitURL = false } = settings?.quicklaunch ?? {};

const searchField = useRef();

Expand Down Expand Up @@ -138,10 +138,15 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea
descriptionMatch = r.description?.toLowerCase().includes(searchString);
r.priority = nameMatch ? 2 * +nameMatch : +descriptionMatch; // eslint-disable-line no-param-reassign
}
return nameMatch || descriptionMatch;
let urlMatch;
if (searchUrls) {
urlMatch = r.href?.toLowerCase().includes(searchString);
r.priority = nameMatch ? 3 * +nameMatch : descriptionMatch ? 2 * +descriptionMatch : +urlMatch;
}
return nameMatch || descriptionMatch || urlMatch;
});

if (searchDescriptions) {
if (searchDescriptions || searchUrls) {
newResults = newResults.sort((a, b) => b.priority - a.priority);
}

Expand Down Expand Up @@ -205,7 +210,7 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea
return () => {
abortController.abort();
};
}, [searchString, servicesAndBookmarks, searchDescriptions, hideVisitURL, searchSuggestions, searchProvider, url, t]);
}, [searchString, servicesAndBookmarks, searchDescriptions, searchUrls, hideVisitURL, searchSuggestions, searchProvider, url, t]);

const [hidden, setHidden] = useState(true);
useEffect(() => {
Expand Down