'/collections', {
params: {
filters: `[["uuid","=","zzzzz-4zz18-0123456789abcde"]]`,
- order: undefined
+ include_old_versions: true,
+ },
+ }
+ );
+ });
+
+ it('should be able to request specific fields', async () => {
+ serverApi.get = jest.fn(() => Promise.resolve(
+ { data: { items: [{}] } }
+ ));
+ const uuid = 'zzzzz-4zz18-0123456789abcde'
+ await collectionService.get(uuid, undefined, ['manifestText']);
+ expect(serverApi.get).toHaveBeenCalledWith(
+ '/collections', {
+ params: {
+ filters: `[["uuid","=","zzzzz-4zz18-0123456789abcde"]]`,
+ include_old_versions: true,
+ select: `["manifest_text"]`
},
}
);
import { ApiActions } from "services/api/api-actions";
import { customEncodeURI } from "common/url";
import { FilterBuilder } from "services/api/filter-builder";
+import { ListArguments } from "services/common-service/common-service";
export type UploadProgress = (fileId: number, loaded: number, total: number, currentTime: number) => void;
]);
}
- async get(uuid: string, showErrors?: boolean) {
+ async get(uuid: string, showErrors?: boolean, select?: string[]) {
super.validateUuid(uuid);
// We use a filtered list request to avoid getting the manifest text
const filters = new FilterBuilder().addEqual('uuid', uuid).getFilters();
- const lst = await super.list({filters}, showErrors);
+ const listArgs: ListArguments = {filters, includeOldVersions: true};
+ if (select) {
+ listArgs.select = select;
+ }
+ const lst = await super.list(listArgs, showErrors);
return lst.items[0];
}
}
list(args: ListArguments = {}, showErrors?: boolean): Promise<ListResults<T>> {
- const { filters, order, ...other } = args;
+ const { filters, select, ...other } = args;
const params = {
...CommonService.mapKeys(snakeCase)(other),
filters: filters ? `[${filters}]` : undefined,
- order: order ? order : undefined
+ select: select
+ ? `[${select.map(snakeCase).map(s => `"${s}"`).join(', ')}]`
+ : undefined
};
if (QueryString.stringify(params).length <= 1500) {
const collectionApiResponse = (apiResponse: CollectionResource) => {
const { uuid, ownerUuid, createdAt, modifiedAt, modifiedByClientUuid, modifiedByUserUuid, name, description, properties, portableDataHash, replicationDesired,
- replicationConfirmedAt, replicationConfirmed, manifestText, deleteAt, trashAt, isTrashed, storageClassesDesired,
+ replicationConfirmedAt, replicationConfirmed, deleteAt, trashAt, isTrashed, storageClassesDesired,
storageClassesConfirmed, storageClassesConfirmedAt, currentVersionUuid, version, preserveVersion, fileCount, fileSizeTotal } = apiResponse;
const response = `
"uuid": "${uuid}",
"replication_desired": ${stringify(replicationDesired)},
"replication_confirmed_at": ${stringify(replicationConfirmedAt)},
"replication_confirmed": ${stringify(replicationConfirmed)},
-"manifest_text": ${stringify(manifestText)},
"name": ${stringify(name)},
"description": ${stringify(description)},
"properties": ${stringifyObject(properties)},
const currentCollection = state.collectionPanel.item;
if (currentCollection && !currentCollection.manifestText) {
- const fetchedCurrentCollection = await services.collectionService.get(currentCollection.uuid);
+ const fetchedCurrentCollection = await services.collectionService.get(currentCollection.uuid, undefined, ['manifestText']);
currentCollection.manifestText = fetchedCurrentCollection.manifestText;
currentCollection.unsignedManifestText = fetchedCurrentCollection.unsignedManifestText;
}
import { resourcesActions } from "../resources/resources-actions";
import { navigateTo } from "../navigation/navigation-action";
import { dialogActions } from "../dialog/dialog-actions";
+import { getResource } from "store/resources/resources";
+import { CollectionResource } from "models/collection";
export const COLLECTION_RESTORE_VERSION_DIALOG = 'collectionRestoreVersionDialog';
export const restoreVersion = (resourceUuid: string) =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
try {
- // Request que entire record because stored old versions usually
- // don't include the manifest_text field.
- const oldVersion = await services.collectionService.get(resourceUuid);
+ // Request the manifest text because stored old versions usually
+ // don't include them.
+ let oldVersion = getResource<CollectionResource>(resourceUuid)(getState().resources);
+ if (!oldVersion) {
+ oldVersion = await services.collectionService.get(resourceUuid);
+ }
+ const oldVersionManifest = await services.collectionService.get(resourceUuid, undefined, ['manifestText']);
+ oldVersion.manifestText = oldVersionManifest.manifestText;
+
const { uuid, version, ...rest} = oldVersion;
const headVersion = await services.collectionService.update(
oldVersion.currentVersionUuid,