-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(plugin-search): improves types (#10955)
There were a number of areas within the Search Plugin where typings could have been improved, namely: - The `customProps` sent to the `ReindexButton`. This now uses the `satisfies` keyword to ensure type strictness. - The `collectionLabels` prop sent to the `ReindexButtonClient` component. This is now standardized behind a new `ResolvedCollectionLabels` type to closely reflect `CollectionLabels`. This was also converted from unnecessarily invoking a function to being a basic object. - The `locale` type sent through `SyncDocArgs`. This now uses `Locale['code']` from Payload.
- Loading branch information
1 parent
0a1cc6a
commit 1771271
Showing
4 changed files
with
29 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 15 additions & 16 deletions
31
packages/plugin-search/src/Search/ui/ReindexButton/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 6 additions & 5 deletions
11
packages/plugin-search/src/Search/ui/ReindexButton/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
import type { CustomComponent, PayloadServerReactComponent, StaticLabel } from 'payload' | ||
import type { CustomComponent, PayloadServerReactComponent } from 'payload' | ||
|
||
import type { CollectionLabels } from '../../../types.js' | ||
import type { CollectionLabels, ResolvedCollectionLabels } from '../../../types.js' | ||
|
||
export type ReindexButtonProps = { | ||
collectionLabels: Record<string, StaticLabel> | ||
collectionLabels: ResolvedCollectionLabels | ||
searchCollections: string[] | ||
searchSlug: string | ||
} | ||
|
||
type ReindexButtonServerProps = { | ||
export type ReindexButtonServerProps = { | ||
collectionLabels: CollectionLabels | ||
} & ReindexButtonProps | ||
} & Omit<ReindexButtonProps, 'collectionLabels'> | ||
|
||
export type SearchReindexButtonClientComponent = ReindexButtonProps | ||
|
||
export type SearchReindexButtonServerComponent = PayloadServerReactComponent< | ||
CustomComponent<ReindexButtonServerProps> | ||
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters