feat: open an injected course page on course block click in popup main (#146)
* feat: Imports to popupcourseblock.tsx * changing the blocks to accept parameters for clicking functionality which may or may not open the calendar * put the click parameter in the div of popupcourseblock * safely calling for onCourseClick in the event it is an undefined function * handled other calls of popupcourseblock with empty functions for now, and i think popupmain opens calendar now when the course block is clicked * feat: Testing out passing params to handleOpenCalendar * url that takes in params to open calendar with params * further work on url params; from popup main to handleopencalendar to calendar using urlsearchparams * feat: small calendar shifting after merge: * fix: merge handling and then references to new click parameter * fix: optional params * feat: split into two functions instead * fix: changing proper usage of handleOpenCalendarWithCourse * feat: show course popup when calendar opened * chore: remove useless commented out code * feat: close popup on calendar nav, fix build errors, remove useless comments/logs * chore: chromatic so dumb fr why aren't you chrome * fix: refactor listeners to build properly * feat: exit early when not in chrome extension * fix: function return type * fix: function return type x2 * fix: generic type for useState * refactor: extract calendar opening on click functions * refactor: chrome runtime mock, omit question mark if no query params, rename calendar event * refactor: move course click event into component directly instead of prop * refactor: removed useless wrapper functions, made popup course block more accessible * fix: i dont wanna talk about it --------- Co-authored-by: Samuel Gunter <sgunter@utexas.edu>
This commit is contained in:
19
src/shared/messages/CalendarMessages.ts
Normal file
19
src/shared/messages/CalendarMessages.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
interface CalendarBackgroundMessages {
|
||||
/**
|
||||
* Opens the calendar page if it is not already open, focuses the tab, and optionally opens the calendar for a specific course
|
||||
*
|
||||
* @param data - The unique id of the course to open the calendar page for (optional)
|
||||
*/
|
||||
switchToCalendarTab: (data: { uniqueId?: number }) => chrome.tabs.Tab;
|
||||
}
|
||||
|
||||
interface CalendarTabMessages {
|
||||
/**
|
||||
* Opens a popup for a specific course on the calendar page
|
||||
*
|
||||
* @param data - The unique id of the course to open on the calendar page
|
||||
*/
|
||||
openCoursePopup: (data: { uniqueId: number }) => chrome.tabs.Tab;
|
||||
}
|
||||
|
||||
export type { CalendarBackgroundMessages, CalendarTabMessages };
|
||||
15
src/shared/messages/TabInfoMessages.ts
Normal file
15
src/shared/messages/TabInfoMessages.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
type TabInfo = {
|
||||
url: string;
|
||||
title: string;
|
||||
};
|
||||
|
||||
interface TabInfoMessages {
|
||||
/**
|
||||
* Gets the info for the tab receiving the message
|
||||
*
|
||||
* @returns The info for the tab receiving the message
|
||||
*/
|
||||
getTabInfo: () => TabInfo;
|
||||
}
|
||||
|
||||
export default TabInfoMessages;
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* This is a type with all the message definitions that can be sent TO specific tabs
|
||||
*/
|
||||
export default interface TAB_MESSAGES {}
|
||||
@@ -1,15 +1,25 @@
|
||||
import { createMessenger } from 'chrome-extension-toolkit';
|
||||
|
||||
import type BrowserActionMessages from './BrowserActionMessages';
|
||||
import type { CalendarBackgroundMessages, CalendarTabMessages } from './CalendarMessages';
|
||||
import type CESMessage from './CESMessage';
|
||||
import type TabInfoMessages from './TabInfoMessages';
|
||||
import type TabManagementMessages from './TabManagementMessages';
|
||||
import type TAB_MESSAGES from './TabMessages';
|
||||
import type { UserScheduleMessages } from './UserScheduleMessages';
|
||||
|
||||
/**
|
||||
* This is a type with all the message definitions that can be sent TO the background script
|
||||
*/
|
||||
export type BACKGROUND_MESSAGES = BrowserActionMessages & TabManagementMessages & UserScheduleMessages & CESMessage;
|
||||
export type BACKGROUND_MESSAGES = BrowserActionMessages &
|
||||
TabManagementMessages &
|
||||
UserScheduleMessages &
|
||||
CESMessage &
|
||||
CalendarBackgroundMessages;
|
||||
|
||||
/**
|
||||
* This is a type with all the message definitions that can be sent TO specific tabs
|
||||
*/
|
||||
export type TAB_MESSAGES = CalendarTabMessages & TabInfoMessages;
|
||||
|
||||
/**
|
||||
* A utility object that can be used to send type-safe messages to the background script
|
||||
@@ -19,4 +29,4 @@ export const background = createMessenger<BACKGROUND_MESSAGES>('background');
|
||||
/**
|
||||
* A utility object that can be used to send type-safe messages to specific tabs
|
||||
*/
|
||||
export const tabs = createMessenger<TAB_MESSAGES>('tab');
|
||||
export const tabs = createMessenger<TAB_MESSAGES>('foreground');
|
||||
|
||||
Reference in New Issue
Block a user