Files
gerrit/polygerrit-ui/app/elements/change-list/gr-create-destination-dialog/gr-create-destination-dialog.js
Ben Rohlfs f534ca2e8a Fix undefined branch in create-destination-dialog
Follow-up of change 234145, where I think this dialog was just
overlooked.

As in all the other dialogs the bare confirm event from gr-dialog must
be prevented from propagating, so that the new detailed event is the
only one handled by parent elements.

Otherwise two 'confirm' events would be handled, and the one from
gr-dialog does not have the 'branch' detail, so it would become
undefined in the dialog.

Bug: Issue 12024
Change-Id: I8374e9dbd27ec69972011e3cfed58acb0f7052d4
2019-12-03 07:59:35 +00:00

71 lines
2.0 KiB
JavaScript

/**
* @license
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function() {
'use strict';
/**
* Fired when a destination has been picked. Event details contain the repo
* name and the branch name.
*
* @event confirm
*/
class GrCreateDestinationDialog extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {
static get is() { return 'gr-create-destination-dialog'; }
static get properties() {
return {
_repo: String,
_branch: String,
_repoAndBranchSelected: {
type: Boolean,
value: false,
computed: '_computeRepoAndBranchSelected(_repo, _branch)',
},
};
}
open() {
this._repo = '';
this._branch = '';
this.$.createOverlay.open();
}
_handleClose() {
this.$.createOverlay.close();
}
_pickerConfirm(e) {
this.$.createOverlay.close();
const detail = {repo: this._repo, branch: this._branch};
// e is a 'confirm' event from gr-dialog. We want to fire a more detailed
// 'confirm' event here, so let's stop propagation of the bare event.
e.preventDefault();
e.stopPropagation();
this.dispatchEvent(new CustomEvent('confirm', {detail, bubbles: false}));
}
_computeRepoAndBranchSelected(repo, branch) {
return !!(repo && branch);
}
}
customElements.define(GrCreateDestinationDialog.is,
GrCreateDestinationDialog);
})();