Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jng34 committed Oct 29, 2024
2 parents 460068f + 2b520c0 commit ee1f3f4
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 90 deletions.
133 changes: 69 additions & 64 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

<p>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</p>


<h2>Table of Contents</h2>

- [**Part 1 : How to join the team**](#part-1--how-to-join-the-team)
Expand All @@ -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**
Expand All @@ -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**

Expand All @@ -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:

Expand Down Expand Up @@ -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_

Expand All @@ -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**
Expand All @@ -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. <details><summary>See screenshot</summary> <img src="https://user-images.githubusercontent.com/73561520/220488394-09bc759e-98d9-4a09-86c6-66378cf50923.png"/></details>
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`
Expand Down
2 changes: 1 addition & 1 deletion backend/models/user.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
58 changes: 35 additions & 23 deletions client/src/components/user-admin/EditUsers.jsx
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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 (
Expand All @@ -86,16 +86,24 @@ const EditUsers = ({ userToEdit, backToSearch, updateUserDb, projects, updateUse
<div className="toggle-flex">
<span className="toggle-status">{isActive.toString()}</span>
<FormGroup>
<FormControlLabel control={<Switch checked={isActive} />} onClick={() => handleSetIsActive()} />
<FormControlLabel
disabled={isSuperAdmin}
control={<Switch checked={isActive} />}
onClick={handleSetIsActive}
/>
</FormGroup>
</div>
</div>
<div className="ua-row toggle-flex">
<div className="user-toggle-column-left">VRSM Admin:</div>
<div className="user-toggle-column-left">VRMS Admin:</div>
<div className="toggle-flex">
<span className="toggle-status">{isAdmin ? "Yes" : "No"}</span>
<span className="toggle-status">{isAdmin || isSuperAdmin ? "Yes" : "No"}</span>
<FormGroup>
<FormControlLabel control={<Switch checked={isAdmin} />} onClick={() => handleSetAccessLevel()} />
<FormControlLabel
disabled={isSuperAdmin}
control={<Switch checked={isAdmin || isSuperAdmin} />}
onClick={handleSetAccessLevel}
/>
</FormGroup>
</div>
</div>
Expand All @@ -110,6 +118,7 @@ const EditUsers = ({ userToEdit, backToSearch, updateUserDb, projects, updateUse
<button
type="button"
className="button-remove"
disabled={isSuperAdmin}
onClick={() => handleRemoveProject(result[0])}
>
(remove)
Expand All @@ -128,6 +137,7 @@ const EditUsers = ({ userToEdit, backToSearch, updateUserDb, projects, updateUse
onChange={(event) => {
setProjectValue(event.target.value);
}}
disabled={isSuperAdmin}
>
<option value="default">Select a project..</option>
{activeProjects.map((result) => {
Expand All @@ -138,13 +148,15 @@ const EditUsers = ({ userToEdit, backToSearch, updateUserDb, projects, updateUse
);
})}
</select>
<button className="button-add" type="submit">
<button className={`button-add ${isSuperAdmin ? 'button-add-disabled' : ''}`}
type="submit"
disabled={isSuperAdmin}>
Add project
</button>
</form>
<div>
<button type="button" className="button-back" onClick={backToSearch}>
Back to search
Back to search
</button>
</div>
</div>
Expand Down
Loading

0 comments on commit ee1f3f4

Please sign in to comment.