-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(www): add alternate link in farsi #1442
Conversation
8f4ab9c
to
323d9b9
Compare
323d9b9
to
a4deeb7
Compare
fbec6fd
to
4a76996
Compare
inner-h-t-m-l="[[localize('server-create-your-own', 'breakLine', '<br/>', 'openLink', '<a href=https://s3.amazonaws.com/outline-vpn/index.html>', 'closeLink', '</a>')]]" | ||
></div> | ||
<div | ||
id="addServerFooterAlt" | ||
hidden$="[[!showAltAccessMessage]]" |
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 approach is problematic because the both templates will be rendered. It pollutes the DOM, causes subtle bugs if you reuse ids and one of them may crash with missing messages.
Use instead: https://polymer-library.polymer-project.org/3.0/docs/devguide/templates#dom-if
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.
After chatting with @jyyi1 I switched this to use dom-if in servers_view/index.ts
but not here. _inputInvalidChanged
here is already relying on the hidden
property in an inadvisable way. But we can't stop using it here without breaking or entirely refactoring that code.
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.
Welcome to developing in the client @ohnorobo !!!!
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.
@fortuna I have a proposal in my comment below, which can simplify the logic in _inputInvalidChanged
. And you will also be able to use dom-if
as well because we will not reference any specific elements in the function. But it requires more code changes. Depending on the workload, we can either refactor it later or do it now.
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.
done
src/www/views/servers_view/index.ts
Outdated
@@ -108,8 +108,14 @@ Polymer({ | |||
</div> | |||
<div | |||
class="footer subtle" | |||
hidden$="[[showAltAccessMessage]]" |
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.
Ditto. Also for the changes below.
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.
Done
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've also replaced two unrelated uses of hidden
in this component with dom-if.
src/www/ui_components/app-root.js
Outdated
@@ -540,6 +540,10 @@ export class AppRoot extends mixinBehaviors([AppLocalizeBehavior], PolymerElemen | |||
toastUrl: { | |||
type: String, | |||
}, | |||
showAltAccessMessage: { | |||
type: Boolean, | |||
computed: '_computeShowAltAccessMessage()', |
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.
You need to express the dependency on the language so it gets recomputed on change.
computed: '_computeShowAltAccessMessage()', | |
computed: '_computeShowAltAccessMessage(language)', |
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.
Please test the behavior change on language change.
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.
done, this definitely fixed some of the weirdness on language change
this.$.invalidAccessKeyFooter.hidden = false; | ||
} else { | ||
this.$.addServerFooter.hidden = false; | ||
this.$.addServerFooter.hidden = false || this.showAltAccessMessage; |
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.
@daniellacosse I feel this logic is not prefect. We may introduce a new boolean
property accessKeyValid
in this element, and update it in this function. In this case, we don't need to reference any specific elements, those elements can bind to this new property, for example, <div id="addServerFooterAlt" hidden$="[[!accessKeyValid || !showAltAccessMessage]]" />
. Just a potential action item, no need to change it in this PR, but we may refactor it later.
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.
That aligns with my suggestion. A variable that indicates whether to show the invalid key error, or the server suggestion message. 👍🏼
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.
Done.
Added invalidAccessKeyInput
property. I know negative booleans are bad, but the logical split here is (no access key input, valid access key input) vs (invalid access key input) so not using the negative made the logic more confusing.
Unfortunately no boolean logic except !var
is allowed in html, so switching to dom-if required adding two new computed properties and two new functions to contain the boolean logic. I've switched the name of the passed property to useAltAccessMessage
everywhere to avoid confusion with the show...
properties that are being computed in this element.
aeb07a5
to
1fca085
Compare
f6198f0
to
d854db6
Compare
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.
Thanks for the changes!
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.
LGTM, thanks.
@@ -298,15 +320,21 @@ Polymer({ | |||
var input = event.target; | |||
input.toggleClass('input-invalid', input.invalid); | |||
if (input.invalid) { | |||
this.$.addServerFooter.hidden = true; | |||
this.$.invalidAccessKeyFooter.hidden = false; | |||
this.invalidAccessKeyInput = true; |
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.
minor this.invalidAccessKeyInput = input.invalid
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.
done
Add an additional message/link to the empty client screen and new server dialog in Farsi (and not on ios.)
This is just manually adding the new strings in English and Farsi. no other translations exist yet, but it doesn't matter because they're only displayed in Farsi. Eventually we will get additional translations which might be helpful if we ever want to expand the languages for this in the future.
Tested (tests done in EN / FA / IT (to represent all other languages which don't have the translated string)):
ios
/osx
exclusion part of this works.hidden
Zero view FA:
Server add view FA: