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

[Vue] migrate siteselector directive and quick-access directive #18292

Merged
merged 156 commits into from Nov 19, 2021

Conversation

diosmosis
Copy link
Member

@diosmosis diosmosis commented Nov 11, 2021

Description:

This PR is based off of #18225.

This PR has a breaking change to createAngularAdapter() so other Vue PRs in progress may need to be modified (unless they are merged before this, then I'll fix the conflicts here).

Changes:

  • Add typescript types for mousetrap library.
  • deprecate autocomplete-matched as it's trivial to implement in siteselector and is not used anywhere else.
  • in broadcast.propagateNewPage() add extra parameter for supplying the entire new URL to load. in this case, it does not build the URL using other parameters.
  • add a MatomoUrl.updateUrl() method that reloads the entire URL (search + hash)
  • make sure promise returned by AjaxHelper.fetch has an abort() method
  • in createAngularAdapter() add vue instance to the event handler functions and postCreate(). this is so ngModel could be connected to v-model in Vue.
  • migrated the siteselector directive.
  • migrated the quick-access directive.
  • migrated the siteselector-model service as the SitesStore. This is shared between quick-access and siteselector. The only state that's shared is the initial list of sites that is loaded once, unlike currently where the list of currently displayed sites is also shared between the two directives.
  • in createAngularAdapter() allow specifying a require: field to the angularjs directive that is created.
  • add the ability to transform values when binding from angularjs => vue (for example, converting values to booleans, as in noclear for siteselector)
  • disable webpack asset size hints (since our assets are already bigger at the end than what is recommended by webpack).
  • when changing sites, removed the showAjaxLoading = false parameter so MatomoUrl.updateUrl() will stay simple. Doesn't seem to have much of an effect IMO so I think it's ok.

image

Review

…se v-model, add event parameters to createAngularAdapter, allow translate to use variadic args or one string array + rebuild
…ndling to just reset back to the previous date since it was easier in vue to do that)
Copy link
Contributor

@peterhashair peterhashair left a comment

Choose a reason for hiding this comment

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

That works for me perfectly, maybe still need to do resolve conflicts, also just a tiny suggestion maybe on key up autocomplete event maybe we need a debounce.

} else if (isEscKey && areSearchResultsDisplayed) {
this.deactivateSearch();
} else {
setTimeout(() => {
Copy link
Member Author

Choose a reason for hiding this comment

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

There wasn't one before but we can add one.

} else if (isEscKey && areSearchResultsDisplayed) {
this.deactivateSearch();
} else {
setTimeout(() => {
Copy link
Member Author

Choose a reason for hiding this comment

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

There wasn't one before but we can add one.

@peterhashair
Copy link
Contributor

@diosmosis also I got an question for function naming.
like that one, do we need a camel case?

export { default as Menudropdown } from './Menudropdown/Menudropdown.vue';

@diosmosis
Copy link
Member Author

I got an question for function naming. like that one, do we need a camel case?

Yes, that would probably be better 👍

@diosmosis diosmosis marked this pull request as draft November 16, 2021 23:47
@diosmosis
Copy link
Member Author

converted to draft so it won't get merged until after the 4.6.0 release

@justinvelluppillai
Copy link
Contributor

converted to draft so it won't get merged until after the 4.6.0 release

PRs merged to 4.x-dev won't be released in 4.6.0

@diosmosis
Copy link
Member Author

@justinvelluppillai ok, removing draft status

@diosmosis diosmosis marked this pull request as ready for review November 17, 2021 01:46
Copy link
Contributor

@peterhashair peterhashair left a comment

Choose a reason for hiding this comment

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

looks good to me.

@sgiehl
Copy link
Member

sgiehl commented Nov 17, 2021

@diosmosis I'm currently doing some local testing of the changes. Will leave some more comments when I find something else.

  • It seems the search results in site selector are not escaped correctly. I have a website with the name <a href="#">?</a>, it displays correctly when listed on opening the siteselector. But when searching, it is only displayed as ?, the html tags seems to be inserted. So maybe a script tag might evaluate here as well.

    Note: In quick search that seems to work correctly.

  • When I type something into the search box in site selector and then click on the input field again, the field either looses it's content (if the request is still pending), or it sometimes even disappears (when the request had finished)

  • Pressing the f key highlights the quick search visually, but doesn't give the input box the focus anymore

  • Pressing the w key opens and highlights the site selector visually, but doesn't give the input box the focus anymore

  • Unrelated to the changes here. But pressing d doesn't open the date picker any longer. Maybe that's due to other vue changes before

@diosmosis
Copy link
Member Author

So maybe a script tag might evaluate here as well.

It's sanitized so dangerous HTML is removed. The other html I guess isn't being escaped properly.

@diosmosis
Copy link
Member Author

It seems the search results in site selector are not escaped correctly. I have a website with the name ?, it displays correctly when listed on opening the siteselector. But when searching, it is only displayed as ?, the html tags seems to be inserted. So maybe a script tag might evaluate here as well.

Can you check again? this is working for me:

image

When I type something into the search box in site selector and then click on the input field again, the field either looses it's content (if the request is still pending), or it sometimes even disappears (when the request had finished)

Looks like there's a bug in the original code. Should be fixed in the vue PR now.

Pressing the f key highlights the quick search visually, but doesn't give the input box the focus anymore

Fixed.

Pressing the w key opens and highlights the site selector visually, but doesn't give the input box the focus anymore

Fixed.

Unrelated to the changes here. But pressing d doesn't open the date picker any longer. Maybe that's due to other vue changes before

Found the issue, will fix in PR to next_release.

@sgiehl
Copy link
Member

sgiehl commented Nov 18, 2021

@diosmosis hm. funny. It works when searching for ? for me as well. But when searching for any letter that actually isn't in the site's name, it doesn't.

image

@sgiehl sgiehl modified the milestones: 4.6.0, 4.7.0 Nov 18, 2021
@diosmosis
Copy link
Member Author

@sgiehl should be fixed. Looks like the issue only occurred when searching for html entity letters (eg, searching for gt which in the backend will match &lt;img onsrc...).

@sgiehl sgiehl removed the Needs Review PRs that need a code review label Nov 19, 2021
Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

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

works now 👍

@sgiehl sgiehl merged commit 5ae81f8 into 4.x-dev Nov 19, 2021
@sgiehl sgiehl deleted the vue-siteselector branch November 19, 2021 14:18
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

4 participants