mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
validation on changing assignment name
This commit is contained in:
@@ -40,6 +40,8 @@ export function UpdateAssignmentName({
|
|||||||
if (name === assignmentName) closeModal();
|
if (name === assignmentName) closeModal();
|
||||||
|
|
||||||
setIsLoading(true); // page refresh resets flag
|
setIsLoading(true); // page refresh resets flag
|
||||||
|
try{
|
||||||
|
|
||||||
await updateAssignment.mutateAsync({
|
await updateAssignment.mutateAsync({
|
||||||
assignment: assignment,
|
assignment: assignment,
|
||||||
moduleName,
|
moduleName,
|
||||||
@@ -54,6 +56,9 @@ export function UpdateAssignmentName({
|
|||||||
getModuleItemUrl(courseName, moduleName, "assignment", name),
|
getModuleItemUrl(courseName, moduleName, "assignment", name),
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
}finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
|||||||
@@ -133,6 +133,18 @@ export async function updateOrCreateAssignmentFile({
|
|||||||
assignmentName: string;
|
assignmentName: string;
|
||||||
assignment: LocalAssignment;
|
assignment: LocalAssignment;
|
||||||
}) {
|
}) {
|
||||||
|
const illegalCharacters = ["<", ">", ":", '"', "/", "\\", "|", "?", "*"];
|
||||||
|
const foundIllegalCharacters = illegalCharacters.filter((char) =>
|
||||||
|
assignmentName.includes(char)
|
||||||
|
);
|
||||||
|
if (foundIllegalCharacters.length > 0) {
|
||||||
|
throw new Error(
|
||||||
|
`"${assignmentName}" cannot contain the following characters: ${foundIllegalCharacters.join(
|
||||||
|
" "
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const courseDirectory = await getCoursePathByName(courseName);
|
const courseDirectory = await getCoursePathByName(courseName);
|
||||||
const folder = path.join(courseDirectory, moduleName, "assignments");
|
const folder = path.join(courseDirectory, moduleName, "assignments");
|
||||||
await fs.mkdir(folder, { recursive: true });
|
await fs.mkdir(folder, { recursive: true });
|
||||||
|
|||||||
Reference in New Issue
Block a user