Skip to content

Commit

Permalink
fix: proposal logbook sometimes show wrong content & message count no…
Browse files Browse the repository at this point in the history
…t display (#1046)

* fix: proposal logbook show wrong content

* fix: total message count not display bug

* fix: test fail fix - permission specific issue

* fix: e2e test permission error fix

* fix: test 403 error fix
  • Loading branch information
Junjiequan authored Apr 12, 2023
1 parent ede6f61 commit f32e448
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CI/ESS/e2e/.env.backend-next
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ RABBITMQ_PASSWORD="rabbitmq"
REGISTER_DOI_URI="https://mds.test.datacite.org/doi"
REGISTER_METADATA_URI="https://mds.test.datacite.org/metadata"
SITE="ESS"
ADMIN_GROUPS=admin,ingestor,archivemanager
CREATE_DATASET_GROUPS=group1,group2,group3
DELETE_GROUPS=archivemanager
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ export class ViewProposalPageComponent implements OnInit, OnDestroy {
this.vm$.subscribe((vm) => {
if (vm.proposal) {
this.proposal = vm.proposal;
this.store.dispatch(
fetchLogbookAction({ name: this.proposal.proposalId })
);

}
})
);
Expand All @@ -116,6 +114,9 @@ export class ViewProposalPageComponent implements OnInit, OnDestroy {
this.store.dispatch(
fetchProposalDatasetsAction({ proposalId: params.id })
);
this.store.dispatch(
fetchLogbookAction({ name: params.id })
);
})
);

Expand Down
2 changes: 1 addition & 1 deletion src/app/state-management/actions/logbooks.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const clearLogbookAction = createAction("[Logbook] Clear Logbook");

export const fetchCountAction = createAction(
"[Logbook] Fetch Count",
props<{ name: string }>()
props<{ name?: string; pid?: string }>()
);
export const fetchCountCompleteAction = createAction(
"[Logbook] Fetch Count Complete",
Expand Down
26 changes: 16 additions & 10 deletions src/app/state-management/effects/logbooks.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export class LogbookEffects {
return this.actions$.pipe(
ofType(fromActions.fetchLogbookAction),
concatLatestFrom(() => this.filters$),
mergeMap(([{ name }, filters]) =>
this.logbookApi
mergeMap(([{ name }, filters]) =>{
return this.logbookApi
.findByName(encodeURIComponent(name), JSON.stringify(filters))
.pipe(
timeout(3000),
Expand All @@ -44,7 +44,9 @@ export class LogbookEffects {
fromActions.fetchCountAction({ name }),
]),
catchError(() => of(fromActions.fetchLogbookFailedAction()))
)
);
}

)
);
});
Expand All @@ -59,7 +61,8 @@ export class LogbookEffects {
.pipe(
timeout(3000),
mergeMap((logbook) => [
fromActions.fetchLogbookCompleteAction({ logbook })
fromActions.fetchLogbookCompleteAction({ logbook }),
fromActions.fetchCountAction({ pid })
]),
catchError(() => of(fromActions.fetchDatasetLogbookFailedAction()))
)
Expand All @@ -71,15 +74,18 @@ export class LogbookEffects {
return this.actions$.pipe(
ofType(fromActions.fetchCountAction),
concatLatestFrom(() => this.filters$),
mergeMap(([{ name }, filters]) => {
mergeMap(([{ name,pid }, filters]) => {
const { skip, limit, sortField, ...theRest } = filters;
return this.logbookApi
.findByName(encodeURIComponent(name), JSON.stringify(theRest))
return (name ? this.logbookApi
.findByName(encodeURIComponent(name), JSON.stringify(theRest)) : this.logbookApi
.findDatasetLogbook(encodeURIComponent(pid), JSON.stringify(theRest)))
.pipe(
map((logbook: Logbook) =>
fromActions.fetchCountCompleteAction({
map((logbook: Logbook) => {
return fromActions.fetchCountCompleteAction({
count: logbook.messages.length,
})
});
}

),
catchError(() => of(fromActions.fetchCountFailedAction()))
);
Expand Down

0 comments on commit f32e448

Please sign in to comment.