Skip to content

Commit

Permalink
Merge pull request #120 from Einstore/pr/page-title
Browse files Browse the repository at this point in the history
add title to all pages
  • Loading branch information
Vašo authored Jul 16, 2019
2 parents a1763e5 + dfad0c4 commit ab22405
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 7 deletions.
7 changes: 1 addition & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ export class EinstoreApp extends React.Component<{}, AppState> {

componentDidMount() {
this.mounted = true
const name = localStorage.getItem('serverName')
if (name) {
document.title = name
}

if (window.Einstore) {
this.refreshServer()
if (this.state.token && this.state.authToken) {
Expand All @@ -169,8 +166,6 @@ export class EinstoreApp extends React.Component<{}, AppState> {
window.Einstore.server().then((server: any) => {
if (this.mounted) {
this.setState({ server })
document.title = server.name
localStorage.setItem('serverName', server.name)
}
})
window.Einstore.serverSettingsPlain().then((settings: any) => {
Expand Down
2 changes: 2 additions & 0 deletions src/components/AddApiKey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import find from 'lodash-es/find'
import Select from 'react-select'
import IconBack from 'shapes/back'
import showMessage from '../utils/showMessage'
import pageTitle from "../utils/pageTitle";

interface AddApiKeysProps {
teamId?: string
Expand Down Expand Up @@ -74,6 +75,7 @@ export default class AddApiKeys extends Component<AddApiKeysProps, AddApiKeysSta

componentDidMount() {
window.Einstore.teams().then((teams) => this.setState({ teams }))
pageTitle('Add new API key')
}

handleChangeTeam = (value: string) => {
Expand Down
2 changes: 2 additions & 0 deletions src/components/ApiKeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import prettyDate from '../utils/prettyDate'
import { ApiKeyType, apiKeyTypePairs } from '../api/types/ApiKeyType'
import { Link } from '@reach/router'
import IconPlus from 'shapes/plus'
import pageTitle from "../utils/pageTitle";

const apiKeyTypeClassnames = {
[ApiKeyType.UPLOAD]: 'apiKey-type-round-label-upload',
Expand Down Expand Up @@ -129,6 +130,7 @@ export default class ApiKeys extends Component<ApiKeysProps, ApiKeysState> {

componentDidMount() {
this.refresh()
pageTitle('API keys')
}

handleDeleteKey = (id: string) => {
Expand Down
5 changes: 5 additions & 0 deletions src/components/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import LoadMore from '../ui/LoadMore'
import IconPlus from 'shapes/plus'
import PlatformIcon from 'ui/PlatformIcon'
import * as browserStorage from '../utils/browserStorage'
import pageTitle from '../utils/pageTitle'

export enum SortDirection {
ASC = 'asc',
Expand Down Expand Up @@ -179,6 +180,10 @@ export default class Overview extends Component<OverviewProps, OverviewState> {
refreshKey: 1,
}

componentDidMount(): void {
pageTitle('Dashboard')
}

refresh = () => {
this.setState((state) => ({ ...state, refreshKey: state.refreshKey + 1 }))
}
Expand Down
8 changes: 8 additions & 0 deletions src/parts/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Form, { exportValidationSchema, FormControl, ValuesObject } from 'ui/Form
import * as Yup from 'yup'
import getBaseUrl from 'utils/getBaseUrl'
import showMessage from "../utils/showMessage";
import pageTitle from "../utils/pageTitle";

export enum AuthView {
RESET_PASSWORD = 'reset-password',
Expand Down Expand Up @@ -422,42 +423,49 @@ export class AuthRoute extends React.Component<RouteComponentProps<AuthRouteProp
render() {
switch (this.props.view) {
case AuthView.LOGIN:
pageTitle('Login')
return (
<div className={cn('auth', 'view-' + this.props.view)}>
<Login onSuccess={this.props.onLogin} />
</div>
)
case AuthView.REGISTRATION:
pageTitle('Registration')
return (
<div className={cn('auth', 'view-' + this.props.view)}>
<Registration onSuccess={this.props.onRegister} />
</div>
)
case AuthView.REGISTRATION_OK:
pageTitle('Thank you')
return (
<div className={cn('auth', 'view-' + this.props.view)}>
<RegistrationOk />
</div>
)
case AuthView.REGISTRATION_FINISH:
pageTitle('Thank you')
return (
<div className={cn('auth', 'view-' + this.props.view)}>
<RegistrationFinish />
</div>
)
case AuthView.RESET_PASSWORD:
pageTitle('Password reset')
return (
<div className={cn('auth', 'view-' + this.props.view)}>
<ResetPassword onSuccess={this.props.onResetPassword} />
</div>
)
case AuthView.SET_PASSWORD:
pageTitle('Set password')
return (
<div className={cn('auth', 'view-' + this.props.view)}>
<SetPassword />
</div>
)
case AuthView.INVITE_FINISH:
pageTitle('Invite')
return (
<div className={cn('auth', 'view-' + this.props.view)}>
<InviteFinish />
Expand Down
7 changes: 6 additions & 1 deletion src/parts/SystemSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import './systemSettings.sass'
import Button from '../components/button'
import previewFileImage from '../utils/previewFileImage'
import IconField from 'ui/IconField'
import pageTitle from "../utils/pageTitle";

function TemplatorUpdate() {
const [isWorking, setIsWorking] = useState(false)
Expand Down Expand Up @@ -167,7 +168,11 @@ class SystemConfigsForm extends React.Component {
}
}

export default class AddTeam extends React.Component {
export default class SystemSettings extends React.Component {
componentDidMount(): void {
pageTitle('System settings')
}

render() {
return (
<div className="sheet">
Expand Down
2 changes: 2 additions & 0 deletions src/parts/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Gravatar from '../components/Gravatar'
import './account.sass'
import './page.sass'
import showMessage from "../utils/showMessage";
import pageTitle from "../utils/pageTitle";

export default class Account extends Component {
state = {
Expand All @@ -16,6 +17,7 @@ export default class Account extends Component {
window.Einstore.me().then((me) => {
this.setState({ old: me, form: { ...me } })
})
pageTitle('My profile')
}

getFormValues = () => {
Expand Down
2 changes: 2 additions & 0 deletions src/parts/appBuilds.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import IconTrash from '../shapes/trash'
import usure from '../utils/usure'
import { navigate } from '@reach/router'
import CardItem from '../components/cardItem'
import pageTitle from "../utils/pageTitle";

export default class AppBuilds extends Component {
state = {
Expand All @@ -21,6 +22,7 @@ export default class AppBuilds extends Component {
this.setState({
build: result[0],
})
pageTitle(this.state.build.name)
})
}

Expand Down
2 changes: 2 additions & 0 deletions src/parts/appDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import './page.sass'
import IconTrash from '../shapes/trash'
import usure from '../utils/usure'
import { navigate } from '@reach/router'
import pageTitle from "../utils/pageTitle";

export default class AppDetail extends Component {
state = {
Expand All @@ -32,6 +33,7 @@ export default class AppDetail extends Component {
...result,
loaded: true,
})
pageTitle(this.state.name)
})
.catch((error) => {
console.log(error)
Expand Down
2 changes: 2 additions & 0 deletions src/parts/team.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import IconInfo from '../shapes/info'
import usure from '../utils/usure'
import getBaseUrl from 'utils/getBaseUrl'
import showMessage from "../utils/showMessage";
import pageTitle from "../utils/pageTitle";

export default class Team extends Component {
state = {
Expand All @@ -35,6 +36,7 @@ export default class Team extends Component {
componentDidMount() {
window.Einstore.teams().then((teams) => this.setState({ teams }))
this.refreshUsers()
pageTitle('Team & members')
}

refreshUsers = () => {
Expand Down
12 changes: 12 additions & 0 deletions src/utils/pageTitle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as browserStorage from './browserStorage'

export default function pageTitle(pageName?: string): void {
const serverName = browserStorage.get('serverName')
let title = pageName ? pageName + ' | ' : ''

if(serverName.length > 0){
title += serverName
}

document.title = title
}

0 comments on commit ab22405

Please sign in to comment.