-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from ucsb-cs156/w24-5pm-2
W24 5pm 2
- Loading branch information
Showing
38 changed files
with
1,781 additions
and
93 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,6 +1,10 @@ | ||
## emacs ## | ||
*~ | ||
|
||
# mac files | ||
|
||
.DS_Store | ||
|
||
# Stryker reports | ||
|
||
frontend/.stryker-tmp | ||
|
Binary file not shown.
This file contains 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
10 changes: 10 additions & 0 deletions
10
frontend/src/main/components/Courses/CourseDescriptionTable.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from "react"; | ||
|
||
export default function CourseDescriptionComponent({ course }) { | ||
return ( | ||
<div> | ||
<h5>Course Description</h5> | ||
<p>{course.description}</p> | ||
</div> | ||
); | ||
} |
This file contains 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
78 changes: 78 additions & 0 deletions
78
frontend/src/main/components/Jobs/UpdateCoursesByQuarterRangeJobForm.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { useState } from "react"; | ||
import { Form, Button, Container, Row, Col } from "react-bootstrap"; | ||
|
||
import { quarterRange } from "main/utils/quarterUtilities"; | ||
|
||
import { useSystemInfo } from "main/utils/systemInfo"; | ||
import SingleQuarterDropdown from "../Quarters/SingleQuarterDropdown"; | ||
|
||
const UpdateCoursesByQuarterRangeJobForm = ({ callback }) => { | ||
const { data: systemInfo } = useSystemInfo(); | ||
|
||
// Stryker disable OptionalChaining | ||
const startQtr = systemInfo?.startQtrYYYYQ || "20211"; | ||
const endQtr = systemInfo?.endQtrYYYYQ || "20214"; | ||
// Stryker enable OptionalChaining | ||
|
||
const quarters = quarterRange(startQtr, endQtr); | ||
|
||
// Stryker disable all : not sure how to test/mock local storage | ||
const localStartQuarter = localStorage.getItem("BasicSearch.StartQuarter"); | ||
const localEndQuarter = localStorage.getItem("BasicSearch.EndQuarter"); | ||
|
||
const [startQuarter, setStartQuarter] = useState( | ||
localStartQuarter || quarters[0].yyyyq, | ||
); | ||
const [endQuarter, setEndQuarter] = useState( | ||
localEndQuarter || quarters[0].yyyyq, | ||
); | ||
|
||
const handleSubmit = (event) => { | ||
event.preventDefault(); | ||
callback({ startQuarter, endQuarter }); | ||
}; | ||
|
||
// Stryker disable all : Stryker is testing by changing the padding to 0. But this is simply a visual optimization as it makes it look better | ||
const padding = { paddingTop: 10, paddingBottom: 10 }; | ||
// Stryker restore all | ||
|
||
return ( | ||
<Form onSubmit={handleSubmit}> | ||
<Container> | ||
<Row> | ||
<Col md="auto"> | ||
<SingleQuarterDropdown | ||
quarters={quarters} | ||
quarter={startQuarter} | ||
setQuarter={setStartQuarter} | ||
controlId={"BasicSearch.StartQuarter"} | ||
label={"Start Quarter"} | ||
/> | ||
</Col> | ||
<Col md="auto"> | ||
<SingleQuarterDropdown | ||
quarters={quarters} | ||
quarter={endQuarter} | ||
setQuarter={setEndQuarter} | ||
controlId={"BasicSearch.EndQuarter"} | ||
label={"End Quarter"} | ||
/> | ||
</Col> | ||
</Row> | ||
<Row style={padding}> | ||
<Col md="auto"> | ||
<Button | ||
variant="primary" | ||
type="submit" | ||
data-testid="updateCoursesByQuarterRange" | ||
> | ||
Update Courses | ||
</Button> | ||
</Col> | ||
</Row> | ||
</Container> | ||
</Form> | ||
); | ||
}; | ||
|
||
export default UpdateCoursesByQuarterRangeJobForm; |
This file contains 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
76 changes: 76 additions & 0 deletions
76
frontend/src/main/components/PersonalSchedules/AddToScheduleModal.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React, { useState } from "react"; | ||
import Modal from "react-bootstrap/Modal"; | ||
import Button from "react-bootstrap/Button"; | ||
import Form from "react-bootstrap/Form"; | ||
import PersonalScheduleSelector from "./PersonalScheduleSelector"; | ||
import { useBackend } from "main/utils/useBackend"; | ||
import { Link } from "react-router-dom"; | ||
|
||
export default function AddToScheduleModal({ section, onAdd }) { | ||
const [showModal, setShowModal] = useState(false); | ||
const [selectedSchedule, setSelectedSchedule] = useState(""); | ||
|
||
// Stryker disable all | ||
const { | ||
data: schedules, | ||
error: _error, | ||
status: _status, | ||
} = useBackend( | ||
["/api/personalschedules/all"], | ||
{ method: "GET", url: "/api/personalschedules/all" }, | ||
[], | ||
); | ||
// Stryker restore all | ||
|
||
const handleModalClose = () => { | ||
setShowModal(false); | ||
}; | ||
|
||
const handleModalSave = () => { | ||
onAdd(section, selectedSchedule); | ||
handleModalClose(); | ||
}; | ||
// Stryker disable all : tested manually, complicated to test | ||
return ( | ||
<> | ||
<Button variant="success" onClick={() => setShowModal(true)}> | ||
Add | ||
</Button> | ||
<Modal show={showModal} onHide={handleModalClose}> | ||
<Modal.Header closeButton> | ||
<Modal.Title>Add to Schedule</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<Form> | ||
{ | ||
/* istanbul ignore next */ schedules.length > 0 ? ( | ||
<Form.Group controlId="scheduleSelect"> | ||
<Form.Label>Select Schedule</Form.Label> | ||
<PersonalScheduleSelector | ||
schedule={selectedSchedule} | ||
setSchedule={setSelectedSchedule} | ||
controlId="scheduleSelect" | ||
/> | ||
</Form.Group> | ||
) : ( | ||
<p> | ||
No schedules found. | ||
<Link to="/personalschedules/create">Create a schedule</Link> | ||
</p> | ||
) | ||
} | ||
</Form> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<Button variant="secondary" onClick={handleModalClose}> | ||
Close | ||
</Button> | ||
<Button variant="primary" onClick={handleModalSave}> | ||
Save Changes | ||
</Button> | ||
</Modal.Footer> | ||
</Modal> | ||
</> | ||
); | ||
// Stryker restore all | ||
} |
This file contains 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
66 changes: 66 additions & 0 deletions
66
frontend/src/main/components/PersonalSchedules/PersonalScheduleSelector.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import { Form } from "react-bootstrap"; | ||
import { useBackend } from "main/utils/useBackend"; | ||
import { yyyyqToQyy } from "main/utils/quarterUtilities.js"; | ||
|
||
const PersonalScheduleSelector = ({ | ||
schedule, | ||
setSchedule, | ||
controlId, | ||
onChange = null, | ||
label = "Schedule", | ||
}) => { | ||
const localSearchSchedule = localStorage.getItem(controlId); | ||
|
||
const [scheduleState, setScheduleState] = useState( | ||
localSearchSchedule || schedule, | ||
); | ||
|
||
// Stryker disable all | ||
const { | ||
data: schedules, | ||
error: _error, | ||
status: _status, | ||
} = useBackend( | ||
["/api/personalschedules/all"], | ||
{ method: "GET", url: "/api/personalschedules/all" }, | ||
[], | ||
); | ||
// Stryker restore all | ||
|
||
useEffect(() => { | ||
if (schedules.length > 0) { | ||
setSchedule(schedules[0].id); | ||
} | ||
}, [schedules, setSchedule]); | ||
|
||
const handleScheduleOnChange = (event) => { | ||
const selectedSchedule = event.target.value; | ||
localStorage.setItem(controlId, selectedSchedule); | ||
setScheduleState(selectedSchedule); | ||
setSchedule(selectedSchedule); | ||
if (onChange != null) { | ||
onChange(event); | ||
} | ||
}; | ||
|
||
return ( | ||
<Form.Group controlId={controlId}> | ||
<Form.Label>{label}</Form.Label> | ||
<Form.Control | ||
as="select" | ||
value={scheduleState} | ||
onChange={handleScheduleOnChange} | ||
> | ||
{schedules && | ||
schedules.map((schedule) => ( | ||
<option key={schedule.id} value={schedule.id}> | ||
{yyyyqToQyy(schedule.quarter)} {schedule.name} | ||
</option> | ||
))} | ||
</Form.Control> | ||
</Form.Group> | ||
); | ||
}; | ||
|
||
export default PersonalScheduleSelector; |
Oops, something went wrong.