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:
@@ -62,6 +62,7 @@ export default function AddNewCourseToGlobalSettingsForm() {
|
||||
const formIsComplete =
|
||||
selectedTerm && selectedCanvasCourse && selectedDirectory;
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<ButtonSelect
|
||||
@@ -94,11 +95,11 @@ export default function AddNewCourseToGlobalSettingsForm() {
|
||||
disabled={!formIsComplete || createCourse.isPending}
|
||||
onClick={async () => {
|
||||
if (formIsComplete) {
|
||||
console.log("Creating course with settings:", selectedDirectory);
|
||||
console.log("Creating course with settings:", selectedDirectory, "old course", courseToImport);
|
||||
const newSettings: LocalCourseSettings = courseToImport
|
||||
? {
|
||||
...courseToImport,
|
||||
name: selectedDirectory,
|
||||
name: name,
|
||||
daysOfWeek: selectedDaysOfWeek,
|
||||
canvasId: selectedCanvasCourse.id,
|
||||
startDate: selectedTerm.start_at ?? "",
|
||||
@@ -114,7 +115,7 @@ export default function AddNewCourseToGlobalSettingsForm() {
|
||||
assets: [],
|
||||
}
|
||||
: {
|
||||
name: selectedDirectory,
|
||||
name: name,
|
||||
assignmentGroups: [],
|
||||
daysOfWeek: selectedDaysOfWeek,
|
||||
canvasId: selectedCanvasCourse.id,
|
||||
@@ -145,10 +146,10 @@ export default function AddNewCourseToGlobalSettingsForm() {
|
||||
</div>
|
||||
{createCourse.isPending && <Spinner />}
|
||||
|
||||
<pre>
|
||||
{/* <pre>
|
||||
<div>Example docker compose</div>
|
||||
<code className="language-yml">{sampleCompose}</code>
|
||||
</pre>
|
||||
</pre> */}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -180,12 +181,10 @@ function OtherSettings({
|
||||
name: string;
|
||||
setName: Dispatch<SetStateAction<string>>;
|
||||
}) {
|
||||
const { data: canvasCourses } = useCourseListInTermQuery(selectedTerm.id);
|
||||
const { data: canvasCourses, isLoading: canvasCoursesLoading } =
|
||||
useCourseListInTermQuery(selectedTerm.id);
|
||||
const { data: allSettings } = useLocalCoursesSettingsQuery();
|
||||
const [directory, setDirectory] = useState("./");
|
||||
// const directoryIsCourseQuery = useDirectoryIsCourseQuery(
|
||||
// selectedDirectory ?? "./"
|
||||
// );
|
||||
|
||||
const populatedCanvasCourseIds = allSettings?.map((s) => s.canvasId) ?? [];
|
||||
const availableCourses =
|
||||
@@ -204,6 +203,20 @@ function OtherSettings({
|
||||
getOptionName={(c) => c?.name ?? ""}
|
||||
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
|
||||
value={directory}
|
||||
|
||||
@@ -100,6 +100,8 @@ export function StoragePathSelector({
|
||||
setArrowUsed(false);
|
||||
setHighlightedIndex(-1);
|
||||
if (shouldFocus) {
|
||||
// Keep the dropdown open by maintaining focus state
|
||||
setIsFocused(true);
|
||||
setTimeout(() => inputRef.current?.focus(), 0);
|
||||
}
|
||||
};
|
||||
@@ -154,7 +156,10 @@ export function StoragePathSelector({
|
||||
className={`dropdown-option w-full px-2 py-1 cursor-pointer ${
|
||||
highlightedIndex === idx ? "bg-blue-700 text-white" : ""
|
||||
}`}
|
||||
onMouseDown={() => handleSelectFolder(option)}
|
||||
onMouseDown={(e) => {
|
||||
e.preventDefault(); // Prevent input blur
|
||||
handleSelectFolder(option, true);
|
||||
}}
|
||||
onMouseEnter={() => setHighlightedIndex(idx)}
|
||||
>
|
||||
{option}
|
||||
|
||||
@@ -103,6 +103,13 @@ async function migrateCourseContent(
|
||||
) {
|
||||
const oldCourseName = settingsFromCourseToImport.name;
|
||||
const newCourseName = settings.name;
|
||||
console.log(
|
||||
"migrating content from ",
|
||||
oldCourseName,
|
||||
"to ",
|
||||
newCourseName
|
||||
);
|
||||
|
||||
const oldModules = await getModuleNamesFromFiles(oldCourseName);
|
||||
await Promise.all(
|
||||
oldModules.map(async (moduleName) => {
|
||||
|
||||
Reference in New Issue
Block a user