Commit 3c93c02e authored by Phil Hughes's avatar Phil Hughes

Merge branch '45462-sha-object-ee' into 'master'

Resolve "`sha-mismatch` vue component is rendering an empty block"

See merge request gitlab-org/gitlab-ee!5658
parents d4e9122b 1874c6bd
<script>
export default {
name: 'MRWidgetMaintainerEdit',
props: {
maintainerEditAllowed: {
type: Boolean,
default: false,
required: false,
},
},
};
</script>
<template>
<section class="mr-info-list mr-links">
<p v-if="maintainerEditAllowed">
{{ s__("mrWidget|Allows edits from maintainers") }}
</p>
</section>
</template>
...@@ -15,7 +15,6 @@ export { default as WidgetHeader } from './components/mr_widget_header.vue'; ...@@ -15,7 +15,6 @@ export { default as WidgetHeader } from './components/mr_widget_header.vue';
export { default as WidgetMergeHelp } from './components/mr_widget_merge_help.vue'; export { default as WidgetMergeHelp } from './components/mr_widget_merge_help.vue';
export { default as WidgetPipeline } from './components/mr_widget_pipeline.vue'; export { default as WidgetPipeline } from './components/mr_widget_pipeline.vue';
export { default as Deployment } from './components/deployment.vue'; export { default as Deployment } from './components/deployment.vue';
export { default as WidgetMaintainerEdit } from './components/mr_widget_maintainer_edit.vue';
export { default as WidgetRelatedLinks } from './components/mr_widget_related_links.vue'; export { default as WidgetRelatedLinks } from './components/mr_widget_related_links.vue';
export { default as MergedState } from './components/states/mr_widget_merged.vue'; export { default as MergedState } from './components/states/mr_widget_merged.vue';
export { default as FailedToMerge } from './components/states/mr_widget_failed_to_merge.vue'; export { default as FailedToMerge } from './components/states/mr_widget_failed_to_merge.vue';
...@@ -45,4 +44,4 @@ export { default as SquashBeforeMerge } from 'ee/vue_merge_request_widget/compon ...@@ -45,4 +44,4 @@ export { default as SquashBeforeMerge } from 'ee/vue_merge_request_widget/compon
export { default as notify } from '../lib/utils/notify'; export { default as notify } from '../lib/utils/notify';
export { default as SourceBranchRemovalStatus } from './components/source_branch_removal_status.vue'; export { default as SourceBranchRemovalStatus } from './components/source_branch_removal_status.vue';
export { default as mrWidgetOptions } from 'ee/vue_merge_request_widget/mr_widget_options'; export { default as mrWidgetOptions } from 'ee/vue_merge_request_widget/mr_widget_options.vue';
<script>
import Project from '~/pages/projects/project'; import Project from '~/pages/projects/project';
import SmartInterval from '~/smart_interval'; import SmartInterval from '~/smart_interval';
import Flash from '../flash'; import createFlash from '../flash';
import { import {
WidgetHeader, WidgetHeader,
WidgetMergeHelp, WidgetMergeHelp,
WidgetPipeline, WidgetPipeline,
Deployment, Deployment,
WidgetMaintainerEdit,
WidgetRelatedLinks, WidgetRelatedLinks,
MergedState, MergedState,
ClosedState, ClosedState,
...@@ -40,10 +41,39 @@ import { setFavicon } from '../lib/utils/common_utils'; ...@@ -40,10 +41,39 @@ import { setFavicon } from '../lib/utils/common_utils';
export default { export default {
el: '#js-vue-mr-widget', el: '#js-vue-mr-widget',
name: 'MRWidget', name: 'MRWidget',
components: {
'mr-widget-header': WidgetHeader,
'mr-widget-merge-help': WidgetMergeHelp,
'mr-widget-pipeline': WidgetPipeline,
Deployment,
'mr-widget-related-links': WidgetRelatedLinks,
'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,
'mr-widget-ready-to-merge': ReadyToMergeState,
'sha-mismatch': ShaMismatchState,
'mr-widget-squash-before-merge': SquashBeforeMerge,
'mr-widget-checking': CheckingState,
'mr-widget-unresolved-discussions': UnresolvedDiscussionsState,
'mr-widget-pipeline-blocked': PipelineBlockedState,
'mr-widget-pipeline-failed': PipelineFailedState,
'mr-widget-merge-when-pipeline-succeeds': MergeWhenPipelineSucceedsState,
'mr-widget-auto-merge-failed': AutoMergeFailed,
'mr-widget-rebase': RebaseState,
SourceBranchRemovalStatus,
},
props: { props: {
mrData: { mrData: {
type: Object, type: Object,
required: false, required: false,
default: null,
}, },
}, },
data() { data() {
...@@ -72,6 +102,13 @@ export default { ...@@ -72,6 +102,13 @@ export default {
(!this.mr.isNothingToMergeState && !this.mr.isMergedState); (!this.mr.isNothingToMergeState && !this.mr.isMergedState);
}, },
}, },
created() {
this.initPolling();
this.bindEventHubListeners();
},
mounted() {
this.handleMounted();
},
methods: { methods: {
createService(store) { createService(store) {
const endpoints = { const endpoints = {
...@@ -100,7 +137,7 @@ export default { ...@@ -100,7 +137,7 @@ export default {
cb.call(null, data); cb.call(null, data);
} }
}) })
.catch(() => new Flash('Something went wrong. Please try again.')); .catch(() => createFlash('Something went wrong. Please try again.'));
}, },
initPolling() { initPolling() {
this.pollingInterval = new SmartInterval({ this.pollingInterval = new SmartInterval({
...@@ -135,7 +172,7 @@ export default { ...@@ -135,7 +172,7 @@ export default {
} }
}) })
.catch(() => { .catch(() => {
new Flash('Something went wrong while fetching the environments for this merge request. Please try again.'); // eslint-disable-line createFlash('Something went wrong while fetching the environments for this merge request. Please try again.'); // eslint-disable-line
}); });
}, },
fetchActionsContent() { fetchActionsContent() {
...@@ -148,7 +185,7 @@ export default { ...@@ -148,7 +185,7 @@ export default {
Project.initRefSwitcher(); Project.initRefSwitcher();
} }
}) })
.catch(() => new Flash('Something went wrong. Please try again.')); .catch(() => createFlash('Something went wrong. Please try again.'));
}, },
handleNotification(data) { handleNotification(data) {
if (data.ci_status === this.mr.ciStatus) return; if (data.ci_status === this.mr.ciStatus) return;
...@@ -203,76 +240,53 @@ export default { ...@@ -203,76 +240,53 @@ export default {
this.initDeploymentsPolling(); this.initDeploymentsPolling();
}, },
}, },
created() { };
this.initPolling(); </script>
this.bindEventHubListeners(); <template>
}, <div class="mr-state-widget prepend-top-default">
mounted() { <mr-widget-header
this.handleMounted(); :mr="mr"
}, />
components: { <mr-widget-pipeline
'mr-widget-header': WidgetHeader, v-if="shouldRenderPipelines"
'mr-widget-merge-help': WidgetMergeHelp, :pipeline="mr.pipeline"
'mr-widget-pipeline': WidgetPipeline, :ci-status="mr.ciStatus"
Deployment, :has-ci="mr.hasCI"
'mr-widget-maintainer-edit': WidgetMaintainerEdit, />
'mr-widget-related-links': WidgetRelatedLinks, <deployment
'mr-widget-merged': MergedState, v-for="deployment in mr.deployments"
'mr-widget-closed': ClosedState, :key="deployment.id"
'mr-widget-merging': MergingState, :deployment="deployment"
'mr-widget-failed-to-merge': FailedToMerge, />
'mr-widget-wip': WorkInProgressState, <div class="mr-widget-section">
'mr-widget-archived': ArchivedState, <component
'mr-widget-conflicts': ConflictsState, :is="componentName"
'mr-widget-nothing-to-merge': NothingToMergeState, :mr="mr"
'mr-widget-not-allowed': NotAllowedState, :service="service"
'mr-widget-missing-branch': MissingBranchState, />
'mr-widget-ready-to-merge': ReadyToMergeState,
'mr-widget-sha-mismatch': ShaMismatchState, <section
'mr-widget-squash-before-merge': SquashBeforeMerge, v-if="mr.maintainerEditAllowed"
'mr-widget-checking': CheckingState, class="mr-info-list mr-links"
'mr-widget-unresolved-discussions': UnresolvedDiscussionsState, >
'mr-widget-pipeline-blocked': PipelineBlockedState, {{ s__("mrWidget|Allows edits from maintainers") }}
'mr-widget-pipeline-failed': PipelineFailedState, </section>
'mr-widget-merge-when-pipeline-succeeds': MergeWhenPipelineSucceedsState,
'mr-widget-auto-merge-failed': AutoMergeFailed, <mr-widget-related-links
'mr-widget-rebase': RebaseState, v-if="shouldRenderRelatedLinks"
SourceBranchRemovalStatus, :state="mr.state"
}, :related-links="mr.relatedLinks"
template: ` />
<div class="mr-state-widget prepend-top-default">
<mr-widget-header :mr="mr" /> <source-branch-removal-status
<mr-widget-pipeline v-if="shouldRenderSourceBranchRemovalStatus"
v-if="shouldRenderPipelines"
:pipeline="mr.pipeline"
:ci-status="mr.ciStatus"
:has-ci="mr.hasCI"
/>
<deployment
v-for="deployment in mr.deployments"
:key="deployment.id"
:deployment="deployment"
/> />
<div class="mr-widget-section">
<component
:is="componentName"
:mr="mr"
:service="service" />
<mr-widget-maintainer-edit
:maintainerEditAllowed="mr.maintainerEditAllowed" />
<mr-widget-related-links
v-if="shouldRenderRelatedLinks"
:state="mr.state"
:related-links="mr.relatedLinks" />
<source-branch-removal-status
v-if="shouldRenderSourceBranchRemovalStatus"
/>
</div>
<div
class="mr-widget-footer"
v-if="shouldRenderMergeHelp">
<mr-widget-merge-help />
</div>
</div> </div>
`, <div
}; class="mr-widget-footer"
v-if="shouldRenderMergeHelp"
>
<mr-widget-merge-help />
</div>
</div>
</template>
<script>
import { n__, s__, __, sprintf } from '~/locale'; import { n__, s__, __, sprintf } from '~/locale';
import CEWidgetOptions from '~/vue_merge_request_widget/mr_widget_options'; import CEWidgetOptions from '~/vue_merge_request_widget/mr_widget_options.vue';
import WidgetApprovals from './components/approvals/mr_widget_approvals'; import WidgetApprovals from './components/approvals/mr_widget_approvals';
import GeoSecondaryNode from './components/states/mr_widget_secondary_geo_node'; import GeoSecondaryNode from './components/states/mr_widget_secondary_geo_node';
import ReportSection from '../vue_shared/security_reports/components/report_section.vue'; import ReportSection from '../vue_shared/security_reports/components/report_section.vue';
...@@ -7,13 +8,13 @@ import GroupedSecurityReportsApp from '../vue_shared/security_reports/grouped_se ...@@ -7,13 +8,13 @@ import GroupedSecurityReportsApp from '../vue_shared/security_reports/grouped_se
import reportsMixin from '../vue_shared/security_reports/mixins/reports_mixin'; import reportsMixin from '../vue_shared/security_reports/mixins/reports_mixin';
export default { export default {
extends: CEWidgetOptions,
components: { components: {
'mr-widget-approvals': WidgetApprovals, 'mr-widget-approvals': WidgetApprovals,
'mr-widget-geo-secondary-node': GeoSecondaryNode, 'mr-widget-geo-secondary-node': GeoSecondaryNode,
GroupedSecurityReportsApp, GroupedSecurityReportsApp,
ReportSection, ReportSection,
}, },
extends: CEWidgetOptions,
mixins: [reportsMixin], mixins: [reportsMixin],
data() { data() {
return { return {
...@@ -118,6 +119,15 @@ export default { ...@@ -118,6 +119,15 @@ export default {
return this.checkReportStatus(this.isLoadingPerformance, this.loadingPerformanceFailed); return this.checkReportStatus(this.isLoadingPerformance, this.loadingPerformanceFailed);
}, },
}, },
created() {
if (this.shouldRenderCodeQuality) {
this.fetchCodeQuality();
}
if (this.shouldRenderPerformance) {
this.fetchPerformance();
}
},
methods: { methods: {
fetchCodeQuality() { fetchCodeQuality() {
const { head_path, base_path } = this.mr.codeclimate; const { head_path, base_path } = this.mr.codeclimate;
...@@ -167,97 +177,100 @@ export default { ...@@ -167,97 +177,100 @@ export default {
}; };
}, },
}, },
created() { };
if (this.shouldRenderCodeQuality) { </script>
this.fetchCodeQuality(); <template>
} <div class="mr-state-widget prepend-top-default">
<mr-widget-header :mr="mr" />
if (this.shouldRenderPerformance) { <mr-widget-pipeline
this.fetchPerformance(); v-if="shouldRenderPipelines"
} :pipeline="mr.pipeline"
}, :ci-status="mr.ciStatus"
template: ` :has-ci="mr.hasCI"
<div class="mr-state-widget prepend-top-default"> />
<mr-widget-header :mr="mr" /> <deployment
<mr-widget-pipeline v-for="deployment in mr.deployments"
v-if="shouldRenderPipelines" :key="deployment.id"
:pipeline="mr.pipeline" :deployment="deployment"
:ci-status="mr.ciStatus" />
:has-ci="mr.hasCI" <mr-widget-approvals
/> v-if="shouldRenderApprovals"
<deployment :mr="mr"
v-for="deployment in mr.deployments" :service="service"
:key="deployment.id" />
:deployment="deployment" <report-section
/> class="js-codequality-widget mr-widget-border-top"
<mr-widget-approvals v-if="shouldRenderCodeQuality"
v-if="shouldRenderApprovals" type="codequality"
:status="codequalityStatus"
:loading-text="translateText('codeclimate').loading"
:error-text="translateText('codeclimate').error"
:success-text="codequalityText"
:unresolved-issues="mr.codeclimateMetrics.newIssues"
:resolved-issues="mr.codeclimateMetrics.resolvedIssues"
:has-issues="hasCodequalityIssues"
/>
<report-section
class="js-performance-widget mr-widget-border-top"
v-if="shouldRenderPerformance"
type="performance"
:status="performanceStatus"
:loading-text="translateText('performance').loading"
:error-text="translateText('performance').error"
:success-text="performanceText"
:unresolved-issues="mr.performanceMetrics.degraded"
:resolved-issues="mr.performanceMetrics.improved"
:neutral-issues="mr.performanceMetrics.neutral"
:has-issues="hasPerformanceMetrics"
/>
<grouped-security-reports-app
v-if="shouldRenderSecurityReport"
:head-blob-path="mr.headBlobPath"
:base-blob-path="mr.baseBlobPath"
:sast-head-path="mr.sast.head_path"
:sast-base-path="mr.sast.base_path"
:sast-help-path="mr.sastHelp"
:dast-head-path="mr.dast.head_path"
:dast-base-path="mr.dast.base_path"
:dast-help-path="mr.dastHelp"
:sast-container-head-path="mr.sastContainer.head_path"
:sast-container-base-path="mr.sastContainer.base_path"
:sast-container-help-path="mr.sastContainerHelp"
:dependency-scanning-head-path="mr.dependencyScanning.head_path"
:dependency-scanning-base-path="mr.dependencyScanning.base_path"
:dependency-scanning-help-path="mr.dependencyScanningHelp"
:vulnerability-feedback-path="mr.vulnerabilityFeedbackPath"
:vulnerability-feedback-help-path="mr.vulnerabilityFeedbackHelpPath"
:pipeline-id="mr.securityReportsPipelineId"
/>
<div class="mr-widget-section">
<component
:is="componentName"
:mr="mr" :mr="mr"
:service="service" :service="service"
/> />
<report-section
class="js-codequality-widget mr-widget-border-top" <section
v-if="shouldRenderCodeQuality" v-if="mr.maintainerEditAllowed"
type="codequality" class="mr-info-list mr-links"
:status="codequalityStatus" >
:loading-text="translateText('codeclimate').loading" {{ s__("mrWidget|Allows edits from maintainers") }}
:error-text="translateText('codeclimate').error" </section>
:success-text="codequalityText"
:unresolved-issues="mr.codeclimateMetrics.newIssues" <mr-widget-related-links
:resolved-issues="mr.codeclimateMetrics.resolvedIssues" v-if="shouldRenderRelatedLinks"
:has-issues="hasCodequalityIssues" :state="mr.state"
/> :related-links="mr.relatedLinks"
<report-section
class="js-performance-widget mr-widget-border-top"
v-if="shouldRenderPerformance"
type="performance"
:status="performanceStatus"
:loading-text="translateText('performance').loading"
:error-text="translateText('performance').error"
:success-text="performanceText"
:unresolved-issues="mr.performanceMetrics.degraded"
:resolved-issues="mr.performanceMetrics.improved"
:neutral-issues="mr.performanceMetrics.neutral"
:has-issues="hasPerformanceMetrics"
/> />
<grouped-security-reports-app <source-branch-removal-status
v-if="shouldRenderSecurityReport" v-if="shouldRenderSourceBranchRemovalStatus"
:head-blob-path="mr.headBlobPath"
:base-blob-path="mr.baseBlobPath"
:sast-head-path="mr.sast.head_path"
:sast-base-path="mr.sast.base_path"
:sast-help-path="mr.sastHelp"
:dast-head-path="mr.dast.head_path"
:dast-base-path="mr.dast.base_path"
:dast-help-path="mr.dastHelp"
:sast-container-head-path="mr.sastContainer.head_path"
:sast-container-base-path="mr.sastContainer.base_path"
:sast-container-help-path="mr.sastContainerHelp"
:dependency-scanning-head-path="mr.dependencyScanning.head_path"
:dependency-scanning-base-path="mr.dependencyScanning.base_path"
:dependency-scanning-help-path="mr.dependencyScanningHelp"
:vulnerability-feedback-path="mr.vulnerabilityFeedbackPath"
:vulnerability-feedback-help-path="mr.vulnerabilityFeedbackHelpPath"
:pipeline-id="mr.securityReportsPipelineId"
/> />
<div class="mr-widget-section">
<component
:is="componentName"
:mr="mr"
:service="service" />
<mr-widget-maintainer-edit
:maintainerEditAllowed="mr.maintainerEditAllowed" />
<mr-widget-related-links
v-if="shouldRenderRelatedLinks"
:state="mr.state"
:related-links="mr.relatedLinks" />
<source-branch-removal-status
v-if="shouldRenderSourceBranchRemovalStatus"
/>
</div>
<div class="mr-widget-footer" v-if="shouldRenderMergeHelp">
<mr-widget-merge-help />
</div>
</div> </div>
`, <div
}; class="mr-widget-footer"
v-if="shouldRenderMergeHelp"
>
<mr-widget-merge-help />
</div>
</div>
</template>
import Vue from 'vue';
import maintainerEditComponent from '~/vue_merge_request_widget/components/mr_widget_maintainer_edit.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
describe('RWidgetMaintainerEdit', () => {
let Component;
let vm;
beforeEach(() => {
Component = Vue.extend(maintainerEditComponent);
});
afterEach(() => {
vm.$destroy();
});
describe('when a maintainer is allowed to edit', () => {
beforeEach(() => {
vm = mountComponent(Component, {
maintainerEditAllowed: true,
});
});
it('it renders the message', () => {
expect(vm.$el.textContent.trim()).toEqual('Allows edits from maintainers');
});
});
describe('when a maintainer is not allowed to edit', () => {
beforeEach(() => {
vm = mountComponent(Component, {
maintainerEditAllowed: false,
});
});
it('hides the message', () => {
expect(vm.$el.textContent.trim()).toEqual('');
});
});
});
import Vue from 'vue'; import Vue from 'vue';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import mrWidgetOptions from 'ee/vue_merge_request_widget/mr_widget_options'; import mrWidgetOptions from 'ee/vue_merge_request_widget/mr_widget_options.vue';
import MRWidgetService from 'ee/vue_merge_request_widget/services/mr_widget_service'; import MRWidgetService from 'ee/vue_merge_request_widget/services/mr_widget_service';
import MRWidgetStore from 'ee/vue_merge_request_widget/stores/mr_widget_store'; import MRWidgetStore from 'ee/vue_merge_request_widget/stores/mr_widget_store';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'spec/helpers/vue_mount_component_helper';
......
import Vue from 'vue'; import Vue from 'vue';
import mrWidgetOptions from '~/vue_merge_request_widget/mr_widget_options'; import mrWidgetOptions from '~/vue_merge_request_widget/mr_widget_options.vue';
import eventHub from '~/vue_merge_request_widget/event_hub'; import eventHub from '~/vue_merge_request_widget/event_hub';
import notify from '~/lib/utils/notify'; import notify from '~/lib/utils/notify';
import { stateKey } from '~/vue_merge_request_widget/stores/state_maps'; import { stateKey } from '~/vue_merge_request_widget/stores/state_maps';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment