Hide the SSH key add field if we already have keys registered
This just makes the UI shorter in this panel, before we add more data, like the server's own host key information. Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -33,6 +33,8 @@ public interface AccountConstants extends Constants {
|
|||||||
String tabWebIdentities();
|
String tabWebIdentities();
|
||||||
String tabAgreements();
|
String tabAgreements();
|
||||||
|
|
||||||
|
String buttonShowAddSshKey();
|
||||||
|
String buttonCloseAddSshKey();
|
||||||
String buttonDeleteSshKey();
|
String buttonDeleteSshKey();
|
||||||
String buttonClearSshKeyInput();
|
String buttonClearSshKeyInput();
|
||||||
String buttonOpenSshKey();
|
String buttonOpenSshKey();
|
||||||
|
@@ -14,6 +14,8 @@ tabSshKeys = SSH Keys
|
|||||||
tabWebIdentities = Identities
|
tabWebIdentities = Identities
|
||||||
tabAgreements = Agreements
|
tabAgreements = Agreements
|
||||||
|
|
||||||
|
buttonShowAddSshKey = Add Key ...
|
||||||
|
buttonCloseAddSshKey = Close
|
||||||
buttonDeleteSshKey = Delete
|
buttonDeleteSshKey = Delete
|
||||||
buttonClearSshKeyInput = Clear
|
buttonClearSshKeyInput = Clear
|
||||||
buttonOpenSshKey = Open Key ...
|
buttonOpenSshKey = Open Key ...
|
||||||
|
@@ -33,6 +33,9 @@ import com.google.gwt.user.client.ui.ClickListener;
|
|||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
|
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
||||||
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||||
|
import com.google.gwt.user.client.ui.Panel;
|
||||||
import com.google.gwt.user.client.ui.RootPanel;
|
import com.google.gwt.user.client.ui.RootPanel;
|
||||||
import com.google.gwt.user.client.ui.SourcesTableEvents;
|
import com.google.gwt.user.client.ui.SourcesTableEvents;
|
||||||
import com.google.gwt.user.client.ui.TableListener;
|
import com.google.gwt.user.client.ui.TableListener;
|
||||||
@@ -54,6 +57,9 @@ class SshKeyPanel extends Composite {
|
|||||||
|
|
||||||
private SshKeyTable keys;
|
private SshKeyTable keys;
|
||||||
|
|
||||||
|
private Button showAddKeyBlock;
|
||||||
|
private Panel addKeyBlock;
|
||||||
|
private Button closeAddKeyBlock;
|
||||||
private Button clearNew;
|
private Button clearNew;
|
||||||
private Button addNew;
|
private Button addNew;
|
||||||
private Button browse;
|
private Button browse;
|
||||||
@@ -63,6 +69,13 @@ class SshKeyPanel extends Composite {
|
|||||||
SshKeyPanel() {
|
SshKeyPanel() {
|
||||||
final FlowPanel body = new FlowPanel();
|
final FlowPanel body = new FlowPanel();
|
||||||
|
|
||||||
|
showAddKeyBlock = new Button(Util.C.buttonShowAddSshKey());
|
||||||
|
showAddKeyBlock.addClickListener(new ClickListener() {
|
||||||
|
public void onClick(Widget sender) {
|
||||||
|
showAddKeyBlock(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
keys = new SshKeyTable();
|
keys = new SshKeyTable();
|
||||||
body.add(keys);
|
body.add(keys);
|
||||||
{
|
{
|
||||||
@@ -74,51 +87,63 @@ class SshKeyPanel extends Composite {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
fp.add(delSel);
|
fp.add(delSel);
|
||||||
|
fp.add(showAddKeyBlock);
|
||||||
body.add(fp);
|
body.add(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
addKeyBlock = new VerticalPanel();
|
||||||
final VerticalPanel fp = new VerticalPanel();
|
addKeyBlock.setVisible(false);
|
||||||
fp.setStyleName("gerrit-AddSshKeyPanel");
|
addKeyBlock.setStyleName("gerrit-AddSshKeyPanel");
|
||||||
fp.add(new SmallHeading(Util.C.addSshKeyPanelHeader()));
|
addKeyBlock.add(new SmallHeading(Util.C.addSshKeyPanelHeader()));
|
||||||
fp.add(new HTML(Util.C.addSshKeyHelp()));
|
addKeyBlock.add(new HTML(Util.C.addSshKeyHelp()));
|
||||||
|
|
||||||
addTxt = new TextArea();
|
addTxt = new TextArea();
|
||||||
addTxt.setVisibleLines(12);
|
addTxt.setVisibleLines(12);
|
||||||
addTxt.setCharacterWidth(80);
|
addTxt.setCharacterWidth(80);
|
||||||
DOM.setElementPropertyBoolean(addTxt.getElement(), "spellcheck", false);
|
DOM.setElementPropertyBoolean(addTxt.getElement(), "spellcheck", false);
|
||||||
fp.add(addTxt);
|
addKeyBlock.add(addTxt);
|
||||||
|
|
||||||
final FlowPanel buttons = new FlowPanel();
|
final HorizontalPanel buttons = new HorizontalPanel();
|
||||||
fp.add(buttons);
|
addKeyBlock.add(buttons);
|
||||||
|
|
||||||
clearNew = new Button(Util.C.buttonClearSshKeyInput());
|
clearNew = new Button(Util.C.buttonClearSshKeyInput());
|
||||||
clearNew.addClickListener(new ClickListener() {
|
clearNew.addClickListener(new ClickListener() {
|
||||||
public void onClick(final Widget sender) {
|
public void onClick(final Widget sender) {
|
||||||
addTxt.setText("");
|
addTxt.setText("");
|
||||||
addTxt.setFocus(true);
|
addTxt.setFocus(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
buttons.add(clearNew);
|
buttons.add(clearNew);
|
||||||
|
|
||||||
browse = new Button(Util.C.buttonOpenSshKey());
|
browse = new Button(Util.C.buttonOpenSshKey());
|
||||||
browse.addClickListener(new ClickListener() {
|
browse.addClickListener(new ClickListener() {
|
||||||
public void onClick(final Widget sender) {
|
public void onClick(final Widget sender) {
|
||||||
doBrowse();
|
doBrowse();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
browse.setVisible(GWT.isScript() && (!loadedApplet || applet != null));
|
browse.setVisible(GWT.isScript() && (!loadedApplet || applet != null));
|
||||||
buttons.add(browse);
|
buttons.add(browse);
|
||||||
|
|
||||||
addNew = new Button(Util.C.buttonAddSshKey());
|
addNew = new Button(Util.C.buttonAddSshKey());
|
||||||
addNew.addClickListener(new ClickListener() {
|
addNew.addClickListener(new ClickListener() {
|
||||||
public void onClick(final Widget sender) {
|
public void onClick(final Widget sender) {
|
||||||
doAddNew();
|
doAddNew();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
buttons.add(addNew);
|
buttons.add(addNew);
|
||||||
body.add(fp);
|
|
||||||
}
|
closeAddKeyBlock = new Button(Util.C.buttonCloseAddSshKey());
|
||||||
|
closeAddKeyBlock.addClickListener(new ClickListener() {
|
||||||
|
public void onClick(final Widget sender) {
|
||||||
|
showAddKeyBlock(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
buttons.add(closeAddKeyBlock);
|
||||||
|
buttons.setCellWidth(closeAddKeyBlock, "100%");
|
||||||
|
buttons.setCellHorizontalAlignment(closeAddKeyBlock,
|
||||||
|
HasHorizontalAlignment.ALIGN_RIGHT);
|
||||||
|
|
||||||
|
body.add(addKeyBlock);
|
||||||
|
|
||||||
initWidget(body);
|
initWidget(body);
|
||||||
}
|
}
|
||||||
@@ -249,10 +274,18 @@ class SshKeyPanel extends Composite {
|
|||||||
public void onSuccess(final List<AccountSshKey> result) {
|
public void onSuccess(final List<AccountSshKey> result) {
|
||||||
keys.display(result);
|
keys.display(result);
|
||||||
keys.finishDisplay(true);
|
keys.finishDisplay(true);
|
||||||
|
if (result.isEmpty()) {
|
||||||
|
showAddKeyBlock(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showAddKeyBlock(final boolean show) {
|
||||||
|
showAddKeyBlock.setVisible(!show);
|
||||||
|
addKeyBlock.setVisible(show);
|
||||||
|
}
|
||||||
|
|
||||||
private class SshKeyTable extends FancyFlexTable<AccountSshKey> {
|
private class SshKeyTable extends FancyFlexTable<AccountSshKey> {
|
||||||
private static final String S_INVALID = "gerrit-SshKeyPanel-Invalid";
|
private static final String S_INVALID = "gerrit-SshKeyPanel-Invalid";
|
||||||
|
|
||||||
@@ -330,6 +363,9 @@ class SshKeyPanel extends Composite {
|
|||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (table.getRowCount() == 1) {
|
||||||
|
showAddKeyBlock(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user