BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
3d89a03e
Unverified
Commit
3d89a03e
authored
Feb 01, 2018
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moves widget header into a vue file
parent
1533cf10
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
53 deletions
+93
-53
mr_widget_header.vue
.../vue_merge_request_widget/components/mr_widget_header.vue
+67
-45
mr_widget_merge_help.vue
..._merge_request_widget/components/mr_widget_merge_help.vue
+2
-2
dependencies.js
...sets/javascripts/vue_merge_request_widget/dependencies.js
+1
-1
mr_widget_header_spec.js
...scripts/vue_mr_widget/components/mr_widget_header_spec.js
+0
-0
mr_widget_merge_help_spec.js
...pts/vue_mr_widget/components/mr_widget_merge_help_spec.js
+23
-5
No files found.
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.
js
→
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.
vue
View file @
3d89a03e
import
tooltip
from
'../../vue_shared/directives/tooltip'
;
<
script
>
import
{
pluralize
}
from
'../../lib/utils/text_utility'
;
import
tooltip
from
'~/vue_shared/directives/tooltip'
;
import
icon
from
'../../vue_shared/components/icon.vue'
;
import
{
n__
}
from
'~/locale'
;
import
icon
from
'~/vue_shared/components/icon.vue'
;
import
clipboardButton
from
'~/vue_shared/components/clipboard_button.vue'
;
export
default
{
export
default
{
name
:
'MRWidgetHeader'
,
name
:
'MRWidgetHeader'
,
props
:
{
mr
:
{
type
:
Object
,
required
:
true
},
},
directives
:
{
directives
:
{
tooltip
,
tooltip
,
},
},
components
:
{
components
:
{
icon
,
icon
,
clipboardButton
,
},
props
:
{
mr
:
{
type
:
Object
,
required
:
true
,
},
},
},
computed
:
{
computed
:
{
shouldShowCommitsBehindText
()
{
shouldShowCommitsBehindText
()
{
return
this
.
mr
.
divergedCommitsCount
>
0
;
return
this
.
mr
.
divergedCommitsCount
>
0
;
},
},
commitsText
()
{
commitsText
()
{
return
pluralize
(
'commit
'
,
this
.
mr
.
divergedCommitsCount
);
return
n__
(
'commit behind'
,
'commits behind
'
,
this
.
mr
.
divergedCommitsCount
);
},
},
branchNameClipboardData
()
{
branchNameClipboardData
()
{
// This supports code in app/assets/javascripts/copy_to_clipboard.js that
// This supports code in app/assets/javascripts/copy_to_clipboard.js that
...
@@ -35,83 +41,99 @@ export default {
...
@@ -35,83 +41,99 @@ export default {
return
branchTitle
.
length
>
32
;
return
branchTitle
.
length
>
32
;
},
},
},
},
template
:
`
};
</
script
>
<
template
>
<div
class=
"mr-source-target"
>
<div
class=
"mr-source-target"
>
<div
class=
"normal"
>
<div
class=
"normal"
>
<strong>
<strong>
Request to merge
{{
s__
(
"mrWidget|Request to merge"
)
}}
<span
<span
class="label
-branch"
class=
"label-branch js-source
-branch"
:class="{'label-truncated': isBranchTitleLong(mr.sourceBranch)
}"
:class=
"
{ 'label-truncated': isBranchTitleLong(mr.sourceBranch)
}"
:title="isBranchTitleLong(mr.sourceBranch) ? mr.sourceBranch : ''"
:title="isBranchTitleLong(mr.sourceBranch) ? mr.sourceBranch : ''"
data-placement="bottom"
data-placement="bottom"
:v-tooltip="isBranchTitleLong(mr.sourceBranch)"
:v-tooltip="isBranchTitleLong(mr.sourceBranch)"
v-html="mr.sourceBranchLink"></span>
v-html="mr.sourceBranchLink"
<button
>
v-tooltip
</span>
class="btn btn-transparent btn-clipboard"
data-title="Copy branch name to clipboard"
<clipboardButton
:data-clipboard-text="branchNameClipboardData">
:text=
"branchNameClipboardData"
<i
:title=
"__('Copy branch name to clipboard')"
aria-hidden="true"
/>
class="fa fa-clipboard"></i>
</button>
{{
s__
(
"mrWidget|into"
)
}}
into
<span
<span
class=
"label-branch"
class=
"label-branch"
:v-tooltip=
"isBranchTitleLong(mr.sourceBranch)"
:v-tooltip=
"isBranchTitleLong(mr.sourceBranch)"
:class="{'label-truncatedtooltip': isBranchTitleLong(mr.targetBranch)
}"
:class=
"
{ 'label-truncatedtooltip': isBranchTitleLong(mr.targetBranch)
}"
:title="isBranchTitleLong(mr.targetBranch) ? mr.targetBranch : ''"
:title="isBranchTitleLong(mr.targetBranch) ? mr.targetBranch : ''"
data-placement="bottom">
data-placement="bottom"
<a :href="mr.targetBranchTreePath">{{mr.targetBranch}}</a>
>
<a
:href=
"mr.targetBranchTreePath"
class=
"js-target-branch"
>
{{
mr
.
targetBranch
}}
</a>
</span>
</span>
</strong>
</strong>
<span
<span
v-if=
"shouldShowCommitsBehindText"
v-if=
"shouldShowCommitsBehindText"
class="diverged-commits-count">
class=
"diverged-commits-count"
(<a :href="mr.targetBranchPath">{{mr.divergedCommitsCount}} {{commitsText}} behind</a>)
>
(
<a
:href=
"mr.targetBranchPath"
>
{{
mr
.
divergedCommitsCount
}}
{{
commitsText
}}
</a>
)
</span>
</span>
</div>
</div>
<div
v-if=
"mr.isOpen"
>
<div
v-if=
"mr.isOpen"
>
<a
<button
href
="#modal_merge_info"
data-target
=
"#modal_merge_info"
data-toggle=
"modal"
data-toggle=
"modal"
:disabled=
"mr.sourceBranchRemoved"
:disabled=
"mr.sourceBranchRemoved"
class="btn btn-sm inline">
class=
"btn btn-sm inline js-check-out-branch"
Check out branch
type=
"button"
</a>
>
{{
s__
(
"mrWidget|Check out branch"
)
}}
</button>
<span
class=
"dropdown prepend-left-10"
>
<span
class=
"dropdown prepend-left-10"
>
<a
<button
type=
"button"
class=
"btn btn-sm inline dropdown-toggle"
class=
"btn btn-sm inline dropdown-toggle"
data-toggle=
"dropdown"
data-toggle=
"dropdown"
aria-label=
"Download as"
aria-label=
"Download as"
role="button">
aria-haspopup=
"true"
<icon
aria-expanded=
"false"
name="download"
>
>
</icon
>
<icon
name=
"download"
/
>
<i
<i
class=
"fa fa-caret-down"
class=
"fa fa-caret-down"
aria-hidden=
"true"
>
aria-hidden=
"true"
>
</i>
</i>
</a
>
</button
>
<ul
class=
"dropdown-menu dropdown-menu-align-right"
>
<ul
class=
"dropdown-menu dropdown-menu-align-right"
>
<li>
<li>
<a
<a
class=
"js-download-email-patches"
:href=
"mr.emailPatchesPath"
:href=
"mr.emailPatchesPath"
download>
download
Email patches
>
{{
s__
(
"mrWidget|Email patches"
)
}}
</a>
</a>
</li>
</li>
<li>
<li>
<a
<a
class=
"js-download-plain-diff"
:href=
"mr.plainDiffPath"
:href=
"mr.plainDiffPath"
download>
download
Plain diff
>
{{
s__
(
"mrWidget|Plain diff"
)
}}
</a>
</a>
</li>
</li>
</ul>
</ul>
</span>
</span>
</div>
</div>
</div>
</div>
`
,
</
template
>
};
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_merge_help.vue
View file @
3d89a03e
...
@@ -7,14 +7,14 @@
...
@@ -7,14 +7,14 @@
missingBranch
:
{
missingBranch
:
{
type
:
String
,
type
:
String
,
required
:
false
,
required
:
false
,
default
:
''
default
:
''
,
},
},
},
},
computed
:
{
computed
:
{
missingBranchInfo
()
{
missingBranchInfo
()
{
return
sprintf
(
return
sprintf
(
s__
(
'mrWidget|If the %{branch} branch exists in your local repository, you can merge this merge request manually using the'
),
s__
(
'mrWidget|If the %{branch} branch exists in your local repository, you can merge this merge request manually using the'
),
{
branch
:
this
.
missingBranch
}
{
branch
:
this
.
missingBranch
}
,
);
);
},
},
},
},
...
...
app/assets/javascripts/vue_merge_request_widget/dependencies.js
View file @
3d89a03e
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
export
{
default
as
Vue
}
from
'vue'
;
export
{
default
as
Vue
}
from
'vue'
;
export
{
default
as
SmartInterval
}
from
'~/smart_interval'
;
export
{
default
as
SmartInterval
}
from
'~/smart_interval'
;
export
{
default
as
WidgetHeader
}
from
'./components/mr_widget_header'
;
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
WidgetDeployment
}
from
'./components/mr_widget_deployment'
;
export
{
default
as
WidgetDeployment
}
from
'./components/mr_widget_deployment'
;
...
...
spec/javascripts/vue_mr_widget/components/mr_widget_header_spec.js
View file @
3d89a03e
This diff is collapsed.
Click to expand it.
spec/javascripts/vue_mr_widget/components/mr_widget_merge_help_spec.js
View file @
3d89a03e
...
@@ -2,9 +2,6 @@ import Vue from 'vue';
...
@@ -2,9 +2,6 @@ import Vue from 'vue';
import
mergeHelpComponent
from
'~/vue_merge_request_widget/components/mr_widget_merge_help.vue'
;
import
mergeHelpComponent
from
'~/vue_merge_request_widget/components/mr_widget_merge_help.vue'
;
import
mountComponent
from
'../../helpers/vue_mount_component_helper'
;
import
mountComponent
from
'../../helpers/vue_mount_component_helper'
;
const
text
=
`If the
${
props
.
missingBranch
}
branch exists in your local repository`
;
describe
(
'MRWidgetMergeHelp'
,
()
=>
{
describe
(
'MRWidgetMergeHelp'
,
()
=>
{
let
vm
;
let
vm
;
let
Component
;
let
Component
;
...
@@ -17,7 +14,7 @@ describe('MRWidgetMergeHelp', () => {
...
@@ -17,7 +14,7 @@ describe('MRWidgetMergeHelp', () => {
vm
.
$destroy
();
vm
.
$destroy
();
});
});
f
describe
(
'with missing branch'
,
()
=>
{
describe
(
'with missing branch'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
vm
=
mountComponent
(
Component
,
{
vm
=
mountComponent
(
Component
,
{
missingBranch
:
'this-is-not-the-branch-you-are-looking-for'
,
missingBranch
:
'this-is-not-the-branch-you-are-looking-for'
,
...
@@ -25,8 +22,16 @@ describe('MRWidgetMergeHelp', () => {
...
@@ -25,8 +22,16 @@ describe('MRWidgetMergeHelp', () => {
});
});
it
(
'renders missing branch information'
,
()
=>
{
it
(
'renders missing branch information'
,
()
=>
{
console
.
log
(
''
,
vm
.
$el
);
expect
(
vm
.
$el
.
textContent
.
trim
().
replace
(
/
[\r\n]
+/g
,
' '
).
replace
(
/
\s\s
+/g
,
' '
),
).
toEqual
(
'If the this-is-not-the-branch-you-are-looking-for branch exists in your local repository, you can merge this merge request manually using the command line'
,
);
});
it
(
'renders element to open a modal'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'a'
).
getAttribute
(
'href'
)).
toEqual
(
'#modal_merge_info'
);
expect
(
vm
.
$el
.
querySelector
(
'a'
).
getAttribute
(
'data-toggle'
)).
toEqual
(
'modal'
);
});
});
});
});
...
@@ -34,5 +39,18 @@ describe('MRWidgetMergeHelp', () => {
...
@@ -34,5 +39,18 @@ describe('MRWidgetMergeHelp', () => {
beforeEach
(()
=>
{
beforeEach
(()
=>
{
vm
=
mountComponent
(
Component
);
vm
=
mountComponent
(
Component
);
});
});
it
(
'renders information about how to merge manually'
,
()
=>
{
expect
(
vm
.
$el
.
textContent
.
trim
().
replace
(
/
[\r\n]
+/g
,
' '
).
replace
(
/
\s\s
+/g
,
' '
),
).
toEqual
(
'You can merge this merge request manually using the command line'
,
);
});
it
(
'renders element to open a modal'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'a'
).
getAttribute
(
'href'
)).
toEqual
(
'#modal_merge_info'
);
expect
(
vm
.
$el
.
querySelector
(
'a'
).
getAttribute
(
'data-toggle'
)).
toEqual
(
'modal'
);
});
});
});
});
});
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