Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): allow set run number event if workflow is as-code #4515

Merged
merged 3 commits into from Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions ui/src/app/service/workflow/workflow.service.ts
Expand Up @@ -61,4 +61,11 @@ export class WorkflowService {
resyncPRAsCode(projectKey: string, workflowName: string) {
return this._http.post(`/project/${projectKey}/workflows/${workflowName}/ascode/resync/pr`, null)
}

updateRunNumber(projectKey: string, workflowName: string, runNumber: number): Observable<null> {
return this._http.post<null>(
`/project/${projectKey}/workflows/${workflowName}/runs/num`,
{ num: runNumber }
);
}
}
@@ -1,4 +1,7 @@
<div id="WorkflowAdmin">
<div class="ui warning message" *ngIf="workflow.from_repository && workflow.from_repository.length > 0">
{{'workflow_ascode_no_edit' | translate}}
</div>
<app-zone header="{{ 'common_icon' | translate }}">
<app-zone-content class="bottom">
<div class="ui form">
Expand Down Expand Up @@ -33,6 +36,7 @@
<div class="field">
<label>{{'workflow_name' | translate}}</label>
<input type="text" name="formWorkflowUpdateName" placeholder="{{ 'workflow_name' | translate}}"
[disabled]="loading || (workflow.from_repository && workflow.from_repository.length > 0)"
[(ngModel)]="workflow.name" [disabled]="loading" required #formWorkflowUpdateName="ngModel"
pattern="^[a-zA-Z0-9._-]{1,}$">
<div *ngIf="formWorkflowUpdateName && formWorkflowUpdateName.invalid && !formWorkflowUpdateName.pristine"
Expand All @@ -42,11 +46,13 @@
</div>
<div class="field">
<label>{{'common_description' | translate}}</label>
<textarea name="description" class="ui" [(ngModel)]="_workflow.description"></textarea>
<textarea name="description" class="ui" [(ngModel)]="_workflow.description"
[disabled]="loading || (workflow.from_repository && workflow.from_repository.length > 0)"></textarea>
</div>
<div class="field">
<label>{{ 'workflow_sidebar_tag_zone' | translate }}</label>
<sui-multi-select name="sidebartagzone" class="selection" *ngIf="existingTags.length > 0"
[isDisabled]="loading || (workflow.from_repository && workflow.from_repository.length > 0)"
[(ngModel)]="selectedTags" [options]="existingTags" [isSearchable]="true"
(ngModelChange)="updateTagMetadata($event)" #multiSelect>
<sui-select-option *ngFor="let i of multiSelect.filteredOptions" [value]="i">
Expand All @@ -58,13 +64,14 @@
<div class="fields">
<div class="three wide field">
<input type="number" name="formWorkflowUpdateHistory"
placeholder="{{ 'workflow_history_length' | translate}}"
[(ngModel)]="_workflow.history_length" [disabled]="loading" required
placeholder="{{ 'workflow_history_length' | translate}}" [disabled]="loading || (workflow.from_repository && workflow.from_repository.length >
0)" [(ngModel)]="_workflow.history_length" [disabled]="loading" required
#formWorkflowUpdateHistory="ngModel" min="1" max="500">
</div>
<div class="thirteen wide field">
<sui-select name="sidebartagzonehistory" class="selection" *ngIf="existingTags.length > 0"
[(ngModel)]="purgeTag" [options]="existingTags" [isSearchable]="true" #SelectPurge>
[(ngModel)]="purgeTag" [options]="existingTags" [isSearchable]="true" [isDisabled]="loading || (workflow.from_repository && workflow.from_repository.length >
0)" #SelectPurge>
<sui-select-option *ngFor="let i of SelectPurge.filteredOptions" [value]="i">
</sui-select-option>
</sui-select>
Expand All @@ -74,15 +81,14 @@
<div class="field">
<label>{{ 'workflow_runnumber_title' | translate }}</label>
<input type="number" name="formWorkflowRunNumUpdateNumber"
placeholder="{{ 'common_loading' | translate}}" [(ngModel)]="runnumber" [disabled]="loading"
required #formWorkflowRunNumUpdateNumber="ngModel">
placeholder="{{ 'common_loading' | translate}}" [(ngModel)]="runnumber" required
#formWorkflowRunNumUpdateNumber="ngModel">
</div>
<div class="submitbutton">
<ng-container *ngIf="workflow.from_repository && workflow.from_repository.length > 0">
<div class="ui right floated" suiPopup [popupText]="'workflow_as_code_no_edit' | translate"
popupPlacement="left">
<button class="ui green button" type="submit" name="savebtn" [class.loading]="loading"
[disabled]="loading || (workflow.from_repository && workflow.from_repository.length > 0)">
<div class="ui right floated">
<button class="ui green button" type="button" [class.loading]=" loading"
(click)="updateRunNumber()">
{{'btn_save' | translate}}
</button>
</div>
Expand Down
39 changes: 27 additions & 12 deletions ui/src/app/views/workflow/show/admin/workflow.admin.component.ts
Expand Up @@ -5,6 +5,7 @@ import { Store } from '@ngxs/store';
import { Project } from 'app/model/project.model';
import { Workflow } from 'app/model/workflow.model';
import { WorkflowRunService } from 'app/service/workflow/run/workflow.run.service';
import { WorkflowService } from 'app/service/workflow/workflow.service';
import { WarningModalComponent } from 'app/shared/modal/warning/warning.component';
import { ToastService } from 'app/shared/toast/ToastService';
import { DeleteWorkflow, DeleteWorkflowIcon, UpdateWorkflow, UpdateWorkflowIcon } from 'app/store/workflow.action';
Expand Down Expand Up @@ -46,7 +47,7 @@ export class WorkflowAdminComponent implements OnInit {
purgeTag: string;
iconUpdated = false;

@ViewChild('updateWarning', {static: false})
@ViewChild('updateWarning', { static: false })
private warningUpdateModal: WarningModalComponent;

loading = false;
Expand All @@ -58,6 +59,7 @@ export class WorkflowAdminComponent implements OnInit {
private _toast: ToastService,
private _router: Router,
private _workflowRunService: WorkflowRunService,
private _workflowService: WorkflowService,
private _cd: ChangeDetectorRef
) { }

Expand All @@ -78,19 +80,19 @@ export class WorkflowAdminComponent implements OnInit {
this._workflowRunService.getTags(this.project.key, this._workflow.name)
.pipe(finalize(() => this._cd.markForCheck()))
.subscribe(tags => {
let existingTags = [];
Object.keys(tags).forEach(k => {
if (tags.hasOwnProperty(k) && this.existingTags.indexOf(k) === -1) {
existingTags.push(k);
}
let existingTags = [];
Object.keys(tags).forEach(k => {
if (tags.hasOwnProperty(k) && this.existingTags.indexOf(k) === -1) {
existingTags.push(k);
}
});
this.existingTags = this.existingTags.concat(existingTags);
});
this.existingTags = this.existingTags.concat(existingTags);
});
this._workflowRunService.getRunNumber(this.project.key, this.workflow)
.pipe(first(), finalize(() => this._cd.markForCheck())).subscribe(n => {
this.originalRunNumber = n.num;
this.runnumber = n.num;
});
this.originalRunNumber = n.num;
this.runnumber = n.num;
});
}

