Add UI for viewing and changing trust setting in repo
This commit is contained in:
parent
dec14647a8
commit
14054a237a
7 changed files with 161 additions and 23 deletions
|
@ -0,0 +1,44 @@
|
|||
import { Input, Component, Inject } from 'ng-metadata/core';
|
||||
import { Repository } from '../../../types/common.types';
|
||||
|
||||
/**
|
||||
* A component that displays the configuration and options for repository signing.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'repository-signing-config',
|
||||
templateUrl: '/static/js/directives/ui/repository-signing-config/repository-signing-config.component.html',
|
||||
})
|
||||
export class RepositorySigningConfigComponent {
|
||||
@Input('<') public repository: Repository;
|
||||
|
||||
private enableTrustInfo: {[key: string]: string} = null;
|
||||
private disableTrustInfo: {[key: string]: string} = null;
|
||||
|
||||
constructor (@Inject("ApiService") private ApiService: any) {
|
||||
|
||||
}
|
||||
|
||||
private askChangeTrust(newState: boolean) {
|
||||
if (newState) {
|
||||
this.enableTrustInfo = {};
|
||||
} else {
|
||||
this.disableTrustInfo = {};
|
||||
}
|
||||
}
|
||||
|
||||
private changeTrust(newState: boolean, callback: (success: boolean) => void) {
|
||||
var params = {
|
||||
'repository': this.repository.namespace + '/' + this.repository.name,
|
||||
};
|
||||
|
||||
var data = {
|
||||
'trust_enabled': newState,
|
||||
};
|
||||
|
||||
var errorDisplay = this.ApiService.errorDisplay('Could not just change trust', callback);
|
||||
this.ApiService.changeRepoTrust(data, params).then((resp) => {
|
||||
this.repository.trust_enabled = newState;
|
||||
callback(true);
|
||||
}, errorDisplay);
|
||||
}
|
||||
}
|
Reference in a new issue