Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<div class="dialog-content">
<div class="dialog-body">
<div class="page-title break-all">
{{
this.sourceItem.folder_linkType.includes('public')
? 'Get public link for'
: 'Publish'
}}
{{ isPublicSourceItem ? 'Get public link for' : 'Publish' }}
{{ sourceItem.displayName }}
</div>
@if (publicLink) {
Expand Down
15 changes: 11 additions & 4 deletions src/app/file-browser/components/publish/publish.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -33,8 +32,6 @@ const mockApiService = {
folderVOs: FolderVO[],
destination: FolderVO,
): Promise<FolderResponse> => await Promise.resolve(new FolderResponse({})),
navigateLean: (folder: FolderVO): Observable<FolderResponse> =>
new Observable<FolderResponse>(),
},
publish: {
getInternetArchiveLink: async () => ({
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 9 additions & 5 deletions src/app/file-browser/components/publish/publish.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand All @@ -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();
Expand All @@ -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,
Expand Down