summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/distrib/data/gitblit.properties5
-rw-r--r--src/main/java/com/gitblit/wicket/panels/ProjectRepositoryPanel.java30
-rw-r--r--src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java28
3 files changed, 50 insertions, 13 deletions
diff --git a/src/main/distrib/data/gitblit.properties b/src/main/distrib/data/gitblit.properties
index 3215094e..30e97896 100644
--- a/src/main/distrib/data/gitblit.properties
+++ b/src/main/distrib/data/gitblit.properties
@@ -766,6 +766,11 @@ web.authenticateAdminPages = true
# SINCE 0.5.0
web.allowCookieAuthentication = true
+# Allow deleting of non empty repositories through the user interface.
+#
+# SINCE 1.6.0
+web.allowDeletingNonEmptyRepositories = true
+
# Config file for storing project metadata
#
# SINCE 1.2.0
diff --git a/src/main/java/com/gitblit/wicket/panels/ProjectRepositoryPanel.java b/src/main/java/com/gitblit/wicket/panels/ProjectRepositoryPanel.java
index a0f8ac48..2c84ac06 100644
--- a/src/main/java/com/gitblit/wicket/panels/ProjectRepositoryPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/ProjectRepositoryPanel.java
@@ -145,20 +145,36 @@ public class ProjectRepositoryPanel extends BasePanel {
@Override
public void onClick() {
- if (app().repositories().deleteRepositoryModel(entry)) {
+ // refresh the model
+ RepositoryModel model = app().repositories().getRepositoryModel(entry.name);
+ if (isDeleteAllowed(model) &&
+ app().repositories().deleteRepositoryModel(model)) {
// redirect to the owning page
- if (entry.isPersonalRepository()) {
- setResponsePage(getPage().getClass(), WicketUtils.newUsernameParameter(entry.projectPath.substring(1)));
+ if (model.isPersonalRepository()) {
+ setResponsePage(getPage().getClass(), WicketUtils.newUsernameParameter(model.projectPath.substring(1)));
} else {
- setResponsePage(getPage().getClass(), WicketUtils.newProjectParameter(entry.projectPath));
+ setResponsePage(getPage().getClass(), WicketUtils.newProjectParameter(model.projectPath));
}
} else {
- error(MessageFormat.format(getString("gb.repositoryDeleteFailed"), entry));
+ error(MessageFormat.format(getString("gb.repositoryDeleteFailed"), model));
}
}
+
+ @Override
+ public boolean isEnabled() {
+ return isDeleteAllowed(entry);
+ }
+
+ private boolean isDeleteAllowed(
+ final RepositoryModel model) {
+ return app().settings().getBoolean(Keys.web.allowDeletingNonEmptyRepositories, true)
+ || !model.hasCommits;
+ }
};
- deleteLink.add(new JavascriptEventConfirmation("onclick", MessageFormat.format(
- localizer.getString("gb.deleteRepository", parent), entry)));
+ if (deleteLink.isEnabled()) {
+ deleteLink.add(new JavascriptEventConfirmation("onclick", MessageFormat.format(
+ localizer.getString("gb.deleteRepository", parent), entry)));
+ }
repositoryLinks.add(deleteLink);
}
} else {
diff --git a/src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java b/src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java
index be5d960b..40cd77e6 100644
--- a/src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java
@@ -334,20 +334,36 @@ public class RepositoriesPanel extends BasePanel {
@Override
public void onClick() {
- if (app().repositories().deleteRepositoryModel(entry)) {
+ // refresh the model
+ RepositoryModel model = app().repositories().getRepositoryModel(entry.name);
+ if (isDeleteAllowed(model) &&
+ app().repositories().deleteRepositoryModel(model)) {
if (dp instanceof SortableRepositoriesProvider) {
- info(MessageFormat.format(getString("gb.repositoryDeleted"), entry));
- ((SortableRepositoriesProvider) dp).remove(entry);
+ info(MessageFormat.format(getString("gb.repositoryDeleted"), model));
+ ((SortableRepositoriesProvider) dp).remove(model);
} else {
setResponsePage(getPage().getClass(), getPage().getPageParameters());
}
} else {
- error(MessageFormat.format(getString("gb.repositoryDeleteFailed"), entry));
+ error(MessageFormat.format(getString("gb.repositoryDeleteFailed"), model));
}
}
+
+ @Override
+ public boolean isEnabled() {
+ return isDeleteAllowed(entry);
+ }
+
+ private boolean isDeleteAllowed(
+ final RepositoryModel model) {
+ return app().settings().getBoolean(Keys.web.allowDeletingNonEmptyRepositories, true)
+ || !model.hasCommits;
+ }
};
- deleteLink.add(new JavascriptEventConfirmation("onclick", MessageFormat.format(
- getString("gb.deleteRepository"), entry)));
+ if (deleteLink.isEnabled()) {
+ deleteLink.add(new JavascriptEventConfirmation("onclick", MessageFormat.format(
+ getString("gb.deleteRepository"), entry)));
+ }
repositoryLinks.add(deleteLink);
row.add(repositoryLinks);
} else if (showOwner) {