Commit 9e971c74 authored by Paul Slaughter's avatar Paul Slaughter

Merge branch...

Merge branch '342311-remove-right-action-menu-when-user-can-t-delete-in-container-registry-details-page' into 'master'

Remove action menu when user can't delete in container registry details

See merge request gitlab-org/gitlab!77692
parents 9680b880 3d10359e
...@@ -143,6 +143,7 @@ export default { ...@@ -143,6 +143,7 @@ export default {
</template> </template>
<template #right-actions> <template #right-actions>
<gl-dropdown <gl-dropdown
v-if="!deleteButtonDisabled"
icon="ellipsis_v" icon="ellipsis_v"
text="More actions" text="More actions"
:text-sr-only="true" :text-sr-only="true"
...@@ -150,11 +151,7 @@ export default { ...@@ -150,11 +151,7 @@ export default {
no-caret no-caret
right right
> >
<gl-dropdown-item <gl-dropdown-item variant="danger" @click="$emit('delete')">
variant="danger"
:disabled="deleteButtonDisabled"
@click="$emit('delete')"
>
{{ __('Delete image repository') }} {{ __('Delete image repository') }}
</gl-dropdown-item> </gl-dropdown-item>
</gl-dropdown> </gl-dropdown>
......
import { GlDropdownItem, GlIcon } from '@gitlab/ui'; import { GlDropdownItem, GlIcon, GlDropdown } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import { GlDropdown } from 'jest/packages_and_registries/container_registry/explorer/stubs';
import { useFakeDate } from 'helpers/fake_date'; import { useFakeDate } from 'helpers/fake_date';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
...@@ -51,6 +50,7 @@ describe('Details Header', () => { ...@@ -51,6 +50,7 @@ describe('Details Header', () => {
const findCleanup = () => findByTestId('cleanup'); const findCleanup = () => findByTestId('cleanup');
const findDeleteButton = () => wrapper.findComponent(GlDropdownItem); const findDeleteButton = () => wrapper.findComponent(GlDropdownItem);
const findInfoIcon = () => wrapper.findComponent(GlIcon); const findInfoIcon = () => wrapper.findComponent(GlIcon);
const findMenu = () => wrapper.findComponent(GlDropdown);
const waitForMetadataItems = async () => { const waitForMetadataItems = async () => {
// Metadata items are printed by a loop in the title-area and it takes two ticks for them to be available // 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', () => { ...@@ -139,51 +139,53 @@ describe('Details Header', () => {
}); });
}); });
describe('delete button', () => { describe('menu', () => {
it('exists', () => { it.each`
mountComponent(); 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', () => { describe('delete button', () => {
mountComponent(); it('exists', () => {
mountComponent();
expect(findDeleteButton().text()).toBe('Delete image repository'); expect(findDeleteButton().exists()).toBe(true);
}); });
it('has the correct props', () => { it('has the correct text', () => {
mountComponent(); mountComponent();
expect(findDeleteButton().attributes()).toMatchObject( expect(findDeleteButton().text()).toBe('Delete image repository');
expect.objectContaining({ });
variant: 'danger',
}),
);
});
it('emits the correct event', () => { it('has the correct props', () => {
mountComponent(); 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` findDeleteButton().vm.$emit('click');
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 } });
expect(findDeleteButton().attributes('disabled')).toBe(isDisabled); expect(wrapper.emitted('delete')).toEqual([[]]);
}, });
); });
}); });
describe('metadata items', () => { describe('metadata items', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment