Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions ui/apps/platform/cypress/helpers/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ const requestConfigForCollections = {
routeMatcherMap: {
[collectionsAlias]: {
method: 'GET',
url: '/v1/collections?query=*',
url: '/v1/collections?query.query=*',
},
[collectionsCountAlias]: {
method: 'GET',
url: '/v1/collections/count?query=*',
url: '/v1/collectionscount?query.query=*',
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ function CollectionsTable({
<TableComposable variant={TableVariant.compact}>
<Thead>
<Tr>
<Th modifier="wrap" width={25} sort={getEnabledSortParams('name')}>
<Th
modifier="wrap"
width={25}
sort={getEnabledSortParams('Collection Name')}
>
Collection
</Th>
<Th modifier="wrap" sort={getEnabledSortParams('description')}>
Description
</Th>
<Th modifier="wrap" width={10} sort={getEnabledSortParams('inUse')}>
<Th modifier="wrap">Description</Th>
<Th modifier="wrap" width={10}>
In use
</Th>
<Th aria-label="Row actions" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ type CollectionsTablePageProps = {
};

const sortOptions = {
sortFields: ['name', 'description', 'inUse'],
defaultSortOption: { field: 'name', direction: 'asc' } as const,
sortFields: ['Collection Name'],
defaultSortOption: { field: 'Collection Name', direction: 'asc' } as const,
};

function CollectionsTablePage({ hasWriteAccessForCollections }: CollectionsTablePageProps) {
Expand Down Expand Up @@ -65,6 +65,7 @@ function CollectionsTablePage({ hasWriteAccessForCollections }: CollectionsTable
error: countError,
refetch: countRefetch,
} = useRestQuery(countQuery);

const isDataAvailable = typeof listData !== 'undefined' && typeof countData !== 'undefined';
const isLoading = !isDataAvailable && (listLoading || countLoading);
const loadError = listError || countError;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ function getEmbeddedCollections({ collection }: ResolvedCollectionResponse): Pro
}
const idSearchString = collection.embeddedCollections.map(({ id }) => id).join(',');
const searchFilter = { 'Collection ID': idSearchString };
const { request } = listCollections(searchFilter, { field: 'name', reversed: false });
const { request } = listCollections(searchFilter, {
field: 'Collection Name',
reversed: false,
});
return request.then((embeddedCollections) => ({ collection, embeddedCollections }));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function fetchDetachedCollections(
const searchOption = { 'Collection Name': searchValue };
const { request } = listCollections(
searchOption,
{ field: 'name', reversed: false },
{ field: 'Collection Name', reversed: false },
pageNumber - 1,
pageSize
);
Expand Down
18 changes: 13 additions & 5 deletions ui/apps/platform/src/services/CollectionsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import qs from 'qs';

import { ListDeployment } from 'types/deployment.proto';
import { SearchFilter, ApiSortOption } from 'types/search';
import { getListQueryParams, getRequestQueryStringForSearchFilter } from 'utils/searchUtils';
import { getRequestQueryStringForSearchFilter } from 'utils/searchUtils';
import { CancellableRequest, makeCancellableAxiosRequest } from './cancellationUtils';
import axios from './instance';
import { Empty, Pagination } from './types';

export const collectionsBaseUrl = '/v1/collections';
export const collectionsCountUrl = '/v1/collections/count';
export const collectionsCountUrl = '/v1/collectionscount';
export const collectionsDryRunUrl = '/v1/collections/dryrun';
export const collectionsAutocompleteUrl = '/v1/collections/autocomplete';

Expand Down Expand Up @@ -47,7 +47,15 @@ export function listCollections(
page?: number,
pageSize?: number
): CancellableRequest<CollectionResponse[]> {
const params = getListQueryParams(searchFilter, sortOption, page, pageSize);
let offset: number | undefined;
if (typeof page === 'number' && typeof pageSize === 'number') {
offset = page > 0 ? page * pageSize : 0;
}
const query = {
query: getRequestQueryStringForSearchFilter(searchFilter),
pagination: { offset, limit: pageSize, sortOption },
};
const params = qs.stringify({ query }, { allowDots: true });
return makeCancellableAxiosRequest((signal) =>
axios
.get<{
Expand All @@ -64,7 +72,7 @@ export function getCollectionCount(searchFilter: SearchFilter): CancellableReque
const query = getRequestQueryStringForSearchFilter(searchFilter);
return makeCancellableAxiosRequest((signal) =>
axios
.get<{ count: number }>(`${collectionsCountUrl}?query=${query}`, { signal })
.get<{ count: number }>(`${collectionsCountUrl}?query.query=${query}`, { signal })
.then((response) => response.data.count)
);
}
Expand Down Expand Up @@ -130,7 +138,7 @@ export function updateCollection(
): CancellableRequest<CollectionResponse> {
return makeCancellableAxiosRequest((signal) =>
axios
.put<CollectionResponse>(`${collectionsBaseUrl}/${id}`, collection, { signal })
.patch<CollectionResponse>(`${collectionsBaseUrl}/${id}`, collection, { signal })
.then((response) => response.data)
);
}
Expand Down