Skip to content

Commit

Permalink
Edit user default privileges for notes (#80)
Browse files Browse the repository at this point in the history
* Add memberID as editor when creating note by default

* Remove the current member from the dropdowns when creating a note

* Remove outdated comment

Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](npm/hosted-git-info@v2.8.8...v2.8.9)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](npm/hosted-git-info@v2.8.8...v2.8.9)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and n3a9 committed May 23, 2021
1 parent 69af5a3 commit 7c1c387
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 33 deletions.
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<h1 align="center">
<a href="https://uiuc.hack4impact.org"><img src="https://raw.githubusercontent.com/hack4impact-uiuc/uiuc.hack4impact.org/master/public/images/colored-logo.svg" alt="YMCA logo" width="150"></a>
<a href="https://uiuc.hack4impact.org"><img src="https://raw.githubusercontent.com/hack4impact-uiuc/uiuc.hack4impact.org/master/public/images/colored-logo.svg" alt="H4I Logo" width="150"></a>
<br/>
Member Database Tool
</br>
</h1>

<p align="center">
<img src="https://img.shields.io/badge/license-MIT-blue?style=flat-square">
<img src="https://github.com/hack4impact-uiuc/memberdb-tool/actions/workflows/api.yaml/badge.svg">
<img src="https://github.com/hack4impact-uiuc/memberdb-tool/actions/workflows/client.yaml/badge.svg">
</p>

<h4 align="center">A project by <a href="https://uiuc.hack4impact.org/" target="_blank">Hack4Impact UIUC</a> for Spring 2021 Tech Lead Training.</a></h4>
<h4 align="center">A project by <a href="https://uiuc.hack4impact.org/" target="_blank">Hack4Impact UIUC</a>.</a></h4>

<p align="center">
<a href="#background">Background</a> •
Expand All @@ -36,13 +38,18 @@ This application is built with React, Express, MongoDB, and tested with Cypress
## Team

