-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Safe Template Errors Fixes #12741
Safe Template Errors Fixes #12741
Conversation
2d0abfd
to
3bcf3c7
Compare
@@ -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( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@kevinjkim Nice start. Thanks. I made a first pass. |
94c6df8
to
7fadff7
Compare
}, | ||
|
||
showCanEditMessage: function(show) { | ||
if (!_.isUndefined(show) && show) { | ||
this.showNotificationMessage(this.getMessage('canEdit')); | ||
this.showNotificationMessage(this.getMessageHTML('canEdit')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I don't know if I'd rename
getMessage
togetMessageHTML
without renaming all the others. I don't like the idea of having 2 methods,getMessage
andgetMessageHTML
. - If we did keep
getMessageHTML
, it should begetMessageHtml
.
jenkins run js |
}, | ||
|
||
showSuccessMessage: function () { | ||
var successMessage = this.getMessage('success'); | ||
this.showNotificationMessage(successMessage); | ||
this.showNotificationMessage(this.getMessageHTML('success')); |
There was a problem hiding this comment.
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');
@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: |
@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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
- I could have both
getMessage()
andgetNotificationMessage()
return a string, but thenshowNotificationMessage()
would have to change all strings to HtmlSnippets. - I could have both
getMessage()
andgetNotificationMessage()
return a HtmlSnippet, but the functions sound like they should return strings instead of HTML code.
Which would you guys prefer?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.') |
There was a problem hiding this comment.
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
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. |
No sandbox yet. I'll make one after we decide what to do with the getMessage/getNotificationMessage thing. |
sandbox up |
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. |
👍 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. |
Right on, sounds like a plan |
6eea7b6
to
ed9e1eb
Compare
Description
TNL-4796
Changes to fix the safe template errors in the user account settings/preferences page.
Sandbox
https://kevinjkim.sandbox.edx.org/
Testing
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