-
Notifications
You must be signed in to change notification settings - Fork 9
#4048 tasks for work packages #4098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
getheobald
wants to merge
24
commits into
develop
Choose a base branch
from
#4048-tasks-for-work-packages
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
3ff416c
#4048 wp query args and project transformer edits to start fetching w…
getheobald a230f8e
#4048 finish backend transformer and query arg updates
getheobald 48f6399
#4048 task card, column, and taskformmodal updates - still getting wb…
getheobald 300fb60
#4048 fixed create task wbs check, chip now showing, updated task mod…
getheobald eec2ab2
Merge remote-tracking branch 'origin/develop' into #4048-tasks-for-wo…
getheobald 1c111ac
#4048 revert overview and preview task include
getheobald 35ea413
#4048 added editTaskWbsElement across stack to handle edits and now i…
getheobald 99f3d44
#4048 wp tasks page with one-line filter, pre-refactor
getheobald b8e54af
#4048 refactor task frontend to accept piecemeal props instead of pro…
getheobald 524b3a0
#4048 revert filter change and call TLC directly from WPVC
getheobald 5047191
#4048 conditionally render wp dropdown, truncate chip, omit chip on w…
getheobald 5cc4512
#4048 remove dead teams code from task frontend
getheobald 5ab8d0f
#4048 clickable chip
getheobald a324ab9
#4048 extraneous imports
getheobald b4832e7
#4048 unit tests
getheobald 359e27d
#4048 lint
getheobald 4f6f675
#4048 tsc check and prettier
getheobald 723e5f1
#4048 freaking commas
getheobald f4232a0
#4048 omg tsc check everything needs a wbsName
getheobald 094ef6b
#4048 remove wp-task association in types, transformers, and query args
getheobald af1cf4d
#4048 full getTasksByWbsElement endpoint
getheobald 4ccc6ea
#4048 revert tasklist props
getheobald 9a64299
#4048 changed tasklistcontent state to flat array but sadly need to r…
getheobald a76d9bb
4048 fixed tasklistcontent to use hook but maintain custom ordering
getheobald File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1677,7 +1677,7 @@ const performSeed: () => Promise<void> = async () => { | |
| "of the wheel and put pedal to the metal. Accelerating down straightaways and taking corners with finesse, it's " + | ||
| 'easy to forget McCauley, in his blue racing jacket and jet black helmet, is racing laps around the roof of ' + | ||
| "Columbus Parking Garage on Northeastern's Boston campus. But that's the reality of Northeastern Electric " + | ||
| 'Racing, a student club that has made due and found massive success in the world of electric racing despite its ' + | ||
| 'Racing, a student club that has made do and found massive success in the world of electric racing despite its ' + | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😭 |
||
| "relative rookie status. McCauley, NER's chief electrical engineer, has seen the club's car, Cinnamon, go from " + | ||
| 'a 5-foot drive test to hitting 60 miles per hour in competitions. "It\'s a go-kart that has 110 kilowatts of ' + | ||
| 'power, 109 kilowatts of power," says McCauley, a fourth-year electrical and computer engineering student. ' + | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,15 +73,25 @@ export default class TasksService { | |
| wbsElement: true, | ||
| workPackages: { include: { wbsElement: true } } | ||
| } | ||
| }, | ||
| workPackage: { | ||
| include: { | ||
| project: { | ||
| include: { | ||
| teams: getTeamQueryArgs(organization.organizationId) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }); | ||
| if (!requestedWbsElement) throw new NotFoundException('WBS Element', wbsPipe(wbsNum)); | ||
| if (requestedWbsElement.dateDeleted) throw new DeletedException('WBS Element', wbsPipe(wbsNum)); | ||
| const { project } = requestedWbsElement; | ||
| if (!project) throw new HttpException(400, "This task's wbs element is not linked to a project!"); | ||
|
|
||
| const { teams } = project; | ||
| if (!requestedWbsElement.project && !requestedWbsElement.workPackage) | ||
| throw new HttpException(400, "This task's wbs element is not linked to a project or work package!"); | ||
|
|
||
| const teams = requestedWbsElement.project?.teams ?? requestedWbsElement.workPackage?.project?.teams; | ||
| if (!teams || teams.length === 0) | ||
| throw new HttpException(400, 'This project needs to be assigned to a team to create a task!'); | ||
|
|
||
|
|
@@ -173,13 +183,16 @@ export default class TasksService { | |
| /** | ||
| * Edits the status of a task in the database | ||
| * @param user the user editing the task | ||
| * @param organizationId the organizqtion Id | ||
| * @param organizationId the organization Id | ||
| * @param taskId the id of the task | ||
| * @param status the new status | ||
| * @returns the updated task | ||
| * @throws if the task does not exist, the task is already deleted, or if the user does not have permissions | ||
| */ | ||
| static async editTaskStatus(user: User, organizationId: string, taskId: string, status: Task_Status) { | ||
| const hasPermission = await userHasPermission(user.userId, organizationId, notGuest); | ||
| if (!hasPermission) throw new AccessDeniedException('Guests cannot edit tasks'); | ||
|
|
||
| // Get the original task and check if it exists | ||
| const originalTask = await prisma.task.findUnique({ where: { taskId }, include: { assignees: true, wbsElement: true } }); | ||
| if (!originalTask) throw new NotFoundException('Task', taskId); | ||
|
|
@@ -190,9 +203,6 @@ export default class TasksService { | |
| throw new HttpException(400, 'A task in progress must have a deadline and assignees!'); | ||
| } | ||
|
|
||
| const hasPermission = await userHasPermission(user.userId, organizationId, notGuest); | ||
| if (!hasPermission) throw new AccessDeniedException('Guests cannot edit tasks'); | ||
|
|
||
| const updatedTask = await prisma.task.update({ | ||
| where: { taskId }, | ||
| data: { status }, | ||
|
|
@@ -216,6 +226,9 @@ export default class TasksService { | |
| assignees: string[], | ||
| organization: Organization | ||
| ): Promise<Task> { | ||
| const hasPermission = await userHasPermission(user.userId, organization.organizationId, notGuest); | ||
| if (!hasPermission) throw new AccessDeniedException('Guests cannot edit tasks'); | ||
|
|
||
| // Get the original task and check if it exists | ||
| const originalTask = await prisma.task.findUnique({ | ||
| where: { taskId }, | ||
|
|
@@ -230,9 +243,6 @@ export default class TasksService { | |
| const originalAssigneeIds = originalTask.assignees.map((assignee) => assignee.userId); | ||
| const newAssigneeIds = assignees.filter((userId) => !originalAssigneeIds.includes(userId)); | ||
|
|
||
| const hasPermission = await userHasPermission(user.userId, organization.organizationId, notGuest); | ||
| if (!hasPermission) throw new AccessDeniedException('Guests cannot edit tasks'); | ||
|
|
||
| // this throws if any of the users aren't found | ||
| const assigneeUsers = await getUsers(assignees); | ||
|
|
||
|
|
@@ -261,6 +271,53 @@ export default class TasksService { | |
| return updatedTask; | ||
| } | ||
|
|
||
| /** | ||
| * Edits the wbs element of a task in the database | ||
| * @param user the user editing the task | ||
| * @param taskId the id of the task | ||
| * @param wbsElementId the id of the new wbs element | ||
| * @param organization the organization that the user is currently in | ||
| * @returns the updated task | ||
| * @throws if the task does not exist, the task is already deleted, the wbs element doesn't exist, or if the user does not have permissions | ||
| */ | ||
| static async editTaskWbsElement( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above, lets just group this in with edit task |
||
| user: User, | ||
| taskId: string, | ||
| wbsElementId: string, | ||
| organization: Organization | ||
| ): Promise<Task> { | ||
| const hasPermission = await userHasPermission(user.userId, organization.organizationId, notGuest); | ||
| if (!hasPermission) throw new AccessDeniedException('Guests cannot edit tasks'); | ||
|
|
||
| // get the original task and check if it exists | ||
| const originalTask = await prisma.task.findUnique({ | ||
| where: { taskId }, | ||
| include: { wbsElement: true } | ||
| }); | ||
|
|
||
| // throw error if there are issues with the task | ||
| if (!originalTask) throw new NotFoundException('Task', taskId); | ||
| if (originalTask.dateDeleted) throw new DeletedException('Task', taskId); | ||
| if (originalTask.wbsElement.organizationId !== organization.organizationId) | ||
| throw new InvalidOrganizationException('Task'); | ||
|
|
||
| const newWbsElement = await prisma.wBS_Element.findUnique({ | ||
| where: { wbsElementId } | ||
| }); | ||
|
|
||
| // throw error if there are issues with the wbs element | ||
| if (!newWbsElement) throw new NotFoundException('WBS Element', wbsElementId); | ||
| if (newWbsElement.dateDeleted) throw new DeletedException('WBS Element', wbsElementId); | ||
|
|
||
| const updatedTask = await prisma.task.update({ | ||
| where: { taskId }, | ||
| data: { wbsElement: { connect: { wbsElementId } } }, | ||
| ...getTaskQueryArgs(organization.organizationId) | ||
| }); | ||
|
|
||
| return taskTransformer(updatedTask); | ||
| } | ||
|
|
||
| /** | ||
| * Delete task in the database | ||
| * @param taskId the id number of the given task | ||
|
|
@@ -391,4 +448,60 @@ export default class TasksService { | |
|
|
||
| return tasks.map(taskCardPreviewTransformer); | ||
| } | ||
|
|
||
| /** | ||
| * Gets all tasks associated with a wbs element | ||
| * If the wbs number is a project (workPackageNumber === 0), returns the project's | ||
| * own tasks merged with all of its work packages' tasks | ||
| * If the wbs number is a work package, returns just that WP's tasks | ||
| * @param wbsNum the wbs number to fetch tasks for | ||
| * @param organization the organization that the user is currently in | ||
| * @returns array of tasks | ||
| */ | ||
| static async getTasksByWbsNum(wbsNum: WbsNumber, organization: Organization): Promise<Task[]> { | ||
| const wbsElement = await prisma.wBS_Element.findUnique({ | ||
| where: { | ||
| wbsNumber: { | ||
| ...wbsNum, | ||
| organizationId: organization.organizationId | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| if (!wbsElement) throw new NotFoundException('WBS Element', wbsPipe(wbsNum)); | ||
| if (wbsElement.dateDeleted) throw new DeletedException('WBS Element', wbsPipe(wbsNum)); | ||
|
|
||
| // project case, so return project's own tasks and all its wp's tasks | ||
| if (wbsNum.workPackageNumber === 0) { | ||
| const project = await prisma.project.findUnique({ | ||
| where: { wbsElementId: wbsElement.wbsElementId }, | ||
| include: { workPackages: { include: { wbsElement: true } } } | ||
| }); | ||
|
|
||
| if (!project) throw new NotFoundException('Project', wbsPipe(wbsNum)); | ||
|
|
||
| const wpWbsElementIds = project.workPackages.map((wp) => wp.wbsElementId); | ||
|
|
||
| const tasks = await prisma.task.findMany({ | ||
| where: { | ||
| dateDeleted: null, | ||
| wbsElementId: { in: [wbsElement.wbsElementId, ...wpWbsElementIds] } | ||
| }, | ||
| ...getTaskQueryArgs(organization.organizationId) | ||
| }); | ||
|
|
||
| return tasks.map(taskTransformer); | ||
| } | ||
|
|
||
| // work package case, so return just that wp's tasks | ||
| const tasks = await prisma.task.findMany({ | ||
| where: { | ||
| dateDeleted: null, | ||
| wbsElementId: wbsElement.wbsElementId | ||
| }, | ||
| ...getTaskQueryArgs(organization.organizationId) | ||
| }); | ||
|
|
||
| return tasks.map(taskTransformer); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless we have different permissions (which I don't think we do) we should just add a wbselement param to the edit and then use that route instead of this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah makes sense. I separated it cause I saw that assignees and status were separated but I guess those have valid reasons and this doesn't, so I'll throw it in with editTask