- {{
- this.sourceItem.folder_linkType.includes('public')
- ? 'Get public link for'
- : 'Publish'
- }}
+ {{ isPublicSourceItem ? 'Get public link for' : 'Publish' }}
{{ sourceItem.displayName }}
@if (publicLink) {
diff --git a/src/app/file-browser/components/publish/publish.component.spec.ts b/src/app/file-browser/components/publish/publish.component.spec.ts
index 8319e2f87..f05fe903a 100644
--- a/src/app/file-browser/components/publish/publish.component.spec.ts
+++ b/src/app/file-browser/components/publish/publish.component.spec.ts
@@ -3,7 +3,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AccountService } from '@shared/services/account/account.service';
import { FolderVO, RecordVO } from '@models/index';
import { FolderResponse } from '@shared/services/api/folder.repo';
-import { Observable } from 'rxjs';
import { MessageService } from '@shared/services/message/message.service';
import { EventService } from '@shared/services/event/event.service';
import { DIALOG_DATA, DialogRef } from '@angular/cdk/dialog';
@@ -33,8 +32,6 @@ const mockApiService = {
folderVOs: FolderVO[],
destination: FolderVO,
): Promise
=> await Promise.resolve(new FolderResponse({})),
- navigateLean: (folder: FolderVO): Observable =>
- new Observable(),
},
publish: {
getInternetArchiveLink: async () => ({
@@ -64,7 +61,9 @@ describe('PublishComponent', () => {
{
provide: DIALOG_DATA,
useValue: {
- item: { folder_linkType: 'linkType' },
+ // No folder_linkType, like items loaded through the Stela
+ // API, which omits it.
+ item: { type: 'type.folder.generic', displayName: 'Test Item' },
},
},
{ provide: DialogRef, useClass: MockDialogRef },
@@ -94,6 +93,14 @@ describe('PublishComponent', () => {
expect(component).toBeTruthy();
});
+ it('should show the publish title when the item has no folder_linkType', () => {
+ const title = fixture.nativeElement.querySelector('.page-title');
+
+ expect(component.isPublicSourceItem).toBeFalse();
+ expect(title.textContent).toContain('Publish');
+ expect(title.textContent).toContain('Test Item');
+ });
+
it('should disaple the public to internet archive button if the user does not have the correct access role', () => {
component.publicItem = new RecordVO({ recordId: 1 });
component.publishIa = null;
diff --git a/src/app/file-browser/components/publish/publish.component.ts b/src/app/file-browser/components/publish/publish.component.ts
index 6c418e652..346821bdf 100644
--- a/src/app/file-browser/components/publish/publish.component.ts
+++ b/src/app/file-browser/components/publish/publish.component.ts
@@ -8,7 +8,6 @@ import { PublicLinkPipe } from '@shared/pipes/public-link.pipe';
import { AccountService } from '@shared/services/account/account.service';
import { GoogleAnalyticsService } from '@shared/services/google-analytics/google-analytics.service';
import { EVENTS } from '@shared/services/google-analytics/events';
-import { FolderResponse } from '@shared/services/api/index.repo';
import { PublicRoutePipe } from '@shared/pipes/public-route.pipe';
import { Router } from '@angular/router';
import { PublishIaData } from '@models/publish-ia-vo';
@@ -33,6 +32,7 @@ export class PublishComponent {
public linkCopied = false;
public iaLinkCopied = false;
public isAtleastManager = false;
+ public isPublicSourceItem = false;
@ViewChild('publicLinkInput', { static: false }) publicLinkInput: ElementRef;
@ViewChild('iaLinkInput', { static: false }) iaLinkInput: ElementRef;
@@ -55,7 +55,11 @@ export class PublishComponent {
this.isAtleastManager =
this.getRole().includes('manager') || this.getRole().includes('owner');
- if (this.sourceItem?.folder_linkType?.includes('public')) {
+ this.isPublicSourceItem =
+ !!this.sourceItem?.type?.includes('public') ||
+ !!this.sourceItem?.folder_linkType?.includes('public');
+
+ if (this.isPublicSourceItem) {
this.publicItem = this.sourceItem;
this.publicLink = this.linkPipe.transform(this.publicItem);
this.checkInternetArchiveLink();
@@ -80,9 +84,9 @@ export class PublishComponent {
let tries = 0;
while (!this.publicItem && tries < 10) {
tries += 1;
- const publicRootResponse = (await this.api.folder
- .navigateLean(publicRoot)
- .toPromise()) as FolderResponse;
+ const publicRootResponse = await this.api.folder.getWithChildren([
+ publicRoot,
+ ]);
const publicRootFull = publicRootResponse.getFolderVO(true);
const publicFolders: FolderVO[] = publicRootFull.ChildItemVOs.filter(
(i) => i instanceof FolderVO,