diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b2dbab6a..6804f2ee 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,7 +3,6 @@

This document outlines the process for joining our team and contributing to the VRMS Github repository. If you notice errors or have important information to add, please feel free to propose changes to this document with a pull request

-

Table of Contents

- [**Part 1 : How to join the team**](#part-1--how-to-join-the-team) @@ -24,15 +23,16 @@ - [**4.1 Push changes to your forked repository**](#41-push-changes-to-your-forked-repository) - [**4.2 Create a pull request on the VRMS repository**](#42-create-a-pull-request-on-the-vrms-repository) - ## **Part 1 : How to join the team** ### **1.1 VRMS contributor expectations** + - Attend at least 1 team meeting per week - Devote a minimum of 6 hours per week to working on VRMS assignments - Communicate with the team leadership if you plan to step away from the project ### **1.2 Reach out to us on Slack** + If you would like to contribute to our project, please reach out to the team leads on Slack or at one of our weekly meetings. You can find the current project team, their slack links, and our team meeting times on the [VRMS Project Details Page](https://www.hackforla.org/projects/vrms). ### **1.3 Become a member of the repository Team** @@ -50,15 +50,16 @@ These steps are manditory in order to contribute to all HackforLA projects. ## **Part 2: How to set up the development environment** ### **2.1 Fork the repository** -*A fork is a copy of the repository that will be placed on your GitHub account url.* -* In https://github.com/hackforla/VRMS, look for the fork icon in the top right. Click it and create a fork of the repository. +_A fork is a copy of the repository that will be placed on your GitHub account url._ + +- In https://github.com/hackforla/VRMS, look for the fork icon in the top right. Click it and create a fork of the repository. -* It should create a copy here: https://github.com/YOUR_GITHUB_USERNAME/vrms, where `YOUR_GITHUB_USERNAME` is replaced with your github username. +- It should create a copy here: https://github.com/YOUR_GITHUB_USERNAME/vrms, where `YOUR_GITHUB_USERNAME` is replaced with your github username. > NOTE: This copy is on a remote server on the GitHub website and not on your computer yet. -* Click the icon again, it will give you the URL associated with your forked repository and not create a new fork. +- Click the icon again, it will give you the URL associated with your forked repository and not create a new fork. ### **2.2 Clone the remote repository to your local computer** @@ -67,39 +68,42 @@ The following process will make a copy of the fork that you just created on your 1. Create a new folder on your local computer that will contain `hackforla` projects. 2. In your shell (terminal), navigate to this folder then run the following commands: - ```bash - git clone https://github.com/YOUR_GITHUB_USERNAME/vrms.git - ``` - You should now have a new folder in your `hackforla` folder called `vrms`. + ```bash + git clone https://github.com/YOUR_GITHUB_USERNAME/vrms.git + ``` + + You should now have a new folder in your `hackforla` folder called `vrms`. 3. Verify which URL your `origin` remote is pointing to: - ```bash - git remote show origin - ``` - Your terminal should return: - ```bash - remote origin - Fetch URL: https://github.com/YOUR_GITHUB_USERNAME/vrms.git - Push URL: https://github.com/YOUR_GITHUB_USERNAME/vrms.git - ... - ``` - - If you accidentally cloned the `hackforla/vrms.git` then you can change your local copy to upload to your fork with the following: - - ```bash - git remote set-url origin https://github.com/YOUR_GITHUB_USERNAME/vrms.git - ``` + + ```bash + git remote show origin + ``` + + Your terminal should return: + + ```bash + remote origin + Fetch URL: https://github.com/YOUR_GITHUB_USERNAME/vrms.git + Push URL: https://github.com/YOUR_GITHUB_USERNAME/vrms.git + ... + ``` + + If you accidentally cloned the `hackforla/vrms.git` then you can change your local copy to upload to your fork with the following: + + ```bash + git remote set-url origin https://github.com/YOUR_GITHUB_USERNAME/vrms.git + ``` 4. Add another remote called `vrms` that points to the `hackforla` version of the repository. This will allow you to incorporate changes later: - ```bash - git remote add vrms https://github.com/hackforla/vrms.git - ``` + ```bash + git remote add vrms https://github.com/hackforla/vrms.git + ``` Note: Understanding how git remotes work will make collaborating much easier. You can learn more about remotes [here](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/configuring-a-remote-for-a-fork) and [here](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes). - -### **2.3 Get up and running** +### **2.3 Get up and running** 1. Have [Node](https://nodejs.org/en/download/) and NPM installed locally: @@ -128,7 +132,7 @@ Note: Understanding how git remotes work will make collaborating much easier. Yo Note 2: `touch` is a Unix/Linux or Mac command; It is not available in Windows. In Windows, use a text editor (e.g. Notepad) to create an empty file and save it in each of the locations as `.env` . (If you use Windows Explorer to create the file it will create a file called `.env.txt`, which will not work.) - - Then paste the content from the [document](https://docs.google.com/document/d/1PdcZhyo2a2lr0JNcgyzpWi98tGkZeH1Zxz-Jnf6JQDU/edit?usp=sharing). It is accessible for the project team members only. + - Then paste the content from the [document](https://docs.google.com/document/d/1PdcZhyo2a2lr0JNcgyzpWi98tGkZeH1Zxz-Jnf6JQDU/edit?usp=sharing). It is accessible for the project team members only. - _Please note that the `ports` for the frontend and backend are set in this location_ @@ -140,16 +144,15 @@ Note: Understanding how git remotes work will make collaborating much easier. Yo - Navigate to the root of the application `vrms/` and run `yarn start` - *Troubleshooting :* If you encounter the following error after running `yarn start`: - - ``` - Error: error:0308010C:digital envelope routines::unsupported - ``` - Try changing your node version to `16.14.2` by running `nvm use 16.14.2`. If you do not have `nvm` installed, see [install instructions](https://github.com/nvm-sh/nvm#installing-and-updating) + _Troubleshooting :_ If you encounter the following error after running `yarn start`: + ``` + Error: error:0308010C:digital envelope routines::unsupported + ``` -You should now have a live app. Happy hacking. + Try changing your node version to `16.14.2` by running `nvm use 16.14.2`. If you do not have `nvm` installed, see [install instructions](https://github.com/nvm-sh/nvm#installing-and-updating) +You should now have a live app. Happy hacking. ### **2.4 Running Tests** @@ -166,66 +169,68 @@ To view and edit the development database manually, you can download [MongoDB Co If you want to install a local copy to experiment with and learn more about MongoDB, you can use [this tutorial](https://zellwk.com/blog/local-mongodb/) - - ## **Part 3: How to work on issues** - ### **3.1 Claim an Issue** -Developers may assign themselves to issues from the [Prioritized Backlog column](https://github.com/hackforla/VRMS/projects/12#column-19074778) of the project board. +Developers may assign themselves to issues from the [Prioritized Backlog column](https://github.com/orgs/hackforla/projects/72/views/1?filterQuery=backlog) of the project board. The Prioritized Backlog column is filtered so the first (top) issue has the highest priority and should be worked on next if possible. Developers may choose from issues with the following `role` labels: + - `role: Front End` - `role: Back End` - `role: Database` Claiming an issue is a two step process: + 1. Assign yourself to the issue using the gear icon in the upper right corner of the issue where it says "Assignees" 2. Move the issue from the `Prioritized Backlog` to the `In Progress` column of the project board - ### **3.2 Create a new branch for each issue you work on** -You will create a new branch for each issue you work on. Doing all your work on feature branches leaves your repository's main branch unmodified and greatly simplifies keeping your fork in sync with the main project. +You will create a new branch for each issue you work on. Doing all your work on feature branches leaves your repository's main branch unmodified and greatly simplifies keeping your fork in sync with the main project. -1. Before creating a new branch, always make sure you are currently on the `development` branch by using the command - ```bash - git branch - ``` +1. Before creating a new branch, always make sure you are currently on the `development` branch by using the command + ```bash + git branch + ``` 2. Before creating a new branch, always pull down the latest changes from the `development` branch by using the command - ```bash - git pull vrms development - ``` + ```bash + git pull vrms development + ``` 3. Finally, create a new branch where you will work on your issue by using the command: - ```bash - git checkout -b your-branch-name - ``` + ```bash + git checkout -b your-branch-name + ``` ### **3.3 Work on the Issue** -Every issue will contain action items you must complete before you are ready to submit a pull request. Be sure to use the checkboxes as you complete each action item so we can track your progress! +Every issue will contain action items you must complete before you are ready to submit a pull request. Be sure to use the checkboxes as you complete each action item so we can track your progress! After you have completed the action items, add and commit the changes to your new branch using the commands + ``` git add . git commit -m "your commit message" -``` - +``` ## **Part 4: How to create pull requests** + ### **4.1 Push changes to your forked repository** + 1. Before pushing code, always pull down the latest changes from the `development` branch by using the command - ``` - git pull vrms development - ``` + ``` + git pull vrms development + ``` 2. Once you are satisfied with your changes, push them to the feature branch you made within your remote repository. - ``` - git push --set-upstream origin your-branch-name - ``` + ``` + git push --set-upstream origin your-branch-name + ``` + ### **4.2 Create a pull request on the VRMS repository** + 1. Go to your fork of the VRMS repository on GitHub and click on the `Compare & pull request` button.
See screenshot
2. Be sure to title your pull request by summarizing the changes you made 3. Be sure to add your issue number where the template says `Fixes #replace_this_text_with_the_issue_number` diff --git a/backend/models/user.model.js b/backend/models/user.model.js index 5ff3ddac..4c2005cc 100644 --- a/backend/models/user.model.js +++ b/backend/models/user.model.js @@ -11,7 +11,7 @@ const userSchema = mongoose.Schema({ email: { type: String, unique: true }, accessLevel: { type: String, - enum: ["user", "admin"], // restricts values to "user" and "admin" + enum: ["user", "admin", "superadmin"], // restricts values to "user", "admin" and "superadmin" default: "user" }, createdDate: { type: Date, default: Date.now }, diff --git a/client/src/components/user-admin/EditUsers.jsx b/client/src/components/user-admin/EditUsers.jsx index 929ec905..894a3628 100644 --- a/client/src/components/user-admin/EditUsers.jsx +++ b/client/src/components/user-admin/EditUsers.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react'; import '../../sass/UserAdmin.scss'; -import { FormGroup, FormControlLabel, Switch } from '@mui/material' +import { FormGroup, FormControlLabel, Switch } from '@mui/material'; // child of UserAdmin. Displays form to update users. const EditUsers = ({ userToEdit, backToSearch, updateUserDb, projects, updateUserActiveStatus, updateUserAccessLevel }) => { @@ -9,6 +9,9 @@ const EditUsers = ({ userToEdit, backToSearch, updateUserDb, projects, updateUse const [isActive, setIsActive] = useState(userToEdit.isActive); const [isAdmin, setIsAdmin] = useState(userToEdit.accessLevel === "admin"); + // Boolean to check if the current user is the super admin + const isSuperAdmin = userToEdit.accessLevel === "superadmin"; + // Prepare data for display const userName = `${userToEdit.name?.firstName} ${userToEdit.name?.lastName}`; const userEmail = userToEdit.email; @@ -18,7 +21,6 @@ const EditUsers = ({ userToEdit, backToSearch, updateUserDb, projects, updateUse const activeProjects = Object.values(projects) .filter((project) => project.projectStatus === 'Active') .sort((a, b) => a.name?.localeCompare(b.name)) - // eslint-disable-next-line no-underscore-dangle .map((p) => [p._id, p.name]); // add user projects to state @@ -35,11 +37,7 @@ const EditUsers = ({ userToEdit, backToSearch, updateUserDb, projects, updateUse const onSubmit = (event) => { event.preventDefault(); - if ( - projectValue.length > 0 && - projectValue !== 'default' && - !userManagedProjects.includes(projectValue) - ) { + if (!isSuperAdmin && projectValue.length > 0 && projectValue !== 'default' && !userManagedProjects.includes(projectValue)) { const newProjects = [...userManagedProjects, projectValue]; updateUserDb(userToEdit, newProjects); setUserManagedProjects(newProjects); @@ -51,24 +49,26 @@ const EditUsers = ({ userToEdit, backToSearch, updateUserDb, projects, updateUse // Remove projects from db const handleRemoveProject = (projectToRemove) => { - if (userManagedProjects.length > 0) { - const newProjects = userManagedProjects.filter( - (p) => p !== projectToRemove - ); + if (!isSuperAdmin && userManagedProjects.length > 0) { + const newProjects = userManagedProjects.filter((p) => p !== projectToRemove); updateUserDb(userToEdit, newProjects); setUserManagedProjects(newProjects); } }; const handleSetIsActive = () => { - setIsActive(!isActive) - updateUserActiveStatus(userToEdit, !isActive) - } + if (!isSuperAdmin) { + setIsActive(!isActive); + updateUserActiveStatus(userToEdit, !isActive); + } + }; const handleSetAccessLevel = () => { - const newAccessLevel = isAdmin ? "user" : "admin"; - setIsAdmin(!isAdmin); - updateUserAccessLevel(userToEdit, newAccessLevel); + if (!isSuperAdmin) { + const newAccessLevel = isAdmin ? "user" : "admin"; + setIsAdmin(!isAdmin); + updateUserAccessLevel(userToEdit, newAccessLevel); + } }; return ( @@ -86,16 +86,24 @@ const EditUsers = ({ userToEdit, backToSearch, updateUserDb, projects, updateUse
{isActive.toString()} - } onClick={() => handleSetIsActive()} /> + } + onClick={handleSetIsActive} + />
-
VRSM Admin:
+
VRMS Admin:
- {isAdmin ? "Yes" : "No"} + {isAdmin || isSuperAdmin ? "Yes" : "No"} - } onClick={() => handleSetAccessLevel()} /> + } + onClick={handleSetAccessLevel} + />
@@ -110,6 +118,7 @@ const EditUsers = ({ userToEdit, backToSearch, updateUserDb, projects, updateUse
diff --git a/client/src/sass/UserAdmin.scss b/client/src/sass/UserAdmin.scss index adf81a32..44f37466 100644 --- a/client/src/sass/UserAdmin.scss +++ b/client/src/sass/UserAdmin.scss @@ -61,14 +61,14 @@ .user-display-column-right { display: flex; flex-direction: column; - flex-basis: 85%; + flex-basis: 80%; margin-bottom: 8px; } .user-toggle-column-left { display: flex; flex-direction: column; - flex-basis: 15%; + flex-basis: 20%; } .toggle-status { @@ -108,6 +108,10 @@ margin-top: 10px; margin-bottom: 10px; } +.button-add-disabled { + opacity: 0.5; + cursor: not-allowed; +} .button-back { background-color: black;