Skip to content

Commit

Permalink
Add auto DOI opt-out toggle for legacy and hosted workflows (#2059)
Browse files Browse the repository at this point in the history
  • Loading branch information
kathy-t authored Feb 12, 2025
1 parent a29f9a1 commit 9da6cbe
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 44 deletions.
129 changes: 88 additions & 41 deletions src/app/shared/entry/doi/manage-dois/manage-dois-dialog.component.html
Original file line number Diff line number Diff line change
@@ -1,47 +1,94 @@
<h1 mat-dialog-title>Manage DOIs</h1>
<mat-dialog-content>
<p>
A Digital Object Identifier (DOI) allows a {{ entryTypeMetadata.term }} version to be easily cited in publications. There are two types
of DOIs:
</p>
<ul>
<li><strong>Version DOI:</strong> represents a specific version.</li>
<li><strong>Concept DOI:</strong> represents all versions and resolves to the latest one.</li>
</ul>
<mat-card *ngIf="!doiInfoMap.size" class="alert alert-info mat-elevation-z mt-3" role="alert">
<mat-icon class="alert-info-icon">info</mat-icon> This {{ entryTypeMetadata.term }} has no DOIs.
</mat-card>
<p *ngIf="doiInfoMap.size">Select which DOI to display publicly:</p>
<mat-radio-group [(ngModel)]="selectedOption" aria-label="Select an option" fxLayout="column" fxLayoutGap="1rem">
<mat-card *ngFor="let doiInfo of doiInfoMap | keyvalue: originalOrder" [class]="doiInfo.key === selectedOption ? 'selected-card' : ''">
<mat-radio-button [value]="doiInfo.key" class="w-100">
<div>
<app-doi-badge [doi]="doiInfo.value.conceptDoi" [displayDoi]="false" class="mr-2"></app-doi-badge>
<strong>{{ doiInfo.key | titlecase }}</strong>
</div>
</mat-radio-button>
<div class="ml-5">
<div class="size-small gray-caption">
<span *ngIf="doiInfo.key === DoiInitiatorEnum.USER"> Manually created by a user in the Dockstore UI. </span>
<span *ngIf="doiInfo.key === DoiInitiatorEnum.DOCKSTORE">
Automatically created by Dockstore for valid tags belonging to published {{ entryTypeMetadata.termPlural }}.
</span>
<span *ngIf="doiInfo.key === DoiInitiatorEnum.GITHUB"> Created by Zenodo's integration with GitHub. </span>
</div>
<span class="mr-4">
<span>Version DOI: </span>
<app-doi-badge *ngIf="doiInfo.value.versionDoi" [doi]="doiInfo.value.versionDoi" [displayInitiator]="false"></app-doi-badge>
<span *ngIf="!doiInfo.value.versionDoi">n/a</span>
</span>
<span>
<span>Concept DOI: </span>
<app-doi-badge *ngIf="doiInfo.value.conceptDoi" [doi]="doiInfo.value.conceptDoi" [displayInitiator]="false"></app-doi-badge>
</span>
</div>
<app-alert></app-alert>
<div>
<p>
A Digital Object Identifier (DOI) allows a {{ entryTypeMetadata.term }} version to be easily cited in publications. There are two
types of DOIs:
</p>
<ul>
<li><strong>Version DOI:</strong> represents a specific version.</li>
<li><strong>Concept DOI:</strong> represents all versions and resolves to the latest one.</li>
</ul>
</div>
<div class="my-5">
<strong class="mr-3">Automatic DOI Generation:</strong>
<strong *ngIf="isGitHubAppEntry">{{ isAutoDoiEnabled ? 'On' : 'Off' }}</strong>
<mat-slide-toggle
*ngIf="!isGitHubAppEntry"
[(ngModel)]="isAutoDoiEnabled"
(change)="toggleAutoDoiGeneration()"
labelPosition="after"
class="align-middle"
>{{ isAutoDoiEnabled ? 'On' : 'Off' }}</mat-slide-toggle
>
<br />

<p class="size-small gray-caption">
<span>
Dockstore automatically creates a DOI for each valid, tagged version of this {{ entryTypeMetadata.term }} if it is published. It
does not require a Zenodo account to be linked.
</span>
<span *ngIf="isGitHubAppEntry">
Edit the enableAutoDoi field in the .dockstore.yml to change your Automatic DOI Generation preference.
</span>
<a
class="ds-green"
[href]="Dockstore.DOCUMENTATION_URL + '/end-user-topics/dois.html#automatic-dockstore-doi-generation'"
target="_blank"
rel="noopener noreferrer"
><mat-icon>info</mat-icon></a
>
</p>
</div>
<div>
<strong>DOI Selection</strong><br />
<p class="size-small gray-caption">Select which DOI to display publicly:</p>
<mat-card *ngIf="!doiInfoMap.size" class="alert alert-info mat-elevation-z mt-3" role="alert">
<mat-icon class="alert-info-icon">info</mat-icon> This {{ entryTypeMetadata.term }} has no DOIs.
</mat-card>
</mat-radio-group>
<mat-radio-group
[(ngModel)]="selectedOption"
aria-label="Select an option"
fxLayout="column"
fxLayoutGap="1rem"
(change)="saveDoiSelection()"
>
<mat-card
*ngFor="let doiInfo of doiInfoMap | keyvalue: originalOrder"
[class]="doiInfo.key === selectedOption ? 'selected-card' : ''"
>
<mat-radio-button [value]="doiInfo.key" class="w-100">
<div>
<app-doi-badge [doi]="doiInfo.value.conceptDoi" [displayDoi]="false" class="mr-2"></app-doi-badge>
<strong>{{ doiInfo.key | titlecase }}</strong>
</div>
</mat-radio-button>
<div class="ml-5">
<div class="size-small gray-caption">
<span *ngIf="doiInfo.key === DoiInitiatorEnum.USER"> Manually created by a user in the Dockstore UI. </span>
<span *ngIf="doiInfo.key === DoiInitiatorEnum.DOCKSTORE">
Automatically created by Dockstore for valid tags belonging to published {{ entryTypeMetadata.termPlural }}.
</span>
<span *ngIf="doiInfo.key === DoiInitiatorEnum.GITHUB"> Created by Zenodo's integration with GitHub. </span>
</div>

<div>
<span class="mr-4">
<span>Version DOI: </span>
<app-doi-badge *ngIf="doiInfo.value.versionDoi" [doi]="doiInfo.value.versionDoi" [displayInitiator]="false"></app-doi-badge>
<span *ngIf="!doiInfo.value.versionDoi">n/a</span>
</span>
<span>
<span>Concept DOI: </span>
<app-doi-badge *ngIf="doiInfo.value.conceptDoi" [doi]="doiInfo.value.conceptDoi" [displayInitiator]="false"></app-doi-badge>
</span>
</div>
</div>
</mat-card>
</mat-radio-group>
</div>
</mat-dialog-content>
<div mat-dialog-actions class="pull-right">
<button mat-button mat-dialog-close class="secondary-1" cdkFocusInitial>Cancel</button>
<button mat-raised-button mat-dialog-close class="accent-1-dark-btn mat-elevation-z" (click)="saveDoiSelection()">Save</button>
<button mat-raised-button mat-dialog-close class="accent-1-dark-btn mat-elevation-z">Done</button>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { Doi, EntryTypeMetadata, Workflow, WorkflowVersion } from 'app/shared/op
import { ManageDoisDialogService } from './manage-dois-dialog.service';
import { MatIconModule } from '@angular/material/icon';
import { DoiBadgeComponent } from '../doi-badge/doi-badge.component';
import { MatLegacySlideToggleModule } from '@angular/material/legacy-slide-toggle';
import { Dockstore } from 'app/shared/dockstore.model';
import { AlertComponent } from 'app/shared/alert/alert.component';

export interface ManageDoisDialogData {
entry: Workflow;
Expand All @@ -32,6 +35,7 @@ export interface DoiInfo {
MatLegacyButtonModule,
MatLegacyCardModule,
MatLegacyRadioModule,
MatLegacySlideToggleModule,
MatIconModule,
FlexModule,
FormsModule,
Expand All @@ -40,14 +44,18 @@ export interface DoiInfo {
KeyValuePipe,
TitleCasePipe,
DoiBadgeComponent,
AlertComponent,
],
})
export class ManageDoisDialogComponent {
Dockstore = Dockstore;
DoiInitiatorEnum = Doi.InitiatorEnum;
entry: Workflow;
entryTypeMetadata: EntryTypeMetadata;
selectedOption: Doi.InitiatorEnum;
doiInfoMap: Map<Doi.InitiatorEnum, DoiInfo> = new Map();
isAutoDoiEnabled: boolean;
isGitHubAppEntry: boolean;

constructor(
public dialogRef: MatLegacyDialogRef<ManageDoisDialogComponent>,
Expand All @@ -57,6 +65,8 @@ export class ManageDoisDialogComponent {
this.entry = data.entry;
this.entryTypeMetadata = data.entry.entryTypeMetadata;
this.selectedOption = data.entry.doiSelection;
this.isAutoDoiEnabled = data.entry.autoGenerateDois;
this.isGitHubAppEntry = data.entry.mode === Workflow.ModeEnum.DOCKSTOREYML;
Object.entries(data.entry.conceptDois).forEach(([initiator, conceptDoi]) => {
let initiatorEnum = Object.keys(Doi.InitiatorEnum).find((i) => Doi.InitiatorEnum[i] === initiator);
let versionDoi = data.version?.dois[initiator];
Expand All @@ -68,6 +78,14 @@ export class ManageDoisDialogComponent {
});
}

/**
* Called on slide toggle to enable or disable auto DOI generation
* @param event toggle event
*/
toggleAutoDoiGeneration() {
this.manageDoisDialogService.toggleAutoDoiGeneration(this.entry, this.isAutoDoiEnabled);
}

saveDoiSelection() {
this.manageDoisDialogService.saveDoiSelection(this.entry, this.selectedOption);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,25 @@ export class ManageDoisDialogService {

this.workflowsService.updateWorkflow(entry.id, newEntryForUpdate).subscribe(
(response) => {
this.alertService.detailedSuccess();
this.alertService.simpleSuccess();
this.workflowService.setWorkflow({ ...this.workflowQuery.getActive(), doiSelection: response.doiSelection });
},
(error) => {
this.alertService.detailedError(error);
}
);
}

toggleAutoDoiGeneration(entry: Workflow, isAutoDoiEnabled: boolean) {
this.alertService.start((isAutoDoiEnabled ? 'Enabling' : 'Disabling') + ' automatic DOI generation');
this.workflowsService.autoGenerateDois(entry.id, { autoGenerateDois: isAutoDoiEnabled }).subscribe(
(response) => {
this.alertService.simpleSuccess();
this.workflowService.setWorkflow({ ...this.workflowQuery.getActive(), autoGenerateDois: response });
},
(error) => {
this.alertService.detailedError(error);
}
);
}
}
4 changes: 2 additions & 2 deletions src/app/workflow/workflow.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ <h3>
class="private-btn small-btn-structure ml-2"
matTooltip="Manage DOIs"
(click)="manageDois()"
[disabled]="!canWrite"
[disabled]="!canWrite || (isRefreshing$ | async)"
>
<img src="../assets/svg/icons-actions-edit.svg" class="pr-2" alt="Manage DOIs" />
Manage DOIs
Expand Down Expand Up @@ -204,7 +204,7 @@ <h3>
mat-button
class="private-btn small-btn-structure"
(click)="toggleLabelsEditMode()"
[disabled]="!canWrite"
[disabled]="!canWrite || (isRefreshing$ | async)"
>
<img src="../assets/svg/icons-actions-edit.svg" class="pr-2" alt="Edit labels" />
Manage labels
Expand Down

0 comments on commit 9da6cbe

Please sign in to comment.