Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
aac2a0c
inital removal of recompose
bnussman Mar 7, 2025
87690d6
clean up search components
bnussman Mar 7, 2025
1b54973
save progress
bnussman Mar 7, 2025
c702494
clean up more
bnussman Mar 7, 2025
56fdbc3
small fix
bnussman Mar 7, 2025
a3dfce0
clean up more
bnussman Mar 7, 2025
b94656d
fix up loading state
bnussman Mar 7, 2025
be9b93d
add image decription
bnussman Mar 7, 2025
f18a145
get new api search working
bnussman Mar 7, 2025
db8b214
save progress
bnussman Mar 10, 2025
53236a9
save progress
bnussman Mar 10, 2025
5ce8b2c
improve search
bnussman Mar 10, 2025
0f72f14
fully support all entities with API search
bnussman Mar 10, 2025
682083a
fully support all entities with API search
bnussman Mar 10, 2025
ea20290
allow images to be searched by tag
bnussman Mar 10, 2025
59c611b
revert extra change
bnussman Mar 10, 2025
aa5e67a
revert extra change
bnussman Mar 10, 2025
a45094c
sort import
bnussman Mar 10, 2025
2475c9d
add changesets
bnussman Mar 10, 2025
7f40f25
error handling for client side search
bnussman Mar 10, 2025
36d57a6
clean up a bit
bnussman Mar 10, 2025
96cca3d
restore linode description
bnussman Mar 10, 2025
dc611ba
clean up a bit more
bnussman Mar 10, 2025
1b68d0d
add todo
bnussman Mar 10, 2025
366689b
fix random dbaas failures
bnussman Mar 10, 2025
268bd3b
Merge branch 'develop' into poc/start-refatcoring-search
bnussman Mar 11, 2025
81d28e5
fix incorrect icons in searchbar
bnussman Mar 11, 2025
8c336b7
add invalidations for new stackscripts query key
bnussman Mar 11, 2025
ca9d237
Merge branch 'develop' into poc/start-refatcoring-search
bnussman Mar 11, 2025
b863fbe
update imports to use queries package
bnussman Mar 11, 2025
882356c
Merge branch 'develop' into poc/start-refatcoring-search
bnussman Mar 12, 2025
0670da8
fix incorrect object storage error type
bnussman Mar 12, 2025
da18128
Merge branch 'develop' into poc/start-refatcoring-search
bnussman Mar 18, 2025
e4f59e1
Merge branch 'develop' into poc/start-refatcoring-search
bnussman Mar 18, 2025
1ad1e52
Update packages/manager/.changeset/pr-11819-tech-stories-174162955299…
bnussman-akamai Mar 18, 2025
7c6f873
Update packages/manager/.changeset/pr-11819-changed-1741629531708.md
bnussman-akamai Mar 18, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Changed
---

