mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 10:10:24 +08:00

* Update the generator to include version * Add versioned APIs * Update imports * Prettier
22 lines
853 B
TypeScript
22 lines
853 B
TypeScript
import { parseListOptionsSelector } from '../../../../features/apiserver/client';
|
|
import { ListOptions } from '../../../../features/apiserver/types';
|
|
import { ListRepositoryApiArg } from '../v0alpha1/endpoints.gen';
|
|
|
|
type ListParams = Omit<ListRepositoryApiArg, 'fieldSelector' | 'labelSelector'> &
|
|
Pick<ListOptions, 'labelSelector' | 'fieldSelector'>;
|
|
|
|
/**
|
|
* A helper function to remove the watch argument from the queryArg and convert field- and labelSelectors to strings
|
|
*/
|
|
export function getListParams(queryArg: ListParams) {
|
|
if (!queryArg) {
|
|
return {};
|
|
}
|
|
const { fieldSelector, labelSelector, watch, ...params } = queryArg;
|
|
return {
|
|
fieldSelector: fieldSelector ? parseListOptionsSelector(fieldSelector) : undefined,
|
|
labelSelector: labelSelector ? parseListOptionsSelector(labelSelector) : undefined,
|
|
...params,
|
|
};
|
|
}
|