<table align="center">
<tr>
<td align="center"><a href="https://www.linkedin.com/in/alicesf2/"><img src="https://media-exp1.licdn.com/dms/image/C4E03AQFT2hqGjVdINA/profile-displayphoto-shrink_200_200/0/1594157771622?e=1616025600&v=beta&t=NX191E0URDPlV6uXPuGROxDJI-UGKYAZmLb8oJyhwyo" width="125px;" alt="Pusheen"/><br /><b>Alice Fang</b></a><br /><sub>Technical Lead</sub></td>
<td align="center"><a href="https://www.linkedin.com/in/matthew-walowski/"><img src="https://media-exp1.licdn.com/dms/image/C5603AQGdnDuAv9d9YQ/profile-displayphoto-shrink_400_400/0/1610475936652?e=1616025600&v=beta&t=Sna8pEfgzUlOGtmuteSswIFvINzF8Bxk1VjMYvVztvw" width="125px;" alt="Matthew Walowski"/><br /><b>Matthew Walowski</b></a><br /><sub>Technical Lead</sub></td>
<td align="center"><a href="https://www.linkedin.com/in/jeffrey-tang/"><img src="https://raw.githubusercontent.com/hack4impact-uiuc/closegap/master/.github/team_pics/jeffrey.jpg" width="125px;" alt="Jeffrey Tang"/><br /><b>Jeffrey Tang</b></a><br /><sub>Technical Lead</sub></td>
<td align="center"><a href="https://www.linkedin.com/in/amit-m-sawhney/"><img src="https://media-exp1.licdn.com/dms/image/C4D03AQF6eWCL4Z8_qg/profile-displayphoto-shrink_400_400/0/1595738823858?e=1616025600&v=beta&t=T3w5-H_yOqKLRZqNmfW9tMb7wN939e6CMuXqL1HpF6U" width="125px;" alt="Angry Pusheen"/><br /><b>Amit Sawhney</b></a><br /><sub>Software Developer</sub></td>
<td align="center"><a href="www.linkedin.com/in/ishaan-r-sharma"><img src="https://media-exp1.licdn.com/dms/image/C5603AQFAVxJujLhpZg/profile-displayphoto-shrink_400_400/0/1610957839107?e=1616630400&v=beta&t=CbltImSSzDrs8_90ZnJ1pERoPe1D0mvE47giPB5yPI0" width="125px;" alt="Chef Pusheen"/><br /><b>Ishaan Sharma</b></a><br /><sub>Software Developer</sub></td>
</tr>
<tr>
<td align="center"><a href="https://www.linkedin.com/in/sirajchokshi/"><img src="https://images.ctfassets.net/xig6hkxlux4q/1N7hNkpNNdSrzFWwWtqy4M/4763811ee8d14d0c1219a15b07294e97/siraj_chokshi.jpg?h=500" width="125px;" alt="Siraj's Picture"/><br /><b>Siraj Chokshi</b></a><br /><sub>Software Developer</sub></td>
<td align="center"><a href="https://www.linkedin.com/in/daniel-moon1/"><img src="https://images.ctfassets.net/xig6hkxlux4q/1ICw2Nu5UoD7kqg9CHVKsY/99f0d50c5734e9af08e1c540e42bab17/daniel_moon.jpg?h=500" width="125px;" alt="Daniel's Picture"/><br /><b>Daniel Moon</b></a><br /><sub>Software Developer</sub></td>
<td align="center"><a href="https://www.linkedin.com/in/leogalindo/"><img src="https://images.ctfassets.net/xig6hkxlux4q/3PvLLGxks8SwEHUYVGB8cM/8a376dd7c7a53cd224da88d4684189f9/leonardo_galindo.jpg?h=500" width="125px;" alt="Leo's Picture"/><br /><b>Leonardo Galindo</b></a><br /><sub>Software Developer</sub></td>
<td align="center"><a href="https://www.linkedin.com/in/alicesf2/"><img src="https://images.ctfassets.net/xig6hkxlux4q/sSyWI6JQ5mcOHWTGXu9de/d5b82e70af4e0155a1bf4daf9572470c/alice_fang.jpg?h=500" width="125px;" alt="Alice's Picture"/><br /><b>Alice Fang</b></a><br /><sub>Technical Lead</sub></td>
<td align="center"><a href="https://www.linkedin.com/in/matthew-walowski/"><img src="https://images.ctfassets.net/xig6hkxlux4q/4p6LeyaGISibB1BsoV3PnW/1b2bb45c6387536fef6eeb4f04239148/matthew_walowski.jpg?h=500" width="125px;" alt="Matthew's Picture"/><br /><b>Matthew Walowski</b></a><br /><sub>Technical Lead</sub></td>
<td align="center"><a href="https://www.linkedin.com/in/jeffrey-tang/"><img src="https://images.ctfassets.net/xig6hkxlux4q/4gL2EIwPsS1eBq6N0OY3OU/f78d7206df31d7285c9e0cab429cdafa/jeffrey_tang.jpg?h=500" width="125px;" alt="Jeffrey's Picture"/><br /><b>Jeffrey Tang</b></a><br /><sub>Technical Lead</sub></td>
</tr>
<tr>
<td align="center"><a href="https://www.linkedin.com/in/amit-m-sawhney/"><img src="https://images.ctfassets.net/xig6hkxlux4q/3tdBQH6lJJpDT9T7eJEy89/a7e68775c6f06c484dae9536a1bae1f0/amit_sawhney.jpg?h=500" width="125px;" alt="Amit's Picture"/><br /><b>Amit Sawhney</b></a><br /><sub>Software Developer</sub></td>
<td align="center"><a href="www.linkedin.com/in/ishaan-r-sharma"><img src="https://images.ctfassets.net/xig6hkxlux4q/bbwQAF9WPPYBkaB1DYmsX/2bb2c7886e8e5ce1e9a69f01dcb3a560/ishaan_sharma.jpg?h=500" width="125px;" alt="Ishaan's Picture"/><br /><b>Ishaan Sharma</b></a><br /><sub>Software Developer</sub></td>
</tr>
</table>

