From f9c3922670cc57a05c5275871c6fa55ce84ed2ec Mon Sep 17 00:00:00 2001 From: Mitchell Date: Sat, 24 Aug 2019 13:22:05 -0500 Subject: [PATCH] refactor: move upload history to its own page --- client/app/app.tsx | 3 +- client/app/components/index.ts | 1 - client/app/components/navbar/navbar.tsx | 17 ++-- .../app/components/sound-list/sound-list.tsx | 5 +- .../upload-history/upload-history.tsx | 53 ------------ client/app/pages/clips/clips.tsx | 2 +- client/app/pages/index.ts | 1 + client/app/pages/soundboard/soundboard.tsx | 1 + client/app/pages/stats/stats.tsx | 12 +-- .../pages/upload-history/upload-history.tsx | 81 +++++++++++++++++++ client/app/stores/app.store.ts | 8 +- client/app/wrapper.tsx | 2 +- 12 files changed, 104 insertions(+), 82 deletions(-) delete mode 100644 client/app/components/upload-history/upload-history.tsx create mode 100644 client/app/pages/upload-history/upload-history.tsx diff --git a/client/app/app.tsx b/client/app/app.tsx index 657f933..7ca4ff1 100644 --- a/client/app/app.tsx +++ b/client/app/app.tsx @@ -2,7 +2,7 @@ import { Provider } from 'mobx-react'; import React from 'react'; import ReactDOM from 'react-dom'; import { BrowserRouter, Route, Switch } from 'react-router-dom'; -import { Admin, Clips, Downloader, NotFound, Oauth, Soundboard, Stats, VideoArchive } from './pages'; +import { Admin, Clips, Downloader, NotFound, Oauth, Soundboard, Stats, UploadHistory, VideoArchive } from './pages'; import './scss/index.scss'; import { rootStoreInstance } from './stores'; import { Wrapper } from './wrapper'; @@ -14,6 +14,7 @@ const App: any = (): any => { + diff --git a/client/app/components/index.ts b/client/app/components/index.ts index 82ef969..732c2bb 100644 --- a/client/app/components/index.ts +++ b/client/app/components/index.ts @@ -2,5 +2,4 @@ export * from './embedded-youtube/embedded-youtube'; export * from './header/header'; export * from './navbar/navbar'; export * from './sound-list/sound-list'; -export * from './upload-history/upload-history'; export * from './uploader/uploader'; diff --git a/client/app/components/navbar/navbar.tsx b/client/app/components/navbar/navbar.tsx index 745baeb..6871ec8 100644 --- a/client/app/components/navbar/navbar.tsx +++ b/client/app/components/navbar/navbar.tsx @@ -1,12 +1,11 @@ import React from 'react'; import { NavLink } from 'react-router-dom'; -import { IClaims, Permissions } from '../../model'; import { OauthService, StorageService } from '../../services'; +import { AppStore } from '../../stores'; import './navbar.scss'; interface Props { - claims?: IClaims; - open: boolean; + appStore: AppStore; onNavClick: () => void; } @@ -37,7 +36,7 @@ export class Navbar extends React.Component { }; renderLoginButton() { - const { claims } = this.props; + const { claims } = this.props.appStore; if (!this.state.oauthUrl) { return null; @@ -69,19 +68,17 @@ export class Navbar extends React.Component { }; render() { - const { claims, open } = this.props; - const openClass = open ? 'navbar--open' : ''; + const { claims, navbarOpen, hasModPermissions, hasAdminPermissions } = this.props.appStore; + const openClass = navbarOpen ? 'navbar--open' : ''; return (
{this.renderNavLink('Soundboard', '/', { exact: true })} + {hasModPermissions() && this.renderNavLink('Upload History', '/upload-history')} {this.renderNavLink('Video Archive', '/video-archive')} {this.renderNavLink('Youtube Downloader', '/downloader')} {this.renderNavLink('Clips', '/clips')} {this.renderNavLink('Stats', '/stats')} - {claims && - claims.permissions && - claims.permissions === Permissions.Admin && - this.renderNavLink('Admin', '/admin')} + {hasAdminPermissions() && this.renderNavLink('Admin', '/admin')} {this.renderLoginButton()} {claims && claims.email &&
{claims.email}
} diff --git a/client/app/components/sound-list/sound-list.tsx b/client/app/components/sound-list/sound-list.tsx index e1ca27d..247a282 100644 --- a/client/app/components/sound-list/sound-list.tsx +++ b/client/app/components/sound-list/sound-list.tsx @@ -5,6 +5,7 @@ import './sound-list.scss'; interface Props { soundList: SoundType[]; type: 'sounds' | 'clips'; + title: string; onPlayDiscord?: (sound: SoundType) => void; showDiscordPlay?: boolean; } @@ -47,13 +48,13 @@ export class SoundList extends React.Component { } render() { - const { showDiscordPlay, soundList, type } = this.props; + const { showDiscordPlay, soundList, title, type } = this.props; return (
- {type} + {title}