diff --git a/ui/package-lock.json b/ui/package-lock.json index a0232cf0..52775705 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -8933,6 +8933,24 @@ "scheduler": "^0.18.0" } }, + "react-fast-compare": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-2.0.4.tgz", + "integrity": "sha512-suNP+J1VU1MWFKcyt7RtjiSWUjvidmQSlqu+eHslq+342xCbGTYmC0mEhPCOHxlW0CywylOC1u2DFAT+bv4dBw==", + "dev": true + }, + "react-helmet": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/react-helmet/-/react-helmet-5.2.1.tgz", + "integrity": "sha512-CnwD822LU8NDBnjCpZ4ySh8L6HYyngViTZLfBBb3NjtrpN8m49clH8hidHouq20I51Y6TpCTISCBbqiY5GamwA==", + "dev": true, + "requires": { + "object-assign": "^4.1.1", + "prop-types": "^15.5.4", + "react-fast-compare": "^2.0.2", + "react-side-effect": "^1.1.0" + } + }, "react-is": { "version": "16.8.6", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.8.6.tgz", @@ -8998,6 +9016,15 @@ "prop-types": "^15.6.1" } }, + "react-side-effect": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/react-side-effect/-/react-side-effect-1.2.0.tgz", + "integrity": "sha512-v1ht1aHg5k/thv56DRcjw+WtojuuDHFUgGfc+bFHOWsF4ZK6C2V57DO0Or0GPsg6+LSTE0M6Ry/gfzhzSwbc5w==", + "dev": true, + "requires": { + "shallowequal": "^1.0.1" + } + }, "react-spring": { "version": "8.0.27", "resolved": "https://registry.npmjs.org/react-spring/-/react-spring-8.0.27.tgz", diff --git a/ui/package.json b/ui/package.json index 6ae8e620..39273a93 100644 --- a/ui/package.json +++ b/ui/package.json @@ -49,6 +49,7 @@ "isarray": "^2.0.5", "lint-staged": "^10.0.7", "parcel-plugin-sw-cache": "^0.3.1", + "react-helmet": "^5.2.1", "react-router-prop-types": "^1.0.4" }, "cache": { diff --git a/ui/src/App.js b/ui/src/App.js index 4e4c9ff7..8e644ad6 100644 --- a/ui/src/App.js +++ b/ui/src/App.js @@ -1,5 +1,6 @@ import React, { Component } from 'react' import { createGlobalStyle } from 'styled-components' +import { Helmet } from 'react-helmet' import Routes from './Routes' import Messages from './components/messages/Messages' @@ -14,6 +15,12 @@ class App extends Component { render() { return ( <> + + + diff --git a/ui/src/Layout.js b/ui/src/Layout.js index 2ad60952..5046c728 100644 --- a/ui/src/Layout.js +++ b/ui/src/Layout.js @@ -7,6 +7,7 @@ import Sidebar from './components/sidebar/Sidebar' import { Query } from 'react-apollo' import gql from 'graphql-tag' import { Authorized } from './AuthorizedRoute' +import Helmet from 'react-helmet' const adminQuery = gql` query adminQuery { @@ -90,52 +91,52 @@ const Title = styled.h1` padding: 5px 12px; ` -class Layout extends Component { - render() { - return ( - - - - - - Photos - - - - Albums - - - {({ loading, error, data }) => { - if (data && data.myUser && data.myUser.admin) { - return ( - - - Settings - - ) - } +const Layout = ({ children, title }) => ( + + + {title ? `${title} - Photoview` : `Photoview`} + + + + + + Photos + + + + Albums + + + {({ loading, error, data }) => { + if (data && data.myUser && data.myUser.admin) { + return ( + + + Settings + + ) + } - return null - }} - - - - - - {this.props.children} -
-
-
-
- Photoview -
-
- ) - } -} + return null + }} +
+
+
+ + + {children} +
+
+
+
+ Photoview +
+
+) Layout.propTypes = { children: PropTypes.any.isRequired, + title: PropTypes.string, } export default Layout diff --git a/ui/src/Pages/AllAlbumsPage/AlbumsPage.js b/ui/src/Pages/AllAlbumsPage/AlbumsPage.js index fee0efbf..19cf7781 100644 --- a/ui/src/Pages/AllAlbumsPage/AlbumsPage.js +++ b/ui/src/Pages/AllAlbumsPage/AlbumsPage.js @@ -21,7 +21,7 @@ const getAlbumsQuery = gql` class AlbumsPage extends Component { render() { return ( - +

Albums

{({ loading, error, data }) => ( diff --git a/ui/src/Pages/PhotosPage/PhotosPage.js b/ui/src/Pages/PhotosPage/PhotosPage.js index 5857342e..c0eb7749 100644 --- a/ui/src/Pages/PhotosPage/PhotosPage.js +++ b/ui/src/Pages/PhotosPage/PhotosPage.js @@ -1,4 +1,5 @@ import React, { Component } from 'react' +import { Helmet } from 'react-helmet' import Layout from '../../Layout' import gql from 'graphql-tag' import { Query } from 'react-apollo' @@ -87,7 +88,7 @@ class PhotosPage extends Component { render() { return ( - + {({ loading, error, data }) => { if (error) return error diff --git a/ui/src/components/albumGallery/AlbumGallery.js b/ui/src/components/albumGallery/AlbumGallery.js index c31b6076..440c761d 100644 --- a/ui/src/components/albumGallery/AlbumGallery.js +++ b/ui/src/components/albumGallery/AlbumGallery.js @@ -70,7 +70,7 @@ const AlbumGallery = ({ album, loading = false, customAlbumLink }) => { } return ( - + {subAlbumElement} {