mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
fixing new course config form
This commit is contained in:
@@ -23,3 +23,5 @@ courses:
|
|||||||
name: 1420_old
|
name: 1420_old
|
||||||
- path: ./3820_BackEnd/2025-fall/Modules/
|
- path: ./3820_BackEnd/2025-fall/Modules/
|
||||||
name: jonathan-backend
|
name: jonathan-backend
|
||||||
|
- path: ./4850_AdvancedFE/2026-spring-alex/modules
|
||||||
|
name: Adv Frontend Spring
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ export default function AddNewCourseToGlobalSettingsForm() {
|
|||||||
const formIsComplete =
|
const formIsComplete =
|
||||||
selectedTerm && selectedCanvasCourse && selectedDirectory;
|
selectedTerm && selectedCanvasCourse && selectedDirectory;
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<ButtonSelect
|
<ButtonSelect
|
||||||
@@ -94,11 +95,11 @@ export default function AddNewCourseToGlobalSettingsForm() {
|
|||||||
disabled={!formIsComplete || createCourse.isPending}
|
disabled={!formIsComplete || createCourse.isPending}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
if (formIsComplete) {
|
if (formIsComplete) {
|
||||||
console.log("Creating course with settings:", selectedDirectory);
|
console.log("Creating course with settings:", selectedDirectory, "old course", courseToImport);
|
||||||
const newSettings: LocalCourseSettings = courseToImport
|
const newSettings: LocalCourseSettings = courseToImport
|
||||||
? {
|
? {
|
||||||
...courseToImport,
|
...courseToImport,
|
||||||
name: selectedDirectory,
|
name: name,
|
||||||
daysOfWeek: selectedDaysOfWeek,
|
daysOfWeek: selectedDaysOfWeek,
|
||||||
canvasId: selectedCanvasCourse.id,
|
canvasId: selectedCanvasCourse.id,
|
||||||
startDate: selectedTerm.start_at ?? "",
|
startDate: selectedTerm.start_at ?? "",
|
||||||
@@ -114,7 +115,7 @@ export default function AddNewCourseToGlobalSettingsForm() {
|
|||||||
assets: [],
|
assets: [],
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
name: selectedDirectory,
|
name: name,
|
||||||
assignmentGroups: [],
|
assignmentGroups: [],
|
||||||
daysOfWeek: selectedDaysOfWeek,
|
daysOfWeek: selectedDaysOfWeek,
|
||||||
canvasId: selectedCanvasCourse.id,
|
canvasId: selectedCanvasCourse.id,
|
||||||
@@ -145,10 +146,10 @@ export default function AddNewCourseToGlobalSettingsForm() {
|
|||||||
</div>
|
</div>
|
||||||
{createCourse.isPending && <Spinner />}
|
{createCourse.isPending && <Spinner />}
|
||||||
|
|
||||||
<pre>
|
{/* <pre>
|
||||||
<div>Example docker compose</div>
|
<div>Example docker compose</div>
|
||||||
<code className="language-yml">{sampleCompose}</code>
|
<code className="language-yml">{sampleCompose}</code>
|
||||||
</pre>
|
</pre> */}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -180,12 +181,10 @@ function OtherSettings({
|
|||||||
name: string;
|
name: string;
|
||||||
setName: Dispatch<SetStateAction<string>>;
|
setName: Dispatch<SetStateAction<string>>;
|
||||||
}) {
|
}) {
|
||||||
const { data: canvasCourses } = useCourseListInTermQuery(selectedTerm.id);
|
const { data: canvasCourses, isLoading: canvasCoursesLoading } =
|
||||||
|
useCourseListInTermQuery(selectedTerm.id);
|
||||||
const { data: allSettings } = useLocalCoursesSettingsQuery();
|
const { data: allSettings } = useLocalCoursesSettingsQuery();
|
||||||
const [directory, setDirectory] = useState("./");
|
const [directory, setDirectory] = useState("./");
|
||||||
// const directoryIsCourseQuery = useDirectoryIsCourseQuery(
|
|
||||||
// selectedDirectory ?? "./"
|
|
||||||
// );
|
|
||||||
|
|
||||||
const populatedCanvasCourseIds = allSettings?.map((s) => s.canvasId) ?? [];
|
const populatedCanvasCourseIds = allSettings?.map((s) => s.canvasId) ?? [];
|
||||||
const availableCourses =
|
const availableCourses =
|
||||||
@@ -204,6 +203,20 @@ function OtherSettings({
|
|||||||
getOptionName={(c) => c?.name ?? ""}
|
getOptionName={(c) => c?.name ?? ""}
|
||||||
center={true}
|
center={true}
|
||||||
/>
|
/>
|
||||||
|
{canvasCoursesLoading && <Spinner />}
|
||||||
|
{!canvasCoursesLoading && availableCourses.length === 0 && (
|
||||||
|
<div className="text-center text-red-300">
|
||||||
|
<div className="flex justify-center ">
|
||||||
|
<div className="text-left">
|
||||||
|
No available courses in this term to add. Either
|
||||||
|
<ol>
|
||||||
|
<li>all courses have already been added, or</li>
|
||||||
|
<li>there are no courses in this term</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<StoragePathSelector
|
<StoragePathSelector
|
||||||
value={directory}
|
value={directory}
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ export function StoragePathSelector({
|
|||||||
setArrowUsed(false);
|
setArrowUsed(false);
|
||||||
setHighlightedIndex(-1);
|
setHighlightedIndex(-1);
|
||||||
if (shouldFocus) {
|
if (shouldFocus) {
|
||||||
|
// Keep the dropdown open by maintaining focus state
|
||||||
|
setIsFocused(true);
|
||||||
setTimeout(() => inputRef.current?.focus(), 0);
|
setTimeout(() => inputRef.current?.focus(), 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -154,7 +156,10 @@ export function StoragePathSelector({
|
|||||||
className={`dropdown-option w-full px-2 py-1 cursor-pointer ${
|
className={`dropdown-option w-full px-2 py-1 cursor-pointer ${
|
||||||
highlightedIndex === idx ? "bg-blue-700 text-white" : ""
|
highlightedIndex === idx ? "bg-blue-700 text-white" : ""
|
||||||
}`}
|
}`}
|
||||||
onMouseDown={() => handleSelectFolder(option)}
|
onMouseDown={(e) => {
|
||||||
|
e.preventDefault(); // Prevent input blur
|
||||||
|
handleSelectFolder(option, true);
|
||||||
|
}}
|
||||||
onMouseEnter={() => setHighlightedIndex(idx)}
|
onMouseEnter={() => setHighlightedIndex(idx)}
|
||||||
>
|
>
|
||||||
{option}
|
{option}
|
||||||
|
|||||||
@@ -103,6 +103,13 @@ async function migrateCourseContent(
|
|||||||
) {
|
) {
|
||||||
const oldCourseName = settingsFromCourseToImport.name;
|
const oldCourseName = settingsFromCourseToImport.name;
|
||||||
const newCourseName = settings.name;
|
const newCourseName = settings.name;
|
||||||
|
console.log(
|
||||||
|
"migrating content from ",
|
||||||
|
oldCourseName,
|
||||||
|
"to ",
|
||||||
|
newCourseName
|
||||||
|
);
|
||||||
|
|
||||||
const oldModules = await getModuleNamesFromFiles(oldCourseName);
|
const oldModules = await getModuleNamesFromFiles(oldCourseName);
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
oldModules.map(async (moduleName) => {
|
oldModules.map(async (moduleName) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user