Fix broken links

This commit is contained in:
John Lyon-Smith
2018-05-14 13:31:46 -07:00
parent 68f976ed7f
commit 5b4798b196
4 changed files with 90 additions and 82 deletions

View File

@@ -56,7 +56,7 @@ export class App extends Component {
<ProtectedRoute exact path="/app/profile" component={Profile} /> <ProtectedRoute exact path="/app/profile" component={Profile} />
<ProtectedRoute exact admin path="/app/home" component={Home} /> <ProtectedRoute exact admin path="/app/home" component={Home} />
<ProtectedRoute exact admin path="/app/teams" component={Teams} /> <ProtectedRoute exact admin path="/app/teams" component={Teams} />
<ProtectedRoute exact admin path="/system" component={System} /> <ProtectedRoute exact admin path="/app/system" component={System} />
<ProtectedRoute exact admin path="/app/users" component={Users} /> <ProtectedRoute exact admin path="/app/users" component={Users} />
<DefaultRoute redirect="/app/home" /> <DefaultRoute redirect="/app/home" />
</Switch> </Switch>

View File

@@ -19,7 +19,7 @@ export class Home extends Component {
<PanelButton <PanelButton
icon="users" icon="users"
text="Users" text="Users"
onClick={() => this.props.history.push("/users")} onClick={() => this.props.history.push("/app/users")}
/> />
</Row.Item> </Row.Item>
<Row.Item width={sizeInfo.panelButtonSpacing} /> <Row.Item width={sizeInfo.panelButtonSpacing} />
@@ -27,7 +27,7 @@ export class Home extends Component {
<PanelButton <PanelButton
icon="teams" icon="teams"
text="Teams" text="Teams"
onClick={() => this.props.history.push("/teams")} onClick={() => this.props.history.push("/app/teams")}
/> />
</Row.Item> </Row.Item>
<Row.Item width={sizeInfo.panelButtonSpacing} /> <Row.Item width={sizeInfo.panelButtonSpacing} />
@@ -35,7 +35,7 @@ export class Home extends Component {
<PanelButton <PanelButton
icon="system" icon="system"
text="System" text="System"
onClick={() => this.props.history.push("/system")} onClick={() => this.props.history.push("/app/system")}
/> />
</Row.Item> </Row.Item>
<Row.Item grow /> <Row.Item grow />

View File

@@ -1,11 +1,16 @@
import React, { Fragment, Component } from 'react' import React, { Fragment, Component } from "react"
import { ProfileForm } from './ProfileForm' import { ProfileForm } from "./ProfileForm"
import { api } from 'src/API' import { api } from "src/API"
import { WaitModal, MessageModal, ChangePasswordModal, ChangeEmailModal } from '../Modal' import {
import { Column, Row } from 'ui' WaitModal,
import { sizeInfo } from 'ui/style' MessageModal,
import PropTypes from 'prop-types' ChangePasswordModal,
import autobind from 'autobind-decorator' ChangeEmailModal,
} from "../Modal"
import { Column, Row } from "ui"
import { sizeInfo } from "ui/style"
import PropTypes from "prop-types"
import autobind from "autobind-decorator"
export class Profile extends Component { export class Profile extends Component {
static propTypes = { static propTypes = {
@@ -23,36 +28,31 @@ export class Profile extends Component {
changeEmailModal: null, changeEmailModal: null,
progressModal: null, progressModal: null,
uploadPercent: 0, uploadPercent: 0,
user user,
} }
} }
componentDidMount() {
this.props.changeTitle('Profile')
}
componentWillUnmount() {
this.props.changeTitle('')
}
@autobind @autobind
handleSaved(user) { handleSaved(user) {
this.setState({ waitModal: { message: 'Updating Profile' } }) this.setState({ waitModal: { message: "Updating Profile" } })
api.updateUser(user).then((updatedUser) => { api
this.setState({ .updateUser(user)
waitModal: null, .then((updatedUser) => {
user: updatedUser this.setState({
waitModal: null,
user: updatedUser,
})
}) })
}).catch((error) => { .catch((error) => {
this.setState({ this.setState({
waitModal: null, waitModal: null,
messageModal: { messageModal: {
icon: 'hand', icon: "hand",
message: 'Unable to save the profile changes.', message: "Unable to save the profile changes.",
detail: error.message, detail: error.message,
}, },
})
}) })
})
} }
@autobind @autobind
@@ -71,20 +71,23 @@ export class Profile extends Component {
if (passwords) { if (passwords) {
this.setState({ this.setState({
waitModal: { message: 'Changing Password' } waitModal: { message: "Changing Password" },
}) })
api.changePassword(passwords).then(() => { api
this.setState({ waitModal: false }) .changePassword(passwords)
}).catch((error) => { .then(() => {
this.setState({ this.setState({ waitModal: false })
waitModal: false, })
messageModal: { .catch((error) => {
icon: 'hand', this.setState({
message: 'Unable to change password', waitModal: false,
detail: error.message, messageModal: {
} icon: "hand",
message: "Unable to change password",
detail: error.message,
},
})
}) })
})
} }
} }
@@ -100,30 +103,38 @@ export class Profile extends Component {
return return
} }
this.setState({ this.setState({
waitModal: { message: 'Requesting Email Change...' } waitModal: { message: "Requesting Email Change..." },
}) })
api.sendConfirmEmail({ newEmail }).then(() => { api
this.setState({ .sendConfirmEmail({ newEmail })
waitModal: null, .then(() => {
messageModal: { this.setState({
icon: 'thumb', waitModal: null,
message: `An email has been sent to '${newEmail}' with a link that you need to click on to finish changing your email.` messageModal: {
} icon: "thumb",
message: `An email has been sent to '${newEmail}' with a link that you need to click on to finish changing your email.`,
},
})
}) })
}).catch((error) => { .catch((error) => {
this.setState({ this.setState({
waitModal: null, waitModal: null,
messageModal: { messageModal: {
icon: 'hand', icon: "hand",
message: 'Unable to request email change.', message: "Unable to request email change.",
detail: error.message detail: error.message,
} },
})
}) })
})
} }
render() { render() {
const { messageModal, waitModal, changeEmailModal, changePasswordModal } = this.state const {
messageModal,
waitModal,
changeEmailModal,
changePasswordModal,
} = this.state
return ( return (
<Fragment> <Fragment>
@@ -138,7 +149,8 @@ export class Profile extends Component {
onSelectImage={this.handleSelectImage} onSelectImage={this.handleSelectImage}
onChangePassword={this.handleChangePassword} onChangePassword={this.handleChangePassword}
onChangeEmail={this.handleChangeEmail} onChangeEmail={this.handleChangeEmail}
userImageUrl={this.state.userImageUrl} /> userImageUrl={this.state.userImageUrl}
/>
</Row.Item> </Row.Item>
<Row.Item grow /> <Row.Item grow />
</Row> </Row>
@@ -146,23 +158,27 @@ export class Profile extends Component {
<Column.Item> <Column.Item>
<MessageModal <MessageModal
open={!!messageModal} open={!!messageModal}
icon={messageModal ? messageModal.icon : ''} icon={messageModal ? messageModal.icon : ""}
title={messageModal ? messageModal.title : ''} title={messageModal ? messageModal.title : ""}
message={messageModal ? messageModal.message : ''} message={messageModal ? messageModal.message : ""}
onDismiss={this.handleMessageModalDismiss} /> onDismiss={this.handleMessageModalDismiss}
/>
<ChangeEmailModal <ChangeEmailModal
open={!!changeEmailModal} open={!!changeEmailModal}
oldEmail={changeEmailModal ? changeEmailModal.oldEmail : ''} oldEmail={changeEmailModal ? changeEmailModal.oldEmail : ""}
onDismiss={this.handleChangeEmailDismiss} /> onDismiss={this.handleChangeEmailDismiss}
/>
<WaitModal <WaitModal
active={!!waitModal} active={!!waitModal}
message={waitModal ? waitModal.message : ''} /> message={waitModal ? waitModal.message : ""}
/>
<ChangePasswordModal <ChangePasswordModal
open={!!changePasswordModal} open={!!changePasswordModal}
onDismiss={this.handleChangePasswordDismiss} /> onDismiss={this.handleChangePasswordDismiss}
/>
</Column.Item> </Column.Item>
<Column.Item grow /> <Column.Item grow />
</Fragment> </Fragment>

View File

@@ -21,14 +21,6 @@ export class System extends Component {
} }
} }
componentDidMount(props) {
this.props.changeTitle("System")
}
componentWillUnmount() {
this.props.changeTitle("")
}
@autobind @autobind
handleDeleteActivities() { handleDeleteActivities() {
this.setState({ this.setState({