## License
Expand Down
6 changes: 5 additions & 1 deletion api/src/api/notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,21 @@ router.post(
'/',
requireLead,
errorWrap(async (req, res) => {
const memberID = req.user._id;
const currentVersion = {
date: Date.now(),
action: Note.actions.CREATED,
memberID: req.user._id,
memberID,
};
if (req.body.metaData.versionHistory) {
req.body.metaData.versionHistory.push(currentVersion);
} else {
req.body.metaData.versionHistory = [currentVersion];
}

// Automatically include the note creator as an editor
req.body.metaData.access.editableBy.push(memberID.toString());

const note = await Note.create(req.body);
res.status(200).json({
success: true,
Expand Down
6 changes: 3 additions & 3 deletions api/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2311,9 +2311,9 @@ [email protected]:
integrity sha512-Io1zA2yOA1YJslkr+AJlWSf2yWFkKjvkcL9Ni1XSUqnGLr/qRQe2UI3Cn/J9MsJht7yEVCe0SscY1HgVMujbgg==

hosted-git-info@^2.1.4:
version "2.8.8"
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488"
integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==
version "2.8.9"
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"
integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==

[email protected]:
version "2.0.0"
Expand Down
Binary file removed client/public/apple-touch-icon.png
Binary file not shown.
Binary file modified client/public/favicon.ico
Binary file not shown.
3 changes: 1 addition & 2 deletions client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="A project template." />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/apple-touch-icon.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>Hack4Impact MERN Template</title>
<title>Hack4Impact MemberDB</title>
</head>

<body>
Expand Down
4 changes: 2 additions & 2 deletions client/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"short_name": "mern-template",
"name": "mern-template",
"short_name": "memberdb",
"name": "memberdb",
"icons": [
{
"src": "favicon.ico",
Expand Down
6 changes: 2 additions & 4 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ function App() {
<Route path={Routes.MEMBER_PAGE}>
<Switch>
<Route path={Routes.NOTE_PAGE}>
<Note user={user} />
{user && <Note user={user} />}
</Route>
<Route DEFAULT>
{user ? <Profile /> : <Redirect to={Routes.LOGIN_PAGE} />}
</Route>
</Switch>
</Route>
<Route path={Routes.NOTE_PAGE}>
<Note user={user} />
</Route>
<Route path={Routes.NOTE_PAGE}>{user && <Note user={user} />}</Route>
<Route path={Routes.NOTES}>
<Notes />
</Route>
Expand Down
38 changes: 29 additions & 9 deletions client/src/pages/Note.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ import {
convertToRaw,
convertFromRaw,
} from 'draft-js';
import PropTypes from 'prop-types';
import {
Button,
Input,
Icon,
Form,
Dropdown,
Grid,
Card,
Message,
} from 'semantic-ui-react';
import 'draft-js/dist/Draft.css';
import PropTypes from 'prop-types';
import { useHistory, useParams, Redirect } from 'react-router-dom';

import EditorToolbar from '../components/notes/EditorToolbar';
Expand All @@ -27,6 +28,7 @@ import {
getNotes,
createNote,
updateNote,
deleteNote,
getMembers,
getNoteLabels,
} from '../utils/apiWrapper';
Expand Down Expand Up @@ -167,7 +169,8 @@ function Note({ user }) {

// get member data for dropdown reference
const allMembers = await getMembers();
// map allMembers into a dropdown-friendly interface

// map allMembers into a dropdown-friendly interface and remove the current user from the list
const cleanedMembers = (allMembers?.data?.result ?? []).map((m) => ({
key: m._id,
text: `${m.firstName} ${m.lastName}`,
Expand Down Expand Up @@ -247,9 +250,8 @@ function Note({ user }) {
labels: noteLabels,
referencedMembers,
access: {
// remove duplicate of current user id's on existing notes
editableBy: [...new Set([...editableBy, user._id])],
viewableBy: [...new Set([...viewableBy, user._id])],
editableBy,
viewableBy,
},
},
},
Expand Down Expand Up @@ -285,14 +287,29 @@ function Note({ user }) {
if (newState) setEditorState(newState);
}

const handleDeleteNote = async () => {
const resp = await deleteNote(noteID);
if (resp.error) setSubmitState(SUBMIT_STATE.error);
else history.push('/notes');
};

switch (noteState) {
case NOTE_STATE.loading:
return <Loading height={500} />;
case NOTE_STATE.error:
return <Redirect to="/notes" />;
default:
return (
<Page title={`${titleCaseFormatter(NOTE_STATE[noteState])} a Note`}>
<Page
title={`${titleCaseFormatter(NOTE_STATE[noteState])} a Note`}
menuItems={
isEditable && (
<Button negative onClick={handleDeleteNote}>
<Icon name="x" /> Delete
</Button>
)
}
>
<Form>
<Grid stackable>
<Grid.Column width={12}>
Expand Down Expand Up @@ -395,7 +412,7 @@ function Note({ user }) {
multiple
search
selection
options={members}
options={members.filter((m) => m.key !== user._id)}
/>
) : (
<DisplayList
Expand All @@ -417,7 +434,7 @@ function Note({ user }) {
multiple
search
selection
options={members}
options={members.filter((m) => m.key !== user._id)}
/>
) : (
<DisplayList
Expand Down Expand Up @@ -455,7 +472,10 @@ function Note({ user }) {
}

Note.propTypes = {
user: PropTypes.object,
user: PropTypes.shape({
_id: PropTypes.string.isRequired,
firstName: PropTypes.string,
}).isRequired,
};

export default Note;
9 changes: 9 additions & 0 deletions client/src/utils/apiWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ export const updateNote = (note, noteID) => {
}));
};

// Deletes a note
export const deleteNote = (noteID) => {
const requestString = `${BACKEND_BASE_URL}/notes/${noteID}`;
return axios.delete(requestString).catch((error) => ({
type: 'UPDATE_NOTE_FAIL',
error,
}));
};

// Creates a new note
export const createNote = (note) => {
const requestString = `${BACKEND_BASE_URL}/notes`;
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -876,9 +876,9 @@ has@^1.0.3:
function-bind "^1.1.1"

hosted-git-info@^2.1.4:
version "2.8.8"
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488"
integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==
version "2.8.9"
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"
integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==

human-signals@^1.1.1:
version "1.1.1"
Expand Down

0 comments on commit 7c1c387

Please sign in to comment.