Skip to content

Commit

Permalink
fix TRS ID "copy button" bug
Browse files Browse the repository at this point in the history
  • Loading branch information
svonworl authored Oct 24, 2024
1 parent d7fa51d commit c9ff712
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/app/workflow/info-tab/info-tab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export class InfoTabComponent extends EntryTab implements OnInit, OnChanges {
this.authors = null;
this.description = null;
}
this.displayTextForButton = this.infoTabService.getTRSId(this.workflow);
}

ngOnInit() {
Expand All @@ -208,9 +209,6 @@ export class InfoTabComponent extends EntryTab implements OnInit, OnChanges {
this.infoTabService.defaultTestFilePathEditing$
.pipe(takeUntil(this.ngUnsubscribe))
.subscribe((editing) => (this.defaultTestFilePathEditing = editing));
this.entryType$
.pipe(takeUntil(this.ngUnsubscribe))
.subscribe((entryType) => (this.displayTextForButton = this.infoTabService.getTRSId(this.workflow, entryType)));
this.infoTabService.forumUrlEditing$.pipe(takeUntil(this.ngUnsubscribe)).subscribe((editing) => (this.forumUrlEditing = editing));
}
/**
Expand Down
15 changes: 10 additions & 5 deletions src/app/workflow/info-tab/info-tab.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { WorkflowsService } from 'app/shared/openapi';
import { ExtendedWorkflowQuery } from 'app/shared/state/extended-workflow.query';
import { WorkflowService } from 'app/shared/state/workflow.service';
import { WorkflowsStubService, WorkflowStubService } from 'app/test/service-stubs';
import { sampleWorkflow3 } from '../../test/mocked-objects';
import { sampleWorkflow3, appToolEntryTypeMetadata, serviceEntryTypeMetadata, notebookEntryTypeMetadata } from '../../test/mocked-objects';
import { InfoTabService } from './info-tab.service';

describe('ValueService', () => {
Expand Down Expand Up @@ -54,10 +54,15 @@ describe('ValueService', () => {
it(`getTRSId should work for tools and workflows`, () => {
service = TestBed.inject(InfoTabService);
const fullWorkflowPath = sampleWorkflow3.full_workflow_path;
expect(service.getTRSId(sampleWorkflow3, EntryType.BioWorkflow)).toBe(`#workflow/${fullWorkflowPath}`);
expect(service.getTRSId(sampleWorkflow3, EntryType.AppTool)).toBe(fullWorkflowPath);
expect(service.getTRSId(sampleWorkflow3, EntryType.Service)).toBe(`#service/${fullWorkflowPath}`);
expect(service.getTRSId(null, EntryType.BioWorkflow)).toBe('');
const clone = Object.assign({}, sampleWorkflow3);
expect(service.getTRSId(clone)).toBe(`#workflow/${fullWorkflowPath}`);
clone.entryTypeMetadata = appToolEntryTypeMetadata;
expect(service.getTRSId(clone)).toBe(fullWorkflowPath);
clone.entryTypeMetadata = serviceEntryTypeMetadata;
expect(service.getTRSId(clone)).toBe(`#service/${fullWorkflowPath}`);
clone.entryTypeMetadata = notebookEntryTypeMetadata;
expect(service.getTRSId(clone)).toBe(`#notebook/${fullWorkflowPath}`);
expect(service.getTRSId(null)).toBe('');
});

it(`getTRSPlainType should work for various descriptor types`, () => {
Expand Down
7 changes: 4 additions & 3 deletions src/app/workflow/info-tab/info-tab.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,12 @@ export class InfoTabService {
);
}

getTRSId(workflow: Workflow | undefined, entryType: EntryType): string {
if (!workflow) {
getTRSId(workflow: Workflow | undefined): string {
if (workflow) {
return workflow.entryTypeMetadata.trsPrefix + workflow.full_workflow_path;
} else {
return '';
}
return this.getTRSIDFromPath(workflow.full_workflow_path, entryType);
}

private getTRSIDFromPath(fullWorkflowPath: string, entryType: EntryType): string {
Expand Down

0 comments on commit c9ff712

Please sign in to comment.