import { ChangeDetectionStrategy , Component } from '@angular/core' ; import { RepositoryFacade } from '@pimp-my-pr/pmp-web/repository/data-access' ; import { MatDialog } from '@angular/material/dialog' ; import { AddEditRepositoryDialogComponent } from '../add-edit-repository-dialog/add-edit-repository-dialog.component' ; import { AddEditRepositoryDialogData , Repository } from '@pimp-my-pr/pmp-web/repository/domain' ; import { GenericDialogComponent } from '@pimp-my-pr/pmp-web/shared/ui-generic-dialog' ; @ Component ( { selector : 'pmp-repository-settings' , templateUrl : './repository-settings.component.html' , styleUrls : [ './repository-settings.component.scss' ] , changeDetection : ChangeDetectionStrategy . OnPush } ) export class RepositorySettingsComponent { repositoryCollection$ = this . repositoryFacade . repositoryCollection$ ; repositoryCollectionLoading$ = this . repositoryFacade . repositoryCollectionLoading$ ; constructor ( private repositoryFacade , private matDialog ) { this . repositoryFacade . getRepositoryCollection ( ) ; } onDeleteRespository ( repository ) { this . matDialog . open ( GenericDialogComponent , { autoFocus : false } ) . afterClosed ( ) . subscribe ( ( shouldDelete ) => { if ( shouldDelete ) { this . repositoryFacade . deleteRepository ( { repositoryId : repository . id } ) ; } } ) ; } onEditRepository ( repository ) { this . matDialog . open < AddEditRepositoryDialogComponent , AddEditRepositoryDialogData > ( AddEditRepositoryDialogComponent , { panelClass : 'add-edit-repository-dialog' , data : { submitMsg : 'Update' , dialogTitle : `Edit ${ repository . name } repository` , repositoryToEdit : repository } } ) ; } openAddRepoDialog ( ) { this . matDialog . open < AddEditRepositoryDialogComponent , AddEditRepositoryDialogData > ( AddEditRepositoryDialogComponent , { panelClass : 'add-edit-repository-dialog' , data : { submitMsg : 'Add' , dialogTitle : 'Add repository' } } ) ; } }