Skip to content

Commit

Permalink
fix: show dry run only if retention enabled, fix sql rollback for policy
Browse files Browse the repository at this point in the history
  • Loading branch information
richardlt committed Mar 9, 2021
1 parent 855efde commit be7f63a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 62 deletions.
2 changes: 1 addition & 1 deletion engine/sql/api/221_workflow_default_retention_policy.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
UPDATE workflow SET retention_policy = '' WHERE retention_policy='return (git_branch_exist == "false" and run_days_before < 2) or run_days_before < 365';

-- +migrate Down
SELECT 1;
UPDATE workflow SET retention_policy = 'return (git_branch_exist == "false" and run_days_before < 2) or run_days_before < 365' WHERE retention_policy = '';
126 changes: 65 additions & 61 deletions ui/src/app/views/workflow/show/admin/workflow.admin.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,67 +135,71 @@
[popupText]="'workflow_retention_maxruns_admin' | translate"></i>
</label>
</div>
<div class="field" *ngIf="retentionRunsPolicyEnabled && apiConfig">
<label>
{{ 'workflow_retention_policy' | translate }}
<i class="circle outline question icon" suiPopup [popupTemplate]="popupRetention"
popupTrigger="outsideClick"></i>
</label>
<ng-template #popupRetention>
You can set a custom retention policy for this workflow, default value is:
<pre>{{apiConfig.default_run_retention_policy}}</pre>
Available variables are: {{availableStringVariables}}.
<br />
<br />
More informations and examples in CDS documentation
<a class="item" target="_blank" rel="noopener noreferrer" href="#"
[routerLink]="['/docs', 'docs', 'concepts', 'workflow', 'retention']">
here</a>.
</ng-template>
<codemirror name="policy" [placeholder]="apiConfig.default_run_retention_policy"
(change)="changeCodeMirror(codemirrorRetentionPolicy)" [(ngModel)]="workflow.retention_policy"
[config]="codeMirrorConfig" #codemirrorRetentionPolicy></codemirror>
</div>
<div class="field">
<button class="ui blue button" type="button" name="dryrun" [class.loading]="loading"
[disabled]="loading" (click)="retentionPolicyDryRun()">
<span>{{'btn_dry_run' | translate}}</span>
</button>
<ng-template let-context let-modal="modal" #modalDryRun>
<div class="header">{{ 'workflow_retention_policy' | translate }}</div>
<div class="content">
<ng-container>
<div class="ui right aligned field ">
<ng-container *ngIf="dryRunStatus === 'INCOMING'">
<i class="circle notch loading blue icon"></i>
</ng-container>
<ng-container *ngIf="dryRunStatus === 'ERROR'">
<i class="close red icon"></i>
</ng-container>
<ng-container *ngIf="dryRunStatus === 'DONE'">
<i class="check green icon"></i>
</ng-container>
{{dryRunAnalyzedRuns + ' / ' + dryRunMaxDatas + ' run analyzed ( ' +
dryRunDatas.length + ' runs kept )'}}
</div>
</ng-container>
<ng-container *ngIf="dryRunStatus === 'DONE' && (!dryRunDatas || dryRunDatas.length === 0)">
<div class="ui info message">All runs would be deleted</div>
</ng-container>
<ng-container *ngIf="dryRunDatas?.length > 0">
<div class="dryrun">
<h4>{{'workflow_retention_result_title' | translate }}</h4>
<app-data-table [withFilter]="" [columns]="dryRunColumns" [data]="dryRunDatas"
[withPagination]="10"></app-data-table>
</div>
</ng-container>
</div>
<div class="actions">
<button class="ui green button" (click)="modal.approve('')" autofocus>{{'btn_close' |
translate }}</button>
</div>
</ng-template>
</div>
<ng-container *ngIf="retentionRunsPolicyEnabled && apiConfig">
<div class="field">
<label>
{{ 'workflow_retention_policy' | translate }}
<i class="circle outline question icon" suiPopup [popupTemplate]="popupRetention"
popupTrigger="outsideClick"></i>
</label>
<ng-template #popupRetention>
You can set a custom retention policy for this workflow, default value is:
<pre>{{apiConfig.default_run_retention_policy}}</pre>
Available variables are: {{availableStringVariables}}.
<br />
<br />
More informations and examples in CDS documentation
<a class="item" target="_blank" rel="noopener noreferrer" href="#"
[routerLink]="['/docs', 'docs', 'concepts', 'workflow', 'retention']">
here</a>.
</ng-template>
<codemirror name="policy" [placeholder]="apiConfig.default_run_retention_policy"
(change)="changeCodeMirror(codemirrorRetentionPolicy)"
[(ngModel)]="workflow.retention_policy" [config]="codeMirrorConfig"
#codemirrorRetentionPolicy></codemirror>
</div>
<div class="field">
<button class="ui blue button" type="button" name="dryrun" [class.loading]="loading"
[disabled]="loading" (click)="retentionPolicyDryRun()">
<span>{{'btn_dry_run' | translate}}</span>
</button>
<ng-template let-context let-modal="modal" #modalDryRun>
<div class="header">{{ 'workflow_retention_policy' | translate }}</div>
<div class="content">
<ng-container>
<div class="ui right aligned field ">
<ng-container *ngIf="dryRunStatus === 'INCOMING'">
<i class="circle notch loading blue icon"></i>
</ng-container>
<ng-container *ngIf="dryRunStatus === 'ERROR'">
<i class="close red icon"></i>
</ng-container>
<ng-container *ngIf="dryRunStatus === 'DONE'">
<i class="check green icon"></i>
</ng-container>
{{dryRunAnalyzedRuns + ' / ' + dryRunMaxDatas + ' run analyzed ( ' +
dryRunDatas.length + ' runs kept )'}}
</div>
</ng-container>
<ng-container
*ngIf="dryRunStatus === 'DONE' && (!dryRunDatas || dryRunDatas.length === 0)">
<div class="ui info message">All runs would be deleted</div>
</ng-container>
<ng-container *ngIf="dryRunDatas?.length > 0">
<div class="dryrun">
<h4>{{'workflow_retention_result_title' | translate }}</h4>
<app-data-table [withFilter]="" [columns]="dryRunColumns" [data]="dryRunDatas"
[withPagination]="10"></app-data-table>
</div>
</ng-container>
</div>
<div class="actions">
<button class="ui green button" (click)="modal.approve('')" autofocus>{{'btn_close' |
translate }}</button>
</div>
</ng-template>
</div>
</ng-container>
<div class="field">
<label>{{ 'workflow_runnumber_title' | translate }}</label>
<input type="number" name="formWorkflowRunNumUpdateNumber"
Expand Down

0 comments on commit be7f63a

Please sign in to comment.