Skip to content
Snippets Groups Projects
Commit b47b7b7a authored by Allen Gilliland's avatar Allen Gilliland
Browse files

provide separate routes for each homepage tab.

parent 2cbd105d
No related branches found
No related tags found
No related merge requests found
......@@ -43,8 +43,8 @@ export default class HeaderTabs extends Component {
return (
<div className="bg-brand text-white">
<a className={activityTab} onClick={() => this.onClickActivityTab()}>Activity</a>
<a className={questionsTab} onClick={() => this.onClickQuestionsTab()}>Saved Questions</a>
<a className={activityTab} href="/">Activity</a>
<a className={questionsTab} href="/?questions">Saved Questions</a>
</div>
);
}
......
......@@ -3,7 +3,6 @@
import React, { Component, PropTypes } from "react";
import Greeting from "metabase/lib/greeting";
import Icon from "metabase/components/Icon.react";
import HeaderTabs from "./HeaderTabs.react";
import Activity from "./Activity.react";
......@@ -12,6 +11,7 @@ import RecentViews from "./RecentViews.react";
import CardFilters from "./CardFilters.react";
import Smile from './Smile.react';
export default class Homepage extends Component {
constructor(props) {
......
......@@ -8,6 +8,7 @@ import thunkMidleware from "redux-thunk";
import HomepageApp from './containers/HomepageApp.react';
import * as reducers from './reducers';
import { setSelectedTab } from './actions';
// import { devTools, persistState } from 'redux-devtools';
// import { LogMonitor } from 'redux-devtools/lib/react';
......@@ -32,7 +33,7 @@ var HomeControllers = angular.module('metabase.home.controllers', [
'metabase.metabase.services'
]);
HomeControllers.controller('Homepage', ['$scope', '$location', function($scope, $location) {
HomeControllers.controller('Homepage', ['$scope', '$location', '$route', '$routeParams', function($scope, $location, $route, $routeParams) {
$scope.Component = HomepageApp;
$scope.props = {
user: $scope.user,
......@@ -45,6 +46,35 @@ HomeControllers.controller('Homepage', ['$scope', '$location', function($scope,
// TODO: reflect onboarding state
// $scope.monitor = LogMonitor;
// mildly hacky way to prevent reloading controllers as the URL changes
var route = $route.current;
$scope.$on('$locationChangeSuccess', function (event) {
var newParams = $route.current.params;
var oldParams = route.params;
if ($route.current.$$route.controller === 'Homepage') {
$route.current = route;
angular.forEach(oldParams, function(value, key) {
delete $route.current.params[key];
delete $routeParams[key];
});
angular.forEach(newParams, function(value, key) {
$route.current.params[key] = value;
$routeParams[key] = value;
});
}
});
$scope.routeParams = $routeParams;
$scope.$watch('routeParams', function() {
if ($scope.routeParams.questions === true) {
$scope.store.dispatch(setSelectedTab('cards'));
} else {
$scope.store.dispatch(setSelectedTab('activity'));
}
}, true);
}]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment