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