Merge branch 'hub-redesign' of https://github.com/frappe/erpnext into hub-redesign
diff --git a/erpnext/public/js/hub/Sidebar.vue b/erpnext/public/js/hub/Sidebar.vue
index b5a4e46..6728664 100644
--- a/erpnext/public/js/hub/Sidebar.vue
+++ b/erpnext/public/js/hub/Sidebar.vue
@@ -19,48 +19,44 @@
 export default {
 	data() {
 		return {
+			hub_registered: hub.settings.registered,
 			items: [
 				{
 					label: __('Browse'),
 					route: 'marketplace/home'
 				},
 				{
-					label: __('Become a Seller'),
-					action: this.show_register_dialog,
-					condition: () => !hub.settings.registered
-				},
-				{
 					label: __('Saved Products'),
 					route: 'marketplace/saved-products',
-					condition: () => hub.settings.registered
+					condition: () => this.hub_registered
 				},
 				{
 					label: __('Your Profile'),
 					route: 'marketplace/profile',
-					condition: () => hub.settings.registered
+					condition: () => this.hub_registered
 				},
 				{
 					label: __('Your Products'),
 					route: 'marketplace/my-products',
-					condition: () => hub.settings.registered
+					condition: () => this.hub_registered
 				},
 				{
 					label: __('Publish Products'),
 					route: 'marketplace/publish',
-					condition: () => hub.settings.registered
+					condition: () => this.hub_registered
 				},
 				{
 					label: __('Selling'),
 					route: 'marketplace/selling',
-					condition: () => hub.settings.registered
+					condition: () => this.hub_registered
 				},
 				{
 					label: __('Buying'),
 					route: 'marketplace/buying',
-					condition: () => hub.settings.registered
+					condition: () => this.hub_registered
 				},
 			],
-			categories: []
+			categories: [],
 		}
 	},
 	created() {
@@ -80,6 +76,10 @@
 					this.update_sidebar_state();
 				});
 			});
+
+		erpnext.hub.on('seller-registered', () => {
+			this.hub_registered = true;
+		})
 	},
 	mounted() {
 		this.update_sidebar_state();
@@ -99,7 +99,7 @@
 			const $siblings = container.find('[data-route]');
 			$siblings.removeClass('active').addClass('text-muted');
 			$sidebar_item.addClass('active').removeClass('text-muted');
-		}
+		},
 	}
 }
 </script>
diff --git a/erpnext/public/js/hub/marketplace.js b/erpnext/public/js/hub/marketplace.js
index 95a7542..373f552 100644
--- a/erpnext/public/js/hub/marketplace.js
+++ b/erpnext/public/js/hub/marketplace.js
@@ -21,15 +21,17 @@
 		this.page = parent.page;
 
 		frappe.db.get_doc('Hub Settings')
-			.then(doc => {
+		.then(doc => {
 				hub.settings = doc;
-				this.registered = doc.registered;
-
+				const is_registered = hub.settings.registered
 				this.setup_header();
 				this.make_sidebar();
 				this.make_body();
 				this.setup_events();
 				this.refresh();
+				if (!is_registered) {
+					this.page.set_primary_action('Become A Seller', this.show_register_dialog.bind(this))
+				}
 			});
 	}
 
@@ -74,8 +76,10 @@
 		});
 
 		erpnext.hub.on('seller-registered', () => {
-			this.registered = 1;
-			this.make_sidebar_nav_buttons();
+			this.page.clear_primary_action()
+			frappe.db.get_doc('Hub Settings').then((doc)=> {
+				hub.settings = doc;
+			});
 		});
 	}
 
@@ -83,86 +87,6 @@
 
 	}
 
-	_refresh() {
-		const route = frappe.get_route();
-		this.subpages = this.subpages || {};
-
-		for (let page in this.subpages) {
-			this.subpages[page].hide();
-		}
-
-		if (route[1] === 'home' && !this.subpages.home) {
-			this.subpages.home = new erpnext.hub.HomePage(this.$body);
-		}
-
-		if (route[1] === 'search' && !this.subpages.search) {
-			this.subpages.search = new erpnext.hub.SearchPage(this.$body);
-		}
-
-		if (route[1] === 'category' && route[2] && !this.subpages.category) {
-			this.subpages.category = new erpnext.hub.CategoryPage(this.$body);
-		}
-
-		if (route[1] === 'item' && route[2] && !this.subpages.item) {
-			this.subpages.item = new erpnext.hub.ItemPage(this.$body);
-		}
-
-		if (route[1] === 'seller' && !this.subpages['seller']) {
-			this.subpages['seller'] = new erpnext.hub.SellerPage(this.$body);
-		}
-
-		if (route[1] === 'register' && !this.subpages.register) {
-			if (this.registered) {
-				frappe.set_route('marketplace', 'home');
-				return;
-			}
-			this.subpages.register = new erpnext.hub.Register(this.$body);
-		}
-
-		// registered seller routes
-		if (route[1] === 'saved-products' && !this.subpages['saved-products']) {
-			this.subpages['saved-products'] = new erpnext.hub.SavedProductsPage(this.$body);
-		}
-
-		if (route[1] === 'profile' && !this.subpages.profile) {
-			this.subpages.profile = new erpnext.hub.ProfilePage(this.$body);
-		}
-
-		if (route[1] === 'publish' && !this.subpages.publish) {
-			this.subpages.publish = new erpnext.hub.PublishPage(this.$body);
-		}
-
-		if (route[1] === 'my-products' && !this.subpages['my-products']) {
-			this.subpages['my-products'] = new erpnext.hub.PublishedProductsPage(this.$body);
-		}
-
-		if (route[1] === 'buying' && !this.subpages['buying']) {
-			this.subpages['buying'] = new erpnext.hub.Buying(this.$body);
-		}
-
-		if (route[1] === 'selling' && !this.subpages['selling']) {
-			this.subpages['selling'] = new erpnext.hub.Selling(this.$body, 'Selling');
-		}
-
-		// dont allow unregistered users to access registered routes
-		const registered_routes = ['saved-products', '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.NotFoundPage(this.$body);
-			}
-			route[1] = 'not_found';
-		}
-
-		this.update_sidebar();
-		frappe.utils.scroll_to(0);
-		this.subpages[route[1]].show();
-	}
-
 	show_register_dialog() {
 		this.register_dialog = ProfileDialog(
 			__('Become a Seller'),
@@ -186,4 +110,5 @@
 		    erpnext.hub.trigger('seller-registered');
 		});
 	}
+
 }