This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #854 from mssola/delete-ui
Added support for removing images/tags
- Loading branch information
Showing
28 changed files
with
661 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
.tags .label.label-success { | ||
margin: 0px 2px; | ||
} | ||
|
||
#remove-repo button { | ||
padding: 0px 10px 0px 0px; | ||
} | ||
|
||
.remove-repo:focus, .remove-repo:hover, .remove-tag:focus, .remove-tag:hover { | ||
text-decoration: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Deletable redirects the user back if delete support is not enabled. A | ||
# `before_action` will be created for the :destroy method. | ||
module Deletable | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
before_action :delete_enabled?, only: [:destroy] | ||
end | ||
|
||
# Returns true if users can delete images/tags. | ||
def delete_enabled? | ||
redirect_to :back, status: :forbidden unless APP_CONFIG.enabled?("delete") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class TagsController < ApplicationController | ||
include Deletable | ||
|
||
# Removes all tags that match the digest of the tag with the given ID. | ||
# Moreover, it will also remove the image if it's left empty after removing | ||
# the tags. | ||
def destroy | ||
tag = Tag.find(params[:id]) | ||
|
||
# And now remove the tag by the digest. If the repository containing said | ||
# tags becomes empty after that, remove it too. | ||
repo = tag.repository | ||
if tag.delete_by_digest!(current_user) | ||
if repo.tags.empty? | ||
repo.delete_and_update!(current_user) | ||
redirect_to namespace_path(repo.namespace), notice: "Image removed with all its tags" | ||
else | ||
redirect_to repository_path(tag.repository), notice: "Tag removed successfully" | ||
end | ||
else | ||
redirect_to repository_path(tag.repository), alert: "Tag could not be removed" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.