James Moger
2014-05-15 51c923705de3c466faa002146a0b544991bf4b22
Remove the edit link and the rss feed link from the repositories panel
2 files modified
94 ■■■■■ changed files
src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.html 20 ●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java 74 ●●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.html
@@ -42,10 +42,6 @@
        </div>    
    </wicket:fragment>
    <wicket:fragment wicket:id="repositoryOwnerLinks">
        <span class="link"><a wicket:id="editRepository"><wicket:message key="gb.edit">[edit]</wicket:message></a></span>
    </wicket:fragment>
    <wicket:fragment wicket:id="flatRepositoryHeader">
        <tr>
            <th class="left" wicket:id="orderByRepository">
@@ -56,8 +52,7 @@
            <th class="hidden-tablet hidden-phone" wicket:id="orderByOwner"><wicket:message key="gb.owner">Owner</wicket:message></th>
            <th class="hidden-phone"></th>
            <th wicket:id="orderByDate"><wicket:message key="gb.lastChange">Last Change</wicket:message></th>
            <th class="hidden-phone"></th>
            <th class="right"></th>
            <th class="right hidden-phone"></th>
        </tr>
    </wicket:fragment>
    
@@ -71,8 +66,7 @@
            <th class="hidden-tablet hidden-phone"><span><wicket:message key="gb.owner">Owner</wicket:message></span></th>
            <th class="hidden-phone"></th>
            <th><wicket:message key="gb.lastChange">Last Change</wicket:message></th>
            <th class="hidden-phone"></th>
            <th class="right"></th>
            <th class="right hidden-phone"></th>
        </tr>
    </wicket:fragment>
    
@@ -87,15 +81,7 @@
        <td class="hidden-tablet hidden-phone author"><span wicket:id="repositoryOwner">[repository owner]</span></td>
        <td class="hidden-phone" style="text-align: right;padding-right:10px;"><img class="inlineIcon" wicket:id="sparkleshareIcon" /><img class="inlineIcon" wicket:id="mirrorIcon" /><img class="inlineIcon" wicket:id="forkIcon" /><img class="inlineIcon" wicket:id="frozenIcon" /><img class="inlineIcon" wicket:id="federatedIcon" /><img class="inlineIcon" wicket:id="accessRestrictionIcon" /></td>
        <td><span wicket:id="repositoryLastChange">[last change]</span></td>
        <td class="hidden-phone" style="text-align: right;padding-right:15px;"><span style="font-size:0.8em;" wicket:id="repositorySize">[repository size]</span></td>
        <td class="rightAlign">
            <span class="hidden-phone">
                <span wicket:id="repositoryLinks"></span>
                <a style="text-decoration: none;" wicket:id="syndication" wicket:message="title:gb.feed">
                    <img style="border:0px;vertical-align:middle;" src="feed_16x16.png"></img>
                </a>
            </span>
        </td>
        <td class="rightAlign hidden-phone" style="text-align: right;padding-right:15px;"><span style="font-size:0.8em;" wicket:id="repositorySize">[repository size]</span></td>
    </wicket:fragment>
    
</wicket:panel>
src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java
@@ -31,7 +31,6 @@
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.ExternalLink;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.repeater.Item;
@@ -46,7 +45,6 @@
import com.gitblit.models.ProjectModel;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.UserModel;
import com.gitblit.servlet.SyndicationServlet;
import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.ModelUtils;
import com.gitblit.utils.StringUtils;
@@ -140,12 +138,11 @@
                Collections.sort(subModels);
                groupedModels.addAll(subModels);
            }
            dp = new RepositoriesProvider(groupedModels);
            dp = new ListDataProvider<RepositoryModel>(groupedModels);
        } else {
            dp = new SortableRepositoriesProvider(models);
        }
        final String baseUrl = WicketUtils.getGitblitURL(getRequest());
        final boolean showSwatch = app().settings().getBoolean(Keys.web.repositoryListSwatches, true);
        DataView<RepositoryModel> dataView = new DataView<RepositoryModel>("row", dp) {
@@ -319,18 +316,6 @@
                    WicketUtils.setHtmlTooltip(lastChangeLabel, getString("gb.author") + ": " + entry.lastChangeAuthor);
                }
                if (user != null && user.canAdmin(entry)) {
                    Fragment repositoryLinks = new Fragment("repositoryLinks",
                            "repositoryOwnerLinks", this);
                    repositoryLinks.add(new BookmarkablePageLink<Void>("editRepository",
                            EditRepositoryPage.class, WicketUtils
                                    .newRepositoryParameter(entry.name)));
                    row.add(repositoryLinks);
                } else {
                    row.add(new Label("repositoryLinks"));
                }
                row.add(new ExternalLink("syndication", SyndicationServlet.asLink(baseUrl,
                        entry.name, null, 0)).setVisible(linksActive));
                WicketUtils.setAlternatingBackground(item, counter);
                counter++;
            }
@@ -387,59 +372,6 @@
        };
    }
    private static class RepositoriesProvider extends ListDataProvider<RepositoryModel> {
        private static final long serialVersionUID = 1L;
        public RepositoriesProvider(List<RepositoryModel> list) {
            super(list);
        }
        @Override
        public List<RepositoryModel> getData() {
            return super.getData();
        }
        public void remove(RepositoryModel model) {
            int index = getData().indexOf(model);
            RepositoryModel groupModel = null;
            if (index == (getData().size() - 1)) {
                // last element
                if (index > 0) {
                    // previous element is group header, then this is last
                    // repository in group. remove group too.
                    if (getData().get(index - 1) instanceof GroupRepositoryModel) {
                        groupModel = getData().get(index - 1);
                    }
                }
            } else if (index < (getData().size() - 1)) {
                // not last element. check next element for group match.
                if (getData().get(index - 1) instanceof GroupRepositoryModel
                        && getData().get(index + 1) instanceof GroupRepositoryModel) {
                    // repository is sandwiched by group headers so this
                    // repository is the only element in the group. remove
                    // group.
                    groupModel = getData().get(index - 1);
                }
            }
            if (groupModel == null) {
                // Find the group and decrement the count
                for (int i = index; i >= 0; i--) {
                    if (getData().get(i) instanceof GroupRepositoryModel) {
                        ((GroupRepositoryModel) getData().get(i)).count--;
                        break;
                    }
                }
            } else {
                // Remove the group header
                getData().remove(groupModel);
            }
            getData().remove(model);
        }
    }
    private static class SortableRepositoriesProvider extends SortableDataProvider<RepositoryModel> {
        private static final long serialVersionUID = 1L;
@@ -449,10 +381,6 @@
        protected SortableRepositoriesProvider(List<RepositoryModel> list) {
            this.list = list;
            setSort(SortBy.date.name(), false);
        }
        public void remove(RepositoryModel model) {
            list.remove(model);
        }
        @Override