-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Migrate Update notifications to Vue.js #7933
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
Conversation
| * This file is licensed under the Affero General Public License version 3 or | ||
| * later. See the COPYING file. | ||
| */ | ||
| if (\OC::$server->getConfig()->getSystemValue('debug', false)) { |
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 we add a helper method for this block? or not worth it?
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.
Makes sense from my POV. I've seen this more and more in apps to get some kind of debug setup for JS code.
| }, | ||
|
|
||
| updated: function () { | ||
| OC.Settings.setupGroupsSelect(this._$notifyGroups); |
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.
Saving is currently not working, need to look into migrating this to:
https://vuejs.org/v2/examples/select2.html
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.
Or better without jQuery: https://github.com/vuejs/awesome-vue#select
apps/updatenotification/js/admin.js
Outdated
| */ | ||
| initialise: function() { | ||
| var data = JSON.parse($('#updatenotification').attr('data-json')); | ||
| this.vm = new Vue(OCA.UpdateNotification.Components.Root); |
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.
@nextcloud/javascript How can I make sure this uses the version we load from the updatenotification/js/vue.js instead of the version from e.g. mail?
Or how do we handle this, when there are multiple different versions on one instance because of multiple apps?
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.
Other apps should only load a library like vue when they are in control over the current route. I don't see a reason why the vue version from e.g. mail would be loaded on the settings page for updates.
Maybe it might make sense to have a common vue shipped with the server so that at least all settings / shipped apps can use the same without having to much library code being distributed across them.
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.
Other apps should only load a library like vue when they are in control over the current route. I don't see a reason why the vue version from e.g. mail would be loaded on the settings page for updates.
Works, until you have an app like notifications, which is loaded on each logged in page that shows the header.
Also in this app, it's loaded in the admin settings. A second app could register for the same section and it would be loaded twice again.
That is why I wondered if we should ship a version in core instead, ref #2692 (comment)
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.
Shipping a version in core has the disadvantage, that it get's hard to update. Is there no way to load your stuff totally isolated in it's own namespace and not polluting the global namespace?
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.
Shipping a version in core has the disadvantage, that it get's hard to update. Is there no way to load your stuff totally isolated in it's own namespace and not polluting the global namespace?
Sure. Just use a bundling tool like webpack and you'll get a single .js file that contains all your app+vendor scripts without interfering with the global libraries. This way, we ship our own, up-to-date version of jQuery, Backbone and Underscore in mail.
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.
Further, this a more general question. The vue library with compiler is quite big. Using webpack et. al. also removes the need for the compiler. These two parts speed up the 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.
https://github.com/nextcloud/twofactor_u2f/pull/74/files could be a reference PR where I also converted an app using simple global scripts to webpack.
Basically you need the following
- npm config to define and download your dependencies
- webpack config for bundling (with one or more entrypoints)
- migrate scripts to modules
Since this will introduce another build step, do you plan to commit the build artifacts?
FYI: If not, people will have to run the build script themselves to use the app. If you do, then it will cause problems with merge conflicts, rebases and git bisects where the built bundle is outdated.
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.
How can we keep the easy development setup then? It would add an additional step to build the js code, which we always tried to avoid for the server part in the past.
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.
How can we keep the easy development setup then? It would add an additional step to build the js code, which we always tried to avoid for the server part in the past.
Correct. And we should discuss this in a separate ticket 😉
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.
Codecov Report
@@ Coverage Diff @@
## master #7933 +/- ##
============================================
+ Coverage 51.75% 51.85% +0.09%
- Complexity 25370 25450 +80
============================================
Files 1601 1602 +1
Lines 95012 95256 +244
Branches 1377 1379 +2
============================================
+ Hits 49178 49394 +216
- Misses 45834 45862 +28
|
| * Creates a new authentication token and loads the updater URL | ||
| */ | ||
| clickUpdaterButton: function() { | ||
| $.ajax({ |
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.
FYI I'd suggest to use js promises that actually allow you to nicely chain async method calls like these here and avoid the callback hell.
Then it would be something like
$.ajax(…)
.then(function(data) {
…
})
.then(function(data) {
…
})
.catch(function(e) {
… handle error …
})
I also did this in the u2f app where lots of async calls are necessary
https://github.com/nextcloud/twofactor_u2f/blob/796ea5495a3c7bc86b4e0956df98a20877a7845e/js/settingsview.js#L205-L223
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, will have a look. At the moment this is just a copy paste of the original
0d06988 to
6dfcaf9
Compare
I used that now. But the styling of the options and the dropdown needs some adjustments due to css class colisions: can you help with that? |
6dfcaf9 to
18e0204
Compare
18e0204 to
88f890a
Compare
|
Maybe we can merge this with the CSS problem, so I can continue with merging the "Can I update?" app before we start with the Nextcloud 14 features. |
Signed-off-by: Joas Schilling <[email protected]>
Signed-off-by: Joas Schilling <[email protected]>
Signed-off-by: Joas Schilling <[email protected]>
Signed-off-by: Joas Schilling <[email protected]>
Signed-off-by: Joas Schilling <[email protected]>
88f890a to
6340e78
Compare
Signed-off-by: Joas Schilling <[email protected]>
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
Signed-off-by: Joas Schilling <[email protected]>
|
Works nicely, thanks for the help! Fixed the unit tests, so now really ready for review |
skjnldsv
left a comment
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.
Okay from me
|
Test restarted, failure unrelated :) |
Signed-off-by: Morris Jobke <[email protected]>
| @@ -1,4 +1,4 @@ | |||
| app_name=notifications | |||
| app_name=updatenotification | |||
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.
@nickvergessen I fixed this 😉
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



No description provided.