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

Show binding changes #263

Merged
merged 13 commits into from
Jun 11, 2018
Merged

Conversation

causztic
Copy link

@causztic causztic commented Jun 8, 2018

Currently on rails error pages, the change of the binding when clicking on the Trace links is not very visible to users.

This PR will add a notification div that will notify the user the current binding that the user is working with in the console.

It uses a simple callback with the anchor's innerHTML and displays it above the last prompt-box.

screen shot 2018-06-08 at 11 34 31 am

@rails-bot
Copy link

r? @gsamokovarov

(@rails-bot has picked a reviewer for you, use r? to override)

// Change the binding of the console
/**
* Change the binding of the console
* Also updates a div to show that it has been changed.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This may change, maybe we won't win a lot by changing the comment here.

Copy link
Author

Choose a reason for hiding this comment

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

Makes sense, I'll revert the change here

var notification = document.createElement('div');
var _this = this;

notification.className = "console-notification";
Copy link
Collaborator

Choose a reason for hiding this comment

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

var notification = document.createElement('div');
notification.className = "console-notification";

var _this = this;
postRequest(url, params, function() {

Can we keep the flow like this here? The operations are "grouped" this way.

Copy link
Author

Choose a reason for hiding this comment

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

sure!


notification.className = "console-notification";
postRequest(url, params, function() {
notification.innerHTML = "Binding has changed to: " + callback();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm thinking whether we call this Context has changed to: because we cannot expect the web console users to know about bindings or the terminology around how code evaluation works in Ruby.

Copy link
Author

Choose a reason for hiding this comment

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

I initially had it as Context as well but renamed it last minute. I guess I can change it back! I agree it sounds more "intuitive" for people using web-console.

@@ -3,6 +3,8 @@
<div class='console-actions'>
<div class='close-button button' title='close'>x</div>
</div>
<div class='console-inner'></div>
<div class='console-inner'>
<div class='console-notifications'></div>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really need the extra layout here? What's so special about the notifications, they look like a regular console line to me.

Copy link
Author

Choose a reason for hiding this comment

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

Initially I had the console-notifications set to be updated whenever the binding changes, but it will disappear out of the scrolling window when the commands exceeds the scrollable view.

I have changed it to append before the lastChild of the prompt-box so that it remains in view, but I forgot to remove the unused console-notifications div. It is now removed!

REPLConsole.prototype.switchBindingTo = function(frameId, callback) {
var url = this.getSessionUrl('trace');
var params = "frame_id=" + encodeURIComponent(frameId);
postRequest(url, params, callback);
var notification = document.createElement('div');
notification.className = "console-notification";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to just feed a new input line?

Copy link
Author

Choose a reason for hiding this comment

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

Currently the default unclassed console text color is black so it won't be visible. I can remove the div but the console text color will need to be changed

@causztic
Copy link
Author

I have refactored the writeOutput and writeError into a write function accepting type and output.

Also introduced a notification type for binding switches and used a complementary colour against the current error colour.

Also made all colour codes consistent.

@causztic
Copy link
Author

Reverted the refactoring and added an extra prototype function for writeNotifications instead.

@@ -3,6 +3,7 @@
<div class='console-actions'>
<div class='close-button button' title='close'>x</div>
</div>
<div class='console-inner'></div>
<div class='console-inner'>
Copy link
Collaborator

Choose a reason for hiding this comment

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

We may drop this diff change as well, e.g. leave it as before:

<div class='console-inner'></div>

@@ -595,13 +595,19 @@ REPLConsole.prototype.writeOutput = function(output) {
this.inner.appendChild(consoleMessage);
this.newPromptBox();
return consoleMessage;
};
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This one too, leave the };, so we don't have this one pop-up in the diff.


REPLConsole.prototype.writeError = function(output) {
var consoleMessage = this.writeOutput(output);
addClass(consoleMessage, "error-message");
return consoleMessage;
};
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here.

var consoleMessage = this.writeOutput(output);
addClass(consoleMessage, "notification-message");
return consoleMessage;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants