import type { IController } from 'angular' ; import { copy , module } from 'angular' ; import type { IModalServiceInstance } from 'angular-ui-bootstrap' ; import type { Application } from '@spinnaker/core' ; import { ManifestWriter , TaskMonitor } from '@spinnaker/core' ; import type { IManifestCoordinates } from '../IManifestCoordinates' ; interface IUndoRolloutCommand { manifestName : string ; location : string ; account : string ; reason : string ; revision : number ; } interface IRolloutRevision { label : string ; revision : number ; } class KubernetesManifestUndoRolloutController implements IController { public taskMonitor : TaskMonitor ; public command : IUndoRolloutCommand ; public verification = { verified : false , } ; public static $inject = [ 'coordinates' , 'revisions' , '$uibModalInstance' , 'application' ] ; constructor ( coordinates , public revisions , private $uibModalInstance , private application ) { this . taskMonitor = new TaskMonitor ( { title : `Undo rollout of ${ coordinates . name } in ${ coordinates . namespace }` , application , modalInstance : $uibModalInstance , } ) ; this . command = { manifestName : coordinates . name , location : coordinates . namespace , account : coordinates . account , reason : null , revision : null , } ; } public isValid ( ) { return this . verification . verified ; } public cancel ( ) { this . $uibModalInstance . dismiss ( ) ; } public undoRollout ( ) { this . taskMonitor . submit ( ( ) => { const payload = copy ( this . command ) as any ; payload . cloudProvider = 'kubernetes' ; return ManifestWriter . undoRolloutManifest ( payload , this . application ) ; } ) ; } } export const KUBERNETES_MANIFEST_UNDO_ROLLOUT_CTRL = 'spinnaker.kubernetes.v2.manifest.undoRollout.controller' ; module ( KUBERNETES_MANIFEST_UNDO_ROLLOUT_CTRL , [ ] ) . controller ( 'kubernetesV2ManifestUndoRolloutCtrl' , KubernetesManifestUndoRolloutController ) ;