From 6929d9df029d230d45d2b3f33717cb0ae6a40c56 Mon Sep 17 00:00:00 2001 From: James Moger Date: Wed, 5 Dec 2012 17:24:18 -0500 Subject: [PATCH] Added attributes tab to Edit User for both site and Manager --- src/com/gitblit/client/EditUserDialog.java | 39 +++++++++++++++++++ .../gitblit/wicket/GitBlitWebApp.properties | 3 +- .../gitblit/wicket/pages/EditUserPage.html | 14 +++++++ .../gitblit/wicket/pages/EditUserPage.java | 5 +++ 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/com/gitblit/client/EditUserDialog.java b/src/com/gitblit/client/EditUserDialog.java index e954fed6..0400f5c9 100644 --- a/src/com/gitblit/client/EditUserDialog.java +++ b/src/com/gitblit/client/EditUserDialog.java @@ -90,7 +90,17 @@ public class EditUserDialog extends JDialog { private JCheckBox canCreateCheckbox; private JCheckBox notFederatedCheckbox; + + private JTextField organizationalUnitField; + + private JTextField organizationField; + private JTextField localityField; + + private JTextField stateProvinceField; + + private JTextField countryCodeField; + private RegistrantPermissionsPanel repositoryPalette; private JPalette teamsPalette; @@ -142,6 +152,12 @@ public class EditUserDialog extends JDialog { Translation.get("gb.excludeFromFederationDescription"), anUser.excludeFromFederation); + organizationalUnitField = new JTextField(anUser.organizationalUnit == null ? "" : anUser.organizationalUnit, 25); + organizationField = new JTextField(anUser.organization == null ? "" : anUser.organization, 25); + localityField = new JTextField(anUser.locality == null ? "" : anUser.locality, 25); + stateProvinceField = new JTextField(anUser.stateProvince == null ? "" : anUser.stateProvince, 25); + countryCodeField = new JTextField(anUser.countryCode == null ? "" : anUser.countryCode, 15); + // credentials are optionally controlled by 3rd-party authentication usernameField.setEnabled(settings.supportsCredentialChanges); passwordField.setEnabled(settings.supportsCredentialChanges); @@ -149,6 +165,12 @@ public class EditUserDialog extends JDialog { displayNameField.setEnabled(settings.supportsDisplayNameChanges); emailAddressField.setEnabled(settings.supportsEmailAddressChanges); + + organizationalUnitField.setEnabled(settings.supportsDisplayNameChanges); + organizationField.setEnabled(settings.supportsDisplayNameChanges); + localityField.setEnabled(settings.supportsDisplayNameChanges); + stateProvinceField.setEnabled(settings.supportsDisplayNameChanges); + countryCodeField.setEnabled(settings.supportsDisplayNameChanges); JPanel fieldsPanel = new JPanel(new GridLayout(0, 1)); fieldsPanel.add(newFieldPanel(Translation.get("gb.username"), usernameField)); @@ -162,6 +184,13 @@ public class EditUserDialog extends JDialog { fieldsPanel.add(newFieldPanel(Translation.get("gb.excludeFromFederation"), notFederatedCheckbox)); + JPanel attributesPanel = new JPanel(new GridLayout(0, 1, 5, 2)); + attributesPanel.add(newFieldPanel(Translation.get("gb.organizationalUnit") + " (OU)", organizationalUnitField)); + attributesPanel.add(newFieldPanel(Translation.get("gb.organization") + " (O)", organizationField)); + attributesPanel.add(newFieldPanel(Translation.get("gb.locality") + " (L)", localityField)); + attributesPanel.add(newFieldPanel(Translation.get("gb.stateProvince") + " (ST)", stateProvinceField)); + attributesPanel.add(newFieldPanel(Translation.get("gb.countryCode") + " (C)", countryCodeField)); + final Insets _insets = new Insets(5, 5, 5, 5); repositoryPalette = new RegistrantPermissionsPanel(RegistrantType.REPOSITORY); teamsPalette = new JPalette(); @@ -170,6 +199,9 @@ public class EditUserDialog extends JDialog { JPanel fieldsPanelTop = new JPanel(new BorderLayout()); fieldsPanelTop.add(fieldsPanel, BorderLayout.NORTH); + JPanel attributesPanelTop = new JPanel(new BorderLayout()); + attributesPanelTop.add(attributesPanel, BorderLayout.NORTH); + JPanel repositoriesPanel = new JPanel(new BorderLayout()) { private static final long serialVersionUID = 1L; @@ -192,6 +224,7 @@ public class EditUserDialog extends JDialog { JTabbedPane panel = new JTabbedPane(JTabbedPane.TOP); panel.addTab(Translation.get("gb.general"), fieldsPanelTop); + panel.addTab(Translation.get("gb.attributes"), attributesPanelTop); if (protocolVersion > 1) { panel.addTab(Translation.get("gb.teamMemberships"), teamsPanel); } @@ -324,6 +357,12 @@ public class EditUserDialog extends JDialog { user.canCreate = canCreateCheckbox.isSelected(); user.excludeFromFederation = notFederatedCheckbox.isSelected(); + user.organizationalUnit = organizationalUnitField.getText().trim(); + user.organization = organizationField.getText().trim(); + user.locality = localityField.getText().trim(); + user.stateProvince = stateProvinceField.getText().trim(); + user.countryCode = countryCodeField.getText().trim(); + for (RegistrantAccessPermission rp : repositoryPalette.getPermissions()) { user.setRepositoryPermission(rp.registrant, rp.permission); } diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties index 9ee9f397..7ce75262 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/com/gitblit/wicket/GitBlitWebApp.properties @@ -433,4 +433,5 @@ gb.warning = warning gb.jceWarning = Your Java Runtime Environment does not have the \"JCE Unlimited Strength Jurisdiction Policy\" files.\nThis will limit the length of passwords you may use to encrypt your keystores to 7 characters.\nThese policy files are an optional download from Oracle.\n\nWould you like to continue and generate the certificate infrastructure anyway?\n\nAnswering No will direct your browser to Oracle's download page so that you may download the policy files. gb.maxActivityCommits = max activity commits gb.maxActivityCommitsDescription = maximum number of commits to contribute to the Activity page -gb.noMaximum = no maximum \ No newline at end of file +gb.noMaximum = no maximum +gb.attributes = attributes \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/EditUserPage.html b/src/com/gitblit/wicket/pages/EditUserPage.html index e697a354..e79011c8 100644 --- a/src/com/gitblit/wicket/pages/EditUserPage.html +++ b/src/com/gitblit/wicket/pages/EditUserPage.html @@ -13,6 +13,7 @@ @@ -36,6 +37,19 @@ + +
+ + + + + + + + +
(OU)
(O)
(L)
(ST)
(C)
+
+
diff --git a/src/com/gitblit/wicket/pages/EditUserPage.java b/src/com/gitblit/wicket/pages/EditUserPage.java index d22800ef..7a01fb68 100644 --- a/src/com/gitblit/wicket/pages/EditUserPage.java +++ b/src/com/gitblit/wicket/pages/EditUserPage.java @@ -239,6 +239,11 @@ public class EditUserPage extends RootSubPage { form.add(new RegistrantPermissionsPanel("repositories", RegistrantType.REPOSITORY, repos, permissions, getAccessPermissions())); form.add(teams.setEnabled(editTeams)); + form.add(new TextField("organizationalUnit").setEnabled(editDisplayName)); + form.add(new TextField("organization").setEnabled(editDisplayName)); + form.add(new TextField("locality").setEnabled(editDisplayName)); + form.add(new TextField("stateProvince").setEnabled(editDisplayName)); + form.add(new TextField("countryCode").setEnabled(editDisplayName)); form.add(new Button("save")); Button cancel = new Button("cancel") { private static final long serialVersionUID = 1L; -- 2.39.5