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