Merge branch 'hub-redesign' of https://github.com/netchampfaris/erpnext into hub-redesign
diff --git a/erpnext/public/js/hub/marketplace.js b/erpnext/public/js/hub/marketplace.js
index ab0d4f7..d393605 100644
--- a/erpnext/public/js/hub/marketplace.js
+++ b/erpnext/public/js/hub/marketplace.js
@@ -8,6 +8,7 @@
 import './pages/profile';
 import './pages/publish';
 import './pages/published_products';
+import './pages/messages';
 import './pages/not_found';
 
 // helpers
@@ -62,11 +63,17 @@
 		$nav_group.empty();
 
 		const user_specific_items_html = this.registered
-			? `<li class="hub-sidebar-item text-muted" data-route="marketplace/profile">
+			? `<li class="hub-sidebar-item" data-route="marketplace/favourites">
+					${__('Favorites')}
+				</li>
+				<li class="hub-sidebar-item text-muted" data-route="marketplace/profile">
 					${__('Your Profile')}
 				</li>
 				<li class="hub-sidebar-item text-muted" data-route="marketplace/publish">
 					${__('Publish Products')}
+				</li>
+				<li class="hub-sidebar-item text-muted" data-route="marketplace/messages">
+					${__('Messages')}
 				</li>`
 
 			: `<li class="hub-sidebar-item text-muted" data-route="marketplace/register">
@@ -77,9 +84,6 @@
 			<li class="hub-sidebar-item" data-route="marketplace/home">
 				${__('Browse')}
 			</li>
-			<li class="hub-sidebar-item" data-route="marketplace/favourites">
-				${__('Favorites')}
-			</li>
 			${user_specific_items_html}
 		`);
 	}
@@ -148,10 +152,6 @@
 			this.subpages.home = new erpnext.hub.Home(this.$body);
 		}
 
-		if (route[1] === 'favourites' && !this.subpages.favourites) {
-			this.subpages.favourites = new erpnext.hub.Favourites(this.$body);
-		}
-
 		if (route[1] === 'search' && !this.subpages.search) {
 			this.subpages.search = new erpnext.hub.SearchPage(this.$body);
 		}
@@ -172,6 +172,11 @@
 			this.subpages.register = new erpnext.hub.Register(this.$body);
 		}
 
+		// registered seller routes
+		if (route[1] === 'favourites' && !this.subpages.favourites) {
+			this.subpages.favourites = new erpnext.hub.Favourites(this.$body);
+		}
+
 		if (route[1] === 'profile' && !this.subpages.profile) {
 			this.subpages.profile = new erpnext.hub.Profile(this.$body);
 		}
@@ -184,6 +189,17 @@
 			this.subpages['my-products'] = new erpnext.hub.PublishedProducts(this.$body);
 		}
 
+		if (route[1] === 'messages' && !this.subpages['messages']) {
+			this.subpages['messages'] = new erpnext.hub.Messages(this.$body);
+		}
+
+		// dont allow unregistered users to access registered routes
+		const registered_routes = ['favourites', 'profile', 'publish', 'my-products', 'messages'];
+		if (!hub.settings.registered && registered_routes.includes(route[1])) {
+			frappe.set_route('marketplace', 'home');
+			return;
+		}
+
 		if (!Object.keys(this.subpages).includes(route[1])) {
 			if (!this.subpages.not_found) {
 				this.subpages.not_found = new erpnext.hub.NotFound(this.$body);
diff --git a/erpnext/public/js/hub/pages/item.js b/erpnext/public/js/hub/pages/item.js
index b3c63c8..559a4d6 100644
--- a/erpnext/public/js/hub/pages/item.js
+++ b/erpnext/public/js/hub/pages/item.js
@@ -2,11 +2,6 @@
 import { get_rating_html } from '../helpers';
 
 erpnext.hub.Item = class Item extends SubPage {
-	make_wrapper() {
-		super.make_wrapper();
-		this.setup_events();
-	}
-
 	refresh() {
 		this.show_skeleton();
 		this.hub_item_code = frappe.get_route()[2];
@@ -45,29 +40,6 @@
 		this.$wrapper.html(skeleton);
 	}
 
-	setup_events() {
-		this.$wrapper.on('click', '.btn-contact-seller', () => {
-			const d = new frappe.ui.Dialog({
-				title: __('Send a message'),
-				fields: [
-					{
-						fieldname: 'to',
-						fieldtype: 'Read Only',
-						label: __('To'),
-						default: this.item.company
-					},
-					{
-						fieldtype: 'Text',
-						fieldname: 'message',
-						label: __('Message')
-					}
-				]
-			});
-
-			d.show();
-		});
-	}
-
 	get_item(hub_item_code) {
 		return hub.call('get_item_details', { hub_item_code });
 	}
@@ -150,7 +122,7 @@
 					</div>
 					<div class="col-md-8">
 						<div class="margin-bottom"><a href="#marketplace/seller/${seller}" class="bold">${seller}</a></div>
-						<button class="btn btn-xs btn-default text-muted btn-contact-seller">
+						<button class="btn btn-xs btn-default text-muted" data-action="contact_seller">
 							${__('Contact Seller')}
 						</button>
 					</div>
@@ -204,6 +176,30 @@
 		this.unpublish_dialog.show();
 	}
 
+	contact_seller() {
+		const d = new frappe.ui.Dialog({
+			title: __('Send a message'),
+			fields: [
+				{
+					fieldname: 'to',
+					fieldtype: 'Read Only',
+					label: __('To'),
+					default: this.item.company
+				},
+				{
+					fieldtype: 'Text',
+					fieldname: 'message',
+					label: __('Message')
+				}
+			],
+			primary_action: ({ message }) => {
+				if (!message) return;
+			}
+		});
+
+		d.show();
+	}
+
 	make_review_area() {
 		this.comment_area = new frappe.ui.ReviewArea({
 			parent: this.$wrapper.find('.timeline-head').empty(),
diff --git a/erpnext/public/js/hub/pages/messages.js b/erpnext/public/js/hub/pages/messages.js
new file mode 100644
index 0000000..ac2057d
--- /dev/null
+++ b/erpnext/public/js/hub/pages/messages.js
@@ -0,0 +1,7 @@
+import SubPage from './subpage';
+
+erpnext.hub.Messages = class Messages extends SubPage {
+    refresh() {
+
+    }
+}
\ No newline at end of file