2017-04-20 09:27:09 -07:00
|
|
|
import Ember from 'ember';
|
|
|
|
import route from 'ember-redux/route';
|
|
|
|
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
|
|
|
|
import { asyncRequestBrowseData } from 'wherehows-web/actions/browse';
|
|
|
|
|
2017-04-27 00:57:29 -07:00
|
|
|
const { Route } = Ember;
|
2017-04-20 09:27:09 -07:00
|
|
|
// TODO: DSS-6581 Create URL retrieval module
|
2017-04-26 01:05:29 -07:00
|
|
|
// TODO: Route should transition to browse/entity, pay attention to the fact that
|
|
|
|
// this route initializes store with entity metrics on entry
|
2017-04-20 09:27:09 -07:00
|
|
|
const entityUrls = {
|
2017-04-26 01:05:29 -07:00
|
|
|
datasets: '/api/v1/datasets?size=10',
|
|
|
|
metrics: '/api/v1/metrics?size=10',
|
|
|
|
flows: '/api/v1/flows?size=10'
|
2017-04-20 09:27:09 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
export default route({
|
|
|
|
model: (dispatch, { entity = 'datasets', page = '1' }) => dispatch(asyncRequestBrowseData(page, entity, entityUrls))
|
2017-04-27 00:57:29 -07:00
|
|
|
})(
|
|
|
|
Route.extend(AuthenticatedRouteMixin, {
|
|
|
|
/**
|
2017-05-02 14:48:48 -07:00
|
|
|
* Browse route does not render any content, but hydrates the store with initial data transition to child route
|
2017-05-02 15:58:03 -07:00
|
|
|
* @param {Object} model result from model call
|
|
|
|
* @param {Ember.Transition} transition
|
2017-04-27 00:57:29 -07:00
|
|
|
*/
|
2017-05-02 14:48:48 -07:00
|
|
|
afterModel(model, transition) {
|
|
|
|
// Extract the entity being viewed from the transition state
|
2017-05-02 16:58:16 -07:00
|
|
|
const { params: { 'browse.entity': { entity = 'datasets' } = {} } } = transition;
|
2017-05-02 14:48:48 -07:00
|
|
|
this.transitionTo('browse.entity', entity);
|
2017-04-27 00:57:29 -07:00
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|