import Flash from '../../../flash'; import mrWidgetAuthorTime from '../../components/mr_widget_author_time'; import tooltip from '../../../vue_shared/directives/tooltip'; import loadingIcon from '../../../vue_shared/components/loading_icon.vue'; import statusIcon from '../mr_widget_status_icon'; import eventHub from '../../event_hub'; export default { name: 'MRWidgetMerged', props: { mr: { type: Object, required: true }, service: { type: Object, required: true }, }, data() { return { isMakingRequest: false, }; }, directives: { tooltip, }, components: { 'mr-widget-author-and-time': mrWidgetAuthorTime, loadingIcon, statusIcon, }, computed: { shouldShowRemoveSourceBranch() { const { sourceBranchRemoved, isRemovingSourceBranch, canRemoveSourceBranch } = this.mr; return !sourceBranchRemoved && canRemoveSourceBranch && !this.isMakingRequest && !isRemovingSourceBranch; }, shouldShowSourceBranchRemoving() { const { sourceBranchRemoved, isRemovingSourceBranch } = this.mr; return !sourceBranchRemoved && (isRemovingSourceBranch || this.isMakingRequest); }, shouldShowMergedButtons() { const { canRevertInCurrentMR, canCherryPickInCurrentMR, revertInForkPath, cherryPickInForkPath } = this.mr; return canRevertInCurrentMR || canCherryPickInCurrentMR || revertInForkPath || cherryPickInForkPath; }, }, methods: { removeSourceBranch() { this.isMakingRequest = true; this.service.removeSourceBranch() .then(res => res.data) .then((data) => { if (data.message === 'Branch was removed') { eventHub.$emit('MRWidgetUpdateRequested', () => { this.isMakingRequest = false; }); } }) .catch(() => { this.isMakingRequest = false; new Flash('Something went wrong. Please try again.'); // eslint-disable-line }); }, }, template: `

The changes were merged into {{mr.targetBranch}}

The source branch has been removed

You can remove source branch now

The source branch is being removed

`, };