From 8bc725871269aa47f8ef6db086a4cfedc75ef140 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Mon, 29 Oct 2012 09:19:03 -0400 Subject: [PATCH] Use repository swatch coloring in registrant permissions panel --- src/com/gitblit/client/EditRepositoryDialog.java | 50 ++++++++++++++++++++++++++++++++++---------------- 1 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/com/gitblit/client/EditRepositoryDialog.java b/src/com/gitblit/client/EditRepositoryDialog.java index 8ce076e..0adf8a8 100644 --- a/src/com/gitblit/client/EditRepositoryDialog.java +++ b/src/com/gitblit/client/EditRepositoryDialog.java @@ -59,6 +59,7 @@ import com.gitblit.Constants.AccessRestrictionType; import com.gitblit.Constants.AuthorizationControl; import com.gitblit.Constants.FederationStrategy; +import com.gitblit.models.RegistrantAccessPermission; import com.gitblit.models.RepositoryModel; import com.gitblit.utils.ArrayUtils; import com.gitblit.utils.StringUtils; @@ -105,6 +106,10 @@ private JRadioButton allowAuthenticated; private JRadioButton allowNamed; + + private JCheckBox allowForks; + + private JCheckBox verifyCommitter; private JComboBox federationStrategy; @@ -112,11 +117,11 @@ private JComboBox headRefField; - private JPalette<String> usersPalette; + private RegistrantPermissionsPanel usersPalette; private JPalette<String> setsPalette; - private JPalette<String> teamsPalette; + private RegistrantPermissionsPanel teamsPalette; private JPalette<String> indexedBranchesPalette; @@ -228,6 +233,9 @@ JPanel authorizationPanel = new JPanel(new GridLayout(0, 1)); authorizationPanel.add(allowAuthenticated); authorizationPanel.add(allowNamed); + + allowForks = new JCheckBox(Translation.get("gb.allowForksDescription"), anRepository.allowForks); + verifyCommitter = new JCheckBox(Translation.get("gb.verifyCommitterDescription"), anRepository.verifyCommitter); // federation strategies - remove ORIGIN choice if this repository has // no origin. @@ -262,27 +270,34 @@ skipSizeCalculation)); fieldsPanel.add(newFieldPanel(Translation.get("gb.skipSummaryMetrics"), skipSummaryMetrics)); - fieldsPanel - .add(newFieldPanel(Translation.get("gb.isFrozen"), isFrozen)); fieldsPanel.add(newFieldPanel(Translation.get("gb.mailingLists"), mailingListsField)); - usersPalette = new JPalette<String>(); + JPanel clonePushPanel = new JPanel(new GridLayout(0, 1)); + clonePushPanel + .add(newFieldPanel(Translation.get("gb.isFrozen"), isFrozen)); + clonePushPanel + .add(newFieldPanel(Translation.get("gb.allowForks"), allowForks)); + clonePushPanel + .add(newFieldPanel(Translation.get("gb.verifyCommitter"), verifyCommitter)); + + usersPalette = new RegistrantPermissionsPanel(); JPanel northAccessPanel = new JPanel(new BorderLayout(5, 5)); northAccessPanel.add(newFieldPanel(Translation.get("gb.accessRestriction"), accessRestriction), BorderLayout.NORTH); northAccessPanel.add(newFieldPanel(Translation.get("gb.authorizationControl"), authorizationPanel), BorderLayout.CENTER); + northAccessPanel.add(clonePushPanel, BorderLayout.SOUTH); JPanel accessPanel = new JPanel(new BorderLayout(5, 5)); accessPanel.add(northAccessPanel, BorderLayout.NORTH); - accessPanel.add(newFieldPanel(Translation.get("gb.permittedUsers"), + accessPanel.add(newFieldPanel(Translation.get("gb.userPermissions"), usersPalette), BorderLayout.CENTER); - teamsPalette = new JPalette<String>(); + teamsPalette = new RegistrantPermissionsPanel(); JPanel teamsPanel = new JPanel(new BorderLayout(5, 5)); teamsPanel.add( - newFieldPanel(Translation.get("gb.permittedTeams"), + newFieldPanel(Translation.get("gb.teamPermissions"), teamsPalette), BorderLayout.CENTER); setsPalette = new JPalette<String>(); @@ -472,7 +487,10 @@ repository.showReadme = showReadme.isSelected(); repository.skipSizeCalculation = skipSizeCalculation.isSelected(); repository.skipSummaryMetrics = skipSummaryMetrics.isSelected(); + repository.isFrozen = isFrozen.isSelected(); + repository.allowForks = allowForks.isSelected(); + repository.verifyCommitter = verifyCommitter.isSelected(); String ml = mailingListsField.getText(); if (!StringUtils.isEmpty(ml)) { @@ -528,16 +546,16 @@ this.allowNamed.setSelected(!authenticated); } - public void setUsers(String owner, List<String> all, List<String> selected) { + public void setUsers(String owner, List<String> all, List<RegistrantAccessPermission> permissions) { ownerField.setModel(new DefaultComboBoxModel(all.toArray())); if (!StringUtils.isEmpty(owner)) { ownerField.setSelectedItem(owner); } - usersPalette.setObjects(all, selected); + usersPalette.setObjects(all, permissions); } - public void setTeams(List<String> all, List<String> selected) { - teamsPalette.setObjects(all, selected); + public void setTeams(List<String> all, List<RegistrantAccessPermission> permissions) { + teamsPalette.setObjects(all, permissions); } public void setRepositories(List<RepositoryModel> repositories) { @@ -590,12 +608,12 @@ return repository; } - public List<String> getPermittedUsers() { - return usersPalette.getSelections(); + public List<RegistrantAccessPermission> getUserAccessPermissions() { + return usersPalette.getPermissions(); } - public List<String> getPermittedTeams() { - return teamsPalette.getSelections(); + public List<RegistrantAccessPermission> getTeamAccessPermissions() { + return teamsPalette.getPermissions(); } public void setCustomFields(RepositoryModel repository, Map<String, String> customFields) { -- Gitblit v1.9.1