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

feat: [M3-7841] - Add the capability to search for a Linode by ID using the main search tool. #11112

Merged
merged 44 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b274baf
unit test coverage for HostNameTableCell
cpathipa Jun 19, 2024
f958dab
Revert "unit test coverage for HostNameTableCell"
cpathipa Jun 19, 2024
5d0a476
Merge branch 'linode:develop' into develop
cpathipa Jun 25, 2024
93aab07
Merge branch 'linode:develop' into develop
cpathipa Jun 25, 2024
d7deb4f
Merge branch 'linode:develop' into develop
cpathipa Jul 1, 2024
a550f05
Merge branch 'linode:develop' into develop
cpathipa Jul 3, 2024
de0f63e
Merge branch 'linode:develop' into develop
cpathipa Jul 5, 2024
426c42c
Merge branch 'linode:develop' into develop
cpathipa Jul 17, 2024
3fb49a6
Merge branch 'linode:develop' into develop
cpathipa Jul 22, 2024
6c76508
Merge branch 'linode:develop' into develop
cpathipa Jul 24, 2024
1653a6b
Merge branch 'linode:develop' into develop
cpathipa Jul 25, 2024
00421cf
Merge branch 'linode:develop' into develop
cpathipa Jul 29, 2024
959730a
Merge branch 'linode:develop' into develop
cpathipa Jul 31, 2024
d9bd490
Merge branch 'linode:develop' into develop
cpathipa Jul 31, 2024
960415e
Merge branch 'linode:develop' into develop
cpathipa Aug 1, 2024
b9f4745
Merge branch 'linode:develop' into develop
cpathipa Aug 2, 2024
b0b9264
Merge branch 'linode:develop' into develop
cpathipa Aug 21, 2024
6c70559
Merge branch 'linode:develop' into develop
cpathipa Aug 28, 2024
96eb34d
Merge branch 'linode:develop' into develop
cpathipa Sep 3, 2024
74b1635
Merge branch 'linode:develop' into develop
cpathipa Sep 4, 2024
70d1422
Merge branch 'linode:develop' into develop
cpathipa Sep 5, 2024
342fd96
Merge branch 'linode:develop' into develop
cpathipa Sep 9, 2024
bfed239
Merge branch 'linode:develop' into develop
cpathipa Sep 13, 2024
8a19f9b
Merge branch 'linode:develop' into develop
cpathipa Sep 17, 2024
9e9c14f
Merge branch 'linode:develop' into develop
cpathipa Sep 17, 2024
a25728e
Merge branch 'linode:develop' into develop
cpathipa Sep 18, 2024
3196f2a
Merge branch 'linode:develop' into develop
cpathipa Sep 19, 2024
4794d04
Merge branch 'linode:develop' into develop
cpathipa Sep 23, 2024
e977a94
Merge branch 'linode:develop' into develop
cpathipa Sep 24, 2024
add3f10
Merge branch 'linode:develop' into develop
cpathipa Sep 24, 2024
2fafd33
Merge branch 'linode:develop' into develop
cpathipa Sep 25, 2024
b3463ae
Merge branch 'linode:develop' into develop
cpathipa Sep 26, 2024
a325e30
Merge branch 'linode:develop' into develop
cpathipa Sep 30, 2024
b1e2a51
chore: [M3-8662] - Update Github Actions actions (#11009)
bnussman-akamai Sep 26, 2024
1b0931b
Merge branch 'develop' of github.com:cpathipa/manager into develop
cpathipa Sep 30, 2024
9b2de1d
Merge branch 'linode:develop' into develop
cpathipa Sep 30, 2024
ff89c50
Merge branch 'linode:develop' into develop
cpathipa Oct 9, 2024
4dbe28d
Merge branch 'linode:develop' into develop
cpathipa Oct 11, 2024
b2b7d97
Merge branch 'linode:develop' into develop
cpathipa Oct 14, 2024
04514de
Merge branch 'linode:develop' into develop
cpathipa Oct 16, 2024
aefedb2
Add capability to search linode by id from main search tool
cpathipa Oct 16, 2024
3c136c8
Added changeset: Add the capability to search for a Linode by ID usin…
cpathipa Oct 16, 2024
9c9875c
Update packages/manager/.changeset/pr-11112-added-1729086990373.md
cpathipa Oct 17, 2024
1a11f03
Update packages/manager/cypress/e2e/core/linodes/search-linodes.spec.ts
cpathipa Oct 17, 2024
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-11112-added-1729086990373.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Added
---

Add the capability to search for a Linode by ID using the main search tool ([#11112](https://github.com/linode/manager/pull/11112))
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { ui } from 'support/ui';
import { cleanUp } from 'support/util/cleanup';
import { authenticate } from 'support/api/authentication';
import { createTestLinode } from 'support/util/linodes';
import type { Linode } from '@linode/api-v4';

authenticate();
describe('Search Linodes', () => {
beforeEach(() => {
cleanUp(['linodes']);
cy.tag('method:e2e');
});

/*
* - Confirm that linodes are searchable and filtered in the UI.
*/
it('create a linode and make sure it shows up in the table and is searchable in main search tool', () => {
cy.defer(() => createTestLinode({ booted: true })).then(
(linode: Linode) => {
cy.visitWithLogin('/linodes');
cy.get(`[data-qa-linode="${linode.label}"]`)
.should('be.visible')
.within(() => {
cy.contains('Running').should('be.visible');
});

// Confirm that linode is listed on the landing page.
cy.findByText(linode.label).should('be.visible');

// Use the main search bar to search and filter linode by label
cy.get('[id="main-search"').type(linode.label);
ui.autocompletePopper.findByTitle(linode.label).should('be.visible');

// Use the main search bar to search and filter linode by id value
cy.get('[id="main-search"').clear().type(`${linode.id}`);
ui.autocompletePopper.findByTitle(linode.label).should('be.visible');

// Use the main search bar to search and filter linode by id: pattern
cy.get('[id="main-search"').clear().type(`id:${linode.id}`);
ui.autocompletePopper.findByTitle(linode.label).should('be.visible');
}
);
});
});
12 changes: 10 additions & 2 deletions packages/manager/src/features/Search/refinedSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import searchString from 'search-string';
import type { SearchField, SearchableItem } from './search.interfaces';

export const COMPRESSED_IPV6_REGEX = /^([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,7})?::([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,7})?$/;
const DEFAULT_SEARCH_FIELDS = ['label', 'tags', 'ips'];
const DEFAULT_SEARCH_FIELDS = ['label', 'tags', 'ips', 'value'];

// =============================================================================
// REFINED SEARCH
Expand Down Expand Up @@ -166,6 +166,11 @@ export const doesSearchTermMatchItemField = (

const fieldValue = ensureValueIsString(flattenedItem[field]);

// Handle numeric comparison (e.g., for the "value" field to search linode by id)
if (typeof fieldValue === 'number') {
return fieldValue === Number(query); // Ensure exact match for numeric fields
}

if (caseSensitive) {
return fieldValue.includes(query);
} else {
Expand All @@ -177,6 +182,7 @@ export const doesSearchTermMatchItemField = (
export const flattenSearchableItem = (item: SearchableItem) => ({
label: item.label,
type: item.entityType,
value: item.value,
...item.data,
});

Expand All @@ -203,17 +209,19 @@ export const getQueryInfo = (parsedQuery: any) => {
};
};

// Our entities have several fields we'd like to search: "tags", "label", "ips".
// Our entities have several fields we'd like to search: "tags", "label", "ips", "value".
// A user might submit the query "tag:my-app". In this case, we want to trade
// "tag" for "tags", since "tags" is the actual name of the intended property.
export const getRealEntityKey = (key: string): SearchField | string => {
const TAGS: SearchField = 'tags';
const LABEL: SearchField = 'label';
const IPS: SearchField = 'ips';
const TYPE: SearchField = 'type';
const VALUE: SearchField = 'value';

const substitutions = {
group: TAGS,
id: VALUE,
ip: IPS,
is: TYPE,
name: LABEL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type SearchableEntityType =
| 'volume';

// These are the properties on our entities we'd like to search
export type SearchField = 'ips' | 'label' | 'tags' | 'type';
export type SearchField = 'ips' | 'label' | 'tags' | 'type' | 'value';

export interface SearchResultsByEntity {
buckets: SearchableItem[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export const bucketToSearchableItem = (
cluster: bucket.cluster,
created: bucket.created,
description: readableBytes(bucket.size).formatted,
icon: 'bucket',
icon: 'storage',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This results rending bucket icon for storage bucket search

label: bucket.label,
path: `/object-storage/buckets/${bucket.cluster}/${bucket.label}`,
},
Expand Down