Skip to content
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

CSC/ECE 517 Fall 2024 - E2488. Reimplement add TA #72

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
147c947
Updated README.md added contributors name
MakarandPundlik Nov 10, 2024
159ca63
Added npm install command
MakarandPundlik Nov 10, 2024
52d4f29
UI enhancements to the TA and Course page
Nov 24, 2024
65421d9
resolved a bug by adding select TA to the final array and removed it …
MakarandPundlik Nov 28, 2024
fbf7ba4
Merge pull request #5 from MakarandPundlik/makarand_features
AnuragGorkar Nov 28, 2024
36e0219
Merge pull request #1 from MakarandPundlik/manage_ta_page
MakarandPundlik Nov 28, 2024
8626591
added unit test cases for columns
MakarandPundlik Nov 30, 2024
104268a
added unit test cases for coursecolumns
MakarandPundlik Nov 30, 2024
d3da1da
added test cases for column button
MakarandPundlik Nov 30, 2024
f81a2ad
Merge pull request #6 from MakarandPundlik/makarand_unit_tests
MakarandPundlik Nov 30, 2024
bd54b4e
Added select feature to Add TA drop down
Nov 30, 2024
d6fc810
Merge pull request #9 from MakarandPundlik/8-add-search-feature-for-s…
AnuragGorkar Nov 30, 2024
57bc5e4
Fetch students as well as TAs in the Add TA page
Rutvik2598 Dec 1, 2024
909c0c3
Merge pull request #10 from MakarandPundlik/3-fetch-all-students-and-…
Rutvik2598 Dec 1, 2024
8108d86
Added permission check before rendering add TA button
Dec 3, 2024
c525ad5
Merge pull request #13 from MakarandPundlik/11-admin-only-access-to-a…
AnuragGorkar Dec 3, 2024
2138f9a
Removed contributor names
MakarandPundlik Dec 7, 2024
59e8b6e
Code cleanup
Dec 7, 2024
e0cf5da
Instructor can also add TA other than Admin
Rutvik2598 Dec 7, 2024
ef6fd6d
Merge pull request #14 from MakarandPundlik/instructor_can_add_ta
AnuragGorkar Dec 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ This project was bootstrapped with [Create React App](https://github.com/faceboo

In the project directory, you can run:

### `npm install`
Installs the dependencies required

### `npm start`

Runs the app in the development mode.\
Expand Down Expand Up @@ -44,3 +47,8 @@ You don’t have to ever use `eject`. The curated feature set is suitable for sm
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove contibutors from here, since its a common readme file.

## Contributers
Makarand Pundlik <br>
Anurag Gorkar <br>
Rutvik Kulkarni <br>
57 changes: 57 additions & 0 deletions src/components/ColumnButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from "react";
import { Button, OverlayTrigger, Tooltip } from "react-bootstrap";

/**
* @author Rutvik Kulkarni on Nov, 2024
*/

interface ColumnButtonProps {
id: string;
label?: string;
tooltip?: string;
variant: string;
size?: "sm" | "lg"; // Matches React-Bootstrap Button prop
className?: string;
onClick: () => void;
icon: React.ReactNode;
}

const ColumnButton: React.FC<ColumnButtonProps> = (props) => {
const {
id,
label,
tooltip,
variant,
size,
className,
onClick,
icon,
} = props;

const displayButton = (
<Button
variant={variant}
size={size}
className={className}
onClick={onClick}
aria-label={label}
>
{icon}
</Button>
);

if (tooltip) {
return (
<OverlayTrigger
placement="top"
overlay={<Tooltip id={`${id}-tooltip`}>{tooltip}</Tooltip>}
>
{displayButton}
</OverlayTrigger>
);
}

return displayButton;
};

export default ColumnButton;
43 changes: 29 additions & 14 deletions src/pages/Courses/CourseColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Button } from "react-bootstrap";
import { BsPencilFill, BsPersonXFill } from "react-icons/bs";
import { MdContentCopy, MdDelete } from "react-icons/md";
import { ICourseResponse as ICourse } from "../../utils/interfaces";
import ColumnButton from "../../components/ColumnButton";


