summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/components/projects
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-web/opendc-web-ui/src/components/projects')
-rw-r--r--opendc-web/opendc-web-ui/src/components/projects/ProjectList.js12
-rw-r--r--opendc-web/opendc-web-ui/src/components/projects/ProjectRow.js31
2 files changed, 24 insertions, 19 deletions
diff --git a/opendc-web/opendc-web-ui/src/components/projects/ProjectList.js b/opendc-web/opendc-web-ui/src/components/projects/ProjectList.js
index 90d42326..cb17b835 100644
--- a/opendc-web/opendc-web-ui/src/components/projects/ProjectList.js
+++ b/opendc-web/opendc-web-ui/src/components/projects/ProjectList.js
@@ -1,12 +1,12 @@
import PropTypes from 'prop-types'
import React from 'react'
-import { Authorization } from '../../shapes'
+import { Project } from '../../shapes'
import ProjectRow from './ProjectRow'
-const ProjectList = ({ authorizations }) => {
+const ProjectList = ({ projects }) => {
return (
<div className="vertically-expanding-container">
- {authorizations.length === 0 ? (
+ {projects.length === 0 ? (
<div className="alert alert-info">
<span className="info-icon fa fa-question-circle mr-2" />
<strong>No projects here yet...</strong> Add some with the 'New Project' button!
@@ -22,8 +22,8 @@ const ProjectList = ({ authorizations }) => {
</tr>
</thead>
<tbody>
- {authorizations.map((authorization) => (
- <ProjectRow projectAuth={authorization} key={authorization.project._id} />
+ {projects.map((project) => (
+ <ProjectRow project={project} key={project._id} />
))}
</tbody>
</table>
@@ -33,7 +33,7 @@ const ProjectList = ({ authorizations }) => {
}
ProjectList.propTypes = {
- authorizations: PropTypes.arrayOf(Authorization).isRequired,
+ projects: PropTypes.arrayOf(Project).isRequired,
}
export default ProjectList
diff --git a/opendc-web/opendc-web-ui/src/components/projects/ProjectRow.js b/opendc-web/opendc-web-ui/src/components/projects/ProjectRow.js
index a0aac098..9a95b777 100644
--- a/opendc-web/opendc-web-ui/src/components/projects/ProjectRow.js
+++ b/opendc-web/opendc-web-ui/src/components/projects/ProjectRow.js
@@ -1,24 +1,29 @@
import classNames from 'classnames'
import React from 'react'
import ProjectActions from '../../containers/projects/ProjectActions'
-import { Authorization } from '../../shapes'
+import { Project } from '../../shapes'
import { AUTH_DESCRIPTION_MAP, AUTH_ICON_MAP } from '../../util/authorizations'
import { parseAndFormatDateTime } from '../../util/date-time'
+import { useAuth } from '../../auth'
-const ProjectRow = ({ projectAuth }) => (
- <tr>
- <td className="pt-3">{projectAuth.project.name}</td>
- <td className="pt-3">{parseAndFormatDateTime(projectAuth.project.datetimeLastEdited)}</td>
- <td className="pt-3">
- <span className={classNames('fa', 'fa-' + AUTH_ICON_MAP[projectAuth.authorizationLevel], 'mr-2')} />
- {AUTH_DESCRIPTION_MAP[projectAuth.authorizationLevel]}
- </td>
- <ProjectActions projectId={projectAuth.project._id} />
- </tr>
-)
+const ProjectRow = ({ project }) => {
+ const { user } = useAuth()
+ const { level } = project.authorizations.find((auth) => auth.userId === user.sub)
+ return (
+ <tr>
+ <td className="pt-3">{project.name}</td>
+ <td className="pt-3">{parseAndFormatDateTime(project.datetimeLastEdited)}</td>
+ <td className="pt-3">
+ <span className={classNames('fa', 'fa-' + AUTH_ICON_MAP[level], 'mr-2')} />
+ {AUTH_DESCRIPTION_MAP[level]}
+ </td>
+ <ProjectActions projectId={project._id} />
+ </tr>
+ )
+}
ProjectRow.propTypes = {
- projectAuth: Authorization.isRequired,
+ project: Project.isRequired,
}
export default ProjectRow