import { Component, ChangeDetectionStrategy, Input, Output, EventEmitter } from '@angular/core';
import { BehaviorSubject } from 'rxjs/Rx';
import { BundleService } from '../services/bundle-service';
var PushPublishDialogContainer = (function () {
    function PushPublishDialogContainer(bundleService) {
        this.bundleService = bundleService;
        this.hidden = false;
        this.close = new EventEmitter(false);
        this.cancel = new EventEmitter(false);
        this.errorMessage = new BehaviorSubject(null);
    }
    PushPublishDialogContainer.prototype.doPushPublish = function (environment) {
        var _this = this;
        this.bundleService.pushPublishRule(this.assetId, environment.id).subscribe(function (result) {
            if (!result.errors) {
                _this.close.emit({ isCanceled: false });
                _this.errorMessage = null;
            }
            else {
                _this.errorMessage.next('Sorry there was an error please try again');
            }
        });
    };
    return PushPublishDialogContainer;
}());
export { PushPublishDialogContainer };
PushPublishDialogContainer.decorators = [
    { type: Component, args: [{
                changeDetection: ChangeDetectionStrategy.OnPush,
                selector: 'cw-push-publish-dialog-container',
                template: "\n  <cw-push-publish-dialog-component\n  [environmentStores]=\"environmentStores\"\n  [hidden]=\"hidden\"\n  [errorMessage]=\"errorMessage | async\"\n  (cancel)=\"hidden = true; close.emit($event); errorMessage = null;\"\n  (doPushPublish)=\"doPushPublish($event)\"\n  ></cw-push-publish-dialog-component>"
            },] },
];
/** @nocollapse */
PushPublishDialogContainer.ctorParameters = function () { return [
    { type: BundleService, },
]; };
PushPublishDialogContainer.propDecorators = {
    'assetId': [{ type: Input },],
    'hidden': [{ type: Input },],
    'environmentStores': [{ type: Input },],
    'close': [{ type: Output },],
    'cancel': [{ type: Output },],
};
//# sourceMappingURL=push-publish-dialog-container.js.map