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
ac242673
Commit
ac242673
authored
Sep 01, 2020
by
Thomas Randolph
Committed by
Olena Horal-Koretska
Sep 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract Merge Request Conflicts warning to component
parent
46d72293
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
160 additions
and
46 deletions
+160
-46
app/assets/javascripts/diffs/components/app.vue
app/assets/javascripts/diffs/components/app.vue
+11
-46
app/assets/javascripts/diffs/components/merge_conflict_warning.vue
...s/javascripts/diffs/components/merge_conflict_warning.vue
+72
-0
spec/frontend/diffs/components/merge_conflict_warning_spec.js
.../frontend/diffs/components/merge_conflict_warning_spec.js
+77
-0
No files found.
app/assets/javascripts/diffs/components/app.vue
View file @
ac242673
<
script
>
<
script
>
import
{
mapState
,
mapGetters
,
mapActions
}
from
'
vuex
'
;
import
{
mapState
,
mapGetters
,
mapActions
}
from
'
vuex
'
;
import
{
GlLoadingIcon
,
Gl
Button
,
GlAlert
,
Gl
Pagination
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
GlLoadingIcon
,
GlPagination
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
Mousetrap
from
'
mousetrap
'
;
import
Mousetrap
from
'
mousetrap
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
getParameterByName
,
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
import
{
getParameterByName
,
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
...
@@ -13,9 +13,12 @@ import eventHub from '../../notes/event_hub';
...
@@ -13,9 +13,12 @@ import eventHub from '../../notes/event_hub';
import
CompareVersions
from
'
./compare_versions.vue
'
;
import
CompareVersions
from
'
./compare_versions.vue
'
;
import
DiffFile
from
'
./diff_file.vue
'
;
import
DiffFile
from
'
./diff_file.vue
'
;
import
NoChanges
from
'
./no_changes.vue
'
;
import
NoChanges
from
'
./no_changes.vue
'
;
import
HiddenFilesWarning
from
'
./hidden_files_warning.vue
'
;
import
CommitWidget
from
'
./commit_widget.vue
'
;
import
CommitWidget
from
'
./commit_widget.vue
'
;
import
TreeList
from
'
./tree_list.vue
'
;
import
TreeList
from
'
./tree_list.vue
'
;
import
HiddenFilesWarning
from
'
./hidden_files_warning.vue
'
;
import
MergeConflictWarning
from
'
./merge_conflict_warning.vue
'
;
import
{
import
{
TREE_LIST_WIDTH_STORAGE_KEY
,
TREE_LIST_WIDTH_STORAGE_KEY
,
INITIAL_TREE_WIDTH
,
INITIAL_TREE_WIDTH
,
...
@@ -33,13 +36,12 @@ export default {
...
@@ -33,13 +36,12 @@ export default {
DiffFile
,
DiffFile
,
NoChanges
,
NoChanges
,
HiddenFilesWarning
,
HiddenFilesWarning
,
MergeConflictWarning
,
CommitWidget
,
CommitWidget
,
TreeList
,
TreeList
,
GlLoadingIcon
,
GlLoadingIcon
,
PanelResizer
,
PanelResizer
,
GlPagination
,
GlPagination
,
GlButton
,
GlAlert
,
GlSprintf
,
GlSprintf
,
},
},
mixins
:
[
glFeatureFlagsMixin
()],
mixins
:
[
glFeatureFlagsMixin
()],
...
@@ -422,49 +424,12 @@ export default {
...
@@ -422,49 +424,12 @@ export default {
:plain-diff-path=
"plainDiffPath"
:plain-diff-path=
"plainDiffPath"
:email-patch-path=
"emailPatchPath"
:email-patch-path=
"emailPatchPath"
/>
/>
<merge-conflict-warning
<div
v-if=
"isDiffHead && hasConflicts"
v-if=
"isDiffHead && hasConflicts"
:class=
"
{
:limited=
"isLimitedContainer"
[CENTERED_LIMITED_CONTAINER_CLASSES]: isLimitedContainer,
:resolution-path=
"conflictResolutionPath"
}"
:mergeable=
"canMerge"
>
/>
<gl-alert
:dismissible=
"false"
:title=
"__('There are merge conflicts')"
variant=
"warning"
class=
"w-100 mb-3"
>
<p
class=
"mb-1"
>
{{
__
(
'
The comparison view may be inaccurate due to merge conflicts.
'
)
}}
</p>
<p
class=
"mb-0"
>
{{
__
(
'
Resolve these conflicts or ask someone with write access to this repository to merge it locally.
'
,
)
}}
</p>
<template
#actions
>
<gl-button
v-if=
"conflictResolutionPath"
:href=
"conflictResolutionPath"
variant=
"info"
class=
"mr-3 gl-alert-action"
>
{{
__
(
'
Resolve conflicts
'
)
}}
</gl-button>
<gl-button
v-if=
"canMerge"
class=
"gl-alert-action"
data-toggle=
"modal"
data-target=
"#modal_merge_info"
>
{{
__
(
'
Merge locally
'
)
}}
</gl-button>
</
template
>
</gl-alert>
</div>
<div
<div
:data-can-create-note=
"getNoteableData.current_user.can_create_note"
:data-can-create-note=
"getNoteableData.current_user.can_create_note"
...
...
app/assets/javascripts/diffs/components/merge_conflict_warning.vue
0 → 100644
View file @
ac242673
<
script
>
import
{
GlButton
,
GlAlert
}
from
'
@gitlab/ui
'
;
import
{
CENTERED_LIMITED_CONTAINER_CLASSES
}
from
'
../constants
'
;
export
default
{
components
:
{
GlAlert
,
GlButton
,
},
props
:
{
limited
:
{
type
:
Boolean
,
required
:
true
,
},
mergeable
:
{
type
:
Boolean
,
required
:
true
,
},
resolutionPath
:
{
type
:
String
,
required
:
true
,
},
},
computed
:
{
containerClasses
()
{
return
{
[
CENTERED_LIMITED_CONTAINER_CLASSES
]:
this
.
limited
,
};
},
},
};
</
script
>
<
template
>
<div
:class=
"containerClasses"
>
<gl-alert
:dismissible=
"false"
:title=
"__('There are merge conflicts')"
variant=
"warning"
class=
"gl-mb-5"
>
<p
class=
"gl-mb-2"
>
{{
__
(
'
The comparison view may be inaccurate due to merge conflicts.
'
)
}}
</p>
<p
class=
"gl-mb-0"
>
{{
__
(
'
Resolve these conflicts or ask someone with write access to this repository to merge it locally.
'
,
)
}}
</p>
<template
#actions
>
<gl-button
v-if=
"resolutionPath"
:href=
"resolutionPath"
variant=
"info"
class=
"gl-mr-5 gl-alert-action"
>
{{
__
(
'
Resolve conflicts
'
)
}}
</gl-button>
<gl-button
v-if=
"mergeable"
class=
"gl-alert-action"
data-toggle=
"modal"
data-target=
"#modal_merge_info"
>
{{
__
(
'
Merge locally
'
)
}}
</gl-button>
</
template
>
</gl-alert>
</div>
</template>
spec/frontend/diffs/components/merge_conflict_warning_spec.js
0 → 100644
View file @
ac242673
import
{
shallowMount
,
mount
}
from
'
@vue/test-utils
'
;
import
MergeConflictWarning
from
'
~/diffs/components/merge_conflict_warning.vue
'
;
import
{
CENTERED_LIMITED_CONTAINER_CLASSES
}
from
'
~/diffs/constants
'
;
const
propsData
=
{
limited
:
true
,
mergeable
:
true
,
resolutionPath
:
'
a-path
'
,
};
const
limitedClasses
=
CENTERED_LIMITED_CONTAINER_CLASSES
.
split
(
'
'
);
function
findResolveButton
(
wrapper
)
{
return
wrapper
.
find
(
'
.gl-alert-actions a.gl-button:first-child
'
);
}
function
findLocalMergeButton
(
wrapper
)
{
return
wrapper
.
find
(
'
.gl-alert-actions button.gl-button:last-child
'
);
}
describe
(
'
MergeConflictWarning
'
,
()
=>
{
let
wrapper
;
const
createComponent
=
(
props
=
{},
{
full
}
=
{
full
:
false
})
=>
{
const
mounter
=
full
?
mount
:
shallowMount
;
wrapper
=
mounter
(
MergeConflictWarning
,
{
propsData
:
{
...
propsData
,
...
props
},
});
};
afterEach
(()
=>
{
wrapper
.
destroy
();
});
it
.
each
`
limited | containerClasses
${
true
}
|
${
limitedClasses
}
${
false
}
|
${[]}
`
(
'
has the correct container classes when limited is $limited
'
,
({
limited
,
containerClasses
})
=>
{
createComponent
({
limited
});
expect
(
wrapper
.
classes
()).
toEqual
(
containerClasses
);
},
);
it
.
each
`
present | resolutionPath
${
false
}
|
${
''
}
${
true
}
|
${
'
some-path
'
}
`
(
'
toggles the resolve conflicts button based on the provided resolutionPath "$resolutionPath"
'
,
({
present
,
resolutionPath
})
=>
{
createComponent
({
resolutionPath
},
{
full
:
true
});
const
resolveButton
=
findResolveButton
(
wrapper
);
expect
(
resolveButton
.
exists
()).
toBe
(
present
);
if
(
present
)
{
expect
(
resolveButton
.
attributes
(
'
href
'
)).
toBe
(
resolutionPath
);
}
},
);
it
.
each
`
present | mergeable
${
false
}
|
${
false
}
${
true
}
|
${
true
}
`
(
'
toggles the local merge button based on the provided mergeable property "$mergable"
'
,
({
present
,
mergeable
})
=>
{
createComponent
({
mergeable
},
{
full
:
true
});
const
localMerge
=
findLocalMergeButton
(
wrapper
);
expect
(
localMerge
.
exists
()).
toBe
(
present
);
},
);
});
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