/**
* @author Atharva Thorve, on December, 2023
Expand Down Expand Up @@ -53,28 +55,41 @@ export const courseColumns = (handleEdit: Fn, handleDelete: Fn, handleTA: Fn, ha
header: "Actions",
cell: ({ row }) => (
<>
<Button variant="outline-warning" size="sm" onClick={() => handleEdit(row)}>
<BsPencilFill />
</Button>
<Button
<ColumnButton
id="edit"
variant="outline-warning"
size="sm"
onClick={() => handleEdit(row)}
tooltip="Edit this course"
icon={<BsPencilFill />}
/>
<ColumnButton
id="delete"
variant="outline-danger"
size="sm"
className="ms-sm-2"
onClick={() => handleDelete(row)}
>
<MdDelete />
</Button>
<Button variant="outline-info" size="sm" className="ms-sm-2" onClick={() => handleTA(row)}>
<BsPersonXFill />
</Button>
<Button
tooltip="Delete this course"
icon={<MdDelete />}
/>
<ColumnButton
id="assign-ta"
variant="outline-info"
size="sm"
className="ms-sm-2"
onClick={() => handleTA(row)}
tooltip="Assign a TA to this course"
icon={<BsPersonXFill />}
/>
<ColumnButton
id="copy"
variant="outline-primary"
size="sm"
className="ms-sm-2"
onClick={() => handleCopy(row)}
>
<MdContentCopy />
</Button>
tooltip="Copy course details"
icon={<MdContentCopy />}
/>
</>
),
}),
Expand Down
48 changes: 30 additions & 18 deletions src/pages/TA/TA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { alertActions } from "store/slices/alertSlice";
import { RootState } from "../../store/store";
import { ITAResponse, ROLE } from "../../utils/interfaces";
import { TAColumns as TA_COLUMNS } from "./TAColumns";
import ColumnButton from "../../components/ColumnButton";
import DeleteTA from "./TADelete";

/**
Expand Down Expand Up @@ -85,26 +86,37 @@ const TAs = () => {
<hr />
</Row>
<Row>
<Col md={{ span: 1, offset: 11 }} style={{paddingBottom: "10px"}}>
<Button variant="outline-success" onClick={() => navigate("new")}>
<BsPersonFillAdd />
</Button>
<Col md={{ span: 1, offset: 11 }} style={{ paddingBottom: "10px" }}>
<ColumnButton
id="add-ta"
variant="outline-success"
size="lg"
className="ms-sm-2"
onClick={() => navigate("new")}
tooltip="Add TA to this course"
icon={<BsPersonFillAdd />}
/>
</Col>
{showDeleteConfirmation.visible && (
<DeleteTA TAData={showDeleteConfirmation.data!} onClose={onDeleteTAHandler} />
)}
</Row>
<Row>
<Table
showGlobalFilter={false}
data={tableData}
columns={tableColumns}
columnVisibility={{
id: false,
institution: auth.user.role === ROLE.SUPER_ADMIN.valueOf(),
}}
/>
</Row>
{tableData.length === 0 ? (
<Row className="mt-md-2 mb-md-2 text-center">
<Col>
<h3>No TAs are assigned for this course.</h3>
</Col>
</Row>
) : (
<Row>
<Table
showGlobalFilter={false}
data={tableData}
columns={tableColumns}
columnVisibility={{
id: false,
institution: auth.user.role === ROLE.SUPER_ADMIN.valueOf(),
}}
/>
</Row>
)}
</Container>
</main>
</Modal.Body>
Expand Down
10 changes: 6 additions & 4 deletions src/pages/TA/TAColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createColumnHelper, Row } from "@tanstack/react-table";
import { Button } from "react-bootstrap";
import { BsPersonXFill } from "react-icons/bs";
import { ITAResponse as ITA } from "../../utils/interfaces";
import ColumnButton from "../../components/ColumnButton";

/**
* @author Atharva Thorve, on December, 2023
Expand Down Expand Up @@ -38,14 +39,15 @@ export const TAColumns = (handleDelete: Fn) => [
header: "Actions",
cell: ({ row }) => (
<>
<Button
<ColumnButton
id="delete-ta"
variant="outline-danger"
size="sm"
className="ms-sm-2"
onClick={() => handleDelete(row)}
>
<BsPersonXFill />
</Button>
tooltip="Delete TA"
icon={<BsPersonXFill />}
/>
</>
),
}),
Expand Down
6 changes: 3 additions & 3 deletions src/pages/TA/TAUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface ITAFormValues {
}

export const transformTAResponse = (taList: string) => {
let taData: IFormOption[] = [{ label: "Select a TA", value: "" }];
let taData: IFormOption[] = [];
let tas: ITA[] = JSON.parse(taList);
tas.forEach((ta) => taData.push({ label: ta.name, value: ta.id! }));
return taData;
Expand All @@ -37,7 +37,7 @@ export async function loadTAs({ params }: any) {
const taRoleUsersResponse = await axiosClient.get(`/users/role/Teaching Assistant`, {
transformResponse: transformTAResponse
});
const taUsers = taRoleUsersResponse.data;

let taUsers = taRoleUsersResponse.data;
taUsers = [{label: "Select a TA", value: ""},...taUsers];
return { taUsers };
}