Skip to content

Commit

Permalink
style changeS
Browse files Browse the repository at this point in the history
  • Loading branch information
frostyfan109 committed Aug 14, 2024
1 parent e122f53 commit dfd4357
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 12 deletions.
12 changes: 11 additions & 1 deletion eduhelx_jupyterlab_student/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
merge as git_merge, abort_merge, delete_local_branch,
is_ancestor_commit, diff_status as git_diff_status
)
from eduhelx_utils.api import Api, AuthType
from eduhelx_utils.api import Api, AuthType, APIException
from eduhelx_utils.process import execute
from .student_repo import StudentClassRepo, NotStudentClassRepositoryException
from ._version import __version__
Expand Down Expand Up @@ -88,6 +88,16 @@ def config(self) -> ExtensionConfig:
def api(self) -> Api:
return self.context.api

# Default error handling
def write_error(self, status_code, **kwargs):
# If exc_info is present, the error is unhandled.
if "exc_info" not in kwargs: return

cls, exc, traceback = kwargs["exc_info"]
if isinstance(exc, APIException):
self.set_status(status_code)
self.finish(exc.response.text)

class WebsocketHandler(WSMixin, WSHandler, BaseHandler):
clients = []
queued_messages = []
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { Fragment, useMemo } from 'react'
import React, { Fragment, useCallback, useMemo } from 'react'
import { Tooltip } from 'antd'
import { FormHelperText, Input } from '@material-ui/core'
import { ArrowBackSharp } from '@material-ui/icons'
import moment from 'moment'
import pluralize from 'pluralize'
import { ArrowBackSharp } from '@material-ui/icons'
import { assignmentInfoClass, assignmentInfoSectionClass, assignmentInfoSectionHeaderClass, assignmentInfoSectionWarningClass, assignmentNameClass, tagClass } from './style'
import { useAssignment } from '../../../contexts'
import { useAssignment, useCommands, } from '../../../contexts'
import { DateFormat } from '../../../utils'

const MS_IN_HOURS = 3.6e6
Expand All @@ -13,7 +14,8 @@ interface AssignmentInfoProps {
}

export const AssignmentInfo = ({ }: AssignmentInfoProps) => {
const { assignment, student, course } = useAssignment()!
const { assignment, student, course, studentNotebookExists } = useAssignment()!
const commands = useCommands()
if (!student || !assignment || !course) return null

const hoursUntilDue = useMemo(() => (
Expand Down Expand Up @@ -99,6 +101,16 @@ export const AssignmentInfo = ({ }: AssignmentInfoProps) => {
else return `You are allowed to submit ${ remainingAttempts }${ assignment.currentAttempts > 0 ? ' more' : ''} ${ pluralize("time", remainingAttempts) }`
}, [assignment])

const studentNotebookInvalid = useMemo(() => (
!studentNotebookExists(assignment)
), [studentNotebookExists, assignment])

const openStudentNotebook = useCallback(async () => {
if (!commands || !assignment) return
const fullNotebookPath = assignment.absoluteDirectoryPath + "/" + assignment.studentNotebookPath
commands.execute('docmanager:open', { path: fullNotebookPath })
}, [commands, assignment])

return (
<div className={ assignmentInfoClass }>
<div>
Expand All @@ -121,18 +133,18 @@ export const AssignmentInfo = ({ }: AssignmentInfoProps) => {
</span>
) }
</div>
<div className={ assignmentInfoSectionClass } style={{ marginTop: 16 }}>
{/* <div className={ assignmentInfoSectionClass } style={{ marginTop: 16 }}>
<h5 className={ assignmentInfoSectionHeaderClass }>Student</h5>
<span>{ student.name }</span>
</div>
<div className={ assignmentInfoSectionClass }>
</div> */}
<div className={ assignmentInfoSectionClass } style={{ marginTop: 16 }}>
<h5 className={ assignmentInfoSectionHeaderClass }>
{ pluralize("Instructor", course.instructors.length) }
</h5>
<span>{ course.instructors.map((ins) => ins.name).join(", ") }</span>
</div>
<div className={ assignmentInfoSectionClass }>
<h5 className={ assignmentInfoSectionHeaderClass }>Due date</h5>
<h5 className={ assignmentInfoSectionHeaderClass }>Due Date</h5>
<div>
{ assignment.isCreated ? (
new DateFormat(assignment.adjustedDueDate!).toBasicDatetime()
Expand Down Expand Up @@ -167,6 +179,32 @@ export const AssignmentInfo = ({ }: AssignmentInfoProps) => {
</div>
</div>
) }
<div className={ assignmentInfoSectionClass } style={{ marginTop: 0, marginBottom: 8 }}>
<h5 className={ assignmentInfoSectionHeaderClass }>
Assignment Notebook
</h5>
<div style={{ width: "100%" }}>
{ !studentNotebookInvalid ? (
<Fragment>
<Input
readOnly
value={ assignment.studentNotebookPath }
inputProps={{ style: { height: 32, fontSize: 15 } }}
style={{ width: "100%" }}
/>
<FormHelperText style={{ color: "#1976d2" }}>
<a onClick={ openStudentNotebook } style={{ cursor: "pointer" }}>
Open notebook
</a>
</FormHelperText>
</Fragment>
) : (
<span>
Not published yet
</span>
) }
</div>
</div>
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ export const AssignmentStagedChanges = ({ ...props }: AssignmentStagedChangesPro
{/* <TextDivider innerStyle={{ fontSize: 'var(--jp-ui-font-size2)' }} style={{ marginBottom: 4 }}>Unsubmitted changes</TextDivider> */}
<div className={ stagedChangesListClass }>
{
stagedChangesSource.slice(0, showMore ? undefined : SHOW_MORE_CUTOFF).map((change) => (
stagedChangesSource.slice(0, showMore ? undefined : SHOW_MORE_CUTOFF).map((change, i) => (
<div className={ stagedChangeListItemClass }>
<div style={{ display: "flex", alignItems: "center" }}>
<div style={{ display: "flex", alignItems: "center", marginTop: i === 0 ? 4 : 0 }}>
{ change.type === "directory" ? (
<folderIcon.react
className={ assignmentStagedChangesFolderIconClass }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const AssignmentSubmitForm = ({ }: AssignmentSubmitFormProps) => {
disabled: disabledStyle
}}
multiline
rows={ 5 }
rows={ 3 }
rowsMax={ 10 }
placeholder="Description (optional)"
title="Enter a description for the submission"
Expand Down
1 change: 1 addition & 0 deletions src/components/assignment-panel/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const panelWrapperClass = (style as any)({
color: 'var(--jp-ui-font-color1)',
fontSize: 'var(--jp-ui-font-size1)',
background: 'var(--jp-layout-color1) !important',
minWidth: 'var(--jp-sidebar-min-width)',
'&, & *': { boxSizing: 'border-box' }
})

Expand Down
3 changes: 3 additions & 0 deletions style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
https://jupyterlab.readthedocs.io/en/stable/developer/css.html
*/
:root {
--jp-sidebar-min-width: 350px !important;
}

0 comments on commit dfd4357

Please sign in to comment.