Commit 611c3a8a authored by Phil Hughes's avatar Phil Hughes

Merge branch...

Merge branch '227016-container-registry-improve-the-experience-for-users-viewing-an-image-repository-who-does-not' into 'master'

Hide tags delete button when none can be deleted

See merge request gitlab-org/gitlab!36300
parents f907ee7c df56c7e2
...@@ -33,6 +33,9 @@ export default { ...@@ -33,6 +33,9 @@ export default {
hasSelectedItems() { hasSelectedItems() {
return this.tags.some(tag => this.selectedItems[tag.name]); return this.tags.some(tag => this.selectedItems[tag.name]);
}, },
showMultiDeleteButton() {
return this.tags.some(tag => tag.destroy_path) && this.isDesktop;
},
}, },
methods: { methods: {
updateSelectedItems(name) { updateSelectedItems(name) {
...@@ -50,7 +53,7 @@ export default { ...@@ -50,7 +53,7 @@ export default {
</h5> </h5>
<gl-button <gl-button
v-if="isDesktop" v-if="showMultiDeleteButton"
:disabled="!hasSelectedItems" :disabled="!hasSelectedItems"
category="secondary" category="secondary"
variant="danger" variant="danger"
......
...@@ -45,7 +45,7 @@ export const ADMIN_GARBAGE_COLLECTION_TIP = s__( ...@@ -45,7 +45,7 @@ export const ADMIN_GARBAGE_COLLECTION_TIP = s__(
); );
export const REMOVE_TAG_BUTTON_DISABLE_TOOLTIP = s__( export const REMOVE_TAG_BUTTON_DISABLE_TOOLTIP = s__(
'ContainerRegistry|Missing or insufficient permission, delete button disabled', 'ContainerRegistry|Deletion disabled due to missing or insufficient permissions.',
); );
// Parameters // Parameters
......
...@@ -6255,6 +6255,9 @@ msgstr "" ...@@ -6255,6 +6255,9 @@ msgstr ""
msgid "ContainerRegistry|Delete selected" msgid "ContainerRegistry|Delete selected"
msgstr "" msgstr ""
msgid "ContainerRegistry|Deletion disabled due to missing or insufficient permissions."
msgstr ""
msgid "ContainerRegistry|Digest: %{imageId}" msgid "ContainerRegistry|Digest: %{imageId}"
msgstr "" msgstr ""
......
...@@ -8,6 +8,7 @@ import { tagsListResponse } from '../../mock_data'; ...@@ -8,6 +8,7 @@ import { tagsListResponse } from '../../mock_data';
describe('Tags List', () => { describe('Tags List', () => {
let wrapper; let wrapper;
const tags = [...tagsListResponse.data]; const tags = [...tagsListResponse.data];
const readOnlyTags = tags.map(t => ({ ...t, destroy_path: undefined }));
const findTagsListRow = () => wrapper.findAll(TagsListRow); const findTagsListRow = () => wrapper.findAll(TagsListRow);
const findDeleteButton = () => wrapper.find(GlButton); const findDeleteButton = () => wrapper.find(GlButton);
...@@ -39,17 +40,20 @@ describe('Tags List', () => { ...@@ -39,17 +40,20 @@ describe('Tags List', () => {
}); });
describe('delete button', () => { describe('delete button', () => {
it('is not shown on mobile view', () => { it.each`
mountComponent({ tags, isDesktop: false }); inputTags | isDesktop | isVisible
${tags} | ${true} | ${true}
expect(findDeleteButton().exists()).toBe(false); ${tags} | ${false} | ${false}
}); ${readOnlyTags} | ${true} | ${false}
${readOnlyTags} | ${false} | ${false}
it('is shown on desktop view', () => { `(
mountComponent(); 'is $isVisible that delete button exists when tags is $inputTags and isDesktop is $isDesktop',
({ inputTags, isDesktop, isVisible }) => {
expect(findDeleteButton().exists()).toBe(true); mountComponent({ tags: inputTags, isDesktop });
});
expect(findDeleteButton().exists()).toBe(isVisible);
},
);
it('has the correct text', () => { it('has the correct text', () => {
mountComponent(); mountComponent();
......
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