it("#create", async () => {
axiosMock
- .onPost("/resource/")
+ .onPost("/resource")
.reply(200, { owner_uuid: "ownerUuidValue" });
const commonResourceService = new CommonResourceService(axiosInstance, "resource", actions);
axiosInstance.post = jest.fn(() => Promise.resolve({data: {}}));
const commonResourceService = new CommonResourceService(axiosInstance, "resource", actions);
await commonResourceService.create({ ownerUuid: "ownerUuidValue" });
- expect(axiosInstance.post).toHaveBeenCalledWith("/resource/", {owner_uuid: "ownerUuidValue"});
+ expect(axiosInstance.post).toHaveBeenCalledWith("/resource", {owner_uuid: "ownerUuidValue"});
});
it("#delete", async () => {
it("#list", async () => {
axiosMock
- .onGet("/resource/")
+ .onGet("/resource")
.reply(200, {
kind: "kind",
offset: 2,
constructor(serverApi: AxiosInstance, resourceType: string, actions: ApiActions) {
this.serverApi = serverApi;
- this.resourceType = '/' + resourceType + '/';
+ this.resourceType = '/' + resourceType;
this.actions = actions;
}
delete(uuid: string): Promise<T> {
return CommonService.defaultResponse(
this.serverApi
- .delete(this.resourceType + uuid),
+ .delete(this.resourceType + '/' + uuid),
this.actions
);
}
get(uuid: string) {
return CommonService.defaultResponse(
this.serverApi
- .get<T>(this.resourceType + uuid),
+ .get<T>(this.resourceType + '/' + uuid),
this.actions
);
}
update(uuid: string, data: Partial<T>) {
return CommonService.defaultResponse(
this.serverApi
- .put<T>(this.resourceType + uuid, data && CommonService.mapKeys(_.snakeCase)(data)),
+ .put<T>(this.resourceType + '/' + uuid, data && CommonService.mapKeys(_.snakeCase)(data)),
this.actions
);
}
trash(uuid: string): Promise<T> {
return CommonResourceService.defaultResponse(
this.serverApi
- .post(this.resourceType + `${uuid}/trash`),
+ .post(this.resourceType + `/${uuid}/trash`),
this.actions
);
}
};
return CommonResourceService.defaultResponse(
this.serverApi
- .post(this.resourceType + `${uuid}/untrash`, {
+ .post(this.resourceType + `/${uuid}/untrash`, {
params: CommonResourceService.mapKeys(_.snakeCase)(params)
}),
this.actions
filters: filters ? `[${filters}]` : undefined,
order: order ? order : undefined
};
-
- const pathUrl = uuid ? `${uuid}/contents` : 'contents';
+ const pathUrl = uuid ? `/${uuid}/contents` : '/contents';
const cfg: AxiosRequestConfig = { params: CommonResourceService.mapKeys(_.snakeCase)(params) };
if (session) {
shared(params: SharedArguments = {}): Promise<ListResults<GroupContentsResource>> {
return CommonResourceService.defaultResponse(
this.serverApi
- .get(this.resourceType + 'shared', { params }),
+ .get(this.resourceType + '/shared', { params }),
this.actions
);
}
redirect_to_new_user: true
};
return CommonService.defaultResponse(
- this.serverApi.post('/users/merge/', params),
+ this.serverApi.post('/users/merge', params),
this.actions,
false
);
}
-}
\ No newline at end of file
+}
axiosInstance.post = jest.fn(() => Promise.resolve({ data: {} }));
const projectService = new ProjectService(axiosInstance, actions);
const resource = await projectService.create({ name: "nameValue" });
- expect(axiosInstance.post).toHaveBeenCalledWith("/groups/", {
+ expect(axiosInstance.post).toHaveBeenCalledWith("/groups", {
name: "nameValue",
group_class: "project"
});
axiosInstance.get = jest.fn(() => Promise.resolve({ data: {} }));
const projectService = new ProjectService(axiosInstance, actions);
const resource = await projectService.list();
- expect(axiosInstance.get).toHaveBeenCalledWith("/groups/", {
+ expect(axiosInstance.get).toHaveBeenCalledWith("/groups", {
params: {
filters: "[" + new FilterBuilder()
.addEqual("groupClass", "project")
activate(uuid: string) {
return CommonResourceService.defaultResponse(
this.serverApi
- .post(this.resourceType + `${uuid}/activate`),
+ .post(this.resourceType + `/${uuid}/activate`),
this.actions
);
}
unsetup(uuid: string) {
return CommonResourceService.defaultResponse(
this.serverApi
- .post(this.resourceType + uuid + '/unsetup'),
+ .post(this.resourceType + `/${uuid}/unsetup`),
this.actions
);
}
await dispatch<any>(uploadCollectionFiles(newCollection.uuid));
dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_CREATE_FORM_NAME }));
dispatch(reset(COLLECTION_CREATE_FORM_NAME));
- dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_CREATE_FORM_NAME));
return newCollection;
} catch (e) {
const error = getCommonResourceServiceError(e);
}));
await services.collectionService.delete(newCollection!.uuid);
}
- dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_CREATE_FORM_NAME));
return;
+ } finally {
+ dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_CREATE_FORM_NAME));
}
};
reduxForm<CollectionCreateFormDialogData>({
form: COLLECTION_CREATE_FORM_NAME,
onSubmit: (data, dispatch) => {
- dispatch(createCollection(data));
+ // Somehow an extra field called 'files' gets added, copy
+ // the data object to get rid of it.
+ dispatch(createCollection({ ownerUuid: data.ownerUuid, name: data.name, description: data.description }));
}
})
)(DialogCollectionCreate);