diff --git a/.babelrc b/.babelrc --- a/.babelrc +++ b/.babelrc @@ -6,5 +6,5 @@ } }] ], - "plugins": ["transform-object-rest-spread"] + "plugins": ["transform-object-rest-spread"] } diff --git a/grunt_config.json b/grunt_config.json --- a/grunt_config.json +++ b/grunt_config.json @@ -16,7 +16,7 @@ "main": { "expand": true, "cwd": "bower_components", - "src": "webcomponentsjs/webcomponents*.*", + "src": "webcomponentsjs/*.*", "dest": "<%= dirs.js.dest %>/vendors" } }, diff --git a/rhodecode/public/js/src/components/rhodecode-app/rhodecode-app.html b/rhodecode/public/js/src/components/rhodecode-app/rhodecode-app.html --- a/rhodecode/public/js/src/components/rhodecode-app/rhodecode-app.html +++ b/rhodecode/public/js/src/components/rhodecode-app/rhodecode-app.html @@ -17,9 +17,14 @@ var ccLog = Logger.get('RhodeCodeApp'); ccLog.setLevel(Logger.OFF); - var rhodeCodeApp = Polymer({ - is: 'rhodecode-app', - attached: function () { + class RhodecodeApp extends Polymer.Element { + + static get is() { + return 'rhodecode-app'; + } + + connectedCallback() { + super.connectedCallback(); ccLog.debug('rhodeCodeApp created'); $.Topic('/notifications').subscribe(this.handleNotifications.bind(this)); $.Topic('/favicon/update').subscribe(this.faviconUpdate.bind(this)); @@ -37,46 +42,47 @@ $(document).ready(function () { this.kickoffChannelstreamPlugin(); }.bind(this)); - }, + } - initPlugins: function(){ + initPlugins() { for (var i = 0; i < window.APPLICATION_PLUGINS.length; i++) { var pluginDef = window.APPLICATION_PLUGINS[i]; - if (pluginDef.component){ + if (pluginDef.component) { var pluginElem = document.createElement(pluginDef.component); this.shadowRoot.appendChild(pluginElem); - if (typeof pluginElem.init !== 'undefined'){ + if (typeof pluginElem.init !== 'undefined') { pluginElem.init(); } } } - }, + } + /** proxy to channelstream connection */ - getChannelStreamConnection: function () { + getChannelStreamConnection() { return this.$['channelstream-connection']; - }, + } - handleNotifications: function (data) { + handleNotifications(data) { var elem = document.getElementById('notifications'); - if(elem){ + if (elem) { elem.handleNotification(data); } - }, + } - faviconUpdate: function (data) { + faviconUpdate(data) { this.shadowRoot.querySelector('rhodecode-favicon').counter = data.count; - }, + } /** opens connection to ws server */ - kickoffChannelstreamPlugin: function (data) { + kickoffChannelstreamPlugin(data) { ccLog.debug('kickoffChannelstreamPlugin'); var channels = ['broadcast']; var addChannels = this.checkViewChannels(); for (var i = 0; i < addChannels.length; i++) { channels.push(addChannels[i]); } - if (window.CHANNELSTREAM_SETTINGS && CHANNELSTREAM_SETTINGS.enabled){ + if (window.CHANNELSTREAM_SETTINGS && CHANNELSTREAM_SETTINGS.enabled) { var channelstreamConnection = this.getChannelStreamConnection(); channelstreamConnection.connectUrl = CHANNELSTREAM_URLS.connect; channelstreamConnection.subscribeUrl = CHANNELSTREAM_URLS.subscribe; @@ -90,9 +96,9 @@ $.Topic('/connection_controller/subscribe').processPrepared(); channelstreamConnection.connect(); } - }, + } - checkViewChannels: function () { + checkViewChannels() { // subscribe to different channels data is sent. var channels = []; @@ -110,10 +116,10 @@ } return channels; - }, + } /** subscribes users from channels in channelstream */ - subscribeToChannelTopic: function (channels) { + subscribeToChannelTopic(channels) { var channelstreamConnection = this.getChannelStreamConnection(); var toSubscribe = channelstreamConnection.calculateSubscribe(channels); ccLog.debug('subscribeToChannelTopic', toSubscribe); @@ -129,34 +135,35 @@ } } } - }, + } /** publish received messages into correct topic */ - receivedMessage: function (event) { + receivedMessage(event) { for (var i = 0; i < event.detail.length; i++) { var message = event.detail[i]; if (message.message.topic) { ccLog.debug('publishing', message.message.topic); $.Topic(message.message.topic).publish(message); } - else if (message.type === 'presence'){ + else if (message.type === 'presence') { $.Topic('/connection_controller/presence').publish(message); } else { ccLog.warn('unhandled message', message); } } - }, + } - handleConnected: function (event) { + handleConnected(event) { var channelstreamConnection = this.getChannelStreamConnection(); channelstreamConnection.set('channelsState', event.detail.channels_info); channelstreamConnection.set('userState', event.detail.state); channelstreamConnection.set('channels', event.detail.channels); this.propagageChannelsState(); - }, - handleSubscribed: function (event) { + } + + handleSubscribed(event) { var channelstreamConnection = this.getChannelStreamConnection(); var channelInfo = event.detail.channels_info; var channelKeys = Object.keys(event.detail.channels_info); @@ -166,9 +173,10 @@ } channelstreamConnection.set('channels', event.detail.channels); this.propagageChannelsState(); - }, + } + /** propagates channel states on topics */ - propagageChannelsState: function (event) { + propagageChannelsState(event) { var channelstreamConnection = this.getChannelStreamConnection(); var channel_data = channelstreamConnection.channelsState; var channels = channelstreamConnection.channels; @@ -179,7 +187,9 @@ ); } } - }); + } + + customElements.define(RhodecodeApp.is, RhodecodeApp); diff --git a/rhodecode/public/js/src/components/rhodecode-favicon/rhodecode-favicon.html b/rhodecode/public/js/src/components/rhodecode-favicon/rhodecode-favicon.html --- a/rhodecode/public/js/src/components/rhodecode-favicon/rhodecode-favicon.html +++ b/rhodecode/public/js/src/components/rhodecode-favicon/rhodecode-favicon.html @@ -4,26 +4,35 @@ diff --git a/rhodecode/public/js/src/components/rhodecode-toast/rhodecode-toast.html b/rhodecode/public/js/src/components/rhodecode-toast/rhodecode-toast.html --- a/rhodecode/public/js/src/components/rhodecode-toast/rhodecode-toast.html +++ b/rhodecode/public/js/src/components/rhodecode-toast/rhodecode-toast.html @@ -1,5 +1,6 @@ - + diff --git a/rhodecode/public/js/src/components/rhodecode-unsafe-html/rhodecode-unsafe-html.html b/rhodecode/public/js/src/components/rhodecode-unsafe-html/rhodecode-unsafe-html.html --- a/rhodecode/public/js/src/components/rhodecode-unsafe-html/rhodecode-unsafe-html.html +++ b/rhodecode/public/js/src/components/rhodecode-unsafe-html/rhodecode-unsafe-html.html @@ -1,4 +1,4 @@ - + diff --git a/rhodecode/templates/base/root.mako b/rhodecode/templates/base/root.mako --- a/rhodecode/templates/base/root.mako +++ b/rhodecode/templates/base/root.mako @@ -27,6 +27,8 @@ c.template_context['default_user'] = { %> + + ${self.title()} diff --git a/webpack.config.js b/webpack.config.js --- a/webpack.config.js +++ b/webpack.config.js @@ -10,6 +10,18 @@ if (process.env.RC_STATIC_DIR) { destinationDirectory = process.env.RC_STATIC_DIR; } +// doing it this way because it seems that plugin via grunt does not pick up .babelrc +let babelRCOptions = { + "presets": [ + ["env", { + "targets": { + "browsers": ["last 2 versions"] + } + }] + ], + "plugins": ["transform-object-rest-spread"] +} + module.exports = { // Tell Webpack which file kicks off our app. entry: { @@ -42,7 +54,8 @@ module.exports = { // polymer-webpack-loader, and hand the output to // babel-loader. This let's us transpile JS in our `