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
3d10359e
Commit
3d10359e
authored
Jan 06, 2022
by
Nicolò Maria Mezzopera
Committed by
Nicolò Maria Mezzopera
Jan 10, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove menu when is not possible to delete
Remove the menu when the only action is not available Changelog: fixed
parent
8f8645a6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
42 deletions
+41
-42
app/assets/javascripts/packages_and_registries/container_registry/explorer/components/details_page/details_header.vue
...istry/explorer/components/details_page/details_header.vue
+2
-5
spec/frontend/packages_and_registries/container_registry/explorer/components/details_page/details_header_spec.js
...y/explorer/components/details_page/details_header_spec.js
+39
-37
No files found.
app/assets/javascripts/packages_and_registries/container_registry/explorer/components/details_page/details_header.vue
View file @
3d10359e
...
...
@@ -143,6 +143,7 @@ export default {
</
template
>
<
template
#right-actions
>
<gl-dropdown
v-if=
"!deleteButtonDisabled"
icon=
"ellipsis_v"
text=
"More actions"
:text-sr-only=
"true"
...
...
@@ -150,11 +151,7 @@ export default {
no-caret
right
>
<gl-dropdown-item
variant=
"danger"
:disabled=
"deleteButtonDisabled"
@
click=
"$emit('delete')"
>
<gl-dropdown-item
variant=
"danger"
@
click=
"$emit('delete')"
>
{{
__
(
'
Delete image repository
'
)
}}
</gl-dropdown-item>
</gl-dropdown>
...
...
spec/frontend/packages_and_registries/container_registry/explorer/components/details_page/details_header_spec.js
View file @
3d10359e
import
{
GlDropdownItem
,
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
GlDropdownItem
,
GlIcon
,
GlDropdown
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
{
GlDropdown
}
from
'
jest/packages_and_registries/container_registry/explorer/stubs
'
;
import
{
useFakeDate
}
from
'
helpers/fake_date
'
;
import
createMockApollo
from
'
helpers/mock_apollo_helper
'
;
import
{
createMockDirective
,
getBinding
}
from
'
helpers/vue_mock_directive
'
;
...
...
@@ -51,6 +50,7 @@ describe('Details Header', () => {
const
findCleanup
=
()
=>
findByTestId
(
'
cleanup
'
);
const
findDeleteButton
=
()
=>
wrapper
.
findComponent
(
GlDropdownItem
);
const
findInfoIcon
=
()
=>
wrapper
.
findComponent
(
GlIcon
);
const
findMenu
=
()
=>
wrapper
.
findComponent
(
GlDropdown
);
const
waitForMetadataItems
=
async
()
=>
{
// Metadata items are printed by a loop in the title-area and it takes two ticks for them to be available
...
...
@@ -139,51 +139,53 @@ describe('Details Header', () => {
});
});
describe
(
'
delete button
'
,
()
=>
{
it
(
'
exists
'
,
()
=>
{
mountComponent
();
describe
(
'
menu
'
,
()
=>
{
it
.
each
`
canDelete | disabled | isVisible
${
true
}
|
${
false
}
|
${
true
}
${
true
}
|
${
true
}
|
${
false
}
${
false
}
|
${
false
}
|
${
false
}
${
false
}
|
${
true
}
|
${
false
}
`
(
'
when canDelete is $canDelete and disabled is $disabled is $isVisible that the menu is visible
'
,
({
canDelete
,
disabled
,
isVisible
})
=>
{
mountComponent
({
propsData
:
{
image
:
{
...
defaultImage
,
canDelete
},
disabled
}
});
expect
(
findDeleteButton
().
exists
()).
toBe
(
true
);
});
expect
(
findMenu
().
exists
()).
toBe
(
isVisible
);
},
);
it
(
'
has the correct text
'
,
()
=>
{
mountComponent
();
describe
(
'
delete button
'
,
()
=>
{
it
(
'
exists
'
,
()
=>
{
mountComponent
();
expect
(
findDeleteButton
().
text
()).
toBe
(
'
Delete image repository
'
);
});
expect
(
findDeleteButton
().
exists
()).
toBe
(
true
);
});
it
(
'
has the correct props
'
,
()
=>
{
mountComponent
();
it
(
'
has the correct text
'
,
()
=>
{
mountComponent
();
expect
(
findDeleteButton
().
attributes
()).
toMatchObject
(
expect
.
objectContaining
({
variant
:
'
danger
'
,
}),
);
});
expect
(
findDeleteButton
().
text
()).
toBe
(
'
Delete image repository
'
);
});
it
(
'
emits the correct event
'
,
()
=>
{
mountComponent
();
it
(
'
has the correct props
'
,
()
=>
{
mountComponent
();
findDeleteButton
().
vm
.
$emit
(
'
click
'
);
expect
(
findDeleteButton
().
attributes
()).
toMatchObject
(
expect
.
objectContaining
({
variant
:
'
danger
'
,
}),
);
});
expect
(
wrapper
.
emitted
(
'
delete
'
)).
toEqual
([[]]);
}
);
it
(
'
emits the correct event
'
,
()
=>
{
mountComponent
(
);
it
.
each
`
canDelete | disabled | isDisabled
${
true
}
|
${
false
}
|
${
undefined
}
${
true
}
|
${
true
}
|
${
'
true
'
}
${
false
}
|
${
false
}
|
${
'
true
'
}
${
false
}
|
${
true
}
|
${
'
true
'
}
`
(
'
when canDelete is $canDelete and disabled is $disabled is $isDisabled that the button is disabled
'
,
({
canDelete
,
disabled
,
isDisabled
})
=>
{
mountComponent
({
propsData
:
{
image
:
{
...
defaultImage
,
canDelete
},
disabled
}
});
findDeleteButton
().
vm
.
$emit
(
'
click
'
);
expect
(
findDeleteButton
().
attributes
(
'
disabled
'
)).
toBe
(
isDisabled
);
}
,
);
expect
(
wrapper
.
emitted
(
'
delete
'
)).
toEqual
([[]]
);
}
);
}
);
});
describe
(
'
metadata items
'
,
()
=>
{
...
...
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