Skip to content
Merged
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
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-12336-fixed-1749131430455.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

Queries from search should properly be converted to strings ([#12336](https://github.com/linode/manager/pull/12336))
4 changes: 2 additions & 2 deletions packages/manager/src/factories/firewalls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const firewallTemplateRulesFactory =
});

export const firewallFactory = Factory.Sync.makeFactory<Firewall>({
created: '2020-01-01 00:00:00',
created: '2020-01-01T00:00:00',
entities: [
{
id: 1,
Expand All @@ -56,7 +56,7 @@ export const firewallFactory = Factory.Sync.makeFactory<Firewall>({
rules: firewallRulesFactory.build(),
status: 'enabled',
tags: [],
updated: '2020-01-01 00:00:00',
updated: '2020-01-01T00:00:00',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an invalid date in our mocks. We use ISO format

});

export const firewallEntityfactory =
Expand Down
3 changes: 3 additions & 0 deletions packages/manager/src/features/Search/refinedSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ export const refinedSearch = (
};

export const formatQuery = (query: string) => {
if (!query || typeof query !== 'string') {
return '';
}
return query.trim().replace(' && ', ' AND ').replace(' || ', ' OR ');
};

Expand Down
6 changes: 5 additions & 1 deletion packages/manager/src/features/Search/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ export const search = (
entities: SearchableItem[],
inputValue: string
): SearchResults => {
if (!inputValue || inputValue === '') {
if (
!inputValue ||
typeof inputValue !== 'string' ||

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a bit overkill now that we made the fix at the router level, but I guess it can't hurt

inputValue.trim() === ''
) {
return { combinedResults: [], searchResultsByEntity: emptyResults };
}

Expand Down
6 changes: 1 addition & 5 deletions packages/manager/src/routes/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ import { createRoute } from '@tanstack/react-router';
import { rootRoute } from '../root';
import { SearchRoute } from './SearchRoute';

type SearchSearchParams = {
query: string;
};

const searchRoute = createRoute({
component: SearchRoute,
getParentRoute: () => rootRoute,
path: 'search',
validateSearch: (search: SearchSearchParams) => search,
validateSearch: (params) => ({ query: String(params.query) }),
});

const searchLandingRoute = createRoute({
Expand Down