Skip to content

Commit

Permalink
Merge pull request #488 from DSD-DBS/fix-git-model-creation
Browse files Browse the repository at this point in the history
Fix git model creation
  • Loading branch information
MoritzWeber0 authored Jan 3, 2023
2 parents 00eda68 + 3efda5e commit aa0ea62
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ def update_git_model_by_id(
def delete_git_model_by_id(
db_git_model: DatabaseGitModel = Depends(get_existing_git_model),
db: Session = Depends(get_db),
) -> DatabaseGitModel:
):
if get_pipelines_for_git_model(db, db_git_model):
raise HTTPException(
status_code=409,
detail={
"err_code": "git_model_used_for_backup",
"reason": f"The git model can't be deleted: it's used for backup jobs",
"reason": "The git model can't be deleted: it's used for backup jobs",
},
)

Expand Down
6 changes: 3 additions & 3 deletions frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { AuthComponent } from './general/auth/auth/auth.component';
import { LogoutRedirectComponent } from './general/auth/logout/logout-redirect/logout-redirect.component';
import { LogoutComponent } from './general/auth/logout/logout/logout.component';
import { CreateProjectComponent } from './projects/create-project/create-project.component';
import { AddGitSourceComponent } from './projects/models/add-git-source/add-git-source.component';
import { CreateModelComponent } from './projects/models/create-model/create-model.component';
import { ModelDescriptionComponent } from './projects/models/model-description/model-description.component';
import { ModelDetailComponent } from './projects/models/model-detail/model-detail.component';
import { T4cModelWrapperComponent } from './projects/models/model-detail/t4c-model-wrapper/t4c-model-wrapper.component';
import { ManageGitModelComponent } from './projects/models/model-source/git/manage-git-model/manage-git-model.component';
import { ManageT4CModelComponent } from './projects/models/model-source/t4c/manage-t4c-model/manage-t4c-model.component';
import { ModelWrapperComponent } from './projects/models/model-wrapper/model-wrapper.component';
import { ProjectDetailsComponent } from './projects/project-detail/project-details.component';
Expand Down Expand Up @@ -84,10 +84,10 @@ const routes: Routes = [
{
path: 'git-model',
children: [
{ path: 'create', component: AddGitSourceComponent },
{ path: 'create', component: ManageGitModelComponent },
{
path: ':git-model',
component: AddGitSourceComponent,
component: ManageGitModelComponent,
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ import { ButtonSkeletonLoaderComponent } from './helpers/skeleton-loaders/button
import { FormFieldSkeletonLoaderComponent } from './helpers/skeleton-loaders/form-field-skeleton-loader/form-field-skeleton-loader.component';
import { MatCardOverviewLoaderComponent } from './helpers/skeleton-loaders/mat-card-overview-loader/mat-card-overview-loader.component';
import { CreateProjectComponent } from './projects/create-project/create-project.component';
import { AddGitSourceComponent } from './projects/models/add-git-source/add-git-source.component';
import { CreateBackupComponent } from './projects/models/backup-settings/create-backup/create-backup.component';
import { TriggerPipelineComponent } from './projects/models/backup-settings/trigger-pipeline/trigger-pipeline.component';
import { ViewLogsDialogComponent } from './projects/models/backup-settings/view-logs-dialog/view-logs-dialog.component';
Expand All @@ -71,6 +70,7 @@ import { ModelDescriptionComponent } from './projects/models/model-description/m
import { ModelDetailComponent } from './projects/models/model-detail/model-detail.component';
import { T4cModelWrapperComponent } from './projects/models/model-detail/t4c-model-wrapper/t4c-model-wrapper.component';
import { ChooseSourceComponent } from './projects/models/model-source/choose-source.component';
import { ManageGitModelComponent } from './projects/models/model-source/git/manage-git-model/manage-git-model.component';
import { ManageT4CModelComponent } from './projects/models/model-source/t4c/manage-t4c-model/manage-t4c-model.component';
import { ModelWrapperComponent } from './projects/models/model-wrapper/model-wrapper.component';
import { ModelOverviewComponent } from './projects/project-detail/model-overview/model-overview.component';
Expand Down Expand Up @@ -112,7 +112,6 @@ import { HomeComponent } from './workspaces/home.component';
@NgModule({
declarations: [
ActiveSessionsComponent,
AddGitSourceComponent,
AlertSettingsComponent,
AppComponent,
AuthComponent,
Expand Down Expand Up @@ -140,6 +139,7 @@ import { HomeComponent } from './workspaces/home.component';
LicencesComponent,
LogoutComponent,
LogoutRedirectComponent,
ManageGitModelComponent,
ManageT4CModelComponent,
MatCardOverviewLoaderComponent,
MatIconComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@

<mat-step label="Add source">
<div [ngSwitch]="source">
<app-create-coworking-method
<app-manage-git-model
*ngSwitchCase="'git-add'"
[asStepper]="true"
(create)="afterSourceCreated($event)"
></app-create-coworking-method>
></app-manage-git-model>
<app-manage-t4c-model
[asStepper]="true"
*ngSwitchCase="'t4c-add'"
[asStepper]="true"
(create)="afterSourceCreated($event)"
></app-manage-t4c-model>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ManageGitModelComponent } from './manage-git-model.component';

xdescribe('ManageGitModelComponent', () => {
let component: ManageGitModelComponent;
let fixture: ComponentFixture<ManageGitModelComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ManageGitModelComponent],
}).compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(ManageGitModelComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ import {
} from 'src/app/services/settings/git-settings.service';

@Component({
selector: 'app-create-coworking-method',
templateUrl: './add-git-source.component.html',
styleUrls: ['./add-git-source.component.css'],
selector: 'app-manage-git-model',
templateUrl: './manage-git-model.component.html',
styleUrls: ['./manage-git-model.component.css'],
})
export class AddGitSourceComponent implements OnInit, OnDestroy {
export class ManageGitModelComponent implements OnInit, OnDestroy {
@Input() asStepper?: boolean;
@Output() create = new EventEmitter<boolean>();

Expand Down Expand Up @@ -133,6 +133,8 @@ export class AddGitSourceComponent implements OnInit, OnDestroy {
this.form.controls.urls.setAsyncValidators([
this.resultUrlPrefixAsyncValidator(),
]);
} else {
this.urls.inputUrl.addValidators([Validators.required]);
}
});

Expand Down Expand Up @@ -224,6 +226,14 @@ export class AddGitSourceComponent implements OnInit, OnDestroy {
this.updateResultUrl();
this.resetRevisions();

if (!this.availableGitInstances.length) {
if (this.form.controls.urls.controls.inputUrl.valid) {
this.enableAllExceptUrls();
} else {
this.disableAllExpectUrls();
}
}

this.urls.inputUrl.updateValueAndValidity();

if (changedInputUrl && hasAbsoluteUrlPrefix(changedInputUrl)) {
Expand Down

0 comments on commit aa0ea62

Please sign in to comment.