Commit 8294756f authored by Andre Guedes's avatar Andre Guedes

Improved readability in tag/image delete condition

parent ea17df5c
......@@ -9,31 +9,37 @@ class Projects::ContainerRegistryController < Projects::ApplicationController
end
def destroy
url = namespace_project_container_registry_index_path(project.namespace, project)
if tag
delete_tag(url)
else
if image.destroy
redirect_to url
delete_tag
else
redirect_to url, alert: 'Failed to remove image'
end
delete_image
end
end
private
def registry_url
@registry_url ||= namespace_project_container_registry_index_path(project.namespace, project)
end
def verify_registry_enabled
render_404 unless Gitlab.config.registry.enabled
end
def delete_tag(url)
def delete_image
if image.destroy
redirect_to registry_url
else
redirect_to registry_url, alert: 'Failed to remove image'
end
end
def delete_tag
if tag.delete
image.destroy if image.tags.empty?
redirect_to url
redirect_to registry_url
else
redirect_to url, alert: 'Failed to remove tag'
redirect_to registry_url, alert: 'Failed to remove tag'
end
end
......
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