Skip to content

Commit

Permalink
Merge pull request #258 from openkfw/252-new-history-endpoints
Browse files Browse the repository at this point in the history
api: New endpoints for project/subproject/workflowitem history
  • Loading branch information
kevinbader authored Apr 30, 2019
2 parents 9893dbf + fcf4e5b commit e2a0616
Show file tree
Hide file tree
Showing 11 changed files with 704 additions and 33 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,30 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added

- Projected budget ratio on project analytics screen [#242](https://github.com/openkfw/TruBudget/pull/242)
- New endpoint `/workflowitem.viewHistory` that returns all changes that have been applied to a particular workflowitem in chronological order. [#252](https://github.com/openkfw/TruBudget/issues/252)

### Changed

- When adding subprojects, projected budgets are not mandatory anymore [#229](https://github.com/openkfw/TruBudget/issues/229)
- Added groups to provisioning [#57](https://github.com/openkfw/TruBudget/issues/57)
- In the frontend directory, the `.env_example` file was removed and the `.env` file is copied into the Docker container instead [#176](https://github.com/openkfw/TruBudget/issues/176)

### Deprecated

- `/project.viewHistory` deprecated in favor of `/project.viewHistory.v2`. [#252](https://github.com/openkfw/TruBudget/issues/252)
- `/subproject.viewHistory` deprecated in favor of `/subproject.viewHistory.v2`. [#252](https://github.com/openkfw/TruBudget/issues/252)

<!-- ### Removed -->

### Fixed

- Fixed line of YAML file for master deployments via docker-compose, so that image of excel export service is pulled correctly [#223](https://github.com/openkfw/TruBudget/issues/223)
- Backup/restore works again. [#237](https://github.com/openkfw/TruBudget/issues/237)
- Budgets on project analytics do not contain open workflow items [#230](https://github.com/openkfw/TruBudget/issues/230)
- Fixed a bug where on smaller screens the action buttons (create & cancel) are hidden and no item could be created [#240](https://github.com/openkfw/TruBudget/issues/240)

<!-- ### Security -->

## [1.0.0-beta.9] - 2019-04-23

### Added
Expand Down
19 changes: 11 additions & 8 deletions api/src/authz/intents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ type Intent =
| "project.intent.listPermissions"
| "project.intent.grantPermission"
| "project.intent.revokePermission"
| "project.viewSummary" // IDs + meta data + allowed intents
| "project.viewDetails" // ID + meta data + allowed intents + history
| "project.viewSummary"
| "project.viewDetails"
| "project.viewHistory"
| "project.assign"
| "project.update"
| "project.close"
| "project.archive"
| "project.createSubproject"
| "project.viewHistory"
| "project.budget.updateProjected"
| "project.budget.deleteProjected"
| "subproject.intent.listPermissions"
Expand All @@ -29,19 +29,20 @@ type Intent =
// TODO: rename to subproject.list
| "subproject.viewSummary"
| "subproject.viewDetails"
| "subproject.viewHistory"
| "subproject.assign"
| "subproject.update"
| "subproject.close"
| "subproject.archive"
| "subproject.createWorkflowitem"
| "subproject.reorderWorkflowitems"
| "subproject.viewHistory"
| "subproject.budget.updateProjected"
| "subproject.budget.deleteProjected"
| "workflowitem.intent.listPermissions"
| "workflowitem.intent.grantPermission"
| "workflowitem.intent.revokePermission"
| "workflowitem.view"
| "workflowitem.viewHistory"
| "workflowitem.assign"
| "workflowitem.update"
| "workflowitem.close"
Expand Down Expand Up @@ -110,12 +111,12 @@ export const projectIntents: Intent[] = [
"project.intent.revokePermission",
"project.viewSummary",
"project.viewDetails",
"project.viewHistory",
"project.assign",
"project.update",
"project.close",
"project.archive",
"project.createSubproject",
"project.viewHistory",
"project.budget.updateProjected",
"project.budget.deleteProjected",
];
Expand All @@ -126,13 +127,13 @@ export const subprojectIntents: Intent[] = [
"subproject.intent.revokePermission",
"subproject.viewSummary",
"subproject.viewDetails",
"subproject.viewHistory",
"subproject.assign",
"subproject.update",
"subproject.close",
"subproject.archive",
"subproject.createWorkflowitem",
"subproject.reorderWorkflowitems",
"subproject.viewHistory",
"subproject.budget.updateProjected",
"subproject.budget.deleteProjected",
];
Expand All @@ -142,6 +143,7 @@ export const workflowitemIntents: Intent[] = [
"workflowitem.intent.grantPermission",
"workflowitem.intent.revokePermission",
"workflowitem.view",
"workflowitem.viewHistory",
"workflowitem.assign",
"workflowitem.update",
"workflowitem.close",
Expand All @@ -165,32 +167,33 @@ export const allIntents: Intent[] = [
"project.intent.revokePermission",
"project.viewSummary",
"project.viewDetails",
"project.viewHistory",
"project.assign",
"project.update",
"project.close",
"project.archive",
"project.createSubproject",
"project.viewHistory",
"project.budget.updateProjected",
"project.budget.deleteProjected",
"subproject.intent.listPermissions",
"subproject.intent.grantPermission",
"subproject.intent.revokePermission",
"subproject.viewSummary",
"subproject.viewDetails",
"subproject.viewHistory",
"subproject.assign",
"subproject.update",
"subproject.close",
"subproject.archive",
"subproject.createWorkflowitem",
"subproject.reorderWorkflowitems",
"subproject.viewHistory",
"subproject.budget.updateProjected",
"subproject.budget.deleteProjected",
"workflowitem.intent.listPermissions",
"workflowitem.intent.grantPermission",
"workflowitem.intent.revokePermission",
"workflowitem.view",
"workflowitem.viewHistory",
"workflowitem.assign",
"workflowitem.update",
"workflowitem.close",
Expand Down
29 changes: 29 additions & 0 deletions api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import * as ProjectPermissionsListAPI from "./project_permissions_list";
import * as ProjectUpdateAPI from "./project_update";
import * as ProjectViewDetailsAPI from "./project_view_details";
import * as ProjectViewHistoryAPI from "./project_view_history";
import * as ProjectViewHistoryAPIv2 from "./project_view_history_v2";
import * as Multichain from "./service";
import * as Cache from "./service/cache2";
import * as DocumentValidationService from "./service/document_validation";
Expand All @@ -52,6 +53,7 @@ import * as ProjectPermissionRevokeService from "./service/project_permission_re
import * as ProjectPermissionsListService from "./service/project_permissions_list";
import * as ProjectProjectedBudgetDeleteService from "./service/project_projected_budget_delete";
import * as ProjectProjectedBudgetUpdateService from "./service/project_projected_budget_update";
import * as ProjectTraceEventsService from "./service/project_trace_events";
import * as ProjectUpdateService from "./service/project_update";
import { ConnectionSettings } from "./service/RpcClient.h";
import * as SubprojectAssignService from "./service/subproject_assign";
Expand All @@ -64,6 +66,7 @@ import * as SubprojectPermissionRevokeService from "./service/subproject_permiss
import * as SubprojectPermissionListService from "./service/subproject_permissions_list";
import * as SubprojectProjectedBudgetDeleteService from "./service/subproject_projected_budget_delete";
import * as SubprojectProjectedBudgetUpdateService from "./service/subproject_projected_budget_update";
import * as SubprojectTraceEventsService from "./service/subproject_trace_events";
import * as SubprojectUpdateService from "./service/subproject_update";
import * as UserAuthenticateService from "./service/user_authenticate";
import * as UserCreateService from "./service/user_create";
Expand All @@ -76,6 +79,7 @@ import * as WorkflowitemListService from "./service/workflowitem_list";
import * as WorkflowitemPermissionGrantService from "./service/workflowitem_permission_grant";
import * as WorkflowitemPermissionRevokeService from "./service/workflowitem_permission_revoke";
import * as WorkflowitemPermissionsListService from "./service/workflowitem_permissions_list";
import * as WorkflowitemTraceEventsService from "./service/workflowitem_trace_events";
import * as WorkflowitemUpdateService from "./service/workflowitem_update";
import * as WorkflowitemsReorderService from "./service/workflowitems_reorder";
import * as SubprojectAssignAPI from "./subproject_assign";
Expand All @@ -90,6 +94,7 @@ import * as SubprojectPermissionListAPI from "./subproject_permissions_list";
import * as SubprojectUpdateAPI from "./subproject_update";
import * as SubprojectViewDetailsAPI from "./subproject_view_details";
import * as SubprojectViewHistoryAPI from "./subproject_view_history";
import * as SubprojectViewHistoryAPIv2 from "./subproject_view_history_v2";
import * as UserAuthenticateAPI from "./user_authenticate";
import * as UserCreateAPI from "./user_create";
import * as UserListAPI from "./user_list";
Expand All @@ -102,6 +107,7 @@ import * as WorkflowitemPermissionRevokeAPI from "./workflowitem_permission_revo
import * as WorkflowitemPermissionsListAPI from "./workflowitem_permissions_list";
import * as WorkflowitemUpdateAPI from "./workflowitem_update";
import * as WorkflowitemValidateDocumentAPI from "./workflowitem_validate_document";
import * as WorkflowitemViewHistoryAPI from "./workflowitem_view_history";
import * as WorkflowitemsReorderAPI from "./workflowitems_reorder";

const URL_PREFIX = "/api";
Expand Down Expand Up @@ -371,6 +377,11 @@ ProjectViewHistoryAPI.addHttpHandler(server, URL_PREFIX, {
SubprojectListService.listSubprojects(db, ctx, user, projectId),
});

ProjectViewHistoryAPIv2.addHttpHandler(server, URL_PREFIX, {
getProjectTraceEvents: (ctx, user, projectId) =>
ProjectTraceEventsService.getTraceEvents(db, ctx, user, projectId),
});

ProjectProjectedBudgetUpdateAPI.addHttpHandler(server, URL_PREFIX, {
updateProjectedBudget: (ctx, user, projectId, orga, amount, currencyCode) =>
ProjectProjectedBudgetUpdateService.updateProjectedBudget(
Expand Down Expand Up @@ -435,6 +446,11 @@ SubprojectViewHistoryAPI.addHttpHandler(server, URL_PREFIX, {
WorkflowitemListService.listWorkflowitems(db, ctx, user, projectId, subprojectId),
});

SubprojectViewHistoryAPIv2.addHttpHandler(server, URL_PREFIX, {
getSubprojectTraceEvents: (ctx, user, projectId, subprojectId) =>
SubprojectTraceEventsService.getTraceEvents(db, ctx, user, projectId, subprojectId),
});

SubprojectPermissionListAPI.addHttpHandler(server, URL_PREFIX, {
listSubprojectPermissions: (ctx, user, projectId, subprojectId) =>
SubprojectPermissionListService.listSubprojectPermissions(
Expand Down Expand Up @@ -498,6 +514,7 @@ SubprojectProjectedBudgetDeleteAPI.addHttpHandler(server, URL_PREFIX, {
currencyCode,
),
});

WorkflowitemsReorderAPI.addHttpHandler(server, URL_PREFIX, {
setWorkflowitemOrdering: (ctx, user, projectId, subprojectId, ordering) =>
WorkflowitemsReorderService.setWorkflowitemOrdering(
Expand All @@ -524,6 +541,18 @@ WorkflowitemListAPI.addHttpHandler(server, URL_PREFIX, {
WorkflowitemListService.listWorkflowitems(db, ctx, user, projectId, subprojectId),
});

WorkflowitemViewHistoryAPI.addHttpHandler(server, URL_PREFIX, {
getWorkflowitemTraceEvents: (ctx, user, projectId, subprojectId, workflowitemId) =>
WorkflowitemTraceEventsService.getTraceEvents(
db,
ctx,
user,
projectId,
subprojectId,
workflowitemId,
),
});

WorkflowitemPermissionsListAPI.addHttpHandler(server, URL_PREFIX, {
listWorkflowitemPermissions: (ctx, user, projectId, subprojectId, workflowitemId) =>
WorkflowitemPermissionsListService.listWorkflowitemPermissions(
Expand Down
1 change: 1 addition & 0 deletions api/src/project_view_history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function mkSwaggerSchema(server: FastifyInstance) {
return {
beforeHandler: [(server as any).authenticate],
schema: {
deprecated: true,
description:
"View the history of a given project (filtered by what the user is allowed to see).",
tags: ["project"],
Expand Down
Loading

0 comments on commit e2a0616

Please sign in to comment.