Skip to content
Open
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: 3 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import {
NavigationCancel,
NavigationEnd,
NavigationError,
NavigationStart,
Router,
} from '@angular/router';
Expand Down Expand Up @@ -122,7 +123,8 @@ export class AppComponent implements OnInit, AfterViewInit {
distinctNext(this.isRouteLoading$, true);
} else if (
event instanceof NavigationEnd ||
event instanceof NavigationCancel
event instanceof NavigationCancel ||
event instanceof NavigationError
) {
distinctNext(this.isRouteLoading$, false);
}
Expand Down
10 changes: 9 additions & 1 deletion src/app/core/submission/resolver/submission-links-to-follow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ import { WorkspaceItem } from '../models/workspaceitem.model';
* Needs to be in a separate file to prevent circular dependencies in webpack.
*/
export const SUBMISSION_LINKS_TO_FOLLOW: FollowLinkConfig<WorkflowItem | WorkspaceItem>[] = [
followLink('item'),
followLink('item', {},
followLink('owningCollection', {},
followLink('parentCommunity', {},
followLink('parentCommunity')),
),
followLink('relationships'),
followLink('version', {}, followLink('versionhistory')),
followLink('thumbnail'),
),
followLink('collection'),
];
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class SubmissionObjectResolver<T> implements Resolve<RemoteData<T>> {
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<RemoteData<T>> {
const itemRD$ = this.dataService.findById(route.params.id,
true,
false,
false,
...SUBMISSION_LINKS_TO_FOLLOW,
).pipe(
Expand Down
2 changes: 1 addition & 1 deletion src/app/item-page/item.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class ItemResolver implements Resolve<RemoteData<Item>> {
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<RemoteData<Item>> {
const itemRD$ = this.itemService.findById(route.params.id,
true,
false,
true,
...getItemPageLinksToFollow(),
).pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ export class ItemVersionsNoticeComponent implements OnInit {
map((isLatest) => isLatest != null && !isLatest),
startWith(false),
);
}

// Compute the destination URL from latestVersion$ with the namespace
this.destinationUrl$ = this.latestVersion$.pipe(
switchMap(latestVersion => latestVersion?.item || of(null)),
Expand All @@ -110,7 +108,11 @@ export class ItemVersionsNoticeComponent implements OnInit {

return finalUrl;
})
);
);
} else {
this.showLatestVersionNotice$ = of(false);
this.destinationUrl$ = of(this.document.location.pathname);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ describe('ItemMyDSpaceResultListElementComponent', () => {
});

it('should have correct badge context', () => {
expect(component.badgeContext).toEqual(Context.Any);
});

it('should show archived badge context when item is archived', () => {
component.dso = Object.assign(new Item(), mockResultObject.indexableObject, { isArchived: true });
component.ngOnInit();

expect(component.badgeContext).toEqual(Context.MyDSpaceArchived);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ItemSearchResultListElementSubmissionComponent extends SearchResult
/**
* Represents the badge context
*/
public badgeContext = Context.MyDSpaceArchived;
public badgeContext = Context.Any;


/**
Expand All @@ -33,6 +33,14 @@ export class ItemSearchResultListElementSubmissionComponent extends SearchResult

ngOnInit() {
super.ngOnInit();

// Show the Archived badge only for items that are actually archived.
if (this.dso?.isArchived) {
this.badgeContext = Context.MyDSpaceArchived;
} else {
this.badgeContext = Context.Any;
}

this.showThumbnails = this.appConfig.browseBy.showThumbnails;
}
}
3 changes: 3 additions & 0 deletions src/app/shared/theme-support/themed.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ export abstract class ThemedComponent<T> implements AfterViewInit, OnDestroy, On

this.lazyLoadSub = this.lazyLoadObs.subscribe(([simpleChanges, constructor]: [SimpleChanges, GenericConstructor<T>]) => {
this.destroyComponentInstance();
if (!this.vcr || !this.themedElementContent) {
return;
}
this.compRef = this.vcr.createComponent(constructor, {
projectableNodes: [this.themedElementContent.nativeElement.childNodes],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('ViewTrackerResolverService', () => {
expect(emittedEvent.properties.dc_identifier).toBeUndefined();
});

it('should handle missing dso gracefully (dc_identifier undefined)', () => {
it('should not emit tracking event when dso is missing', () => {
const routeSnapshot = {
data: {
dso: {
Expand All @@ -111,9 +111,7 @@ describe('ViewTrackerResolverService', () => {
service.resolve(routeSnapshot, stateSnapshot);
routerEvents$.next(new ResolveEnd(1, '/', '/', {} as any));

expect(emittedEvent).toBeDefined();
expect(emittedEvent.action).toBe('page_view');
expect(emittedEvent.properties.dc_identifier).toBeUndefined();
expect(emittedEvent).toBeUndefined();
});

it('should use custom dsoPath from route data when provided', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class ViewTrackerResolverService {
const dsoPath = routeSnapshot.data.dsoPath || 'dso.payload'; // Fetch the resolvers passed via the route data
this.router.events.pipe(
filter(event => event instanceof ResolveEnd),
filter(() => !!this.getNestedProperty(routeSnapshot.data, dsoPath)),
take(1),
Comment on lines +28 to 29
switchMap(() =>
this.referrerService.getReferrer().pipe(take(1))))
Expand Down
Loading