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
06b31461
Commit
06b31461
authored
Sep 11, 2017
by
Simon Knox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve merge request widget status icon UX
x to indicate failure or cannot merge
parent
cd61d6e6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
19 deletions
+84
-19
mr_widget_ready_to_merge.js
...uest_widget/components/states/mr_widget_ready_to_merge.js
+24
-8
mr_widget_ready_to_merge_spec.js
...widget/components/states/mr_widget_ready_to_merge_spec.js
+60
-11
No files found.
app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_ready_to_merge.js
View file @
06b31461
...
...
@@ -38,24 +38,40 @@ export default {
return
this
.
useCommitMessageWithDescription
?
withoutDesc
:
withDesc
;
},
mergeButtonClass
()
{
const
defaultClass
=
'btn btn-sm btn-success accept-merge-request'
;
const
failedClass
=
`
${
defaultClass
}
btn-danger`
;
const
inActionClass
=
`
${
defaultClass
}
btn-info`
;
status
()
{
const
{
pipeline
,
isPipelineActive
,
isPipelineFailed
,
hasCI
,
ciStatus
}
=
this
.
mr
;
if
(
hasCI
&&
!
ciStatus
)
{
return
failedClass
;
return
'failed'
;
}
else
if
(
!
pipeline
)
{
return
defaultClass
;
return
'success'
;
}
else
if
(
isPipelineActive
)
{
return
inActionClass
;
return
'pending'
;
}
else
if
(
isPipelineFailed
)
{
return
'failed'
;
}
return
'success'
;
},
mergeButtonClass
()
{
const
defaultClass
=
'btn btn-sm btn-success accept-merge-request'
;
const
failedClass
=
`
${
defaultClass
}
btn-danger`
;
const
inActionClass
=
`
${
defaultClass
}
btn-info`
;
if
(
this
.
status
===
'failed'
)
{
return
failedClass
;
}
else
if
(
this
.
status
===
'pending'
)
{
return
inActionClass
;
}
return
defaultClass
;
},
iconClass
()
{
if
(
this
.
status
===
'failed'
||
!
this
.
commitMessage
.
length
||
!
this
.
isMergeAllowed
()
||
this
.
mr
.
preventMerge
)
{
return
'failed'
;
}
return
'success'
;
},
mergeButtonText
()
{
if
(
this
.
isMergingImmediately
)
{
return
'Merge in progress'
;
...
...
@@ -208,7 +224,7 @@ export default {
},
template
:
`
<div class="mr-widget-body media">
<status-icon
status="succe
ss" />
<status-icon
:status="iconCla
ss" />
<div class="media-body">
<div class="mr-widget-body-controls media space-children">
<span class="btn-group append-bottom-5">
...
...
spec/javascripts/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js
View file @
06b31461
...
...
@@ -95,35 +95,84 @@ describe('MRWidgetReadyToMerge', () => {
});
});
describe
(
'status'
,
()
=>
{
it
(
'defaults to success'
,
()
=>
{
vm
.
mr
.
pipeline
=
true
;
expect
(
vm
.
status
).
toEqual
(
'success'
);
});
it
(
'returns failed when MR has CI but also has an unknown status'
,
()
=>
{
vm
.
mr
.
hasCI
=
true
;
expect
(
vm
.
status
).
toEqual
(
'failed'
);
});
it
(
'returns default when MR has no pipeline'
,
()
=>
{
expect
(
vm
.
status
).
toEqual
(
'success'
);
});
it
(
'returns pending when pipeline is active'
,
()
=>
{
vm
.
mr
.
pipeline
=
{};
vm
.
mr
.
isPipelineActive
=
true
;
expect
(
vm
.
status
).
toEqual
(
'pending'
);
});
it
(
'returns failed when pipeline is failed'
,
()
=>
{
vm
.
mr
.
pipeline
=
{};
vm
.
mr
.
isPipelineFailed
=
true
;
expect
(
vm
.
status
).
toEqual
(
'failed'
);
});
});
describe
(
'mergeButtonClass'
,
()
=>
{
const
defaultClass
=
'btn btn-sm btn-success accept-merge-request'
;
const
failedClass
=
`
${
defaultClass
}
btn-danger`
;
const
inActionClass
=
`
${
defaultClass
}
btn-info`
;
it
(
'should return default class'
,
()
=>
{
it
(
'defaults to success class'
,
()
=>
{
expect
(
vm
.
mergeButtonClass
).
toEqual
(
defaultClass
);
});
it
(
'returns success class for success status'
,
()
=>
{
vm
.
mr
.
pipeline
=
true
;
expect
(
vm
.
mergeButtonClass
).
toEqual
(
defaultClass
);
});
it
(
'should return failed class when MR has CI but also has an unknown status'
,
()
=>
{
it
(
'returns info class for pending status'
,
()
=>
{
vm
.
mr
.
pipeline
=
{};
vm
.
mr
.
isPipelineActive
=
true
;
expect
(
vm
.
mergeButtonClass
).
toEqual
(
inActionClass
);
});
it
(
'returns failed class for failed status'
,
()
=>
{
vm
.
mr
.
hasCI
=
true
;
expect
(
vm
.
mergeButtonClass
).
toEqual
(
failedClass
);
});
});
it
(
'should return default class when MR has no pipeline'
,
()
=>
{
expect
(
vm
.
mergeButtonClass
).
toEqual
(
defaultClass
);
describe
(
'status icon'
,
()
=>
{
it
(
'defaults to tick icon'
,
()
=>
{
expect
(
vm
.
iconClass
).
toEqual
(
'success'
);
});
it
(
'should return in action class when pipeline is active'
,
()
=>
{
it
(
'shows tick for success status'
,
()
=>
{
vm
.
mr
.
pipeline
=
true
;
expect
(
vm
.
iconClass
).
toEqual
(
'success'
);
});
it
(
'shows tick for pending status'
,
()
=>
{
vm
.
mr
.
pipeline
=
{};
vm
.
mr
.
isPipelineActive
=
true
;
expect
(
vm
.
mergeButtonClass
).
toEqual
(
inActionClass
);
expect
(
vm
.
iconClass
).
toEqual
(
'success'
);
});
it
(
'should return failed class when pipeline is failed'
,
()
=>
{
vm
.
mr
.
pipeline
=
{};
vm
.
mr
.
isPipelineFailed
=
true
;
expect
(
vm
.
mergeButtonClass
).
toEqual
(
failedClass
);
it
(
'shows x for failed status'
,
()
=>
{
vm
.
mr
.
hasCI
=
true
;
expect
(
vm
.
iconClass
).
toEqual
(
'failed'
);
});
it
(
'shows x for merge not allowed'
,
()
=>
{
vm
.
mr
.
hasCI
=
true
;
expect
(
vm
.
iconClass
).
toEqual
(
'failed'
);
});
});
...
...
@@ -177,7 +226,7 @@ describe('MRWidgetReadyToMerge', () => {
expect
(
vm
.
isMergeButtonDisabled
).
toBeTruthy
();
});
it
(
'should return true when the
re
vm instance is making request'
,
()
=>
{
it
(
'should return true when the vm instance is making request'
,
()
=>
{
vm
.
isMakingRequest
=
true
;
expect
(
vm
.
isMergeButtonDisabled
).
toBeTruthy
();
});
...
...
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