Skip to content

Conversation

@nickvergessen
Copy link
Member

No description provided.

* 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)) {
Copy link
Member Author

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?

Copy link
Member

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);
Copy link
Member Author

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

Copy link
Member

Choose a reason for hiding this comment

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

*/
initialise: function() {
var data = JSON.parse($('#updatenotification').attr('data-json'));
this.vm = new Vue(OCA.UpdateNotification.Components.Root);
Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

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)

Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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 😉

Copy link
Member Author

Choose a reason for hiding this comment

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

@codecov
Copy link

codecov bot commented Jan 18, 2018

Codecov Report

Merging #7933 into master will increase coverage by 0.09%.
The diff coverage is 57.89%.

@@             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
Impacted Files Coverage Δ Complexity Δ
apps/updatenotification/templates/admin.php 0% <0%> (ø) 0 <0> (ø) ⬇️
...pps/updatenotification/lib/AppInfo/Application.php 7.4% <0%> (ø) 10 <0> (ø) ⬇️
apps/updatenotification/lib/Settings/Admin.php 73.58% <68.75%> (-3.92%) 11 <3> (+3)
settings/Middleware/SubadminMiddleware.php 46.42% <0%> (-46.43%) 12% <0%> (+6%)
...ddleware/Security/Exceptions/NotAdminException.php 66.66% <0%> (-33.34%) 2% <0%> (+1%)
...amework/Middleware/Security/SecurityMiddleware.php 58.18% <0%> (-19.87%) 52% <0%> (+26%)
...e/AppFramework/DependencyInjection/DIContainer.php 68.42% <0%> (-14.31%) 85% <0%> (+31%)
apps/user_ldap/lib/Connection.php 54.74% <0%> (-3.33%) 122% <0%> (+3%)
apps/files_trashbin/lib/Expiration.php 90.32% <0%> (-1.62%) 29% <0%> (ø)
lib/private/L10N/L10N.php 85.96% <0%> (-1.31%) 5% <0%> (+1%)
... and 17 more

* Creates a new authentication token and loads the updater URL
*/
clickUpdaterButton: function() {
$.ajax({
Copy link
Member

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

Copy link
Member Author

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

@nickvergessen
Copy link
Member Author

@skjnldsv

Or better without jQuery: https://github.com/vuejs/awesome-vue#select

I used that now. But the styling of the options and the dropdown needs some adjustments due to css class colisions:

bildschirmfoto von 2018-01-31 10-55-37

can you help with that?

@skjnldsv
Copy link
Member

can you help with that?

giphy

@skjnldsv skjnldsv self-assigned this Jan 31, 2018
@nickvergessen nickvergessen force-pushed the update-notification-vuejs branch from 6dfcaf9 to 18e0204 Compare February 1, 2018 10:09
@nickvergessen nickvergessen force-pushed the update-notification-vuejs branch from 18e0204 to 88f890a Compare February 14, 2018 16:22
@nickvergessen
Copy link
Member Author

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.

@nickvergessen nickvergessen added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Feb 22, 2018
@nickvergessen nickvergessen force-pushed the update-notification-vuejs branch from 88f890a to 6340e78 Compare February 22, 2018 09:22
Signed-off-by: Joas Schilling <[email protected]>
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
@skjnldsv
Copy link
Member

@nickvergessen
capture d ecran_2018-02-22_17-00-33

skjnldsv and others added 2 commits February 22, 2018 17:03
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
Signed-off-by: Joas Schilling <[email protected]>
@nickvergessen
Copy link
Member Author

Works nicely, thanks for the help!

Fixed the unit tests, so now really ready for review

Copy link
Member

@skjnldsv skjnldsv left a comment

Choose a reason for hiding this comment

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

Okay from me

@skjnldsv
Copy link
Member

Test restarted, failure unrelated :)

Signed-off-by: Morris Jobke <[email protected]>
@@ -1,4 +1,4 @@
app_name=notifications
app_name=updatenotification
Copy link
Member

Choose a reason for hiding this comment

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

@nickvergessen I fixed this 😉

Copy link
Member Author

Choose a reason for hiding this comment

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

🙈 thanks

@MorrisJobke MorrisJobke added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Feb 26, 2018
@nickvergessen nickvergessen merged commit abb0a08 into master Feb 26, 2018
@nickvergessen nickvergessen deleted the update-notification-vuejs branch February 26, 2018 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants