github.com/quickfeed/quickfeed@v0.0.0-20240507093252-ed8ca812a09c/public/src/components/CourseLinks.tsx (about)

     1  import React from "react"
     2  import { Link } from "react-router-dom"
     3  import { Repository_Type } from "../../proto/qf/types_pb"
     4  import { getCourseID } from "../Helpers"
     5  import { useAppState } from "../overmind"
     6  
     7  /** CourseLinks displays various repository links for the current course, in addition to links to take the user to the group page. */
     8  const CourseLinks = (): JSX.Element => {
     9      const state = useAppState()
    10      const courseID = getCourseID()
    11      const enrollment = state.enrollmentsByCourseID[courseID.toString()]
    12      const repo = state.repositories[courseID.toString()]
    13  
    14      return (
    15          <div className="col-lg-3">
    16              <div className="list-group width-resize">
    17                  <div className="list-group-item list-group-item-action active text-center">
    18                      <h6>
    19                          <strong>Links</strong>
    20                      </h6>
    21                  </div>
    22  
    23                  <a
    24                      href={repo[Repository_Type.USER]}
    25                      target={"_blank"}
    26                      rel="noopener noreferrer"
    27                      className="list-group-item list-group-item-action"
    28                  >
    29                      User Repository
    30                  </a>
    31  
    32                  {repo[Repository_Type.GROUP] ? (
    33                      <a
    34                          href={repo[Repository_Type.GROUP]}
    35                          target={"_blank"}
    36                          rel="noopener noreferrer"
    37                          className="list-group-item list-group-item-action overflow-ellipses"
    38                          style={{ textAlign: "left" }}
    39                      >
    40                          Group Repository ({enrollment.group?.name})
    41                      </a>
    42                  ) : null}
    43  
    44                  <a
    45                      href={repo[Repository_Type.ASSIGNMENTS]}
    46                      target={"_blank"}
    47                      rel="noopener noreferrer"
    48                      className="list-group-item list-group-item-action"
    49                  >
    50                      Assignments
    51                  </a>
    52  
    53                  <a
    54                      href={repo[Repository_Type.INFO]}
    55                      target={"_blank"}
    56                      rel="noopener noreferrer"
    57                      className="list-group-item list-group-item-action"
    58                  >
    59                      Course Info
    60                  </a>
    61  
    62                  {state.hasGroup(courseID.toString()) ? (
    63                      <Link
    64                          to={`/course/${courseID}/group`}
    65                          className="list-group-item list-group-item-action"
    66                      >
    67                          View Group
    68                      </Link>
    69                  ) : (
    70                      <Link
    71                          to={`/course/${courseID}/group`}
    72                          className="list-group-item list-group-item-action list-group-item-success"
    73                      >
    74                          Create a Group
    75                      </Link>
    76                  )}
    77              </div>
    78          </div>
    79      )
    80  }
    81  
    82  export default CourseLinks