Updates main search to use new API search implementation for large accounts ([#11819](https://github.com/linode/manager/pull/11819))
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tech Stories
---

Updates main search to not depend on `recompose` library ([#11819](https://github.com/linode/manager/pull/11819))
3 changes: 2 additions & 1 deletion packages/manager/src/__data__/searchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const searchbarResult1 = {
searchText: 'result',
tags: [],
},
entityType: 'linode' as any,
entityType: 'linode' as const,
label: 'result1',
value: '111111',
};
Expand All @@ -57,6 +57,7 @@ export const searchbarResult2 = {
searchText: 'result',
tags: ['tag1', 'tag2'],
},
entityType: 'nodebalancer' as const,
label: 'result2',
value: '222222',
};
2 changes: 1 addition & 1 deletion packages/manager/src/components/Tag/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const Tag = (props: TagProps) => {
if (closeMenu) {
closeMenu();
}
history.push(`/search/?query=tag:${label}`);
history.push(`/search?query=tag:${label}`);
};

// If maxLength is set, truncate display to that length.
Expand Down
9 changes: 9 additions & 0 deletions packages/manager/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ export const ENABLE_DEV_TOOLS = getBooleanEnv(
export const ENABLE_MAINTENANCE_MODE =
import.meta.env.REACT_APP_ENABLE_MAINTENANCE_MODE === 'true';

/**
* Because Cloud Manager uses two different search implementations depending on the account's
* size, we have this environment variable which allows us to force Cloud Manager to use
* a desired implementation.
*
* @example REACT_APP_FORCE_SEARCH_TYPE=api
*/
export const FORCE_SEARCH_TYPE = import.meta.env.REACT_APP_FORCE_SEARCH_TYPE;

/** required for the app to function */
export const APP_ROOT =
import.meta.env.REACT_APP_APP_ROOT || 'http://localhost:3000';
Expand Down
1 change: 1 addition & 0 deletions packages/manager/src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface ImportMetaEnv {
REACT_APP_DISABLE_NEW_RELIC?: boolean;
REACT_APP_ENABLE_DEV_TOOLS?: boolean;
REACT_APP_ENABLE_MAINTENANCE_MODE?: string;
REACT_APP_FORCE_SEARCH_TYPE?: 'api' | 'client';
REACT_APP_GPAY_ENV?: 'PRODUCTION' | 'TEST';
REACT_APP_GPAY_MERCHANT_ID?: string;
REACT_APP_LAUNCH_DARKLY_ID?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ vi.mock('@linode/queries', async (importOriginal) => ({
useRegionsQuery: queryMocks.useRegionsQuery,
}));

vi.mock('src/queries/databases/databases', () => ({
useDatabaseTypesQuery: queryMocks.useDatabaseTypesQuery,
}));
vi.mock(import('src/queries/databases/databases'), async (importOriginal) => {
const actual = await importOriginal();
return {
...actual,
useDatabaseTypesQuery: queryMocks.useDatabaseTypesQuery,
};
});

describe('DatabaseSummaryClusterConfiguration', () => {
it('should display correctly for default db', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ const queryMocks = vi.hoisted(() => ({
useDatabaseCredentialsQuery: vi.fn().mockReturnValue({}),
}));

vi.mock('src/queries/databases/databases', () => ({
useDatabaseCredentialsQuery: queryMocks.useDatabaseCredentialsQuery,
}));
vi.mock(import('src/queries/databases/databases'), async (importOriginal) => {
const actual = await importOriginal();
return {
...actual,
useDatabaseCredentialsQuery: queryMocks.useDatabaseCredentialsQuery,
};
});

describe('DatabaseSummaryConnectionDetails', () => {
it('should display correctly for default db', async () => {
Expand Down
10 changes: 7 additions & 3 deletions packages/manager/src/features/Databases/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ const queryMocks = vi.hoisted(() => ({
useDatabaseTypesQuery: vi.fn().mockReturnValue({}),
}));

vi.mock('src/queries/databases/databases', () => ({
useDatabaseTypesQuery: queryMocks.useDatabaseTypesQuery,
}));
vi.mock(import('src/queries/databases/databases'), async (importOriginal) => {
const actual = await importOriginal();
return {
...actual,
useDatabaseTypesQuery: queryMocks.useDatabaseTypesQuery,
};
});

describe('useIsDatabasesEnabled', () => {
it('should return correctly for non V1/V2 user', async () => {
Expand Down
9 changes: 2 additions & 7 deletions packages/manager/src/features/Kubernetes/kubeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import type {
KubernetesTieredVersion,
KubernetesVersion,
} from '@linode/api-v4/lib/kubernetes';
import type { Region } from '@linode/api-v4/lib/regions';
import type { ExtendedType } from 'src/utilities/extendType';

interface ClusterData {
Expand Down Expand Up @@ -52,14 +51,10 @@ export const getTotalClusterMemoryCPUAndStorage = (
);
};

export const getDescriptionForCluster = (
cluster: KubernetesCluster,
regions: Region[]
) => {
const region = regions.find((r) => r.id === cluster.region);
export const getDescriptionForCluster = (cluster: KubernetesCluster) => {
const description: string[] = [
`Kubernetes ${cluster.k8s_version}`,
region?.label ?? cluster.region,
Copy link
Member Author

Choose a reason for hiding this comment

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

The one trade-off this PR makes is that our "entityToSearchableItem" functions must be pure and not require extra API data. This is functionality we can add back in the future, but not as easily right now.

cluster.region,
];

if (cluster.control_plane.high_availability) {
Expand Down
22 changes: 1 addition & 21 deletions packages/manager/src/features/Linodes/presentation.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { displayTypeForKubePoolNode, typeLabelDetails } from './presentation';
import { typeLabelDetails } from './presentation';

describe('Linode presentation helpers', () => {
describe('type label details', () => {
Expand Down Expand Up @@ -27,24 +27,4 @@ describe('Linode presentation helpers', () => {
expect(typedLabel.includes('4CPU'));
});
});

describe('Display for Kube pool nodes', () => {
it('should return a string with heading, size, and CPUs', () => {
expect(displayTypeForKubePoolNode('standard', 4096, 2)).toEqual(
'Standard 4 GB, 2 CPUs'
);
});

it('should pluralize CPUs correctly', () => {
expect(displayTypeForKubePoolNode('standard', 2048, 1)).toEqual(
'Standard 2 GB, 1 CPU'
);
});

it('should format highmem instances', () => {
expect(displayTypeForKubePoolNode('highmem', 2048, 1)).toEqual(
'High Memory 2 GB, 1 CPU'
);
});
});
});
39 changes: 0 additions & 39 deletions packages/manager/src/features/Linodes/presentation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { ExtendedType } from 'src/utilities/extendType';

export const titlecase = (string: string): string => {
return `${string.substr(0, 1).toUpperCase()}${string.substr(1)}`;
};
Expand All @@ -22,40 +20,3 @@ export const typeLabelDetails = (
const diskG = disk / 1024;
return `${cpus} CPU, ${diskG} GB Storage, ${memG} GB RAM`;
};

export const displayType = (
linodeTypeId: null | string,
types: Pick<ExtendedType, 'formattedLabel' | 'id'>[]
): string => {
if (linodeTypeId === null) {
return 'No Plan';
}

const foundType = types.find((t) => t.id === linodeTypeId);
if (foundType && foundType.formattedLabel) {
return foundType.formattedLabel;
}

return 'Unknown Plan';
};

export const displayClass = (category: string) => {
const formattedCategory = category === 'highmem' ? 'High Memory' : category;
return titlecase(formattedCategory);
};

export const displaySize = (memory: number) => {
const memG = memory / 1024;
return `${memG} GB`;
};

export const displayTypeForKubePoolNode = (
category: string,
memory: number,
vcpus: number
) => {
const label = displayClass(category);
const size = displaySize(memory);
const cpus = `${vcpus} CPU${vcpus !== 1 ? 's' : ''}`;
return `${label} ${size}, ${cpus}`;
};

This file was deleted.

4 changes: 2 additions & 2 deletions packages/manager/src/features/Search/ResultGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import { TableRow } from 'src/components/TableRow';
import { StyledButton, StyledTypography } from './ResultGroup.styles';
import { ResultRow } from './ResultRow';

import type { ResultRowDataOption } from './types';
import type { SearchableItem } from './search.interfaces';

interface ResultGroupProps {
entity: string;
groupSize: number;
results: ResultRowDataOption[];
results: SearchableItem[];
}

export const ResultGroup = (props: ResultGroupProps) => {
Expand Down
8 changes: 5 additions & 3 deletions packages/manager/src/features/Search/ResultRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import {
StyledTagTableCell,
} from './ResultRow.styles';

import type { ResultRowDataOption } from './types';
import type { SearchableItem } from './search.interfaces';

interface ResultRowProps {
result: ResultRowDataOption;
result: SearchableItem;
}

export const ResultRow = (props: ResultRowProps) => {
Expand Down Expand Up @@ -47,7 +47,9 @@ export const ResultRow = (props: ResultRowProps) => {
</StyledCreatedTableCell>

<StyledTagTableCell>
<Tags data-testid={'result-tags'} tags={result.data.tags} />
{result.data.tags && (
<Tags data-testid={'result-tags'} tags={result.data.tags} />
)}
</StyledTagTableCell>
</Hidden>
</StyledTableRow>
Expand Down
Loading