-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move PaginatedResourceTable and ResourceLabeledSelect to type file, i…
…mproving naming
- Loading branch information
1 parent
bec8e7a
commit c19aabe
Showing
9 changed files
with
97 additions
and
73 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
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { StorePaginationResult } from '@shell/types/store/pagination.types'; | ||
|
||
/** | ||
* see {@link PagTableFetchSecondaryResources} | ||
*/ | ||
export type PagTableFetchSecondaryResourcesOpts = { canPaginate: boolean } | ||
/** | ||
* see {@link PagTableFetchSecondaryResources} | ||
*/ | ||
export type PagTableFetchSecondaryResourcesReturns = Promise<any> | ||
/** | ||
* Function to fetch resources that are required to supplement information needed by rows in a PaginatedResourceTable | ||
* | ||
* Used in scenarios where ALL resources are expected | ||
*/ | ||
export type PagTableFetchSecondaryResources = (opts: PagTableFetchSecondaryResourcesOpts) => PagTableFetchSecondaryResourcesReturns | ||
|
||
/** | ||
* see {@link PagTableFetchPageSecondaryResources} | ||
*/ | ||
export type PagTableFetchPageSecondaryResourcesOpts = { canPaginate: boolean, force: boolean, page: any[], pagResult: StorePaginationResult } | ||
/** | ||
* Function to fetch resources that are required to supplement information needed by a single page in a PaginatedResourceTable | ||
*/ | ||
export type PagTableFetchPageSecondaryResources = (opts: PagTableFetchPageSecondaryResourcesOpts) => Promise<any> | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { LabelSelectPaginationFunctionOptions } from '@shell/components/form/labeled-select-utils/labeled-select.utils'; | ||
import { LabelSelectPaginateFn } from '@shell/types/components/labeledSelect'; | ||
|
||
type PaginateTypeOverridesFn = (opts: LabelSelectPaginationFunctionOptions) => LabelSelectPaginationFunctionOptions; | ||
|
||
interface SharedSettings { | ||
/** | ||
* Provide specific LabelSelect options for this mode (paginated / not paginated) | ||
*/ | ||
labelSelectOptions?: { [key: string]: any }, | ||
/** | ||
* Map, filter, tweak, etc the resources to show in the LabelSelect | ||
*/ | ||
updateResources?: (resources: any[]) => any[] | ||
} | ||
|
||
/** | ||
* Settings to use when the LabelSelect is paginating | ||
*/ | ||
export interface ResourceLabeledSelectPaginateSettings extends SharedSettings { | ||
/** | ||
* Override the convenience function which fetches a page of results | ||
*/ | ||
overrideRequest?: LabelSelectPaginateFn, | ||
/** | ||
* Override the default settings used in the convenience function to fetch a page of results | ||
*/ | ||
requestSettings?: PaginateTypeOverridesFn, | ||
} | ||
|
||
/** | ||
* Settings to use when the LabelSelect is fetching all resources (not paginating) | ||
*/ | ||
export type ResourceLabeledSelectSettings = SharedSettings | ||
|
||
/** | ||
* Force a specific mode | ||
*/ | ||
export enum RESOURCE_LABEL_SELECT_MODE { | ||
/** | ||
* Fetch all resources | ||
*/ | ||
ALL_RESOURCES = 'ALL', // eslint-disable-line no-unused-vars | ||
/** | ||
* Determine if all resources are fetched given system settings | ||
*/ | ||
DYNAMIC = 'DYNAMIC', // eslint-disable-line no-unused-vars | ||
} | ||