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

feat(www): add alternate link in farsi #1442

Merged
merged 7 commits into from
Oct 25, 2022
Merged

feat(www): add alternate link in farsi #1442

merged 7 commits into from
Oct 25, 2022

Conversation

ohnorobo
Copy link
Contributor

@ohnorobo ohnorobo commented Oct 19, 2022

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)):

  • viewing the zero view
  • viewing the server add view
  • inputting a bad ss key in the server add view (to switch to the bad ss key message) and then removing the key to switch back to the access message
  • @kevindamm-jigsaw tested that theios/osx exclusion part of this works.
  • that messages are re-localized/properties recomputed correctly on language change
  • that the zero page / page view with servers still renders correctly without hidden

Zero view FA:
image

Server add view FA:
image

@ohnorobo ohnorobo force-pushed the external-link branch 2 times, most recently from 8f4ab9c to 323d9b9 Compare October 19, 2022 18:22
@daniellacosse daniellacosse changed the title add link in english/farsi feat(www): add link in english/farsi Oct 19, 2022
@ohnorobo ohnorobo changed the title feat(www): add link in english/farsi feat(www): add alternate link in farsi Oct 24, 2022
@ohnorobo ohnorobo force-pushed the external-link branch 5 times, most recently from fbec6fd to 4a76996 Compare October 24, 2022 13:45
@ohnorobo ohnorobo requested a review from a team October 24, 2022 13:52
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]]"
Copy link
Collaborator

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

Copy link
Contributor Author

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.

Copy link
Contributor

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 !!!!

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

src/www/ui_components/add-server-view.js Outdated Show resolved Hide resolved
src/www/ui_components/add-server-view.js Outdated Show resolved Hide resolved
@@ -108,8 +108,14 @@ Polymer({
</div>
<div
class="footer subtle"
hidden$="[[showAltAccessMessage]]"
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor Author

@ohnorobo ohnorobo Oct 25, 2022

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 Show resolved Hide resolved
src/www/messages/en.json Show resolved Hide resolved
@ohnorobo ohnorobo marked this pull request as ready for review October 24, 2022 16:52
src/www/messages/en.json Show resolved Hide resolved
src/www/ui_components/add-server-view.js Show resolved Hide resolved
@@ -540,6 +540,10 @@ export class AppRoot extends mixinBehaviors([AppLocalizeBehavior], PolymerElemen
toastUrl: {
type: String,
},
showAltAccessMessage: {
type: Boolean,
computed: '_computeShowAltAccessMessage()',
Copy link
Collaborator

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.

Suggested change
computed: '_computeShowAltAccessMessage()',
computed: '_computeShowAltAccessMessage(language)',

Copy link
Collaborator

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.

Copy link
Contributor Author

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;
Copy link
Contributor

@jyyi1 jyyi1 Oct 24, 2022

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.

Copy link
Collaborator

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. 👍🏼

Copy link
Contributor Author

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.

src/www/messages/en.json Show resolved Hide resolved
Copy link
Collaborator

@fortuna fortuna left a 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!

Copy link
Contributor

@jyyi1 jyyi1 left a 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;
Copy link
Contributor

@jyyi1 jyyi1 Oct 25, 2022

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@ohnorobo ohnorobo merged commit 0d32b1e into master Oct 25, 2022
@sbruens sbruens deleted the external-link branch March 5, 2024 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants