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
897a37b8
Commit
897a37b8
authored
Oct 23, 2019
by
Winnie Hellmann
Committed by
Kushal Pandya
Oct 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use EpicActionsSplitButton in RelatedItemsTreeHeader
parent
8a6d7e6b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
137 additions
and
66 deletions
+137
-66
ee/app/assets/javascripts/related_items_tree/components/epic_actions_split_button.vue
...lated_items_tree/components/epic_actions_split_button.vue
+37
-0
ee/app/assets/javascripts/related_items_tree/components/related_items_tree_header.vue
...lated_items_tree/components/related_items_tree_header.vue
+22
-21
ee/app/assets/javascripts/related_items_tree/constants.js
ee/app/assets/javascripts/related_items_tree/constants.js
+0
-16
ee/app/assets/stylesheets/components/related_items_tree.scss
ee/app/assets/stylesheets/components/related_items_tree.scss
+0
-9
ee/spec/javascripts/related_items_tree/components/related_items_tree_header_spec.js
...d_items_tree/components/related_items_tree_header_spec.js
+78
-20
No files found.
ee/app/assets/javascripts/related_items_tree/components/epic_actions_split_button.vue
0 → 100644
View file @
897a37b8
<
script
>
import
SplitButton
from
'
~/vue_shared/components/split_button.vue
'
;
import
{
s__
}
from
'
~/locale
'
;
const
actionItems
=
[
{
title
:
s__
(
'
Epics|Add an epic
'
),
description
:
s__
(
'
Epics|Add an existing epic as a child epic.
'
),
eventName
:
'
showAddEpicForm
'
,
},
{
title
:
s__
(
'
Epics|Create new epic
'
),
description
:
s__
(
'
Epics|Create an epic within this group and add it as a child epic.
'
),
eventName
:
'
showCreateEpicForm
'
,
},
];
export
default
{
actionItems
,
components
:
{
SplitButton
,
},
};
</
script
>
<
template
>
<split-button
:action-items=
"$options.actionItems"
class=
"js-add-epics-button"
menu-class=
"dropdown-menu-large"
right
size=
"sm"
v-on=
"$listeners"
/>
</
template
>
ee/app/assets/javascripts/related_items_tree/components/related_items_tree_header.vue
View file @
897a37b8
...
@@ -6,16 +6,15 @@ import { GlButton, GlTooltipDirective } from '@gitlab/ui';
...
@@ -6,16 +6,15 @@ import { GlButton, GlTooltipDirective } from '@gitlab/ui';
import
{
sprintf
,
s__
}
from
'
~/locale
'
;
import
{
sprintf
,
s__
}
from
'
~/locale
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
DroplabDropdownButton
from
'
~/vue_shared/components/droplab_dropdown_button.vue
'
;
import
{
issuableTypesMap
}
from
'
ee/related_issues/constants
'
;
import
{
EpicDropdownActions
}
from
'
../constants
'
;
import
EpicActionsSplitButton
from
'
./epic_actions_split_button.vue
'
;
export
default
{
export
default
{
EpicDropdownActions
,
components
:
{
components
:
{
Icon
,
Icon
,
GlButton
,
GlButton
,
DroplabDropdown
Button
,
EpicActionsSplit
Button
,
},
},
directives
:
{
directives
:
{
GlTooltip
:
GlTooltipDirective
,
GlTooltip
:
GlTooltipDirective
,
...
@@ -32,15 +31,20 @@ export default {
...
@@ -32,15 +31,20 @@ export default {
},
},
methods
:
{
methods
:
{
...
mapActions
([
'
toggleAddItemForm
'
,
'
toggleCreateEpicForm
'
]),
...
mapActions
([
'
toggleAddItemForm
'
,
'
toggleCreateEpicForm
'
]),
handleActionClick
({
id
,
issuableType
})
{
showAddEpicForm
()
{
if
(
id
===
0
)
{
this
.
toggleAddItemForm
({
this
.
toggleAddItemForm
({
issuableType
:
issuableTypesMap
.
EPIC
,
issuableType
,
toggleState
:
true
,
toggleState
:
true
,
});
});
},
}
else
{
showAddIssueForm
()
{
this
.
toggleCreateEpicForm
({
toggleState
:
true
});
this
.
toggleAddItemForm
({
}
issuableType
:
issuableTypesMap
.
ISSUE
,
toggleState
:
true
,
});
},
showCreateEpicForm
()
{
this
.
toggleCreateEpicForm
({
toggleState
:
true
});
},
},
},
},
};
};
...
@@ -67,13 +71,10 @@ export default {
...
@@ -67,13 +71,10 @@ export default {
</div>
</div>
<div
class=
"d-inline-flex"
>
<div
class=
"d-inline-flex"
>
<template
v-if=
"parentItem.userPermissions.adminEpic"
>
<template
v-if=
"parentItem.userPermissions.adminEpic"
>
<droplab-dropdown-button
<epic-actions-split-button
:actions=
"$options.EpicDropdownActions"
:class=
"headerItems[0].qaClass"
:default-action=
"0"
@
showAddEpicForm=
"showAddEpicForm"
:primary-button-class=
"`$
{headerItems[0].qaClass} js-add-epics-button`"
@
showCreateEpicForm=
"showCreateEpicForm"
class="btn-create-epic"
size="sm"
@onActionClick="handleActionClick"
/>
/>
<slot
name=
"issueActions"
>
<slot
name=
"issueActions"
>
...
@@ -81,7 +82,7 @@ export default {
...
@@ -81,7 +82,7 @@ export default {
:class=
"headerItems[1].qaClass"
:class=
"headerItems[1].qaClass"
class=
"ml-1 js-add-issues-button"
class=
"ml-1 js-add-issues-button"
size=
"sm"
size=
"sm"
@
click=
"
handleActionClick(
{ id: 0, issuableType: 'issue' })
"
@
click=
"
showAddIssueForm
"
>
{{
__
(
'
Add an issue
'
)
}}
</gl-button
>
{{
__
(
'
Add an issue
'
)
}}
</gl-button
>
>
</slot>
</slot>
...
...
ee/app/assets/javascripts/related_items_tree/constants.js
View file @
897a37b8
import
{
s__
}
from
'
~/locale
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
issuableTypesMap
}
from
'
ee/related_issues/constants
'
;
export
const
ChildType
=
{
export
const
ChildType
=
{
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
...
@@ -43,21 +42,6 @@ export const RemoveItemModalProps = {
...
@@ -43,21 +42,6 @@ export const RemoveItemModalProps = {
},
},
};
};
export
const
EpicDropdownActions
=
[
{
id
:
0
,
issuableType
:
issuableTypesMap
.
EPIC
,
title
:
s__
(
'
Epics|Add an epic
'
),
description
:
s__
(
'
Epics|Add an existing epic as a child epic.
'
),
},
{
id
:
1
,
issuableType
:
issuableTypesMap
.
EPIC
,
title
:
s__
(
'
Epics|Create new epic
'
),
description
:
s__
(
'
Epics|Create an epic within this group and add it as a child epic.
'
),
},
];
export
const
OVERFLOW_AFTER
=
5
;
export
const
OVERFLOW_AFTER
=
5
;
export
const
itemRemoveModalId
=
'
item-remove-confirmation
'
;
export
const
itemRemoveModalId
=
'
item-remove-confirmation
'
;
ee/app/assets/stylesheets/components/related_items_tree.scss
View file @
897a37b8
...
@@ -2,15 +2,6 @@
...
@@ -2,15 +2,6 @@
border-top-left-radius
:
0
;
border-top-left-radius
:
0
;
border-top-right-radius
:
0
;
border-top-right-radius
:
0
;
.btn-create-epic
{
.dropdown-menu
{
top
:
100%
;
right
:
0
;
bottom
:
auto
;
left
:
auto
;
}
}
.add-item-form-container
{
.add-item-form-container
{
border-bottom
:
1px
solid
$border-color
;
border-bottom
:
1px
solid
$border-color
;
}
}
...
...
ee/spec/javascripts/related_items_tree/components/related_items_tree_header_spec.js
View file @
897a37b8
...
@@ -3,10 +3,10 @@ import { GlButton } from '@gitlab/ui';
...
@@ -3,10 +3,10 @@ import { GlButton } from '@gitlab/ui';
import
RelatedItemsTreeHeader
from
'
ee/related_items_tree/components/related_items_tree_header.vue
'
;
import
RelatedItemsTreeHeader
from
'
ee/related_items_tree/components/related_items_tree_header.vue
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
DroplabDropdownButton
from
'
~/vue_shared/components/droplab_dropdown_button.vue
'
;
import
createDefaultStore
from
'
ee/related_items_tree/store
'
;
import
createDefaultStore
from
'
ee/related_items_tree/store
'
;
import
*
as
epicUtils
from
'
ee/related_items_tree/utils/epic_utils
'
;
import
*
as
epicUtils
from
'
ee/related_items_tree/utils/epic_utils
'
;
import
{
issuableTypesMap
}
from
'
ee/related_issues/constants
'
;
import
{
issuableTypesMap
}
from
'
ee/related_issues/constants
'
;
import
EpicActionsSplitButton
from
'
ee/related_items_tree/components/epic_actions_split_button.vue
'
;
import
{
mockParentItem
,
mockQueryResponse
}
from
'
../mock_data
'
;
import
{
mockParentItem
,
mockQueryResponse
}
from
'
../mock_data
'
;
...
@@ -37,6 +37,9 @@ describe('RelatedItemsTree', () => {
...
@@ -37,6 +37,9 @@ describe('RelatedItemsTree', () => {
describe
(
'
RelatedItemsTreeHeader
'
,
()
=>
{
describe
(
'
RelatedItemsTreeHeader
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
const
findAddIssuesButton
=
()
=>
wrapper
.
find
(
GlButton
);
const
findEpicsSplitButton
=
()
=>
wrapper
.
find
(
EpicActionsSplitButton
);
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
...
@@ -53,34 +56,89 @@ describe('RelatedItemsTree', () => {
...
@@ -53,34 +56,89 @@ describe('RelatedItemsTree', () => {
});
});
});
});
describe
(
'
methods
'
,
()
=>
{
describe
(
'
epic actions split button
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
wrapper
=
createComponent
();
wrapper
=
createComponent
();
});
});
describe
(
'
handleActionClick
'
,
()
=>
{
describe
(
'
showAddEpicForm event
'
,
()
=>
{
const
issuableType
=
issuableTypesMap
.
Epic
;
let
toggleAddItemForm
;
it
(
'
calls `toggleAddItemForm` action when provided `id` param as value `0`
'
,
()
=>
{
spyOn
(
wrapper
.
vm
,
'
toggleAddItemForm
'
);
wrapper
.
vm
.
handleActionClick
({
beforeEach
(()
=>
{
id
:
0
,
toggleAddItemForm
=
jasmine
.
createSpy
();
issuableType
,
wrapper
.
vm
.
$store
.
hotUpdate
({
actions
:
{
toggleAddItemForm
,
},
});
});
});
expect
(
wrapper
.
vm
.
toggleAddItemForm
).
toHaveBeenCalledWith
({
it
(
'
dispatches toggleAddItemForm action
'
,
()
=>
{
issuableType
,
findEpicsSplitButton
().
vm
.
$emit
(
'
showAddEpicForm
'
);
expect
(
toggleAddItemForm
).
toHaveBeenCalled
();
const
payload
=
toggleAddItemForm
.
calls
.
mostRecent
().
args
[
1
];
expect
(
payload
).
toEqual
({
issuableType
:
issuableTypesMap
.
EPIC
,
toggleState
:
true
,
toggleState
:
true
,
});
});
});
});
});
describe
(
'
showCreateEpicForm event
'
,
()
=>
{
let
toggleCreateEpicForm
;
beforeEach
(()
=>
{
toggleCreateEpicForm
=
jasmine
.
createSpy
();
wrapper
.
vm
.
$store
.
hotUpdate
({
actions
:
{
toggleCreateEpicForm
,
},
});
});
it
(
'
dispatches toggleCreateEpicForm action
'
,
()
=>
{
findEpicsSplitButton
().
vm
.
$emit
(
'
showCreateEpicForm
'
);
expect
(
toggleCreateEpicForm
).
toHaveBeenCalled
();
const
payload
=
toggleCreateEpicForm
.
calls
.
mostRecent
().
args
[
1
];
expect
(
payload
).
toEqual
({
toggleState
:
true
});
});
});
});
describe
(
'
add issues button
'
,
()
=>
{
beforeEach
(()
=>
{
wrapper
=
createComponent
();
});
describe
(
'
click event
'
,
()
=>
{
let
toggleAddItemForm
;
beforeEach
(()
=>
{
toggleAddItemForm
=
jasmine
.
createSpy
();
wrapper
.
vm
.
$store
.
hotUpdate
({
actions
:
{
toggleAddItemForm
,
},
});
});
it
(
'
dispatches toggleAddItemForm action
'
,
()
=>
{
findAddIssuesButton
().
vm
.
$emit
(
'
click
'
);
it
(
'
calls `toggleCreateEpicForm` action when provided `id` param value is not `0`
'
,
()
=>
{
expect
(
toggleAddItemForm
).
toHaveBeenCalled
();
spyOn
(
wrapper
.
vm
,
'
toggleCreateEpicForm
'
);
wrapper
.
vm
.
handleActionClick
({
id
:
1
})
;
const
payload
=
toggleAddItemForm
.
calls
.
mostRecent
().
args
[
1
]
;
expect
(
wrapper
.
vm
.
toggleCreateEpicForm
).
toHaveBeenCalledWith
({
toggleState
:
true
});
expect
(
payload
).
toEqual
({
issuableType
:
issuableTypesMap
.
ISSUE
,
toggleState
:
true
,
});
});
});
});
});
});
});
...
@@ -115,11 +173,11 @@ describe('RelatedItemsTree', () => {
...
@@ -115,11 +173,11 @@ describe('RelatedItemsTree', () => {
});
});
it
(
'
renders `Add an epic` dropdown button
'
,
()
=>
{
it
(
'
renders `Add an epic` dropdown button
'
,
()
=>
{
expect
(
wrapper
.
find
(
DroplabDropdownButton
).
isVisible
()).
toBe
(
true
);
expect
(
findEpicsSplitButton
(
).
isVisible
()).
toBe
(
true
);
});
});
it
(
'
renders `Add an issue` dropdown button
'
,
()
=>
{
it
(
'
renders `Add an issue` dropdown button
'
,
()
=>
{
const
addIssueBtn
=
wrapper
.
find
(
GlButton
);
const
addIssueBtn
=
findAddIssuesButton
(
);
expect
(
addIssueBtn
.
isVisible
()).
toBe
(
true
);
expect
(
addIssueBtn
.
isVisible
()).
toBe
(
true
);
expect
(
addIssueBtn
.
text
()).
toBe
(
'
Add an issue
'
);
expect
(
addIssueBtn
.
text
()).
toBe
(
'
Add an issue
'
);
...
@@ -131,7 +189,7 @@ describe('RelatedItemsTree', () => {
...
@@ -131,7 +189,7 @@ describe('RelatedItemsTree', () => {
it
(
'
defaults to button
'
,
()
=>
{
it
(
'
defaults to button
'
,
()
=>
{
wrapper
=
createComponent
();
wrapper
=
createComponent
();
expect
(
wrapper
.
find
(
GlButton
).
exists
()).
toBe
(
true
);
expect
(
findAddIssuesButton
(
).
exists
()).
toBe
(
true
);
});
});
it
(
'
uses provided slot content
'
,
()
=>
{
it
(
'
uses provided slot content
'
,
()
=>
{
...
@@ -145,7 +203,7 @@ describe('RelatedItemsTree', () => {
...
@@ -145,7 +203,7 @@ describe('RelatedItemsTree', () => {
},
},
});
});
expect
(
wrapper
.
find
(
GlButton
).
exists
()).
toBe
(
false
);
expect
(
findAddIssuesButton
(
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
issueActions
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
issueActions
).
exists
()).
toBe
(
true
);
});
});
});
});
...
...
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