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

Add Custom Events and Schedule Notes to Skeleton Mode #702

Merged
merged 52 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
e90358e
Add custom events
KevinWu098 Sep 19, 2023
2df1cb5
Updated CustomEventDetailView
KevinWu098 Sep 19, 2023
6accc9c
Extracted schedule note component
KevinWu098 Sep 19, 2023
22a86d0
Extract custom events box
KevinWu098 Sep 19, 2023
ee8869c
Clean up endpoint
KevinWu098 Sep 19, 2023
2dc66dd
Update styling
KevinWu098 Sep 19, 2023
5fad63e
Refactor Custom Events box
KevinWu098 Sep 19, 2023
4d72161
Disable custom event creation
KevinWu098 Sep 19, 2023
cd9ef3e
Refactor schedule note box
KevinWu098 Sep 19, 2023
ed2e3b2
Remove uneeded functions
KevinWu098 Sep 19, 2023
a706ba3
Disable schedule select popover
KevinWu098 Sep 19, 2023
aff6ca2
Add docs
KevinWu098 Sep 19, 2023
4a5dd09
Refactor code
KevinWu098 Sep 19, 2023
4453f24
Subscribe to AppStore
KevinWu098 Sep 20, 2023
c7934dd
Refactor CustomEventDialog
KevinWu098 Sep 20, 2023
0d67d97
Fix error message
KevinWu098 Sep 20, 2023
7f3a8f9
Properly subscribe to AppStore for SkeleMode
KevinWu098 Sep 20, 2023
e55f80c
Refactor default states
KevinWu098 Sep 20, 2023
f90268f
Update styling of buttons
KevinWu098 Sep 20, 2023
d3e8341
Refactor code
KevinWu098 Sep 20, 2023
0f90194
Refactor code
KevinWu098 Sep 20, 2023
7ae2f6f
Add useCallback
KevinWu098 Sep 20, 2023
671dcbf
Refactor top-level conditional
KevinWu098 Sep 20, 2023
cedc57e
Refactor uneeded props
KevinWu098 Sep 20, 2023
cc03759
Remove negative margins
KevinWu098 Sep 20, 2023
d6372cc
Refactor styling
KevinWu098 Sep 20, 2023
f950b52
Adjust margins
KevinWu098 Sep 20, 2023
123cd6d
Update styling
KevinWu098 Sep 20, 2023
9ec9f89
Disable actions in skeleton mode
KevinWu098 Sep 21, 2023
9d05055
Refactor skeleton mode trigger
KevinWu098 Sep 21, 2023
0d452b2
Move URL to local
KevinWu098 Sep 21, 2023
3dc6b16
Update docs
KevinWu098 Sep 21, 2023
7a8b049
Refactor uneeded props
KevinWu098 Sep 21, 2023
b636a63
Refactor code
KevinWu098 Sep 23, 2023
79e885b
Update styling
KevinWu098 Sep 23, 2023
9bb713e
Remove grids
KevinWu098 Sep 23, 2023
a8bd5fe
Type the event, not the function
KevinWu098 Sep 23, 2023
577f328
Refactor code heirarchy
KevinWu098 Sep 23, 2023
5abc755
Various fixes
KevinWu098 Oct 1, 2023
f335548
Revert isWebsocAlive ping
KevinWu098 Oct 2, 2023
32e617f
Fix loadSchedule
KevinWu098 Oct 2, 2023
b25c288
Merge branch 'main' into skeleton-details
KevinWu098 Oct 2, 2023
a158489
Merge branch 'main' into skeleton-details
KevinWu098 Oct 30, 2023
1750bbc
Merge branch 'main' into skeleton-details
KevinWu098 Nov 16, 2023
460bc6c
Merge main
KevinWu098 Nov 24, 2023
c0692a7
Set correct building values
KevinWu098 Nov 24, 2023
66e0528
De-arrow handler functions
KevinWu098 Nov 24, 2023
f0c6c1c
Merge branch 'main' into skeleton-details
KevinWu098 Nov 30, 2023
6f6031b
Remove unused prop
KevinWu098 Nov 30, 2023
7a774a4
Merge branch 'main' into skeleton-details
KevinWu098 Nov 30, 2023
e02ad0a
Noop to backend
KevinWu098 Nov 30, 2023
410b760
Revert "Noop to backend"
KevinWu098 Nov 30, 2023
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
5 changes: 2 additions & 3 deletions apps/antalmanac/src/actions/AppStoreActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ export const loadSchedule = async (userId: string, rememberMe: boolean) => {
window.confirm(`Are you sure you want to load a different schedule? You have unsaved changes!`))
) {
userId = userId.replace(/\s+/g, '');

if (userId.length > 0) {
if (rememberMe) {
window.localStorage.setItem('userID', userId);
Expand All @@ -122,15 +121,15 @@ export const loadSchedule = async (userId: string, rememberMe: boolean) => {
const res = await trpc.users.getUserData.query({ userId });
const scheduleSaveState = res?.userData;

if (scheduleSaveState === undefined) {
if (scheduleSaveState == null) {
openSnackbar('error', `Couldn't find schedules for username "${userId}".`);
} else if (await AppStore.loadSchedule(scheduleSaveState)) {
openSnackbar('success', `Schedule for username "${userId}" loaded.`);
} else {
AppStore.loadSkeletonSchedule(scheduleSaveState);
openSnackbar(
'error',
`Network error loading course information for "${userId}".
`Network error loading course information for "${userId}".
If this continues to happen, please submit a feedback form.`
);
}
Expand Down
29 changes: 25 additions & 4 deletions apps/antalmanac/src/components/Calendar/CalendarToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ function AddScheduleButton() {
*/
function SelectSchedulePopover(props: { scheduleNames: string[] }) {
const [currentScheduleIndex, setCurrentScheduleIndex] = useState(AppStore.getCurrentScheduleIndex());
const [skeletonMode, setSkeletonMode] = useState(AppStore.getSkeletonMode());

const [anchorEl, setAnchorEl] = useState<HTMLElement>();

Expand Down Expand Up @@ -156,17 +157,23 @@ function SelectSchedulePopover(props: { scheduleNames: string[] }) {
setCurrentScheduleIndex(AppStore.getCurrentScheduleIndex());
}, []);

const handleSkeletonModeChange = () => {
setSkeletonMode(AppStore.getSkeletonMode());
};

useEffect(() => {
AppStore.on('addedCoursesChange', handleScheduleIndexChange);
AppStore.on('customEventsChange', handleScheduleIndexChange);
AppStore.on('colorChange', handleScheduleIndexChange);
AppStore.on('currentScheduleIndexChange', handleScheduleIndexChange);
AppStore.on('skeletonModeChange', handleSkeletonModeChange);

return () => {
AppStore.off('addedCoursesChange', handleScheduleIndexChange);
AppStore.off('customEventsChange', handleScheduleIndexChange);
AppStore.off('colorChange', handleScheduleIndexChange);
AppStore.off('currentScheduleIndexChange', handleScheduleIndexChange);
AppStore.off('skeletonModeChange', handleSkeletonModeChange);
};
}, [handleScheduleIndexChange]);

Expand All @@ -178,6 +185,7 @@ function SelectSchedulePopover(props: { scheduleNames: string[] }) {
variant="outlined"
onClick={handleClick}
sx={{ minWidth, maxWidth, justifyContent: 'space-between' }}
disabled={skeletonMode}
>
<Typography whiteSpace="nowrap" textOverflow="ellipsis" overflow="hidden" textTransform="none">
{currentScheduleName}
Expand Down Expand Up @@ -246,8 +254,8 @@ export interface CalendarPaneToolbarProps {
*/
function CalendarPaneToolbar(props: CalendarPaneToolbarProps) {
const { showFinalsSchedule, toggleDisplayFinalsSchedule } = props;

const [scheduleNames, setScheduleNames] = useState(AppStore.getScheduleNames());
const [skeletonMode, setSkeletonMode] = useState(AppStore.getSkeletonMode());

const handleToggleFinals = useCallback(() => {
logAnalytics({
Expand All @@ -261,6 +269,18 @@ function CalendarPaneToolbar(props: CalendarPaneToolbarProps) {
setScheduleNames(AppStore.getScheduleNames());
}, []);

useEffect(() => {
const handleSkeletonModeChange = () => {
setSkeletonMode(AppStore.getSkeletonMode());
};

AppStore.on('skeletonModeChange', handleSkeletonModeChange);

return () => {
AppStore.off('skeletonModeChange', handleSkeletonModeChange);
};
}, []);

useEffect(() => {
AppStore.on('scheduleNamesChange', handleScheduleNamesChange);

Expand Down Expand Up @@ -290,6 +310,7 @@ function CalendarPaneToolbar(props: CalendarPaneToolbarProps) {
variant={showFinalsSchedule ? 'contained' : 'outlined'}
onClick={handleToggleFinals}
size="small"
disabled={skeletonMode}
>
Finals
</Button>
Expand All @@ -301,20 +322,20 @@ function CalendarPaneToolbar(props: CalendarPaneToolbarProps) {
<Box display="flex" flexWrap="wrap" gap={0.5}>
<Box display="flex" alignItems="center" gap={0.5}>
<Tooltip title="Undo last action">
<IconButton onClick={handleUndo} size="medium">
<IconButton onClick={handleUndo} size="medium" disabled={skeletonMode}>
<UndoIcon fontSize="small" />
</IconButton>
</Tooltip>

<Tooltip title="Clear schedule">
<IconButton onClick={handleClearSchedule} size="medium">
<IconButton onClick={handleClearSchedule} size="medium" disabled={skeletonMode}>
<DeleteIcon fontSize="small" />
</IconButton>
</Tooltip>
</Box>

<Box display="flex" flexWrap="wrap" alignItems="center" gap={0.5}>
<CustomEventDialog scheduleNames={scheduleNames} key="custom" />
<CustomEventDialog key="custom" scheduleNames={AppStore.getScheduleNames()} />
</Box>
</Box>
</Paper>
Expand Down
22 changes: 12 additions & 10 deletions apps/antalmanac/src/components/Calendar/CourseCalendarEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,18 @@ const CourseCalendarEvent = (props: CourseCalendarEventProps) => {
return (
<Paper className={classes.customEventContainer} ref={paperRef}>
<div className={classes.title}>{title}</div>
<div className={classes.table}>
Location: &nbsp;&nbsp;
<Link
className={classes.clickableLocation}
to={`/map?location=${building ?? 0}`}
onClick={focusMap}
>
{building ? buildingCatalogue[+building].name : ''}
</Link>
</div>
{building && (
<div className={classes.table}>
Location:&nbsp;
<Link
className={classes.clickableLocation}
to={`/map?location=${building ?? 0}`}
onClick={focusMap}
>
{buildingCatalogue[+building].name}
</Link>
</div>
)}
<div className={classes.buttonBar}>
<div className={`${classes.colorPicker}`}>
<ColorPicker
Expand Down
Loading