Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHE-1002 Add target UX improvements #1119

Merged
merged 1 commit into from
Apr 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -340,35 +340,75 @@ private void updateButtons() {
return;
}

// Update text of Connect / Disconnect button
if (selectedTarget.isConnected()) {
view.setConnectButtonText("Disconnect");
} else {
view.setConnectButtonText("Connect");
}
view.enableConnectButton(!selectedTarget.isDirty());

view.enableCancelButton(selectedTarget.isDirty());
// Disable Save and Cancel buttons and enable Connect for non dirty target.
if (!selectedTarget.isDirty()) {
view.enableConnectButton(true);
view.enableCancelButton(false);
view.enableSaveButton(false);

view.unmarkTargetName();
view.unmarkHost();
view.unmarkPort();
return;
}

view.enableConnectButton(false);
view.enableCancelButton(true);

if (StringUtils.isNullOrEmpty(view.getTargetName()) ||
StringUtils.isNullOrEmpty(view.getHost()) ||
StringUtils.isNullOrEmpty(view.getPort())) {
// target name must be not empty
if (view.getTargetName().isEmpty()) {
view.markTargetNameInvalid();
view.enableSaveButton(false);
} else {
if (selectedTarget.isDirty()) {
for (Target target : targets) {
if (target == selectedTarget) {
continue;
}
return;
}

if (target.getName().equals(view.getTargetName())) {
view.enableSaveButton(false);
return;
}
boolean enableSave = true;

// check target name to being not empty
if (view.getTargetName().isEmpty()) {
enableSave = false;
view.markTargetNameInvalid();
} else {
boolean targetAlreadyExists = false;
for (Target target : targets) {
if (target != selectedTarget && target.getName().equals(view.getTargetName())) {
targetAlreadyExists = true;
break;
}
}

view.enableSaveButton(selectedTarget.isDirty());
if (targetAlreadyExists) {
enableSave = false;
view.markTargetNameInvalid();
} else {
view.unmarkTargetName();
}
}

// check host to being not empty
if (view.getHost().isEmpty()) {
enableSave = false;
view.markHostInvalid();
} else {
view.unmarkHost();
}

// check port to being not empty
if (view.getPort().isEmpty()) {
enableSave = false;
view.markPortInvalid();
} else {
view.unmarkPort();
}

view.enableSaveButton(enableSave);
}

@Override
Expand Down Expand Up @@ -700,24 +740,32 @@ protected void onErrorReceived(Throwable exception) {
* Ensures machine is started.
*/
private void onConnected(final String machineId) {
machineService.getMachine(machineId).then(new Operation<MachineDto>() {
// There is a little bug in machine service on the server side.
// The machine info is updated with a little delay after running a machine.
// Using timer must fix the problem.
new Timer() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not clear about timer, how it solve problem? Why you set 500 not 600? Can accept it as urgent fix but must be fixed ASAP. Other ok for me

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you say that there is a bug in machine API than create an issue and assign it to me, please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure where is a problem. But when I receive a RUNNING state via websocket I ask the machine service about the machine and get CREATING state. Only waiting for a while gives the result.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure it's a temporary desigion and has to be fixed ASAP.

@Override
public void apply(MachineDto machineDto) throws OperationException {
if (machineDto.getStatus() == RUNNING) {
eventBus.fireEvent(new MachineStateEvent(machineDto, MachineStateEvent.MachineAction.RUNNING));
connectNotification.setTitle(machineLocale.targetsViewConnectSuccess(machineDto.getConfig().getName()));
connectNotification.setStatus(StatusNotification.Status.SUCCESS);
updateTargets(machineDto.getConfig().getName());
} else {
onConnectingFailed(null);
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
onConnectingFailed(null);
public void run() {
machineService.getMachine(machineId).then(new Operation<MachineDto>() {
@Override
public void apply(MachineDto machineDto) throws OperationException {
if (machineDto.getStatus() == RUNNING) {
eventBus.fireEvent(new MachineStateEvent(machineDto, MachineStateEvent.MachineAction.RUNNING));
connectNotification.setTitle(machineLocale.targetsViewConnectSuccess(machineDto.getConfig().getName()));
connectNotification.setStatus(StatusNotification.Status.SUCCESS);
updateTargets(machineDto.getConfig().getName());
} else {
onConnectingFailed(null);
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
onConnectingFailed(null);
}
});
}
});
}.schedule(500);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,36 @@ public interface TargetsView extends View<TargetsView.ActionDelegate> {
*/
String getPort();

/**
* Adds error mark to target name field.
*/
void markTargetNameInvalid();

/**
* Removes error mark from target name field.
*/
void unmarkTargetName();

/**
* Adds error mark to host field.
*/
void markHostInvalid();

/**
* Removes error mark from host field.
*/
void unmarkHost();

/**
* Adds error mark to port field.
*/
void markPortInvalid();

/**
* Removes error mark from port field.
*/
void unmarkPort();

/**
* Sets SSH user name.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ interface TargetsViewImplUiBinder extends UiBinder<Widget, TargetsViewImpl> {
FlowPanel propertiesPanel;

@UiField
TextBox targetName;
org.eclipse.che.ide.ui.TextBox targetName;

@UiField
TextBox host;
org.eclipse.che.ide.ui.TextBox host;

@UiField
TextBox port;
org.eclipse.che.ide.ui.TextBox port;

@UiField
TextBox userName;
Expand Down Expand Up @@ -428,6 +428,36 @@ public String getTargetName() {
return targetName.getValue();
}

@Override
public void markTargetNameInvalid() {
targetName.markInvalid();
}

@Override
public void unmarkTargetName() {
targetName.unmark();
}

@Override
public void markHostInvalid() {
host.markInvalid();
}

@Override
public void unmarkHost() {
host.unmark();
}

@Override
public void markPortInvalid() {
port.markInvalid();
}

@Override
public void unmarkPort() {
port.unmark();
}

@Override
public void setHost(String host) {
this.host.setValue(host);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'
xmlns:che='urn:import:org.eclipse.che.ide.ui.listbox'>
xmlns:ide='urn:import:org.eclipse.che.ide.ui'>

<ui:with field='machineLocale' type='org.eclipse.che.ide.extension.machine.client.MachineLocalizationConstant'/>

Expand Down Expand Up @@ -165,13 +165,13 @@
<g:FlowPanel ui:field="propertiesPanel" styleName="{style.propertiesPanel}" visible="false">

<g:Label width="100%" text="Name" addStyleNames="{style.label} {style.delimiter}"/>
<g:TextBox width="100%" height="14px" ui:field="targetName" tabIndex="0"/>
<ide:TextBox width="100%" height="14px" ui:field="targetName" tabIndex="0"/>

<g:Label width="100%" text="Host" addStyleNames="{style.label} {style.delimiter}"/>
<g:TextBox width="100%" height="14px" ui:field="host" tabIndex="0"/>
<ide:TextBox width="100%" height="14px" ui:field="host" tabIndex="0"/>

<g:Label width="100%" text="Port" addStyleNames="{style.label}"/>
<g:TextBox width="100%" height="14px" ui:field="port" tabIndex="0"/>
<ide:TextBox width="100%" height="14px" ui:field="port" tabIndex="0"/>

<g:Label width="100%" text="Login" addStyleNames="{style.label} {style.delimiter}"/>
<g:TextBox width="100%" height="14px" ui:field="userName" tabIndex="0"/>
Expand Down