Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
6abbe64d
Commit
6abbe64d
authored
Mar 08, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EE port of merge-request-widget-source-branch-improvements
parent
dfb021cc
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
148 additions
and
16 deletions
+148
-16
app/assets/javascripts/vue_merge_request_widget/components/source_branch_removal_status.vue
...equest_widget/components/source_branch_removal_status.vue
+34
-0
app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_ready_to_merge.js
...uest_widget/components/states/mr_widget_ready_to_merge.js
+2
-2
app/assets/javascripts/vue_merge_request_widget/dependencies.js
...sets/javascripts/vue_merge_request_widget/dependencies.js
+3
-1
app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
...javascripts/vue_merge_request_widget/mr_widget_options.js
+8
-0
changelogs/unreleased/merge-request-widget-source-branch-improvements.yml
...eased/merge-request-widget-source-branch-improvements.yml
+6
-0
ee/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
...javascripts/vue_merge_request_widget/mr_widget_options.js
+7
-4
spec/features/merge_request/user_sees_merge_widget_spec.rb
spec/features/merge_request/user_sees_merge_widget_spec.rb
+25
-1
spec/javascripts/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js
...widget/components/states/mr_widget_ready_to_merge_spec.js
+4
-8
spec/javascripts/vue_mr_widget/ee_mr_widget_options_spec.js
spec/javascripts/vue_mr_widget/ee_mr_widget_options_spec.js
+18
-0
spec/javascripts/vue_mr_widget/mr_widget_options_spec.js
spec/javascripts/vue_mr_widget/mr_widget_options_spec.js
+41
-0
No files found.
app/assets/javascripts/vue_merge_request_widget/components/source_branch_removal_status.vue
0 → 100644
View file @
6abbe64d
<
script
>
import
tooltip
from
'
../../vue_shared/directives/tooltip
'
;
import
{
__
}
from
'
../../locale
'
;
export
default
{
directives
:
{
tooltip
,
},
created
()
{
this
.
removesBranchText
=
__
(
'
<strong>Removes</strong> source branch
'
);
this
.
tooltipTitle
=
__
(
'
A user with write access to the source branch selected this option
'
);
},
};
</
script
>
<
template
>
<p
v-once
class=
"mr-info-list mr-links source-branch-removal-status append-bottom-0"
>
<span
class=
"status-text"
v-html=
"removesBranchText"
>
</span>
<i
v-tooltip
class=
"fa fa-question-circle"
:title=
"tooltipTitle"
:aria-label=
"tooltipTitle"
>
</i>
</p>
</
template
>
app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_ready_to_merge.js
View file @
6abbe64d
...
@@ -94,7 +94,7 @@ export default {
...
@@ -94,7 +94,7 @@ export default {
||
this
.
mr
.
preventMerge
);
||
this
.
mr
.
preventMerge
);
},
},
isRemoveSourceBranchButtonDisabled
()
{
isRemoveSourceBranchButtonDisabled
()
{
return
this
.
isMergeButtonDisabled
||
!
this
.
mr
.
canRemoveSourceBranch
;
return
this
.
isMergeButtonDisabled
;
},
},
shouldShowSquashBeforeMerge
()
{
shouldShowSquashBeforeMerge
()
{
const
{
commitsCount
,
enableSquashBeforeMerge
}
=
this
.
mr
;
const
{
commitsCount
,
enableSquashBeforeMerge
}
=
this
.
mr
;
...
@@ -286,7 +286,7 @@ export default {
...
@@ -286,7 +286,7 @@ export default {
</span>
</span>
<div class="media-body-wrap space-children">
<div class="media-body-wrap space-children">
<template v-if="shouldShowMergeControls()">
<template v-if="shouldShowMergeControls()">
<label>
<label
v-if="mr.canRemoveSourceBranch"
>
<input
<input
id="remove-source-branch-input"
id="remove-source-branch-input"
v-model="removeSourceBranch"
v-model="removeSourceBranch"
...
...
app/assets/javascripts/vue_merge_request_widget/dependencies.js
View file @
6abbe64d
...
@@ -40,7 +40,9 @@ export { default as MRWidgetStore } from 'ee/vue_merge_request_widget/stores/mr_
...
@@ -40,7 +40,9 @@ export { default as MRWidgetStore } from 'ee/vue_merge_request_widget/stores/mr_
export
{
default
as
MRWidgetService
}
from
'
ee/vue_merge_request_widget/services/mr_widget_service
'
;
export
{
default
as
MRWidgetService
}
from
'
ee/vue_merge_request_widget/services/mr_widget_service
'
;
export
{
default
as
eventHub
}
from
'
./event_hub
'
;
export
{
default
as
eventHub
}
from
'
./event_hub
'
;
export
{
default
as
getStateKey
}
from
'
ee/vue_merge_request_widget/stores/get_state_key
'
;
export
{
default
as
getStateKey
}
from
'
ee/vue_merge_request_widget/stores/get_state_key
'
;
export
{
default
as
mrWidgetOptions
}
from
'
ee/vue_merge_request_widget/mr_widget_options
'
;
export
{
default
as
stateMaps
}
from
'
ee/vue_merge_request_widget/stores/state_maps
'
;
export
{
default
as
stateMaps
}
from
'
ee/vue_merge_request_widget/stores/state_maps
'
;
export
{
default
as
SquashBeforeMerge
}
from
'
ee/vue_merge_request_widget/components/states/mr_widget_squash_before_merge
'
;
export
{
default
as
SquashBeforeMerge
}
from
'
ee/vue_merge_request_widget/components/states/mr_widget_squash_before_merge
'
;
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
mrWidgetOptions
}
from
'
ee/vue_merge_request_widget/mr_widget_options
'
;
app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
View file @
6abbe64d
...
@@ -33,6 +33,7 @@ import {
...
@@ -33,6 +33,7 @@ import {
stateMaps
,
stateMaps
,
SquashBeforeMerge
,
SquashBeforeMerge
,
notify
,
notify
,
SourceBranchRemovalStatus
,
}
from
'
./dependencies
'
;
}
from
'
./dependencies
'
;
import
{
setFavicon
}
from
'
../lib/utils/common_utils
'
;
import
{
setFavicon
}
from
'
../lib/utils/common_utils
'
;
...
@@ -69,6 +70,9 @@ export default {
...
@@ -69,6 +70,9 @@ export default {
shouldRenderDeployments
()
{
shouldRenderDeployments
()
{
return
this
.
mr
.
deployments
.
length
;
return
this
.
mr
.
deployments
.
length
;
},
},
shouldRenderSourceBranchRemovalStatus
()
{
return
!
this
.
mr
.
canRemoveSourceBranch
&&
this
.
mr
.
shouldRemoveSourceBranch
;
},
},
},
methods
:
{
methods
:
{
createService
(
store
)
{
createService
(
store
)
{
...
@@ -235,6 +239,7 @@ export default {
...
@@ -235,6 +239,7 @@ export default {
'
mr-widget-merge-when-pipeline-succeeds
'
:
MergeWhenPipelineSucceedsState
,
'
mr-widget-merge-when-pipeline-succeeds
'
:
MergeWhenPipelineSucceedsState
,
'
mr-widget-auto-merge-failed
'
:
AutoMergeFailed
,
'
mr-widget-auto-merge-failed
'
:
AutoMergeFailed
,
'
mr-widget-rebase
'
:
RebaseState
,
'
mr-widget-rebase
'
:
RebaseState
,
SourceBranchRemovalStatus
,
},
},
template
:
`
template
:
`
<div class="mr-state-widget prepend-top-default">
<div class="mr-state-widget prepend-top-default">
...
@@ -260,6 +265,9 @@ export default {
...
@@ -260,6 +265,9 @@ export default {
v-if="shouldRenderRelatedLinks"
v-if="shouldRenderRelatedLinks"
:state="mr.state"
:state="mr.state"
:related-links="mr.relatedLinks" />
:related-links="mr.relatedLinks" />
<source-branch-removal-status
v-if="shouldRenderSourceBranchRemovalStatus"
/>
</div>
</div>
<div
<div
class="mr-widget-footer"
class="mr-widget-footer"
...
...
changelogs/unreleased/merge-request-widget-source-branch-improvements.yml
0 → 100644
View file @
6abbe64d
---
title
:
Fixes remove source branch checkbox being visible when user cannot remove the
branch
merge_request
:
author
:
type
:
changed
ee/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
View file @
6abbe64d
...
@@ -373,12 +373,15 @@ export default {
...
@@ -373,12 +373,15 @@ export default {
:is="componentName"
:is="componentName"
:mr="mr"
:mr="mr"
:service="service" />
:service="service" />
<mr-widget-maintainer-edit
:maintainerEditAllowed="mr.maintainerEditAllowed" />
<mr-widget-related-links
<mr-widget-related-links
v-if="shouldRenderRelatedLinks"
v-if="shouldRenderRelatedLinks"
:related-links="mr.relatedLinks"
:state="mr.state"
:related-links="mr.relatedLinks" />
<source-branch-removal-status
v-if="shouldRenderSourceBranchRemovalStatus"
/>
/>
<mr-widget-maintainer-edit
:maintainerEditAllowed="mr.maintainerEditAllowed" />
</div>
</div>
<div class="mr-widget-footer" v-if="shouldRenderMergeHelp">
<div class="mr-widget-footer" v-if="shouldRenderMergeHelp">
<mr-widget-merge-help />
<mr-widget-merge-help />
...
...
spec/features/merge_request/user_sees_merge_widget_spec.rb
View file @
6abbe64d
require
'rails_helper'
require
'rails_helper'
describe
'Merge request > User sees merge widget'
,
:js
do
describe
'Merge request > User sees merge widget'
,
:js
do
include
ProjectForksHelper
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project_only_mwps
)
{
create
(
:project
,
:repository
,
only_allow_merge_if_pipeline_succeeds:
true
)
}
let
(
:project_only_mwps
)
{
create
(
:project
,
:repository
,
only_allow_merge_if_pipeline_succeeds:
true
)
}
let
(
:user
)
{
project
.
creator
}
let
(
:user
)
{
project
.
creator
}
...
@@ -285,7 +287,29 @@ describe 'Merge request > User sees merge widget', :js do
...
@@ -285,7 +287,29 @@ describe 'Merge request > User sees merge widget', :js do
end
end
it
'user cannot remove source branch'
do
it
'user cannot remove source branch'
do
expect
(
page
).
to
have_field
(
'remove-source-branch-input'
,
disabled:
true
)
expect
(
page
).
not_to
have_field
(
'remove-source-branch-input'
)
end
end
context
'user cannot merge project and cannot push to fork'
,
:js
do
let
(
:forked_project
)
{
fork_project
(
project
,
nil
,
repository:
true
)
}
let
(
:user2
)
{
create
(
:user
)
}
before
do
project
.
add_developer
(
user2
)
sign_out
(
:user
)
sign_in
(
user2
)
merge_request
.
update
(
source_project:
forked_project
,
target_project:
project
,
merge_params:
{
'force_remove_source_branch'
=>
'1'
}
)
visit
project_merge_request_path
(
project
,
merge_request
)
end
it
'user cannot remove source branch'
do
expect
(
page
).
not_to
have_field
(
'remove-source-branch-input'
)
expect
(
page
).
to
have_content
(
'Removes source branch'
)
end
end
end
end
...
...
spec/javascripts/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js
View file @
6abbe64d
...
@@ -517,13 +517,9 @@ describe('MRWidgetReadyToMerge', () => {
...
@@ -517,13 +517,9 @@ describe('MRWidgetReadyToMerge', () => {
describe
(
'
Remove source branch checkbox
'
,
()
=>
{
describe
(
'
Remove source branch checkbox
'
,
()
=>
{
describe
(
'
when user can merge but cannot delete branch
'
,
()
=>
{
describe
(
'
when user can merge but cannot delete branch
'
,
()
=>
{
it
(
'
isRemoveSourceBranchButtonDisabled should be true
'
,
()
=>
{
expect
(
vm
.
isRemoveSourceBranchButtonDisabled
).
toBe
(
true
);
});
it
(
'
should be disabled in the rendered output
'
,
()
=>
{
it
(
'
should be disabled in the rendered output
'
,
()
=>
{
const
checkboxElement
=
vm
.
$el
.
querySelector
(
'
#remove-source-branch-input
'
);
const
checkboxElement
=
vm
.
$el
.
querySelector
(
'
#remove-source-branch-input
'
);
expect
(
checkboxElement
.
getAttribute
(
'
disabled
'
)).
toBe
(
'
disabled
'
);
expect
(
checkboxElement
).
toBeNull
(
);
});
});
});
});
...
@@ -540,7 +536,7 @@ describe('MRWidgetReadyToMerge', () => {
...
@@ -540,7 +536,7 @@ describe('MRWidgetReadyToMerge', () => {
it
(
'
should be enabled in rendered output
'
,
()
=>
{
it
(
'
should be enabled in rendered output
'
,
()
=>
{
const
checkboxElement
=
this
.
customVm
.
$el
.
querySelector
(
'
#remove-source-branch-input
'
);
const
checkboxElement
=
this
.
customVm
.
$el
.
querySelector
(
'
#remove-source-branch-input
'
);
expect
(
checkboxElement
.
getAttribute
(
'
disabled
'
))
.
toBeNull
();
expect
(
checkboxElement
).
not
.
toBeNull
();
});
});
});
});
});
});
...
@@ -549,12 +545,12 @@ describe('MRWidgetReadyToMerge', () => {
...
@@ -549,12 +545,12 @@ describe('MRWidgetReadyToMerge', () => {
describe
(
'
when allowed to merge
'
,
()
=>
{
describe
(
'
when allowed to merge
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
vm
=
createComponent
({
vm
=
createComponent
({
mr
:
{
isMergeAllowed
:
true
},
mr
:
{
isMergeAllowed
:
true
,
canRemoveSourceBranch
:
true
},
});
});
});
});
it
(
'
shows remove source branch checkbox
'
,
()
=>
{
it
(
'
shows remove source branch checkbox
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-remove-source-branch-checkbox
'
)).
toBeDefined
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-remove-source-branch-checkbox
'
)).
not
.
toBeNull
();
});
});
it
(
'
shows modify commit message button
'
,
()
=>
{
it
(
'
shows modify commit message button
'
,
()
=>
{
...
...
spec/javascripts/vue_mr_widget/ee_mr_widget_options_spec.js
View file @
6abbe64d
...
@@ -781,4 +781,22 @@ describe('ee merge request widget options', () => {
...
@@ -781,4 +781,22 @@ describe('ee merge request widget options', () => {
});
});
});
});
});
});
describe
(
'
rendering source branch removal status
'
,
()
=>
{
it
(
'
renders when user cannot remove branch and branch should be removed
'
,
(
done
)
=>
{
vm
.
mr
.
canRemoveSourceBranch
=
false
;
vm
.
mr
.
shouldRemoveSourceBranch
=
true
;
vm
.
$nextTick
(()
=>
{
const
tooltip
=
vm
.
$el
.
querySelector
(
'
.fa-question-circle
'
);
expect
(
vm
.
$el
.
textContent
).
toContain
(
'
Removes source branch
'
);
expect
(
tooltip
.
getAttribute
(
'
data-original-title
'
)).
toBe
(
'
A user with write access to the source branch selected this option
'
,
);
done
();
});
});
});
});
});
spec/javascripts/vue_mr_widget/mr_widget_options_spec.js
View file @
6abbe64d
...
@@ -81,6 +81,29 @@ describe('mrWidgetOptions', () => {
...
@@ -81,6 +81,29 @@ describe('mrWidgetOptions', () => {
});
});
});
});
describe
(
'
shouldRenderSourceBranchRemovalStatus
'
,
()
=>
{
it
(
'
should return true when cannot remove source branch and branch will be removed
'
,
()
=>
{
vm
.
mr
.
canRemoveSourceBranch
=
false
;
vm
.
mr
.
shouldRemoveSourceBranch
=
true
;
expect
(
vm
.
shouldRenderSourceBranchRemovalStatus
).
toBeTruthy
();
});
it
(
'
should return false when can remove source branch and branch will be removed
'
,
()
=>
{
vm
.
mr
.
canRemoveSourceBranch
=
true
;
vm
.
mr
.
shouldRemoveSourceBranch
=
true
;
expect
(
vm
.
shouldRenderSourceBranchRemovalStatus
).
toBeFalsy
();
});
it
(
'
should return false when cannot remove source branch and branch will not be removed
'
,
()
=>
{
vm
.
mr
.
canRemoveSourceBranch
=
false
;
vm
.
mr
.
shouldRemoveSourceBranch
=
false
;
expect
(
vm
.
shouldRenderSourceBranchRemovalStatus
).
toBeFalsy
();
});
});
describe
(
'
shouldRenderDeployments
'
,
()
=>
{
describe
(
'
shouldRenderDeployments
'
,
()
=>
{
it
(
'
should return false for the initial data
'
,
()
=>
{
it
(
'
should return false for the initial data
'
,
()
=>
{
expect
(
vm
.
shouldRenderDeployments
).
toBeFalsy
();
expect
(
vm
.
shouldRenderDeployments
).
toBeFalsy
();
...
@@ -379,4 +402,22 @@ describe('mrWidgetOptions', () => {
...
@@ -379,4 +402,22 @@ describe('mrWidgetOptions', () => {
});
});
});
});
});
});
describe
(
'
rendering source branch removal status
'
,
()
=>
{
it
(
'
renders when user cannot remove branch and branch should be removed
'
,
(
done
)
=>
{
vm
.
mr
.
canRemoveSourceBranch
=
false
;
vm
.
mr
.
shouldRemoveSourceBranch
=
true
;
vm
.
$nextTick
(()
=>
{
const
tooltip
=
vm
.
$el
.
querySelector
(
'
.fa-question-circle
'
);
expect
(
vm
.
$el
.
textContent
).
toContain
(
'
Removes source branch
'
);
expect
(
tooltip
.
getAttribute
(
'
data-original-title
'
)).
toBe
(
'
A user with write access to the source branch selected this option
'
,
);
done
();
});
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment