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 #95

Merged
merged 8 commits into from
Jan 26, 2018
Merged

Vue #95

merged 8 commits into from
Jan 26, 2018

Conversation

nickvergessen
Copy link
Member

@nickvergessen nickvergessen commented Oct 20, 2017

@georgehrke mind having a look at the Vue stuff? I think it was pretty easy and straight forward after reading the docs

Fix #2


Todos:

  • Migrate JS to Vue.JS
  • Use webpack to manage the JS
  • Change .js files to .vue files (HTML not in strings and phpstorm support)
    • Reactivate actions and deleting
  • Add make file to development
  • Clarify with @MorrisJobke how we can do this for packaging.

@nickvergessen
Copy link
Member Author

Rebased on top of the latest changes
@MariusBluem feel free to test it.

@MorrisJobke
Copy link
Member

@nickvergessen Do we really want it in 13 or wait for 14?

@nickvergessen
Copy link
Member Author

I don't care too much, it comes with the nice addition that the icon is now always visible and there is a decent empty content view.

But yeah it's a complete rewrite of the js.

@MariusBluem
Copy link
Member

@nickvergessen Do we really want it in 13 or wait for 14?

13 please since having the bell always would be ❤️ for the release 😄

With empty content it looks nice, but when you have notfications, the UI is a bit broken (at least on Safari) ...

  • not possible to close a notification
  • style is broken:

bildschirmfoto 2018-01-08 um 13 53 11

@MorrisJobke
Copy link
Member

13 please since having the bell always would be ❤️ for the release 😄

We only have the RC stage left and I would avoid to bring in completely rewritten code that late. :/

Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen
Copy link
Member Author

@ChristophWurst can you check the last commit, is that correct?

If so we need to discuss with @MorrisJobke how we do that for shipped apps?
Add a special command to a make file?

@@ -7,6 +7,8 @@
* later. See the COPYING file.
*/

require('./notification');
Copy link
Member

Choose a reason for hiding this comment

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

Actually, the intended use is that the require call returns the module. The way you're using it webpack will load the module, but the module then just registers some stuff in a global variable which you later access. This is kinda hacky and error-prone.

I don't know if it's easy to migrate here, but get rid of the OCA.XXX = xxx stuff. Don't use those globals and instead, have webpack locate the module and inside the module you export whatever you previously registered as global variable.

Does that make sense? :)

Copy link
Member

Choose a reason for hiding this comment

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

See nextcloud/twofactor_u2f@ae4fe1c#diff-ccd4d3da9150404f0f6690291ba3add9 as an example. The view class is exported because it's the returned value of the module definition.

Copy link
Member Author

Choose a reason for hiding this comment

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

Worked fine for the components I think.
in app.js the exporting to OCA.Notifications is okay I guess?

Copy link
Member

Choose a reason for hiding this comment

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

in app.js the exporting to OCA.Notifications is okay I guess?

Is OCA.Notifications used elsewhere, outside of this app?

Copy link
Member

Choose a reason for hiding this comment

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

If not, how about making app.js a module like the other components which you then load in a init.js script where you start the app like

define(function(require) {
    'use strict';

    var $ = require('jquery')
    var App = require('./app')

    $(function() {
        var app = new App()
        app.initialize()
    })
})

Copy link
Member Author

Choose a reason for hiding this comment

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

ReferenceError: define is not defined

😢

Copy link
Member Author

Choose a reason for hiding this comment

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

is reported for app.js but I dont get why :/

Copy link
Member

Choose a reason for hiding this comment

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

Hmmmm but you don't include the app.js file directly, right? It's bundled with webpack.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, tested it a bit, when I remove import Vue from 'vue'; it works. should I move that somewhere else, or replace it with a different call?

@ChristophWurst
Copy link
Member

Yeah, tested it a bit, when I remove import Vue from 'vue'; it works. should I move that somewhere else, or replace it with a different call?

Yes, correct. Just cloned this branch and you're apparently mixing module syntax. The import … syntax is ES6, while define … is commonjs module syntax.

Use var Vue = require('vue'); instead.

@nickvergessen
Copy link
Member Author

Use var Vue = require('vue'); instead.

TypeError: e is not a constructor