deleteIcon(): void {
Expand Down Expand Up @@ -151,7 +153,20 @@ export class WorkflowAdminComponent implements OnInit {
], { queryParams: { tab: 'advanced' } });
});
}
};
}

updateRunNumber() {
this._workflowService.updateRunNumber(this.project.key, this.workflow.name, this.runnumber)
.pipe(finalize(() => {
this.loading = false;
this._cd.markForCheck();
})).subscribe(() => {
this._toast.success('', this._translate.instant('workflow_updated'));
this._router.navigate([
'/project', this.project.key, 'workflow', this.workflow.name
], { queryParams: { tab: 'advanced' } });
})
}

deleteWorkflow(): void {
this.store.dispatch(new DeleteWorkflow({
Expand Down
3 changes: 2 additions & 1 deletion ui/src/assets/i18n/en.json
Expand Up @@ -1087,6 +1087,7 @@
"workflow_template_help_edit_from": "Current workflow template is synchronized from URL. You can't edit it.",
"workflow_template_import_from_url": "Import from URL",
"workflow_template_imported_from_url": "Imported from URL",
"workflow_ascode_no_edit": "Your workflow is configured as as-code, therefore some workflow data updates are not possible on UI",
bnjjj marked this conversation as resolved.
Show resolved Hide resolved
"application_repository_help_line_1": "Your application was not imported from your code.",
"environment_repository_help_line_1": "Your environment was not imported from your code.",
"pipeline_repository_help_line_1": "Your pipeline was not imported from your code.",
Expand All @@ -1102,4 +1103,4 @@
"workflow_error_unknown_key_description": "Key not found, please check that your all keys mentioned really exist. Or you can check if your SSH key which you mentioned in your application settings for your git repository is always valid and added on your git repository to have at least READ access.",
"workflow_error_bad_vcs_strategy_title": "Bad VCS settings on application",
"workflow_error_bad_vcs_strategy_description": "Please check if your SSH key which you mentioned in your application settings for your git repository is always valid and added on your git repository to have at least READ access. You can also check that you have a SSH key mentioned if you selected SSH mode on your application."
}
}
3 changes: 2 additions & 1 deletion ui/src/assets/i18n/fr.json
Expand Up @@ -1088,6 +1088,7 @@
"workflow_template_help_edit_from": "Le modèle de workflow est synchronisé à partir d'une URL, vous ne pouvez pas modifier ses informations.",
"workflow_template_import_from_url": "Importer depuis une URL",
"workflow_template_imported_from_url": "Importé depuis une URL",
"workflow_ascode_no_edit": "Votre workflow est configuré en as-code, par conséquent certaines mises à jours des données de workflows sont impossibles via l'interface.",
"application_repository_help_line_1": "Votre application n'a pas été importée depuis votre code.",
"pipeline_repository_help_line_1": "Votre pipeline n'a pas été importé depuis votre code.",
"environment_repository_help_line_1": "Votre environnement n'a pas été importé depuis votre code.",
Expand All @@ -1103,4 +1104,4 @@
"workflow_error_unknown_key_description": "Veuillez vérifier que la clé SSH avec laquelle vous avez lié votre application à votre dépôt git est bien active et indiqué sur votre dépôt git pour avoir les accès",
"workflow_error_bad_vcs_strategy_title": "Mauvaise configuration des paramètres VCS de votre application",
"workflow_error_bad_vcs_strategy_description": "Veuillez vérifier que la clé SSH avec laquelle vous avez lié votre application à votre dépôt git est bien active et indiqué sur votre dépôt git pour avoir les accès. Veuillez aussi vérifier que vous ayez bien une clé ssh de mentionnée dans votre fichier yaml d'application pointant sur votre dépôt git si vous avez mis le mode de clone SSH."
}
}