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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safe Template Errors Fixes #12741

Merged
merged 1 commit into from
Jun 22, 2016
Merged

Safe Template Errors Fixes #12741

merged 1 commit into from
Jun 22, 2016

Conversation

kevinjkim
Copy link
Contributor

@kevinjkim kevinjkim commented Jun 13, 2016

Description

TNL-4796

Changes to fix the safe template errors in the user account settings/preferences page.

Sandbox

Testing

  • safecommit shows 0 violations
  • Unit, integration, acceptance tests as appropriate

Reviewers

If you've been tagged for review, please check your corresponding box once you've given the 馃憤.

Devops assistance

Don't think I need this

FYI: @robrap

Post-review

  • Squash commits

@kevinjkim kevinjkim force-pushed the kkim/safe_template branch 2 times, most recently from 2d0abfd to 3bcf3c7 Compare June 14, 2016 18:51
@@ -41,10 +41,11 @@
EmailFieldView: FieldViews.TextFieldView.extend({
fieldTemplate: field_text_account_template,
successMessage: function () {
return this.indicators.success + StringUtils.interpolate(
return HtmlUtils.joinHtml(
this.indicators.success, StringUtils.interpolate(
Copy link
Contributor

@robrap robrap Jun 15, 2016

Choose a reason for hiding this comment

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

I would rename all the indicators from indicators.success to indicators.successHtml.
Also, could you put StringUtils.interpolate() param on the next line, indented with the first parameter?
Note: I cleaned up these comments once I reviewed the indicators.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this.indicators.success does contain HTML. It didn't give any errors in the safe template run, but once I started to change other things around, this didn't work as is.

@robrap
Copy link
Contributor

robrap commented Jun 15, 2016

@kevinjkim Nice start. Thanks. I made a first pass.

@kevinjkim kevinjkim force-pushed the kkim/safe_template branch 2 times, most recently from 94c6df8 to 7fadff7 Compare June 15, 2016 18:14
},

showCanEditMessage: function(show) {
if (!_.isUndefined(show) && show) {
this.showNotificationMessage(this.getMessage('canEdit'));
this.showNotificationMessage(this.getMessageHTML('canEdit'));
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. I don't know if I'd rename getMessage to getMessageHTML without renaming all the others. I don't like the idea of having 2 methods, getMessage and getMessageHTML.
  2. If we did keep getMessageHTML, it should be getMessageHtml.

@kevinjkim
Copy link
Contributor Author

jenkins run js

},

showSuccessMessage: function () {
var successMessage = this.getMessage('success');
this.showNotificationMessage(successMessage);
this.showNotificationMessage(this.getMessageHTML('success'));
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did this function need to change? As is, the variable successMessage is set and then unused. Maybe you should just change the earlier line to the following, if you just wanted the name change:

var successMessage = this.getMessageHtml('success');

@andy-armstrong
Copy link
Contributor

@kevinjkim I don't know how you would feel about this, but I'm wondering if you could take over my PR too since it is resolving a lot of the same issues. I never seem to have time to get back to it:

https://github.com/edx/edx-platform/pull/11856

@jcdyer
Copy link
Contributor

jcdyer commented Jun 20, 2016

@andy-armstrong We might be able to get @kevinjkim working on that issue, but we need to get the time zone work merged first. It might be another sprint before we can get him started on it.

@@ -116,8 +141,8 @@
},

showSuccessMessage: function () {
var successMessage = this.getMessage('success');
this.showNotificationMessage(successMessage);
var successMessage = this.getMessage('success').toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this line be deleted?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1, why are we calling getMessage('success') twice in succession here? Either remove this line, or use the variable in the following line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently, this.getMessage() returns a HtmlSnippet while view.getNotificationMessage() returns a string. Additionally, showNotificationMessage() takes a HtmlSnippet which is why line 145 has the repeated getMessage() call since line 144 has the toString() call.

  1. I could have both getMessage() and getNotificationMessage() return a string, but then showNotificationMessage() would have to change all strings to HtmlSnippets.
  2. I could have both getMessage() and getNotificationMessage() return a HtmlSnippet, but the functions sound like they should return strings instead of HTML code.

Which would you guys prefer?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see. They should definitely be standardized to be the same thing I think. Is there actual html content in the return value of getMessage()? If so, HtmlSnippets would be best, but if there's no html to be seen, strings would be easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

getMessage() does have html so i'll go with HtmlSnippets.

HtmlUtils.joinHtml(
view.indicators.error,
gettext('You must sign out and sign back in ' +
'before your language changes take effect.')
Copy link
Contributor

Choose a reason for hiding this comment

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

This sentence needs to remain all on one line to ensure correct translation. If that's causing line-too-long quality failures, you can make an exception in jshint like this: https://github.com/edx/edx-platform/blob/master/lms/static/js/certificates/views/certificate_invalidation_view.js#L49

@efischer19
Copy link
Contributor

Looking good so far. Is there a sandbox up? The biggest thing I've found with these types of PRs is manual confirmation of the affected pages after fixing linter errors.

@kevinjkim
Copy link
Contributor Author

No sandbox yet. I'll make one after we decide what to do with the getMessage/getNotificationMessage thing.

@kevinjkim
Copy link
Contributor Author

sandbox up

@efischer19
Copy link
Contributor

Sandbox looks good, I was able to click around all the affected pages and everything seemed to load fine, no js errors.

馃憤 , assuming the coveralls failure goes away after squash/rebasing. LMK if you need a hand with that.

@jcdyer
Copy link
Contributor

jcdyer commented Jun 22, 2016

馃憤 Don't forget to squash.

@efischer19 This branch is not merging to master, but back to the main feature branch, which has its own PR. I think the coverage issue can be resolved on that branch.

@efischer19
Copy link
Contributor

Right on, sounds like a plan

@kevinjkim kevinjkim merged this pull request into kkim/tz_pref_AS Jun 22, 2016
@kevinjkim kevinjkim deleted the kkim/safe_template branch June 22, 2016 17:28
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.

None yet

5 participants