When I do require('vue'); I get ReferenceError: Vue is not defined

@ChristophWurst
Copy link
Member

vuejs/vue#5470 (comment) maybe

@nickvergessen
Copy link
Member Author

That worked, squashed it all

Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen
Copy link
Member Author

@MorrisJobke make package should be ready for testing.
Can you also check that strings are correctly extracted from .vue files?

OC.Notification.showTemporary(t('notifications', 'Failed to dismiss notification'));
is a new string

}
</script>

<style scoped>
Copy link
Member

Choose a reason for hiding this comment

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

I guess you can omit the style tag if it's unused

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, tested and done

@nickvergessen
Copy link
Member Author

nickvergessen commented Jan 24, 2018

Last two thing I don't understand:

  • it always generates a js/merged.js.map file.
    Since we don't load that with script() I think we don't need to ship it.
    Can we also stop generating it? And if so, how?

  • Currently it seems to always package the dev version of vue, as per console:

    You are running Vue in development mode.
    Make sure to turn on production mode when deploying for production.
    See more tips at https://vuejs.org/guide/deployment.html
    

    Can that be easily adjusted for the package?

Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen nickvergessen force-pushed the vue branch 2 times, most recently from 3687744 to d1d788a Compare January 24, 2018 10:11
Signed-off-by: Joas Schilling <coding@schilljs.com>
@ChristophWurst
Copy link
Member

it always generates a js/merged.js.map file.
Since we don't load that with script() I think we don't need to ship it.
Can we also stop generating it? And if so, how?

They are very useful for debugging, e.g. when people report errors on the client-side, the browser will otherwise not be able to tell you where the error occurred in your respective source file. Hence, it will just show error on line 254485 -> not helpful at all.
To my understanding the browser will load this automatically and webpack should add a source map comment to your bundled script file: https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Use_a_source_map

@nickvergessen
Copy link
Member Author

They are very useful for debugging, e.g. when people report errors on the client-side, the browser will otherwise not be able to tell you where the error occurred in your respective source file. Hence, it will just show error on line 254485 -> not helpful at all.
To my understanding the browser will load this automatically and webpack should add a source map comment to your bundled script file: https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Use_a_source_map

Ah okay, so we will keep it and ship it. Fine by me, just didnt know what this is about

Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen
Copy link
Member Author

Fixed the vue dev issue, although that should work automatically as per https://vuejs.org/v2/guide/deployment.html
However, it did not, so now I build in a hard coded switch for it.

Ready to review and merge:
@ChristophWurst @MorrisJobke @georgehrke @juliushaertl

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Code looks good so far, didn't test though

--exclude=/.drone.yml \
--exclude=/node_modules \
--exclude=/npm-debug.log \
--exclude=/package.json \
Copy link
Member

Choose a reason for hiding this comment

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

if you're using an up-to-date version of npm, it will generate a package-lock.json. You might want to exclude that too.

Copy link
Member Author

Choose a reason for hiding this comment

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

dont have that on npm 5.6.0

Copy link
Member

Choose a reason for hiding this comment

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

Okay, maybe it's just generated if you use npm install --save xxx or similar https://docs.npmjs.com/files/package-lock.json

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm let me add this, so everyone is installing the same stuff?

Copy link
Member

Choose a reason for hiding this comment

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

Exactly, it locks down the exact version number, just like composer does with composer.lock

Copy link
Member

Choose a reason for hiding this comment

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

Oh, and it speeds up npm install as npm doesn't have to build the dependency graph 👍

package.json Outdated
"vue": "^2.5.13"
},
"devDependencies": {
"babel-core": "^6.26.0",
Copy link
Member

Choose a reason for hiding this comment

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

not sure if you actually need/use babel. Looks like it's all ES5 and thus can be run in all our supported browsers.

package.json Outdated
"vue-loader": "^13.7.0",
"vue-template-compiler": "^2.5.13",
"webpack": "^3.6.0",
"webpack-dev-server": "^2.11.0"
Copy link
Member

Choose a reason for hiding this comment

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

dev-server is probably not needed and can be removed

Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Copy link
Member

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

Copy link
Member

@MariusBluem MariusBluem left a comment

Choose a reason for hiding this comment

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

Tested. Works 👍

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.

4 participants