diff --git a/engine/api/templates.go b/engine/api/templates.go index b5d0caca80..c83217748c 100644 --- a/engine/api/templates.go +++ b/engine/api/templates.go @@ -60,41 +60,9 @@ func (api *API) postTemplateHandler() service.Handler { return err } - var grp *sdk.Group - var err error - // if imported from url try to download files then overrides request - if data.ImportURL != "" { - t := new(bytes.Buffer) - if err := exportentities.DownloadTemplate(data.ImportURL, t); err != nil { - return sdk.NewError(sdk.ErrWrongRequest, err) - } - wt, err := exportentities.ReadTemplateFromTar(tar.NewReader(t)) - if err != nil { - return err - } - wt.ImportURL = data.ImportURL - data = wt - - // group name should be set - if data.Group == nil { - return sdk.NewErrorFrom(sdk.ErrWrongRequest, "missing group name") - } - - grp, err = group.LoadByName(ctx, api.mustDB(), data.Group.Name, group.LoadOptions.WithMembers) - if err != nil { - return sdk.NewError(sdk.ErrWrongRequest, err) - } - data.GroupID = grp.ID - - // check the workflow template extracted - if err := data.IsValid(); err != nil { - return err - } - } else { - grp, err = group.LoadByID(ctx, api.mustDB(), data.GroupID, group.LoadOptions.WithMembers) - if err != nil { - return err - } + grp, err := group.LoadByID(ctx, api.mustDB(), data.GroupID, group.LoadOptions.WithMembers) + if err != nil { + return err } data.Version = 1 @@ -201,42 +169,10 @@ func (api *API) putTemplateHandler() service.Handler { return err } - var grp *sdk.Group - // if imported from url try to download files then overrides request - if data.ImportURL != "" { - t := new(bytes.Buffer) - if err := exportentities.DownloadTemplate(data.ImportURL, t); err != nil { - return sdk.NewError(sdk.ErrWrongRequest, err) - } - wt, err := exportentities.ReadTemplateFromTar(tar.NewReader(t)) - if err != nil { - return err - } - wt.ImportURL = data.ImportURL - data = wt - - // group name should be set - if data.Group == nil { - return sdk.NewErrorFrom(sdk.ErrWrongRequest, "missing group name") - } - - // check that the user is admin on the given template's group - grp, err = group.LoadByName(ctx, api.mustDB(), data.Group.Name, group.LoadOptions.WithMembers) - if err != nil { - return sdk.NewError(sdk.ErrWrongRequest, err) - } - data.GroupID = grp.ID - - // check the workflow template extracted - if err := data.IsValid(); err != nil { - return err - } - } else { - // check that the group exists and user is admin for group id - grp, err = group.LoadByID(ctx, api.mustDB(), data.GroupID, group.LoadOptions.WithMembers) - if err != nil { - return err - } + // check that the group exists and user is admin for group id + grp, err := group.LoadByID(ctx, api.mustDB(), data.GroupID, group.LoadOptions.WithMembers) + if err != nil { + return err } if !isGroupAdmin(ctx, grp) { diff --git a/sdk/workflow_template.go b/sdk/workflow_template.go index 271f69531f..4f5c9d5960 100644 --- a/sdk/workflow_template.go +++ b/sdk/workflow_template.go @@ -57,7 +57,6 @@ type WorkflowTemplate struct { Applications ApplicationTemplates `json:"applications" db:"applications"` Environments EnvironmentTemplates `json:"environments" db:"environments"` Version int64 `json:"version" db:"version"` - ImportURL string `json:"import_url" db:"import_url"` // aggregates Group *Group `json:"group,omitempty" db:"-"` FirstAudit *AuditWorkflowTemplate `json:"first_audit,omitempty" db:"-"` @@ -86,14 +85,6 @@ func (w *WorkflowTemplate) Scan(src interface{}) error { // IsValid returns workflow template validity. func (w *WorkflowTemplate) IsValid() error { - // no more checks if import url is set, fields will be overrited by downloaded files - if w.ImportURL != "" { - if !IsURL(w.ImportURL) || !strings.HasSuffix(w.ImportURL, ".yml") { - return NewErrorFrom(ErrWrongRequest, "invalid given import url") - } - return nil - } - if w.GroupID == 0 { return NewErrorFrom(ErrWrongRequest, "invalid group id for template") } @@ -188,7 +179,6 @@ func (w *WorkflowTemplate) Update(data WorkflowTemplate) { w.Applications = data.Applications w.Environments = data.Environments w.Version = w.Version + 1 - w.ImportURL = data.ImportURL } func (w WorkflowTemplate) Path() string { diff --git a/ui/src/app/model/workflow-template.model.ts b/ui/src/app/model/workflow-template.model.ts index 21d8f94bab..b50a0b6f87 100644 --- a/ui/src/app/model/workflow-template.model.ts +++ b/ui/src/app/model/workflow-template.model.ts @@ -21,7 +21,6 @@ export class WorkflowTemplate { last_audit: AuditWorkflowTemplate; editable: boolean; change_message: string; - import_url: string; } export class WorkflowTemplateParameter { diff --git a/ui/src/app/views/settings/workflow-template/form/workflow-template.form.component.ts b/ui/src/app/views/settings/workflow-template/form/workflow-template.form.component.ts index c346be3bb1..1ac5338200 100644 --- a/ui/src/app/views/settings/workflow-template/form/workflow-template.form.component.ts +++ b/ui/src/app/views/settings/workflow-template/form/workflow-template.form.component.ts @@ -29,8 +29,6 @@ export class WorkflowTemplateFormComponent { this._workflowTemplate = { editable: true }; } - this.importFromURL = !!this._workflowTemplate.import_url; - this.changeMessage = null; this.parameterKeys = []; @@ -125,7 +123,6 @@ export class WorkflowTemplateFormComponent { environmentErrors: { [key: number]: WorkflowTemplateError; }; environmentKeys: Array; changeMessage: string; - importFromURL: boolean; constructor( private _sharedService: SharedService, @@ -149,11 +146,6 @@ export class WorkflowTemplateFormComponent { } clickSave() { - if (this.importFromURL) { - this.save.emit({ import_url: this.workflowTemplate.import_url }); - return; - } - if (!this.workflowTemplate.name || !this.workflowTemplate.group_id) { return; } @@ -229,9 +221,4 @@ export class WorkflowTemplateFormComponent { environmentValueChange(key: number, value: string) { this.environmentValues[key] = value; } - - changeFromURL() { - this.importFromURL = !this.importFromURL; - this._cd.markForCheck(); - } } diff --git a/ui/src/app/views/settings/workflow-template/form/workflow-template.form.html b/ui/src/app/views/settings/workflow-template/form/workflow-template.form.html index 16fdb6f485..abf1fc24f9 100644 --- a/ui/src/app/views/settings/workflow-template/form/workflow-template.form.html +++ b/ui/src/app/views/settings/workflow-template/form/workflow-template.form.html @@ -6,14 +6,14 @@
{{'common_help_no_group' | translate}}
-
+
{{'workflow_template_help_edit_from' | translate}}
+ [readonly]="!workflowTemplate.editable">
@@ -23,11 +23,11 @@
-
@@ -40,31 +40,14 @@ + [readonly]="!workflowTemplate.editable">
{{'common_or' | translate}}
-
-
-
- - {{'workflow_template_import_from_url' | translate}} - - {{'workflow_template_imported_from_url' | - translate}} -
-
- -
-
-
-
-
+
@@ -72,33 +55,33 @@
+ [readonly]="!workflowTemplate.editable">
- -
+ [disabled]="!workflowTemplate.editable">
-
-
+
@@ -125,56 +108,56 @@
-
-
-
-
-
-
-
+
@@ -184,12 +167,9 @@
diff --git a/ui/src/assets/i18n/en.json b/ui/src/assets/i18n/en.json index f080fdf279..fe2a607af1 100644 --- a/ui/src/assets/i18n/en.json +++ b/ui/src/assets/i18n/en.json @@ -126,7 +126,6 @@ "btn_add": "Add", "btn_back": "Back", "btn_filter": "Filter", - "btn_synchronize": "Synchronize", "cdsctl_choice_os": "Choose your OS", "cdsctl_choice_arch": "Choose your architecture", "cdsctl_choice_options": "Choose your options", @@ -859,8 +858,6 @@ "workflow_template_init_from_workflow": "Init a template", "workflow_template_help_add_from": "Current workflow template was initialized with data from \"{{workflowName}}\" workflow in \"{{projectKey}}\" project. The data will not be stored until you save the template.", "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_template_param_select_key": "Select a key", "workflow_warning_deprecated_yaml": "Yaml workflow configuration is deprecated", "application_repository_help_line_1": "Your application was not imported from your code.",