Fix DAR-85
This commit is contained in:
Binary file not shown.
@@ -16,6 +16,9 @@ const images = {
|
|||||||
done: require("./images/done.png"),
|
done: require("./images/done.png"),
|
||||||
target: require("./images/target.png"),
|
target: require("./images/target.png"),
|
||||||
pin: require("./images/pin.png"),
|
pin: require("./images/pin.png"),
|
||||||
|
hardhat: require("./images/hardhat.png"),
|
||||||
|
clipboard: require("./images/clipboard.png"),
|
||||||
|
question: require("./images/question.png"),
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Icon extends Component {
|
export class Icon extends Component {
|
||||||
|
|||||||
BIN
mobile/src/ui/images/clipboard.png
Normal file
BIN
mobile/src/ui/images/clipboard.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 937 B |
BIN
mobile/src/ui/images/hardhat.png
Normal file
BIN
mobile/src/ui/images/hardhat.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
BIN
mobile/src/ui/images/question.png
Normal file
BIN
mobile/src/ui/images/question.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
@@ -1,13 +1,18 @@
|
|||||||
import React, { Component, Fragment } from 'react'
|
import React, { Component, Fragment } from "react"
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from "prop-types"
|
||||||
import autobind from 'autobind-decorator'
|
import autobind from "autobind-decorator"
|
||||||
import { TeamList } from './TeamList'
|
import { TeamList } from "./TeamList"
|
||||||
import { TeamForm } from './TeamForm'
|
import { TeamForm } from "./TeamForm"
|
||||||
import { TeamFormPlaceholder } from './TeamFormPlaceholder'
|
import { TeamFormPlaceholder } from "./TeamFormPlaceholder"
|
||||||
import { api } from 'src/API'
|
import { api } from "src/API"
|
||||||
import { Row, Column, Box } from 'ui'
|
import { Row, Column, Box } from "ui"
|
||||||
import { YesNoMessageModal, MessageModal, ChangeEmailModal, WaitModal } from '../Modal'
|
import {
|
||||||
import { sizeInfo, colorInfo } from 'ui/style'
|
YesNoMessageModal,
|
||||||
|
MessageModal,
|
||||||
|
ChangeEmailModal,
|
||||||
|
WaitModal,
|
||||||
|
} from "../Modal"
|
||||||
|
import { sizeInfo, colorInfo } from "ui/style"
|
||||||
|
|
||||||
export class Teams extends Component {
|
export class Teams extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@@ -28,24 +33,27 @@ export class Teams extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.changeTitle('Teams')
|
this.props.changeTitle("Teams")
|
||||||
|
|
||||||
api.listTeams().then((list) => {
|
api
|
||||||
list.items.sort((teamA, teamB) => (teamA.name.localeCompare(teamB.name)))
|
.listTeams()
|
||||||
|
.then((list) => {
|
||||||
|
list.items.sort((teamA, teamB) => teamA.name.localeCompare(teamB.name))
|
||||||
this.setState({ teams: list.items })
|
this.setState({ teams: list.items })
|
||||||
}).catch((error) => {
|
})
|
||||||
|
.catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
messageModal: {
|
messageModal: {
|
||||||
icon: 'hand',
|
icon: "hand",
|
||||||
message: 'Unable to get the list of teams.',
|
message: "Unable to get the list of teams.",
|
||||||
detail: error.message,
|
detail: error.message,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.props.changeTitle('')
|
this.props.changeTitle("")
|
||||||
}
|
}
|
||||||
|
|
||||||
removeUnfinishedNewTeam() {
|
removeUnfinishedNewTeam() {
|
||||||
@@ -64,9 +72,10 @@ export class Teams extends Component {
|
|||||||
this.nextSelectedTeam = team
|
this.nextSelectedTeam = team
|
||||||
this.setState({
|
this.setState({
|
||||||
yesNoModal: {
|
yesNoModal: {
|
||||||
question: 'This team has been modified. Are you sure you would like to navigate away?',
|
question:
|
||||||
onDismiss: this.handleModifiedModalDismiss
|
"This team has been modified. Are you sure you would like to navigate away?",
|
||||||
}
|
onDismiss: this.handleModifiedModalDismiss,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.setState({ selectedTeam: team })
|
this.setState({ selectedTeam: team })
|
||||||
@@ -77,43 +86,51 @@ export class Teams extends Component {
|
|||||||
@autobind
|
@autobind
|
||||||
handleSave(team) {
|
handleSave(team) {
|
||||||
if (team._id) {
|
if (team._id) {
|
||||||
this.setState({ waitModal: { message: 'Updating Team' } })
|
this.setState({ waitModal: { message: "Updating Team" } })
|
||||||
api.updateTeam(team).then((updatedTeam) => {
|
api
|
||||||
|
.updateTeam(team)
|
||||||
|
.then((updatedTeam) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: null,
|
waitModal: null,
|
||||||
teams: this.state.teams.map((team) => (team._id === updatedTeam._id ? updatedTeam : team)),
|
teams: this.state.teams.map(
|
||||||
|
(team) => (team._id === updatedTeam._id ? updatedTeam : team)
|
||||||
|
),
|
||||||
modified: false,
|
modified: false,
|
||||||
selectedTeam: updatedTeam
|
selectedTeam: updatedTeam,
|
||||||
})
|
})
|
||||||
}).catch((error) => {
|
})
|
||||||
|
.catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: null,
|
waitModal: null,
|
||||||
messageModal: {
|
messageModal: {
|
||||||
icon: 'hand',
|
icon: "hand",
|
||||||
message: 'Unable to save the team changes',
|
message: "Unable to save the team changes",
|
||||||
detail: error.message,
|
detail: error.message,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.setState({ waitModal: { message: 'Creating Team' } })
|
this.setState({ waitModal: { message: "Creating Team" } })
|
||||||
api.createTeam(team).then((createdTeam) => {
|
api
|
||||||
|
.createTeam(team)
|
||||||
|
.then((createdTeam) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: false,
|
waitModal: false,
|
||||||
teams: this.state.teams.map((team) => (!team._id ? createdTeam : team)).sort((a, b) => (
|
teams: this.state.teams
|
||||||
a.name < b.name ? -1 : a.name > b.name ? 1 : 0
|
.map((team) => (!team._id ? createdTeam : team))
|
||||||
)),
|
.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0)),
|
||||||
modified: false,
|
modified: false,
|
||||||
selectedTeam: createdTeam
|
selectedTeam: createdTeam,
|
||||||
})
|
})
|
||||||
}).catch((error) => {
|
})
|
||||||
|
.catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: null,
|
waitModal: null,
|
||||||
messageModal: {
|
messageModal: {
|
||||||
icon: 'hand',
|
icon: "hand",
|
||||||
message: 'Unable to create the team.',
|
message: "Unable to create the team.",
|
||||||
detail: error.message,
|
detail: error.message,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -121,31 +138,38 @@ export class Teams extends Component {
|
|||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
handleChangeEmail() {
|
handleChangeEmail() {
|
||||||
this.setState({ changeEmailModal: { oldEmail: this.state.selectedTeam.email } })
|
this.setState({
|
||||||
|
changeEmailModal: { oldEmail: this.state.selectedTeam.email },
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
handleResendEmail() {
|
handleResendEmail() {
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: { message: 'Resending Email...' }
|
waitModal: { message: "Resending Email..." },
|
||||||
})
|
})
|
||||||
api.sendConfirmEmail({ existingEmail: this.state.selectedTeam.email }).then(() => {
|
api
|
||||||
|
.sendConfirmEmail({ existingEmail: this.state.selectedTeam.email })
|
||||||
|
.then(() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: null,
|
waitModal: null,
|
||||||
messageModal: {
|
messageModal: {
|
||||||
icon: 'thumb',
|
icon: "thumb",
|
||||||
message: `An email has been sent to '${this.state.selectedTeam.email}' with further instructions.`
|
message: `An email has been sent to '${
|
||||||
}
|
this.state.selectedTeam.email
|
||||||
|
}' with further instructions.`,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}).catch((error) => {
|
})
|
||||||
|
.catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
error: true,
|
error: true,
|
||||||
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,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -157,26 +181,32 @@ export class Teams extends Component {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: { message: 'Requesting Email Change...' }
|
waitModal: { message: "Requesting Email Change..." },
|
||||||
})
|
})
|
||||||
if (this.state.selectedTeam) {
|
if (this.state.selectedTeam) {
|
||||||
api.sendConfirmEmail({ existingEmail: this.state.selectedTeam.email, newEmail }).then(() => {
|
api
|
||||||
|
.sendConfirmEmail({
|
||||||
|
existingEmail: this.state.selectedTeam.email,
|
||||||
|
newEmail,
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: null,
|
waitModal: null,
|
||||||
messageModal: {
|
messageModal: {
|
||||||
icon: 'hand',
|
icon: "hand",
|
||||||
message: `An email has been sent to '${newEmail}' to confirm this email.`
|
message: `An email has been sent to '${newEmail}' to confirm this email.`,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}).catch((error) => {
|
})
|
||||||
|
.catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
error: true,
|
error: true,
|
||||||
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,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -186,9 +216,10 @@ export class Teams extends Component {
|
|||||||
handleRemove() {
|
handleRemove() {
|
||||||
this.setState({
|
this.setState({
|
||||||
yesNoModal: {
|
yesNoModal: {
|
||||||
question: 'Are you sure you want to remove this team? This will also remove them from any teams they belong to.',
|
question:
|
||||||
onDismiss: this.handleRemoveModalDismiss
|
"Are you sure you want to remove this team? This will also remove them from any teams they belong to.",
|
||||||
}
|
onDismiss: this.handleRemoveModalDismiss,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,31 +227,39 @@ export class Teams extends Component {
|
|||||||
handleRemoveModalDismiss(yes) {
|
handleRemoveModalDismiss(yes) {
|
||||||
if (yes) {
|
if (yes) {
|
||||||
const selectedTeamId = this.state.selectedTeam._id
|
const selectedTeamId = this.state.selectedTeam._id
|
||||||
const selectedIndex = this.state.teams.findIndex((team) => (team._id === selectedTeamId))
|
const selectedIndex = this.state.teams.findIndex(
|
||||||
|
(team) => team._id === selectedTeamId
|
||||||
|
)
|
||||||
|
|
||||||
if (selectedIndex >= 0) {
|
if (selectedIndex >= 0) {
|
||||||
this.setState({ waitModal: { message: 'Removing Team' } })
|
this.setState({ waitModal: { message: "Removing Team" } })
|
||||||
api.deleteTeam(selectedTeamId).then(() => {
|
api
|
||||||
|
.deleteTeam(selectedTeamId)
|
||||||
|
.then(() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: null,
|
waitModal: null,
|
||||||
teams: [...this.state.teams.slice(0, selectedIndex), ...this.state.teams.slice(selectedIndex + 1)],
|
teams: [
|
||||||
selectedTeam: null
|
...this.state.teams.slice(0, selectedIndex),
|
||||||
|
...this.state.teams.slice(selectedIndex + 1),
|
||||||
|
],
|
||||||
|
selectedTeam: null,
|
||||||
})
|
})
|
||||||
}).catch((error) => {
|
})
|
||||||
|
.catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: null,
|
waitModal: null,
|
||||||
messageModal: {
|
messageModal: {
|
||||||
icon: 'hand',
|
icon: "hand",
|
||||||
message: 'Unable to remove the team.',
|
message: "Unable to remove the team.",
|
||||||
detail: error.message,
|
detail: error.message,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
yesNoModal: null
|
yesNoModal: null,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,14 +268,14 @@ export class Teams extends Component {
|
|||||||
if (yes) {
|
if (yes) {
|
||||||
this.setState({
|
this.setState({
|
||||||
selectedTeam: this.nextSelectedTeam,
|
selectedTeam: this.nextSelectedTeam,
|
||||||
modified: false
|
modified: false,
|
||||||
})
|
})
|
||||||
this.removeUnfinishedNewTeam()
|
this.removeUnfinishedNewTeam()
|
||||||
delete this.nextSelectedTeam
|
delete this.nextSelectedTeam
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
yesNoModal: null
|
yesNoModal: null,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,10 +291,14 @@ export class Teams extends Component {
|
|||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
handleAddNewTeam() {
|
handleAddNewTeam() {
|
||||||
|
let teams = this.state.teams
|
||||||
|
|
||||||
|
if (teams.length > 0 && !!teams[0]._id) {
|
||||||
let newTeam = {}
|
let newTeam = {}
|
||||||
let newTeams = [newTeam].concat(this.state.teams)
|
let newTeams = [newTeam].concat(this.state.teams)
|
||||||
this.setState({ teams: newTeams, selectedTeam: newTeam })
|
this.setState({ teams: newTeams, selectedTeam: newTeam })
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { messageModal, yesNoModal, changeEmailModal } = this.state
|
const { messageModal, yesNoModal, changeEmailModal } = this.state
|
||||||
@@ -266,43 +309,65 @@ export class Teams extends Component {
|
|||||||
<Column.Item grow>
|
<Column.Item grow>
|
||||||
<Row fillParent>
|
<Row fillParent>
|
||||||
<Row.Item width={sizeInfo.formRowSpacing} />
|
<Row.Item width={sizeInfo.formRowSpacing} />
|
||||||
<Row.Item width='25vw'>
|
<Row.Item width="25vw">
|
||||||
<TeamList teams={this.state.teams} selectedTeam={this.state.selectedTeam}
|
<TeamList
|
||||||
selectionModified={this.state.modified} onTeamListClick={this.handleTeamListClick}
|
teams={this.state.teams}
|
||||||
onAddNewTeam={this.handleAddNewTeam} />
|
selectedTeam={this.state.selectedTeam}
|
||||||
|
selectionModified={this.state.modified}
|
||||||
|
onTeamListClick={this.handleTeamListClick}
|
||||||
|
onAddNewTeam={this.handleAddNewTeam}
|
||||||
|
/>
|
||||||
</Row.Item>
|
</Row.Item>
|
||||||
<Row.Item width={sizeInfo.formRowSpacing} />
|
<Row.Item width={sizeInfo.formRowSpacing} />
|
||||||
<Row.Item grow>
|
<Row.Item grow>
|
||||||
<Box border={{ width: sizeInfo.headerBorderWidth, color: colorInfo.headerBorder }} radius={sizeInfo.formBoxRadius}>
|
<Box
|
||||||
{
|
border={{
|
||||||
this.state.selectedTeam
|
width: sizeInfo.headerBorderWidth,
|
||||||
? <TeamForm team={this.state.selectedTeam} onSave={this.handleSave}
|
color: colorInfo.headerBorder,
|
||||||
onRemove={this.handleRemove} onModifiedChanged={this.handleModifiedChanged}
|
}}
|
||||||
onChangeEmail={this.handleChangeEmail} onResendEmail={this.handleResendEmail} />
|
radius={sizeInfo.formBoxRadius}>
|
||||||
: <TeamFormPlaceholder />
|
{this.state.selectedTeam ? (
|
||||||
}
|
<TeamForm
|
||||||
|
team={this.state.selectedTeam}
|
||||||
|
onSave={this.handleSave}
|
||||||
|
onRemove={this.handleRemove}
|
||||||
|
onModifiedChanged={this.handleModifiedChanged}
|
||||||
|
onChangeEmail={this.handleChangeEmail}
|
||||||
|
onResendEmail={this.handleResendEmail}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<TeamFormPlaceholder />
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</Row.Item>
|
</Row.Item>
|
||||||
<Row.Item width={sizeInfo.formRowSpacing} />
|
<Row.Item width={sizeInfo.formRowSpacing} />
|
||||||
</Row>
|
</Row>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
<Column.Item height={sizeInfo.formColumnSpacing}>
|
<Column.Item height={sizeInfo.formColumnSpacing}>
|
||||||
<ChangeEmailModal open={!!changeEmailModal}
|
<ChangeEmailModal
|
||||||
|
open={!!changeEmailModal}
|
||||||
oldEmail={changeEmailModal && changeEmailModal.oldEmail}
|
oldEmail={changeEmailModal && changeEmailModal.oldEmail}
|
||||||
onDismiss={this.handleChangeEmailDismiss} />
|
onDismiss={this.handleChangeEmailDismiss}
|
||||||
|
/>
|
||||||
|
|
||||||
<YesNoMessageModal open={!!yesNoModal}
|
<YesNoMessageModal
|
||||||
question={yesNoModal ? yesNoModal.question : ''}
|
open={!!yesNoModal}
|
||||||
onDismiss={yesNoModal && yesNoModal.onDismiss} />
|
question={yesNoModal ? yesNoModal.question : ""}
|
||||||
|
onDismiss={yesNoModal && yesNoModal.onDismiss}
|
||||||
|
/>
|
||||||
|
|
||||||
<MessageModal
|
<MessageModal
|
||||||
open={!!messageModal}
|
open={!!messageModal}
|
||||||
icon={messageModal ? messageModal.icon : ''}
|
icon={messageModal ? messageModal.icon : ""}
|
||||||
message={messageModal ? messageModal.message : ''}
|
message={messageModal ? messageModal.message : ""}
|
||||||
detail={messageModal && messageModal.detail}
|
detail={messageModal && messageModal.detail}
|
||||||
onDismiss={this.handleMessageModalDismiss} />
|
onDismiss={this.handleMessageModalDismiss}
|
||||||
|
/>
|
||||||
|
|
||||||
<WaitModal active={!!this.state.waitModal} message={this.state.waitModal ? this.state.waitModal.message : ''} />
|
<WaitModal
|
||||||
|
active={!!this.state.waitModal}
|
||||||
|
message={this.state.waitModal ? this.state.waitModal.message : ""}
|
||||||
|
/>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
import React, { Component, Fragment } from 'react'
|
import React, { Component, Fragment } from "react"
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from "prop-types"
|
||||||
import autobind from 'autobind-decorator'
|
import autobind from "autobind-decorator"
|
||||||
import { UserList } from './UserList'
|
import { UserList } from "./UserList"
|
||||||
import { UserForm } from './UserForm'
|
import { UserForm } from "./UserForm"
|
||||||
import { UserFormPlaceholder } from './UserFormPlaceholder'
|
import { UserFormPlaceholder } from "./UserFormPlaceholder"
|
||||||
import { api } from 'src/API'
|
import { api } from "src/API"
|
||||||
import { Row, Column, Box } from 'ui'
|
import { Row, Column, Box } from "ui"
|
||||||
import { YesNoMessageModal, MessageModal, ChangeEmailModal, WaitModal } from '../Modal'
|
import {
|
||||||
import { sizeInfo, colorInfo } from 'ui/style'
|
YesNoMessageModal,
|
||||||
|
MessageModal,
|
||||||
|
ChangeEmailModal,
|
||||||
|
WaitModal,
|
||||||
|
} from "../Modal"
|
||||||
|
import { sizeInfo, colorInfo } from "ui/style"
|
||||||
|
|
||||||
export class Users extends Component {
|
export class Users extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@@ -28,24 +33,29 @@ export class Users extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.changeTitle('Users')
|
this.props.changeTitle("Users")
|
||||||
|
|
||||||
api.listUsers().then((list) => {
|
api
|
||||||
list.items.sort((userA, userB) => (userA.lastName.localeCompare(userB.lastName)))
|
.listUsers()
|
||||||
|
.then((list) => {
|
||||||
|
list.items.sort((userA, userB) =>
|
||||||
|
userA.lastName.localeCompare(userB.lastName)
|
||||||
|
)
|
||||||
this.setState({ users: list.items })
|
this.setState({ users: list.items })
|
||||||
}).catch((error) => {
|
})
|
||||||
|
.catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
messageModal: {
|
messageModal: {
|
||||||
icon: 'hand',
|
icon: "hand",
|
||||||
message: 'Unable to get the list of users.',
|
message: "Unable to get the list of users.",
|
||||||
detail: error.message,
|
detail: error.message,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.props.changeTitle('')
|
this.props.changeTitle("")
|
||||||
}
|
}
|
||||||
|
|
||||||
removeUnfinishedNewUser() {
|
removeUnfinishedNewUser() {
|
||||||
@@ -64,9 +74,10 @@ export class Users extends Component {
|
|||||||
this.nextSelectedUser = user
|
this.nextSelectedUser = user
|
||||||
this.setState({
|
this.setState({
|
||||||
yesNoModal: {
|
yesNoModal: {
|
||||||
question: 'This user has been modified. Are you sure you would like to navigate away?',
|
question:
|
||||||
onDismiss: this.handleModifiedModalDismiss
|
"This user has been modified. Are you sure you would like to navigate away?",
|
||||||
}
|
onDismiss: this.handleModifiedModalDismiss,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.setState({ selectedUser: user })
|
this.setState({ selectedUser: user })
|
||||||
@@ -77,43 +88,54 @@ export class Users extends Component {
|
|||||||
@autobind
|
@autobind
|
||||||
handleSave(user) {
|
handleSave(user) {
|
||||||
if (user._id) {
|
if (user._id) {
|
||||||
this.setState({ waitModal: { message: 'Updating User' } })
|
this.setState({ waitModal: { message: "Updating User" } })
|
||||||
api.updateUser(user).then((updatedUser) => {
|
api
|
||||||
|
.updateUser(user)
|
||||||
|
.then((updatedUser) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: null,
|
waitModal: null,
|
||||||
users: this.state.users.map((user) => (user._id === updatedUser._id ? updatedUser : user)),
|
users: this.state.users.map(
|
||||||
|
(user) => (user._id === updatedUser._id ? updatedUser : user)
|
||||||
|
),
|
||||||
modified: false,
|
modified: false,
|
||||||
selectedUser: updatedUser
|
selectedUser: updatedUser,
|
||||||
})
|
})
|
||||||
}).catch((error) => {
|
})
|
||||||
|
.catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: null,
|
waitModal: null,
|
||||||
messageModal: {
|
messageModal: {
|
||||||
icon: 'hand',
|
icon: "hand",
|
||||||
message: 'Unable to save the user changes',
|
message: "Unable to save the user changes",
|
||||||
detail: error.message,
|
detail: error.message,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.setState({ waitModal: { message: 'Creating User' } })
|
this.setState({ waitModal: { message: "Creating User" } })
|
||||||
api.createUser(user).then((createdUser) => {
|
api
|
||||||
|
.createUser(user)
|
||||||
|
.then((createdUser) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: false,
|
waitModal: false,
|
||||||
users: this.state.users.map((user) => (!user._id ? createdUser : user)).sort((a, b) => (
|
users: this.state.users
|
||||||
a.lastName < b.lastName ? -1 : a.lastName > b.lastName : 0
|
.map((user) => (!user._id ? createdUser : user))
|
||||||
)),
|
.sort(
|
||||||
|
(a, b) =>
|
||||||
|
((a.lastName < b.lastName ? -1 : a.lastName > b.lastName): 0)
|
||||||
|
),
|
||||||
modified: false,
|
modified: false,
|
||||||
selectedUser: createdUser
|
selectedUser: createdUser,
|
||||||
})
|
})
|
||||||
}).catch((error) => {
|
})
|
||||||
|
.catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: null,
|
waitModal: null,
|
||||||
messageModal: {
|
messageModal: {
|
||||||
icon: 'hand',
|
icon: "hand",
|
||||||
message: 'Unable to create the user.',
|
message: "Unable to create the user.",
|
||||||
detail: error.message,
|
detail: error.message,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -121,31 +143,38 @@ export class Users extends Component {
|
|||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
handleChangeEmail() {
|
handleChangeEmail() {
|
||||||
this.setState({ changeEmailModal: { oldEmail: this.state.selectedUser.email } })
|
this.setState({
|
||||||
|
changeEmailModal: { oldEmail: this.state.selectedUser.email },
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
handleResendEmail() {
|
handleResendEmail() {
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: { message: 'Resending Email...' }
|
waitModal: { message: "Resending Email..." },
|
||||||
})
|
})
|
||||||
api.sendConfirmEmail({ existingEmail: this.state.selectedUser.email }).then(() => {
|
api
|
||||||
|
.sendConfirmEmail({ existingEmail: this.state.selectedUser.email })
|
||||||
|
.then(() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: null,
|
waitModal: null,
|
||||||
messageModal: {
|
messageModal: {
|
||||||
icon: 'thumb',
|
icon: "thumb",
|
||||||
message: `An email has been sent to '${this.state.selectedUser.email}' with further instructions.`
|
message: `An email has been sent to '${
|
||||||
}
|
this.state.selectedUser.email
|
||||||
|
}' with further instructions.`,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}).catch((error) => {
|
})
|
||||||
|
.catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
error: true,
|
error: true,
|
||||||
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,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -157,26 +186,32 @@ export class Users extends Component {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: { message: 'Requesting Email Change...' }
|
waitModal: { message: "Requesting Email Change..." },
|
||||||
})
|
})
|
||||||
if (this.state.selectedUser) {
|
if (this.state.selectedUser) {
|
||||||
api.sendConfirmEmail({ existingEmail: this.state.selectedUser.email, newEmail }).then(() => {
|
api
|
||||||
|
.sendConfirmEmail({
|
||||||
|
existingEmail: this.state.selectedUser.email,
|
||||||
|
newEmail,
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: null,
|
waitModal: null,
|
||||||
messageModal: {
|
messageModal: {
|
||||||
icon: 'hand',
|
icon: "hand",
|
||||||
message: `An email has been sent to '${newEmail}' to confirm this email.`
|
message: `An email has been sent to '${newEmail}' to confirm this email.`,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}).catch((error) => {
|
})
|
||||||
|
.catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
error: true,
|
error: true,
|
||||||
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,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -186,9 +221,10 @@ export class Users extends Component {
|
|||||||
handleRemove() {
|
handleRemove() {
|
||||||
this.setState({
|
this.setState({
|
||||||
yesNoModal: {
|
yesNoModal: {
|
||||||
question: 'Are you sure you want to remove this user? This will also remove them from any teams they belong to.',
|
question:
|
||||||
onDismiss: this.handleRemoveModalDismiss
|
"Are you sure you want to remove this user? This will also remove them from any teams they belong to.",
|
||||||
}
|
onDismiss: this.handleRemoveModalDismiss,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,31 +232,39 @@ export class Users extends Component {
|
|||||||
handleRemoveModalDismiss(yes) {
|
handleRemoveModalDismiss(yes) {
|
||||||
if (yes) {
|
if (yes) {
|
||||||
const selectedUserId = this.state.selectedUser._id
|
const selectedUserId = this.state.selectedUser._id
|
||||||
const selectedIndex = this.state.users.findIndex((user) => (user._id === selectedUserId))
|
const selectedIndex = this.state.users.findIndex(
|
||||||
|
(user) => user._id === selectedUserId
|
||||||
|
)
|
||||||
|
|
||||||
if (selectedIndex >= 0) {
|
if (selectedIndex >= 0) {
|
||||||
this.setState({ waitModal: { message: 'Removing User' } })
|
this.setState({ waitModal: { message: "Removing User" } })
|
||||||
api.deleteUser(selectedUserId).then(() => {
|
api
|
||||||
|
.deleteUser(selectedUserId)
|
||||||
|
.then(() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: null,
|
waitModal: null,
|
||||||
users: [...this.state.users.slice(0, selectedIndex), ...this.state.users.slice(selectedIndex + 1)],
|
users: [
|
||||||
selectedUser: null
|
...this.state.users.slice(0, selectedIndex),
|
||||||
|
...this.state.users.slice(selectedIndex + 1),
|
||||||
|
],
|
||||||
|
selectedUser: null,
|
||||||
})
|
})
|
||||||
}).catch((error) => {
|
})
|
||||||
|
.catch((error) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
waitModal: null,
|
waitModal: null,
|
||||||
messageModal: {
|
messageModal: {
|
||||||
icon: 'hand',
|
icon: "hand",
|
||||||
message: 'Unable to remove the user.',
|
message: "Unable to remove the user.",
|
||||||
detail: error.message,
|
detail: error.message,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
yesNoModal: null
|
yesNoModal: null,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,14 +273,14 @@ export class Users extends Component {
|
|||||||
if (yes) {
|
if (yes) {
|
||||||
this.setState({
|
this.setState({
|
||||||
selectedUser: this.nextSelectedUser,
|
selectedUser: this.nextSelectedUser,
|
||||||
modified: false
|
modified: false,
|
||||||
})
|
})
|
||||||
this.removeUnfinishedNewUser()
|
this.removeUnfinishedNewUser()
|
||||||
delete this.nextSelectedUser
|
delete this.nextSelectedUser
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
yesNoModal: null
|
yesNoModal: null,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,10 +296,14 @@ export class Users extends Component {
|
|||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
handleAddNewUser() {
|
handleAddNewUser() {
|
||||||
|
let users = this.state.users
|
||||||
|
|
||||||
|
if (users.length > 0 && !!users[0]._id) {
|
||||||
let newUser = {}
|
let newUser = {}
|
||||||
let newUsers = [newUser].concat(this.state.users)
|
let newUsers = [newUser].concat(users)
|
||||||
this.setState({ users: newUsers, selectedUser: newUser })
|
this.setState({ users: newUsers, selectedUser: newUser })
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { messageModal, yesNoModal, changeEmailModal } = this.state
|
const { messageModal, yesNoModal, changeEmailModal } = this.state
|
||||||
@@ -266,43 +314,65 @@ export class Users extends Component {
|
|||||||
<Column.Item grow>
|
<Column.Item grow>
|
||||||
<Row fillParent>
|
<Row fillParent>
|
||||||
<Row.Item width={sizeInfo.formRowSpacing} />
|
<Row.Item width={sizeInfo.formRowSpacing} />
|
||||||
<Row.Item width='25vw'>
|
<Row.Item width="25vw">
|
||||||
<UserList users={this.state.users} selectedUser={this.state.selectedUser}
|
<UserList
|
||||||
selectionModified={this.state.modified} onUserListClick={this.handleUserListClick}
|
users={this.state.users}
|
||||||
onAddNewUser={this.handleAddNewUser} />
|
selectedUser={this.state.selectedUser}
|
||||||
|
selectionModified={this.state.modified}
|
||||||
|
onUserListClick={this.handleUserListClick}
|
||||||
|
onAddNewUser={this.handleAddNewUser}
|
||||||
|
/>
|
||||||
</Row.Item>
|
</Row.Item>
|
||||||
<Row.Item width={sizeInfo.formRowSpacing} />
|
<Row.Item width={sizeInfo.formRowSpacing} />
|
||||||
<Row.Item grow>
|
<Row.Item grow>
|
||||||
<Box border={{ width: sizeInfo.headerBorderWidth, color: colorInfo.headerBorder }} radius={sizeInfo.formBoxRadius}>
|
<Box
|
||||||
{
|
border={{
|
||||||
this.state.selectedUser
|
width: sizeInfo.headerBorderWidth,
|
||||||
? <UserForm user={this.state.selectedUser} onSave={this.handleSave}
|
color: colorInfo.headerBorder,
|
||||||
onRemove={this.handleRemove} onModifiedChanged={this.handleModifiedChanged}
|
}}
|
||||||
onChangeEmail={this.handleChangeEmail} onResendEmail={this.handleResendEmail} />
|
radius={sizeInfo.formBoxRadius}>
|
||||||
: <UserFormPlaceholder />
|
{this.state.selectedUser ? (
|
||||||
}
|
<UserForm
|
||||||
|
user={this.state.selectedUser}
|
||||||
|
onSave={this.handleSave}
|
||||||
|
onRemove={this.handleRemove}
|
||||||
|
onModifiedChanged={this.handleModifiedChanged}
|
||||||
|
onChangeEmail={this.handleChangeEmail}
|
||||||
|
onResendEmail={this.handleResendEmail}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<UserFormPlaceholder />
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</Row.Item>
|
</Row.Item>
|
||||||
<Row.Item width={sizeInfo.formRowSpacing} />
|
<Row.Item width={sizeInfo.formRowSpacing} />
|
||||||
</Row>
|
</Row>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
<Column.Item height={sizeInfo.formColumnSpacing}>
|
<Column.Item height={sizeInfo.formColumnSpacing}>
|
||||||
<ChangeEmailModal open={!!changeEmailModal}
|
<ChangeEmailModal
|
||||||
|
open={!!changeEmailModal}
|
||||||
oldEmail={changeEmailModal && changeEmailModal.oldEmail}
|
oldEmail={changeEmailModal && changeEmailModal.oldEmail}
|
||||||
onDismiss={this.handleChangeEmailDismiss} />
|
onDismiss={this.handleChangeEmailDismiss}
|
||||||
|
/>
|
||||||
|
|
||||||
<YesNoMessageModal open={!!yesNoModal}
|
<YesNoMessageModal
|
||||||
question={yesNoModal ? yesNoModal.question : ''}
|
open={!!yesNoModal}
|
||||||
onDismiss={yesNoModal && yesNoModal.onDismiss} />
|
question={yesNoModal ? yesNoModal.question : ""}
|
||||||
|
onDismiss={yesNoModal && yesNoModal.onDismiss}
|
||||||
|
/>
|
||||||
|
|
||||||
<MessageModal
|
<MessageModal
|
||||||
open={!!messageModal}
|
open={!!messageModal}
|
||||||
icon={messageModal ? messageModal.icon : ''}
|
icon={messageModal ? messageModal.icon : ""}
|
||||||
message={messageModal ? messageModal.message : ''}
|
message={messageModal ? messageModal.message : ""}
|
||||||
detail={messageModal && messageModal.detail}
|
detail={messageModal && messageModal.detail}
|
||||||
onDismiss={this.handleMessageModalDismiss} />
|
onDismiss={this.handleMessageModalDismiss}
|
||||||
|
/>
|
||||||
|
|
||||||
<WaitModal active={!!this.state.waitModal} message={this.state.waitModal ? this.state.waitModal.message : ''} />
|
<WaitModal
|
||||||
|
active={!!this.state.waitModal}
|
||||||
|
message={this.state.waitModal ? this.state.waitModal.message : ""}
|
||||||
|
/>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user