diff --git a/app/components/Auth.js b/app/components/Auth.js
deleted file mode 100644
index 894ffb6ce..000000000
--- a/app/components/Auth.js
+++ /dev/null
@@ -1,75 +0,0 @@
-// @flow
-import * as React from 'react';
-import { Provider, observer, inject } from 'mobx-react';
-import stores from 'stores';
-import AuthStore from 'stores/AuthStore';
-import ApiKeysStore from 'stores/ApiKeysStore';
-import UsersStore from 'stores/UsersStore';
-import CollectionsStore from 'stores/CollectionsStore';
-import IntegrationsStore from 'stores/IntegrationsStore';
-import LoadingIndicator from 'components/LoadingIndicator';
-import { isCustomSubdomain } from 'shared/utils/domains';
-
-type Props = {
- auth: AuthStore,
- children?: React.Node,
-};
-
-let authenticatedStores;
-
-const Auth = observer(({ auth, children }: Props) => {
- if (auth.authenticated) {
- const { user, team } = auth;
- const { hostname } = window.location;
-
- if (!team || !user) {
- return ;
- }
-
- // If we're authenticated but viewing a subdomain that doesn't match the
- // currently authenticated team then kick the user to the teams subdomain.
- if (
- process.env.SUBDOMAINS_ENABLED &&
- team.subdomain &&
- isCustomSubdomain(hostname) &&
- !hostname.startsWith(`${team.subdomain}.`)
- ) {
- window.location.href = `${team.url}${window.location.pathname}`;
- return ;
- }
-
- // Only initialize stores once. Kept in global scope because otherwise they
- // will get overridden on route change
- if (!authenticatedStores) {
- authenticatedStores = {
- integrations: new IntegrationsStore({
- ui: stores.ui,
- }),
- apiKeys: new ApiKeysStore(),
- users: new UsersStore(),
- collections: new CollectionsStore({
- ui: stores.ui,
- teamId: team.id,
- }),
- };
-
- if (window.Bugsnag) {
- Bugsnag.user = {
- id: user.id,
- name: user.name,
- teamId: team.id,
- team: team.name,
- };
- }
-
- authenticatedStores.collections.fetchPage({ limit: 100 });
- }
-
- return {children};
- }
-
- auth.logout();
- return null;
-});
-
-export default inject('auth')(Auth);
diff --git a/app/components/Authenticated.js b/app/components/Authenticated.js
new file mode 100644
index 000000000..29e43e574
--- /dev/null
+++ b/app/components/Authenticated.js
@@ -0,0 +1,41 @@
+// @flow
+import * as React from 'react';
+import { observer, inject } from 'mobx-react';
+import AuthStore from 'stores/AuthStore';
+import LoadingIndicator from 'components/LoadingIndicator';
+import { isCustomSubdomain } from 'shared/utils/domains';
+
+type Props = {
+ auth: AuthStore,
+ children?: React.Node,
+};
+
+const Authenticated = observer(({ auth, children }: Props) => {
+ if (auth.authenticated) {
+ const { user, team } = auth;
+ const { hostname } = window.location;
+
+ if (!team || !user) {
+ return ;
+ }
+
+ // If we're authenticated but viewing a subdomain that doesn't match the
+ // currently authenticated team then kick the user to the teams subdomain.
+ if (
+ process.env.SUBDOMAINS_ENABLED &&
+ team.subdomain &&
+ isCustomSubdomain(hostname) &&
+ !hostname.startsWith(`${team.subdomain}.`)
+ ) {
+ window.location.href = `${team.url}${window.location.pathname}`;
+ return ;
+ }
+
+ return children;
+ }
+
+ auth.logout();
+ return null;
+});
+
+export default inject('auth')(Authenticated);
diff --git a/app/components/DocumentHistory/DocumentHistory.js b/app/components/DocumentHistory/DocumentHistory.js
index e9cab099c..5d0e0f7ef 100644
--- a/app/components/DocumentHistory/DocumentHistory.js
+++ b/app/components/DocumentHistory/DocumentHistory.js
@@ -7,7 +7,7 @@ import styled from 'styled-components';
import Waypoint from 'react-waypoint';
import ArrowKeyNavigation from 'boundless-arrow-key-navigation';
-import { DEFAULT_PAGINATION_LIMIT } from 'stores/DocumentsStore';
+import { DEFAULT_PAGINATION_LIMIT } from 'stores/BaseStore';
import Document from 'models/Document';
import RevisionsStore from 'stores/RevisionsStore';
diff --git a/app/components/DocumentViews/DocumentViewersStore.js b/app/components/DocumentViews/DocumentViewersStore.js
deleted file mode 100644
index 336e3ae44..000000000
--- a/app/components/DocumentViews/DocumentViewersStore.js
+++ /dev/null
@@ -1,42 +0,0 @@
-// @flow
-import { observable, action } from 'mobx';
-import invariant from 'invariant';
-import { client } from 'utils/ApiClient';
-import type { User } from 'types';
-
-type View = {
- user: User,
- count: number,
-};
-
-class DocumentViewersStore {
- documentId: string;
- @observable viewers: Array;
- @observable isFetching: boolean;
-
- @action
- fetchViewers = async () => {
- this.isFetching = true;
-
- try {
- const res = await client.post(
- '/views.list',
- {
- id: this.documentId,
- },
- { cache: true }
- );
- invariant(res && res.data, 'Data should be available');
- this.viewers = res.data.users;
- } catch (e) {
- console.error('Something went wrong');
- }
- this.isFetching = false;
- };
-
- constructor(documentId: string) {
- this.documentId = documentId;
- }
-}
-
-export default DocumentViewersStore;
diff --git a/app/components/DocumentViews/DocumentViews.js b/app/components/DocumentViews/DocumentViews.js
deleted file mode 100644
index b2c4b274c..000000000
--- a/app/components/DocumentViews/DocumentViews.js
+++ /dev/null
@@ -1,71 +0,0 @@
-// @flow
-import * as React from 'react';
-import { observable } from 'mobx';
-import { observer } from 'mobx-react';
-import Popover from 'components/Popover';
-import styled from 'styled-components';
-import DocumentViewers from './components/DocumentViewers';
-import DocumentViewersStore from './DocumentViewersStore';
-import Flex from 'shared/components/Flex';
-
-const Container = styled(Flex)`
- font-size: 13px;
- user-select: none;
-
- a {
- color: #ccc;
-
- &:hover {
- color: #aaa;
- }
- }
-`;
-
-type Props = {
- documentId: string,
- count: number,
-};
-
-@observer
-class DocumentViews extends React.Component {
- @observable opened: boolean = false;
- anchor: ?HTMLElement;
- store: DocumentViewersStore;
-
- constructor(props: Props) {
- super(props);
- this.store = new DocumentViewersStore(props.documentId);
- }
-
- openPopover = () => {
- this.opened = true;
- };
-
- closePopover = () => {
- this.opened = false;
- };
-
- setRef = (ref: ?HTMLElement) => {
- this.anchor = ref;
- };
-
- render() {
- return (
-
-
- Viewed {this.props.count} {this.props.count === 1 ? 'time' : 'times'}
-
- {this.opened && (
-
-
-
- )}
-
- );
- }
-}
-
-export default DocumentViews;
diff --git a/app/components/DocumentViews/components/DocumentViewers/DocumentViewers.js b/app/components/DocumentViews/components/DocumentViewers/DocumentViewers.js
deleted file mode 100644
index c034f4297..000000000
--- a/app/components/DocumentViews/components/DocumentViewers/DocumentViewers.js
+++ /dev/null
@@ -1,52 +0,0 @@
-// @flow
-import * as React from 'react';
-import Flex from 'shared/components/Flex';
-import styled from 'styled-components';
-import map from 'lodash/map';
-import Avatar from 'components/Avatar';
-import Scrollable from 'components/Scrollable';
-
-type Props = {
- viewers: Array