debian-mirror-gitlab/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue

609 lines
20 KiB
Vue
Raw Normal View History

2018-11-08 19:23:39 +05:30
<script>
2021-03-11 19:13:27 +05:30
import { GlSafeHtmlDirective } from '@gitlab/ui';
2020-04-08 14:13:33 +05:30
import { isEmpty } from 'lodash';
2022-03-02 08:16:31 +05:30
import { registerExtension } from '~/vue_merge_request_widget/components/extensions';
2020-07-28 23:09:34 +05:30
import MrWidgetApprovals from 'ee_else_ce/vue_merge_request_widget/components/approvals/approvals.vue';
2021-03-11 19:13:27 +05:30
import MRWidgetService from 'ee_else_ce/vue_merge_request_widget/services/mr_widget_service';
import MRWidgetStore from 'ee_else_ce/vue_merge_request_widget/stores/mr_widget_store';
2021-11-18 22:05:49 +05:30
import { stateToComponentMap as classState } from 'ee_else_ce/vue_merge_request_widget/stores/state_maps';
2021-09-30 23:02:18 +05:30
import createFlash from '~/flash';
2021-03-11 19:13:27 +05:30
import { secondsToMilliseconds } from '~/lib/utils/datetime_utility';
import notify from '~/lib/utils/notify';
2020-01-01 13:55:28 +05:30
import { sprintf, s__, __ } from '~/locale';
import Project from '~/pages/projects/project';
import SmartInterval from '~/smart_interval';
2021-03-11 19:13:27 +05:30
import { setFaviconOverlay } from '../lib/utils/favicon';
2020-01-01 13:55:28 +05:30
import Loading from './components/loading.vue';
2021-03-11 19:13:27 +05:30
import MrWidgetAlertMessage from './components/mr_widget_alert_message.vue';
2018-12-13 13:39:08 +05:30
import WidgetHeader from './components/mr_widget_header.vue';
2019-02-15 15:39:39 +05:30
import MrWidgetPipelineContainer from './components/mr_widget_pipeline_container.vue';
2018-12-13 13:39:08 +05:30
import WidgetRelatedLinks from './components/mr_widget_related_links.vue';
2021-03-11 19:13:27 +05:30
import WidgetSuggestPipeline from './components/mr_widget_suggest_pipeline.vue';
import SourceBranchRemovalStatus from './components/source_branch_removal_status.vue';
2018-12-13 13:39:08 +05:30
import ArchivedState from './components/states/mr_widget_archived.vue';
2021-03-11 19:13:27 +05:30
import MrWidgetAutoMergeEnabled from './components/states/mr_widget_auto_merge_enabled.vue';
import AutoMergeFailed from './components/states/mr_widget_auto_merge_failed.vue';
import CheckingState from './components/states/mr_widget_checking.vue';
import ClosedState from './components/states/mr_widget_closed.vue';
2018-12-13 13:39:08 +05:30
import ConflictsState from './components/states/mr_widget_conflicts.vue';
2021-03-11 19:13:27 +05:30
import FailedToMerge from './components/states/mr_widget_failed_to_merge.vue';
import MergedState from './components/states/mr_widget_merged.vue';
import MergingState from './components/states/mr_widget_merging.vue';
2018-12-13 13:39:08 +05:30
import MissingBranchState from './components/states/mr_widget_missing_branch.vue';
import NotAllowedState from './components/states/mr_widget_not_allowed.vue';
import PipelineBlockedState from './components/states/mr_widget_pipeline_blocked.vue';
2021-03-11 19:13:27 +05:30
import RebaseState from './components/states/mr_widget_rebase.vue';
import NothingToMergeState from './components/states/nothing_to_merge.vue';
2018-12-13 13:39:08 +05:30
import PipelineFailedState from './components/states/pipeline_failed.vue';
2021-03-11 19:13:27 +05:30
import ReadyToMergeState from './components/states/ready_to_merge.vue';
2021-10-27 15:23:28 +05:30
import ShaMismatch from './components/states/sha_mismatch.vue';
2021-03-11 19:13:27 +05:30
import UnresolvedDiscussionsState from './components/states/unresolved_discussions.vue';
import WorkInProgressState from './components/states/work_in_progress.vue';
2021-11-18 22:05:49 +05:30
import ExtensionsContainer from './components/extensions/container';
import { STATE_MACHINE, stateToComponentMap } from './constants';
2021-03-11 19:13:27 +05:30
import eventHub from './event_hub';
import mergeRequestQueryVariablesMixin from './mixins/merge_request_query_variables';
2020-10-24 23:57:45 +05:30
import getStateQuery from './queries/get_state.query.graphql';
2022-03-02 08:16:31 +05:30
import terraformExtension from './extensions/terraform';
2022-04-04 11:22:00 +05:30
import accessibilityExtension from './extensions/accessibility';
2017-08-17 22:00:37 +05:30
export default {
2019-10-12 21:52:04 +05:30
// False positive i18n lint: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/25
2020-04-22 19:07:51 +05:30
// eslint-disable-next-line @gitlab/require-i18n-strings
2017-08-17 22:00:37 +05:30
name: 'MRWidget',
2021-01-03 14:25:43 +05:30
directives: {
SafeHtml: GlSafeHtmlDirective,
},
2018-11-08 19:23:39 +05:30
components: {
2020-01-01 13:55:28 +05:30
Loading,
2021-11-18 22:05:49 +05:30
ExtensionsContainer,
2018-11-08 19:23:39 +05:30
'mr-widget-header': WidgetHeader,
2020-03-13 15:44:24 +05:30
'mr-widget-suggest-pipeline': WidgetSuggestPipeline,
2019-02-15 15:39:39 +05:30
MrWidgetPipelineContainer,
2018-11-08 19:23:39 +05:30
'mr-widget-related-links': WidgetRelatedLinks,
2019-07-07 11:18:12 +05:30
MrWidgetAlertMessage,
2018-11-08 19:23:39 +05:30
'mr-widget-merged': MergedState,
'mr-widget-closed': ClosedState,
'mr-widget-merging': MergingState,
'mr-widget-failed-to-merge': FailedToMerge,
'mr-widget-wip': WorkInProgressState,
'mr-widget-archived': ArchivedState,
'mr-widget-conflicts': ConflictsState,
'mr-widget-nothing-to-merge': NothingToMergeState,
'mr-widget-not-allowed': NotAllowedState,
'mr-widget-missing-branch': MissingBranchState,
2021-11-11 11:23:49 +05:30
'mr-widget-ready-to-merge': window.gon?.features?.restructuredMrWidget
? () => import('./components/states/new_ready_to_merge.vue')
: ReadyToMergeState,
2021-10-27 15:23:28 +05:30
'sha-mismatch': ShaMismatch,
2018-11-08 19:23:39 +05:30
'mr-widget-checking': CheckingState,
'mr-widget-unresolved-discussions': UnresolvedDiscussionsState,
'mr-widget-pipeline-blocked': PipelineBlockedState,
'mr-widget-pipeline-failed': PipelineFailedState,
2019-09-04 21:01:54 +05:30
MrWidgetAutoMergeEnabled,
2018-11-08 19:23:39 +05:30
'mr-widget-auto-merge-failed': AutoMergeFailed,
'mr-widget-rebase': RebaseState,
SourceBranchRemovalStatus,
2021-11-11 11:23:49 +05:30
GroupedCodequalityReportsApp: () =>
import('../reports/codequality_report/grouped_codequality_reports_app.vue'),
GroupedTestReportsApp: () =>
import('../reports/grouped_test_report/grouped_test_reports_app.vue'),
TerraformPlan: () => import('./components/terraform/mr_widget_terraform_container.vue'),
GroupedAccessibilityReportsApp: () =>
import('../reports/accessibility_report/grouped_accessibility_reports_app.vue'),
2020-07-28 23:09:34 +05:30
MrWidgetApprovals,
2021-01-03 14:25:43 +05:30
SecurityReportsApp: () => import('~/vue_shared/security_reports/security_reports_app.vue'),
2021-11-11 11:23:49 +05:30
MergeChecksFailed: () => import('./components/states/merge_checks_failed.vue'),
2021-12-11 22:18:48 +05:30
ReadyToMerge: ReadyToMergeState,
2018-11-08 19:23:39 +05:30
},
2020-10-24 23:57:45 +05:30
apollo: {
state: {
query: getStateQuery,
manual: true,
skip() {
return !this.mr || !window.gon?.features?.mergeRequestWidgetGraphql;
},
variables() {
return this.mergeRequestQueryVariables;
},
2020-11-24 15:15:51 +05:30
result({ data: { project } }) {
if (project) {
this.mr.setGraphqlData(project);
this.loading = false;
}
2020-10-24 23:57:45 +05:30
},
},
},
mixins: [mergeRequestQueryVariablesMixin],
2017-09-10 17:25:29 +05:30
props: {
mrData: {
type: Object,
required: false,
2018-11-08 19:23:39 +05:30
default: null,
2017-09-10 17:25:29 +05:30
},
},
2017-08-17 22:00:37 +05:30
data() {
2020-01-01 13:55:28 +05:30
const store = this.mrData && new MRWidgetStore(this.mrData);
2017-08-17 22:00:37 +05:30
return {
mr: store,
2020-01-01 13:55:28 +05:30
state: store && store.state,
service: store && this.createService(store),
2021-11-18 22:05:49 +05:30
machineState: store?.machineValue || STATE_MACHINE.definition.initial,
2020-11-24 15:15:51 +05:30
loading: true,
2021-11-18 22:05:49 +05:30
recomputeComponentName: 0,
2017-08-17 22:00:37 +05:30
};
},
computed: {
2020-11-24 15:15:51 +05:30
isLoaded() {
if (window.gon?.features?.mergeRequestWidgetGraphql) {
return !this.loading;
}
return this.mr;
},
2020-07-28 23:09:34 +05:30
shouldRenderApprovals() {
return this.mr.state !== 'nothingToMerge';
},
2017-08-17 22:00:37 +05:30
componentName() {
2021-11-18 22:05:49 +05:30
return stateToComponentMap[this.machineState] || classState[this.mr.state];
2017-08-17 22:00:37 +05:30
},
2020-05-24 23:13:21 +05:30
hasPipelineMustSucceedConflict() {
return !this.mr.hasCI && this.mr.onlyAllowMergeIfPipelineSucceeds;
},
2017-08-17 22:00:37 +05:30
shouldRenderPipelines() {
2020-05-24 23:13:21 +05:30
return this.mr.hasCI || this.hasPipelineMustSucceedConflict;
2017-08-17 22:00:37 +05:30
},
2020-03-13 15:44:24 +05:30
shouldSuggestPipelines() {
2021-11-18 22:05:49 +05:30
const { hasCI, mergeRequestAddCiConfigPath, isDismissedSuggestPipeline } = this.mr;
return !hasCI && mergeRequestAddCiConfigPath && !isDismissedSuggestPipeline;
2020-03-13 15:44:24 +05:30
},
2020-07-28 23:09:34 +05:30
shouldRenderCodeQuality() {
2021-10-27 15:23:28 +05:30
return this.mr?.codequalityReportsPath;
2020-07-28 23:09:34 +05:30
},
2017-08-17 22:00:37 +05:30
shouldRenderRelatedLinks() {
2019-09-04 21:01:54 +05:30
return Boolean(this.mr.relatedLinks) && !this.mr.isNothingToMergeState;
2017-08-17 22:00:37 +05:30
},
2018-05-09 12:01:36 +05:30
shouldRenderSourceBranchRemovalStatus() {
2018-12-13 13:39:08 +05:30
return (
!this.mr.canRemoveSourceBranch &&
this.mr.shouldRemoveSourceBranch &&
2021-03-08 18:12:59 +05:30
!this.mr.isNothingToMergeState &&
!this.mr.isMergedState
2018-12-13 13:39:08 +05:30
);
},
2019-02-15 15:39:39 +05:30
shouldRenderCollaborationStatus() {
return this.mr.allowCollaboration && this.mr.isOpen;
},
2018-12-13 13:39:08 +05:30
shouldRenderMergedPipeline() {
2020-04-08 14:13:33 +05:30
return this.mr.state === 'merged' && !isEmpty(this.mr.mergePipeline);
2018-12-13 13:39:08 +05:30
},
2019-07-07 11:18:12 +05:30
showMergePipelineForkWarning() {
return Boolean(
this.mr.mergePipelinesEnabled && this.mr.sourceProjectId !== this.mr.targetProjectId,
);
},
2021-01-03 14:25:43 +05:30
shouldRenderSecurityReport() {
2021-03-11 19:13:27 +05:30
return Boolean(this.mr.pipeline.id);
2021-01-03 14:25:43 +05:30
},
2022-03-02 08:16:31 +05:30
shouldRenderTerraformPlans() {
return Boolean(this.mr?.terraformReportsPath);
},
2019-09-04 21:01:54 +05:30
mergeError() {
2020-03-13 15:44:24 +05:30
let { mergeError } = this.mr;
if (mergeError && mergeError.slice(-1) === '.') {
mergeError = mergeError.slice(0, -1);
}
2021-03-08 18:12:59 +05:30
return sprintf(
2021-03-11 19:13:27 +05:30
s__('mrWidget|%{mergeError}. Try again.'),
2021-03-08 18:12:59 +05:30
{
mergeError,
},
false,
);
2019-07-07 11:18:12 +05:30
},
2020-05-24 23:13:21 +05:30
shouldShowAccessibilityReport() {
2022-04-04 11:22:00 +05:30
return Boolean(this.mr?.accessibilityReportPath);
2020-05-24 23:13:21 +05:30
},
2021-01-29 00:20:46 +05:30
formattedHumanAccess() {
return (this.mr.humanAccess || '').toLowerCase();
},
2021-09-04 01:27:46 +05:30
hasAlerts() {
return this.mr.mergeError || this.showMergePipelineForkWarning;
},
2021-11-18 22:05:49 +05:30
shouldShowExtension() {
return (
window.gon?.features?.refactorMrWidgetsExtensions ||
window.gon?.features?.refactorMrWidgetsExtensionsUser
);
},
2021-12-11 22:18:48 +05:30
isRestructuredMrWidgetEnabled() {
return window.gon?.features?.restructuredMrWidget;
},
2018-12-13 13:39:08 +05:30
},
watch: {
2021-11-18 22:05:49 +05:30
'mr.machineValue': {
handler(newValue) {
this.machineState = newValue;
},
},
2018-12-13 13:39:08 +05:30
state(newVal, oldVal) {
if (newVal !== oldVal && this.shouldRenderMergedPipeline) {
// init polling
this.initPostMergeDeploymentsPolling();
}
2017-08-17 22:00:37 +05:30
},
2022-03-02 08:16:31 +05:30
shouldRenderTerraformPlans(newVal) {
if (newVal) {
this.registerTerraformPlans();
}
},
2022-04-04 11:22:00 +05:30
shouldShowAccessibilityReport(newVal) {
if (newVal) {
this.registerAccessibilityExtension();
}
},
2017-08-17 22:00:37 +05:30
},
2018-11-08 19:23:39 +05:30
mounted() {
2020-03-13 15:44:24 +05:30
MRWidgetService.fetchInitialData()
2020-11-24 15:15:51 +05:30
.then(({ data, headers }) => {
this.startingPollInterval = Number(headers['POLL-INTERVAL']);
this.initWidget(data);
})
2020-03-13 15:44:24 +05:30
.catch(() =>
2021-09-04 01:27:46 +05:30
createFlash({
message: __('Unable to load the merge request widget. Try reloading the page.'),
}),
2020-03-13 15:44:24 +05:30
);
2018-11-08 19:23:39 +05:30
},
2018-12-05 23:21:45 +05:30
beforeDestroy() {
eventHub.$off('mr.discussion.updated', this.checkStatus);
2020-01-01 13:55:28 +05:30
if (this.pollingInterval) {
this.pollingInterval.destroy();
}
if (this.deploymentsInterval) {
this.deploymentsInterval.destroy();
}
2018-12-13 13:39:08 +05:30
if (this.postMergeDeploymentsInterval) {
this.postMergeDeploymentsInterval.destroy();
}
2018-12-05 23:21:45 +05:30
},
2017-08-17 22:00:37 +05:30
methods: {
2020-01-01 13:55:28 +05:30
initWidget(data = {}) {
if (this.mr) {
this.mr.setData({ ...window.gl.mrWidgetData, ...data });
} else {
this.mr = new MRWidgetStore({ ...window.gl.mrWidgetData, ...data });
}
2021-11-18 22:05:49 +05:30
this.machineState = this.mr.machineValue;
2020-01-01 13:55:28 +05:30
if (!this.state) {
this.state = this.mr.state;
}
if (!this.service) {
this.service = this.createService(this.mr);
}
this.setFaviconHelper();
this.initDeploymentsPolling();
if (this.shouldRenderMergedPipeline) {
this.initPostMergeDeploymentsPolling();
}
this.initPolling();
this.bindEventHubListeners();
eventHub.$on('mr.discussion.updated', this.checkStatus);
},
2019-03-02 22:35:43 +05:30
getServiceEndpoints(store) {
return {
2017-08-17 22:00:37 +05:30
mergePath: store.mergePath,
mergeCheckPath: store.mergeCheckPath,
cancelAutoMergePath: store.cancelAutoMergePath,
removeWIPPath: store.removeWIPPath,
sourceBranchPath: store.sourceBranchPath,
ciEnvironmentsStatusPath: store.ciEnvironmentsStatusPath,
2019-09-30 21:07:59 +05:30
mergeRequestBasicPath: store.mergeRequestBasicPath,
mergeRequestWidgetPath: store.mergeRequestWidgetPath,
2019-10-12 21:52:04 +05:30
mergeRequestCachedWidgetPath: store.mergeRequestCachedWidgetPath,
2017-08-17 22:00:37 +05:30
mergeActionsContentPath: store.mergeActionsContentPath,
2018-03-17 18:26:18 +05:30
rebasePath: store.rebasePath,
2020-07-28 23:09:34 +05:30
apiApprovalsPath: store.apiApprovalsPath,
apiApprovePath: store.apiApprovePath,
apiUnapprovePath: store.apiUnapprovePath,
2017-08-17 22:00:37 +05:30
};
2019-03-02 22:35:43 +05:30
},
createService(store) {
return new MRWidgetService(this.getServiceEndpoints(store));
2017-08-17 22:00:37 +05:30
},
2019-02-15 15:39:39 +05:30
checkStatus(cb, isRebased) {
2021-03-11 19:13:27 +05:30
if (window.gon?.features?.mergeRequestWidgetGraphql) {
this.$apollo.queries.state.refetch();
}
2018-12-13 13:39:08 +05:30
return this.service
.checkStatus()
2019-10-12 21:52:04 +05:30
.then(({ data }) => {
2018-03-17 18:26:18 +05:30
this.handleNotification(data);
2019-02-15 15:39:39 +05:30
this.mr.setData(data, isRebased);
2018-03-17 18:26:18 +05:30
this.setFaviconHelper();
2017-08-17 22:00:37 +05:30
if (cb) {
2018-03-17 18:26:18 +05:30
cb.call(null, data);
2017-08-17 22:00:37 +05:30
}
})
2021-09-04 01:27:46 +05:30
.catch(() =>
createFlash({
message: __('Something went wrong. Please try again.'),
}),
);
2018-12-13 13:39:08 +05:30
},
setFaviconHelper() {
if (this.mr.ciStatusFaviconPath) {
return setFaviconOverlay(this.mr.ciStatusFaviconPath);
}
return Promise.resolve();
2017-08-17 22:00:37 +05:30
},
initPolling() {
2018-03-17 18:26:18 +05:30
this.pollingInterval = new SmartInterval({
2017-08-17 22:00:37 +05:30
callback: this.checkStatus,
2020-11-24 15:15:51 +05:30
startingInterval: this.startingPollInterval,
maxInterval: this.startingPollInterval + secondsToMilliseconds(4 * 60),
2021-03-08 18:12:59 +05:30
hiddenInterval: secondsToMilliseconds(6 * 60),
2020-04-22 19:07:51 +05:30
incrementByFactorOf: 2,
2017-08-17 22:00:37 +05:30
});
},
initDeploymentsPolling() {
2018-12-13 13:39:08 +05:30
this.deploymentsInterval = this.deploymentsPoll(this.fetchPreMergeDeployments);
},
initPostMergeDeploymentsPolling() {
this.postMergeDeploymentsInterval = this.deploymentsPoll(this.fetchPostMergeDeployments);
},
deploymentsPoll(callback) {
return new SmartInterval({
callback,
2020-04-22 19:07:51 +05:30
startingInterval: 30 * 1000,
maxInterval: 240 * 1000,
incrementByFactorOf: 4,
2017-08-17 22:00:37 +05:30
immediateExecution: true,
});
},
2018-12-13 13:39:08 +05:30
fetchDeployments(target) {
return this.service.fetchDeployments(target);
2017-08-17 22:00:37 +05:30
},
2018-12-13 13:39:08 +05:30
fetchPreMergeDeployments() {
return this.fetchDeployments()
.then(({ data }) => {
2018-03-17 18:26:18 +05:30
if (data.length) {
this.mr.deployments = data;
2017-08-17 22:00:37 +05:30
}
})
2018-12-13 13:39:08 +05:30
.catch(() => this.throwDeploymentsError());
},
fetchPostMergeDeployments() {
return this.fetchDeployments('merge_commit')
.then(({ data }) => {
if (data.length) {
this.mr.postMergeDeployments = data;
}
})
.catch(() => this.throwDeploymentsError());
},
throwDeploymentsError() {
2021-09-04 01:27:46 +05:30
createFlash({
message: __(
2018-12-13 13:39:08 +05:30
'Something went wrong while fetching the environments for this merge request. Please try again.',
),
2021-09-04 01:27:46 +05:30
});
2017-08-17 22:00:37 +05:30
},
fetchActionsContent() {
2018-12-13 13:39:08 +05:30
this.service
.fetchMergeActionsContent()
2021-03-08 18:12:59 +05:30
.then((res) => {
2018-03-17 18:26:18 +05:30
if (res.data) {
2017-08-17 22:00:37 +05:30
const el = document.createElement('div');
2018-03-17 18:26:18 +05:30
el.innerHTML = res.data;
2017-08-17 22:00:37 +05:30
document.body.appendChild(el);
2021-03-11 19:13:27 +05:30
document.dispatchEvent(new CustomEvent('merged:UpdateActions'));
2018-03-17 18:26:18 +05:30
Project.initRefSwitcher();
2017-08-17 22:00:37 +05:30
}
})
2021-09-04 01:27:46 +05:30
.catch(() =>
createFlash({
message: __('Something went wrong. Please try again.'),
}),
);
2017-08-17 22:00:37 +05:30
},
handleNotification(data) {
if (data.ci_status === this.mr.ciStatus) return;
2018-03-17 18:26:18 +05:30
if (!data.pipeline) return;
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
const { label } = data.pipeline.details.status;
2019-09-30 21:07:59 +05:30
const title = sprintf(__('Pipeline %{label}'), { label });
const message = sprintf(__('Pipeline %{label} for "%{dataTitle}"'), {
dataTitle: data.title,
label,
});
2017-08-17 22:00:37 +05:30
notify.notifyMe(title, message, this.mr.gitlabLogo);
},
resumePolling() {
this.pollingInterval.resume();
},
stopPolling() {
this.pollingInterval.stopTimer();
},
bindEventHubListeners() {
2021-03-08 18:12:59 +05:30
eventHub.$on('MRWidgetUpdateRequested', (cb) => {
2017-08-17 22:00:37 +05:30
this.checkStatus(cb);
});
2021-03-08 18:12:59 +05:30
eventHub.$on('MRWidgetRebaseSuccess', (cb) => {
2019-02-15 15:39:39 +05:30
this.checkStatus(cb, true);
});
2017-08-17 22:00:37 +05:30
// `params` should be an Array contains a Boolean, like `[true]`
// Passing parameter as Boolean didn't work.
2021-03-08 18:12:59 +05:30
eventHub.$on('SetBranchRemoveFlag', (params) => {
2018-11-08 19:23:39 +05:30
[this.mr.isRemovingSourceBranch] = params;
2017-08-17 22:00:37 +05:30
});
2021-03-08 18:12:59 +05:30
eventHub.$on('FailedToMerge', (mergeError) => {
2017-08-17 22:00:37 +05:30
this.mr.state = 'failedToMerge';
this.mr.mergeError = mergeError;
});
2021-03-08 18:12:59 +05:30
eventHub.$on('UpdateWidgetData', (data) => {
2017-08-17 22:00:37 +05:30
this.mr.setData(data);
});
eventHub.$on('FetchActionsContent', () => {
this.fetchActionsContent();
});
eventHub.$on('EnablePolling', () => {
this.resumePolling();
});
eventHub.$on('DisablePolling', () => {
this.stopPolling();
});
},
2020-10-24 23:57:45 +05:30
dismissSuggestPipelines() {
this.mr.isDismissedSuggestPipeline = true;
},
2022-03-02 08:16:31 +05:30
registerTerraformPlans() {
if (this.shouldRenderTerraformPlans && this.shouldShowExtension) {
registerExtension(terraformExtension);
}
},
2022-04-04 11:22:00 +05:30
registerAccessibilityExtension() {
if (this.shouldShowAccessibilityReport && this.shouldShowExtension) {
registerExtension(accessibilityExtension);
}
},
2017-08-17 22:00:37 +05:30
},
2018-11-08 19:23:39 +05:30
};
</script>
<template>
2020-11-24 15:15:51 +05:30
<div v-if="isLoaded" class="mr-state-widget gl-mt-3">
2021-09-04 01:27:46 +05:30
<header class="gl-rounded-base gl-border-solid gl-border-1 gl-border-gray-100">
<mr-widget-alert-message v-if="shouldRenderCollaborationStatus" type="info">
{{ s__('mrWidget|Members who can merge are allowed to add commits.') }}
</mr-widget-alert-message>
<mr-widget-header :mr="mr" />
</header>
2020-03-13 15:44:24 +05:30
<mr-widget-suggest-pipeline
v-if="shouldSuggestPipelines"
2020-10-24 23:57:45 +05:30
data-testid="mr-suggest-pipeline"
2020-03-13 15:44:24 +05:30
class="mr-widget-workflow"
:pipeline-path="mr.mergeRequestAddCiConfigPath"
2020-04-08 14:13:33 +05:30
:pipeline-svg-path="mr.pipelinesEmptySvgPath"
2021-01-29 00:20:46 +05:30
:human-access="formattedHumanAccess"
2020-10-24 23:57:45 +05:30
:user-callouts-path="mr.userCalloutsPath"
:user-callout-feature-id="mr.suggestPipelineFeatureId"
@dismiss="dismissSuggestPipelines"
2020-03-13 15:44:24 +05:30
/>
2019-02-15 15:39:39 +05:30
<mr-widget-pipeline-container
2019-01-03 12:48:30 +05:30
v-if="shouldRenderPipelines"
2019-02-15 15:39:39 +05:30
class="mr-widget-workflow"
:mr="mr"
2019-01-03 12:48:30 +05:30
/>
2020-07-28 23:09:34 +05:30
<mr-widget-approvals
v-if="shouldRenderApprovals"
class="mr-widget-workflow"
:mr="mr"
:service="service"
/>
2019-02-15 15:39:39 +05:30
<div class="mr-section-container mr-widget-workflow">
2021-09-04 01:27:46 +05:30
<div v-if="hasAlerts" class="gl-overflow-hidden mr-widget-alert-container">
<mr-widget-alert-message v-if="mr.mergeError" type="danger" dismissible>
<span v-safe-html="mergeError"></span>
</mr-widget-alert-message>
<mr-widget-alert-message
v-if="showMergePipelineForkWarning"
type="warning"
:help-path="mr.mergeRequestPipelinesHelpPath"
>
{{
s__(
'mrWidget|If the last pipeline ran in the fork project, it may be inaccurate. Before merge, we advise running a pipeline in this project.',
)
}}
<template #link-content>
{{ __('Learn more') }}
</template>
</mr-widget-alert-message>
</div>
2021-11-18 22:05:49 +05:30
<extensions-container :mr="mr" />
2020-07-28 23:09:34 +05:30
<grouped-codequality-reports-app
v-if="shouldRenderCodeQuality"
2021-09-04 01:27:46 +05:30
:head-blob-path="mr.headBlobPath"
:base-blob-path="mr.baseBlobPath"
2021-03-11 19:13:27 +05:30
:codequality-reports-path="mr.codequalityReportsPath"
2020-07-28 23:09:34 +05:30
:codequality-help-path="mr.codequalityHelpPath"
/>
2021-01-03 14:25:43 +05:30
<security-reports-app
v-if="shouldRenderSecurityReport"
:pipeline-id="mr.pipeline.id"
2021-02-22 17:27:13 +05:30
:project-id="mr.sourceProjectId"
2021-01-03 14:25:43 +05:30
:security-reports-docs-path="mr.securityReportsDocsPath"
2021-02-22 17:27:13 +05:30
:target-project-full-path="mr.targetProjectFullPath"
:mr-iid="mr.iid"
2021-01-03 14:25:43 +05:30
/>
2018-11-18 11:00:15 +05:30
<grouped-test-reports-app
v-if="mr.testResultsPath"
2018-12-13 13:39:08 +05:30
class="js-reports-container"
2018-11-18 11:00:15 +05:30
:endpoint="mr.testResultsPath"
2021-04-29 21:17:54 +05:30
:head-blob-path="mr.headBlobPath"
2020-07-28 23:09:34 +05:30
:pipeline-path="mr.pipeline.path"
2018-11-18 11:00:15 +05:30
/>
2018-12-13 13:39:08 +05:30
2022-03-02 08:16:31 +05:30
<terraform-plan
v-if="mr.terraformReportsPath && !shouldShowExtension"
:endpoint="mr.terraformReportsPath"
/>
2020-04-22 19:07:51 +05:30
2020-05-24 23:13:21 +05:30
<grouped-accessibility-reports-app
v-if="shouldShowAccessibilityReport"
:endpoint="mr.accessibilityReportPath"
/>
2022-04-04 11:22:00 +05:30
<div class="mr-widget-section" data-qa-selector="mr_widget_content">
2019-02-15 15:39:39 +05:30
<component :is="componentName" :mr="mr" :service="service" />
2021-12-11 22:18:48 +05:30
<ready-to-merge
v-if="isRestructuredMrWidgetEnabled && mr.commitsCount"
:mr="mr"
:service="service"
/>
<div v-else class="mr-widget-info">
2019-09-04 21:01:54 +05:30
<mr-widget-related-links
v-if="shouldRenderRelatedLinks"
:state="mr.state"
:related-links="mr.relatedLinks"
2021-12-11 22:18:48 +05:30
class="mr-info-list gl-ml-7 gl-pb-5"
2019-09-04 21:01:54 +05:30
/>
2018-11-08 19:23:39 +05:30
2019-09-04 21:01:54 +05:30
<source-branch-removal-status v-if="shouldRenderSourceBranchRemovalStatus" />
</div>
2017-09-10 17:25:29 +05:30
</div>
2017-08-17 22:00:37 +05:30
</div>
2019-02-15 15:39:39 +05:30
<mr-widget-pipeline-container
v-if="shouldRenderMergedPipeline"
class="js-post-merge-pipeline mr-widget-workflow"
:mr="mr"
:is-post-merge="true"
/>
2018-11-08 19:23:39 +05:30
</div>
2020-01-01 13:55:28 +05:30
<loading v-else />
2018-11-08 19:23:39 +05:30
</template>