Commit 08083f43 authored by Mike Greiling's avatar Mike Greiling

Merge branch 'refactor/move-mr-widget-ready-to-merge-vue-component' into 'master'

Move ReadyToMerge vue component

See merge request gitlab-org/gitlab-ce!17545
parents 41636097 5cb0a2ef
<script>
import successSvg from 'icons/_icon_status_success.svg'; import successSvg from 'icons/_icon_status_success.svg';
import warningSvg from 'icons/_icon_status_warning.svg'; import warningSvg from 'icons/_icon_status_warning.svg';
import simplePoll from '~/lib/utils/simple_poll'; import simplePoll from '~/lib/utils/simple_poll';
...@@ -7,7 +8,10 @@ import statusIcon from '../mr_widget_status_icon.vue'; ...@@ -7,7 +8,10 @@ import statusIcon from '../mr_widget_status_icon.vue';
import eventHub from '../../event_hub'; import eventHub from '../../event_hub';
export default { export default {
name: 'MRWidgetReadyToMerge', name: 'ReadyToMerge',
components: {
statusIcon,
},
props: { props: {
mr: { type: Object, required: true }, mr: { type: Object, required: true },
service: { type: Object, required: true }, service: { type: Object, required: true },
...@@ -26,9 +30,6 @@ export default { ...@@ -26,9 +30,6 @@ export default {
warningSvg, warningSvg,
}; };
}, },
components: {
statusIcon,
},
computed: { computed: {
shouldShowMergeWhenPipelineSucceedsText() { shouldShowMergeWhenPipelineSucceedsText() {
return this.mr.isPipelineActive; return this.mr.isPipelineActive;
...@@ -217,136 +218,146 @@ export default { ...@@ -217,136 +218,146 @@ export default {
}); });
}, },
}, },
template: ` };
<div class="mr-widget-body media"> </script>
<status-icon :status="iconClass" />
<div class="media-body"> <template>
<div class="mr-widget-body-controls media space-children"> <div class="mr-widget-body media">
<span class="btn-group append-bottom-5"> <status-icon :status="iconClass" />
<button <div class="media-body">
@click="handleMergeButtonClick()" <div class="mr-widget-body-controls media space-children">
:disabled="isMergeButtonDisabled" <span class="btn-group append-bottom-5">
:class="mergeButtonClass" <button
type="button" @click="handleMergeButtonClick()"
class="qa-merge-button"> :disabled="isMergeButtonDisabled"
<i :class="mergeButtonClass"
v-if="isMakingRequest" type="button"
class="fa fa-spinner fa-spin" class="qa-merge-button">
aria-hidden="true" /> <i
{{mergeButtonText}} v-if="isMakingRequest"
</button> class="fa fa-spinner fa-spin"
aria-hidden="true"
></i>
{{ mergeButtonText }}
</button>
<button
v-if="shouldShowMergeOptionsDropdown"
:disabled="isMergeButtonDisabled"
type="button"
class="btn btn-sm btn-info dropdown-toggle js-merge-moment"
data-toggle="dropdown"
aria-label="Select merge moment">
<i
class="fa fa-chevron-down"
aria-hidden="true"
></i>
</button>
<ul
v-if="shouldShowMergeOptionsDropdown"
class="dropdown-menu dropdown-menu-right"
role="menu">
<li>
<a
@click.prevent="handleMergeButtonClick(true)"
class="merge_when_pipeline_succeeds"
href="#">
<span class="media">
<span
v-html="successSvg"
class="merge-opt-icon"
aria-hidden="true"></span>
<span class="media-body merge-opt-title">Merge when pipeline succeeds</span>
</span>
</a>
</li>
<li>
<a
@click.prevent="handleMergeButtonClick(false, true)"
class="accept-merge-request"
href="#">
<span class="media">
<span
v-html="warningSvg"
class="merge-opt-icon"
aria-hidden="true"></span>
<span class="media-body merge-opt-title">Merge immediately</span>
</span>
</a>
</li>
</ul>
</span>
<div class="media-body-wrap space-children">
<template v-if="shouldShowMergeControls()">
<label v-if="mr.canRemoveSourceBranch">
<input
id="remove-source-branch-input"
v-model="removeSourceBranch"
class="js-remove-source-branch-checkbox"
:disabled="isRemoveSourceBranchButtonDisabled"
type="checkbox"/> Remove source branch
</label>
<!-- Placeholder for EE extension of this component -->
<squash-before-merge
v-if="shouldShowSquashBeforeMerge"
:mr="mr"
:is-merge-button-disabled="isMergeButtonDisabled" />
<span
v-if="mr.ffOnlyEnabled"
class="js-fast-forward-message">
Fast-forward merge without a merge commit
</span>
<button <button
v-if="shouldShowMergeOptionsDropdown" v-else
@click="toggleCommitMessageEditor"
:disabled="isMergeButtonDisabled" :disabled="isMergeButtonDisabled"
type="button" class="js-modify-commit-message-button btn btn-default btn-xs"
class="btn btn-sm btn-info dropdown-toggle js-merge-moment" type="button">
data-toggle="dropdown" Modify commit message
aria-label="Select merge moment">
<i
class="fa fa-chevron-down"
aria-hidden="true" />
</button> </button>
<ul </template>
v-if="shouldShowMergeOptionsDropdown" <template v-else>
class="dropdown-menu dropdown-menu-right" <span class="bold js-resolve-mr-widget-items-message">
role="menu"> You can only merge once the items above are resolved
<li> </span>
<a </template>
@click.prevent="handleMergeButtonClick(true)"
class="merge_when_pipeline_succeeds"
href="#">
<span class="media">
<span
v-html="successSvg"
class="merge-opt-icon"
aria-hidden="true"></span>
<span class="media-body merge-opt-title">Merge when pipeline succeeds</span>
</span>
</a>
</li>
<li>
<a
@click.prevent="handleMergeButtonClick(false, true)"
class="accept-merge-request"
href="#">
<span class="media">
<span
v-html="warningSvg"
class="merge-opt-icon"
aria-hidden="true"></span>
<span class="media-body merge-opt-title">Merge immediately</span>
</span>
</a>
</li>
</ul>
</span>
<div class="media-body-wrap space-children">
<template v-if="shouldShowMergeControls()">
<label v-if="mr.canRemoveSourceBranch">
<input
id="remove-source-branch-input"
v-model="removeSourceBranch"
class="js-remove-source-branch-checkbox"
:disabled="isRemoveSourceBranchButtonDisabled"
type="checkbox"/> Remove source branch
</label>
<!-- Placeholder for EE extension of this component -->
<squash-before-merge
v-if="shouldShowSquashBeforeMerge"
:mr="mr"
:is-merge-button-disabled="isMergeButtonDisabled" />
<span
v-if="mr.ffOnlyEnabled"
class="js-fast-forward-message">
Fast-forward merge without a merge commit
</span>
<button
v-else
@click="toggleCommitMessageEditor"
:disabled="isMergeButtonDisabled"
class="js-modify-commit-message-button btn btn-default btn-xs"
type="button">
Modify commit message
</button>
</template>
<template v-else>
<span class="bold js-resolve-mr-widget-items-message">
You can only merge once the items above are resolved
</span>
</template>
</div>
</div> </div>
<div </div>
v-if="showCommitMessageEditor" <div
class="prepend-top-default commit-message-editor"> v-if="showCommitMessageEditor"
<div class="form-group clearfix"> class="prepend-top-default commit-message-editor">
<label <div class="form-group clearfix">
class="control-label" <label
for="commit-message"> class="control-label"
Commit message for="commit-message">
</label> Commit message
<div class="col-sm-10"> </label>
<div class="commit-message-container"> <div class="col-sm-10">
<div class="max-width-marker"></div> <div class="commit-message-container">
<textarea <div class="max-width-marker"></div>
v-model="commitMessage" <textarea
class="form-control js-commit-message" id="commit-message"
required="required" v-model="commitMessage"
rows="14" class="form-control js-commit-message"
name="Commit message"></textarea> required="required"
</div> rows="14"
<p class="hint">Try to keep the first line under 52 characters and the others under 72</p> name="Commit message"></textarea>
<div class="hint"> </div>
<a <p class="hint">
@click.prevent="updateCommitMessage" Try to keep the first line under 52 characters and the others under 72
href="#">{{commitMessageLinkTitle}}</a> </p>
</div> <div class="hint">
<a
@click.prevent="updateCommitMessage"
href="#"
>
{{ commitMessageLinkTitle }}
</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
`, </div>
}; </template>
...@@ -27,7 +27,7 @@ export { default as ConflictsState } from './components/states/mr_widget_conflic ...@@ -27,7 +27,7 @@ export { default as ConflictsState } from './components/states/mr_widget_conflic
export { default as NothingToMergeState } from './components/states/nothing_to_merge.vue'; export { default as NothingToMergeState } from './components/states/nothing_to_merge.vue';
export { default as MissingBranchState } from './components/states/mr_widget_missing_branch.vue'; export { default as MissingBranchState } from './components/states/mr_widget_missing_branch.vue';
export { default as NotAllowedState } from './components/states/mr_widget_not_allowed.vue'; export { default as NotAllowedState } from './components/states/mr_widget_not_allowed.vue';
export { default as ReadyToMergeState } from './components/states/mr_widget_ready_to_merge'; export { default as ReadyToMergeState } from './components/states/ready_to_merge.vue';
export { default as ShaMismatchState } from './components/states/sha_mismatch.vue'; export { default as ShaMismatchState } from './components/states/sha_mismatch.vue';
export { default as UnresolvedDiscussionsState } from './components/states/unresolved_discussions.vue'; export { default as UnresolvedDiscussionsState } from './components/states/unresolved_discussions.vue';
export { default as PipelineBlockedState } from './components/states/mr_widget_pipeline_blocked.vue'; export { default as PipelineBlockedState } from './components/states/mr_widget_pipeline_blocked.vue';
......
---
title: Move ReadyToMerge vue component
merge_request: 17545
author: George Tsiolis
type: performance
...@@ -2,7 +2,7 @@ module QA ...@@ -2,7 +2,7 @@ module QA
module Page module Page
module MergeRequest module MergeRequest
class Show < Page::Base class Show < Page::Base
view 'app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_ready_to_merge.js' do view 'app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue' do
element :merge_button element :merge_button
element :fast_forward_message, 'Fast-forward merge without a merge commit' element :fast_forward_message, 'Fast-forward merge without a merge commit'
end end
......
import Vue from 'vue'; import Vue from 'vue';
import readyToMergeComponent from '~/vue_merge_request_widget/components/states/mr_widget_ready_to_merge'; import ReadyToMerge from '~/vue_merge_request_widget/components/states/ready_to_merge.vue';
import eventHub from '~/vue_merge_request_widget/event_hub'; import eventHub from '~/vue_merge_request_widget/event_hub';
import * as simplePoll from '~/lib/utils/simple_poll'; import * as simplePoll from '~/lib/utils/simple_poll';
const commitMessage = 'This is the commit message'; const commitMessage = 'This is the commit message';
const commitMessageWithDescription = 'This is the commit message description'; const commitMessageWithDescription = 'This is the commit message description';
const createComponent = (customConfig = {}) => { const createComponent = (customConfig = {}) => {
const Component = Vue.extend(readyToMergeComponent); const Component = Vue.extend(ReadyToMerge);
const mr = { const mr = {
isPipelineActive: false, isPipelineActive: false,
pipeline: null, pipeline: null,
...@@ -36,7 +36,7 @@ const createComponent = (customConfig = {}) => { ...@@ -36,7 +36,7 @@ const createComponent = (customConfig = {}) => {
}); });
}; };
describe('MRWidgetReadyToMerge', () => { describe('ReadyToMerge', () => {
let vm; let vm;
beforeEach(() => { beforeEach(() => {
...@@ -49,7 +49,7 @@ describe('MRWidgetReadyToMerge', () => { ...@@ -49,7 +49,7 @@ describe('MRWidgetReadyToMerge', () => {
describe('props', () => { describe('props', () => {
it('should have props', () => { it('should have props', () => {
const { mr, service } = readyToMergeComponent.props; const { mr, service } = ReadyToMerge.props;
expect(mr.type instanceof Object).toBeTruthy(); expect(mr.type instanceof Object).toBeTruthy();
expect(mr.required).toBeTruthy(); expect(mr.required).toBeTruthy();
......
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