Skip to content

Commit

Permalink
Change user and content ids to UUIDs.
Browse files Browse the repository at this point in the history
  • Loading branch information
dqnykamp committed Aug 20, 2024
1 parent 965f321 commit b3929c7
Show file tree
Hide file tree
Showing 55 changed files with 2,419 additions and 2,081 deletions.
25 changes: 12 additions & 13 deletions client/src/Tools/_framework/Paths/Activities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ import {
License,
LicenseCode,
UserInfo,
} from "./ActivityEditor";
import { DateTime } from "luxon";
} from "./../../../_utils/types";
import { MdClose, MdOutlineSearch } from "react-icons/md";
import { ShareDrawer, shareDrawerActions } from "../ToolPanels/ShareDrawer";

// what is a better solution than this?
let folderJustCreated = -1; // if a folder was just created, set autoFocusName true for the card with the matching id
let folderJustCreated = ""; // if a folder was just created, set autoFocusName true for the card with the matching id

export async function action({ request, params }) {
const formData = await request.formData();
Expand Down Expand Up @@ -171,7 +170,7 @@ export async function loader({ params, request }) {
let listViewPref = !prefData.data.cardView;

return {
folderId: params.folderId ? Number(params.folderId) : null,
folderId: params.folderId ? params.folderId : null,
content: data.content,
allDoenetmlVersions: data.allDoenetmlVersions,
allLicenses: data.allLicenses,
Expand All @@ -193,16 +192,16 @@ export function Activities() {
listViewPref,
query,
} = useLoaderData() as {
folderId: number | null;
folderId: string | null;
content: ContentStructure[];
allDoenetmlVersions: DoenetmlVersion[];
allLicenses: License[];
userId: number;
userId: string;
folder: ContentStructure | null;
listViewPref: Boolean;
query: string | null;
};
const [settingsContentId, setSettingsContentId] = useState<number | null>(
const [settingsContentId, setSettingsContentId] = useState<string | null>(
null,
);
const {
Expand Down Expand Up @@ -250,13 +249,13 @@ export function Activities() {
const [listView, setListView] = useState(listViewPref);

const [moveToFolderContent, setMoveToFolderContent] = useState<{
id: number;
id: string;
isPublic: boolean;
isShared: boolean;
sharedWith: UserInfo[];
licenseCode: LicenseCode | null;
}>({
id: -1,
id: "",
isPublic: false,
isShared: false,
sharedWith: [],
Expand Down Expand Up @@ -290,7 +289,7 @@ export function Activities() {
licenseCode,
parentFolderId,
}: {
id: number;
id: string;
position: number;
numCards: number;
assignmentStatus: AssignmentStatus;
Expand All @@ -299,7 +298,7 @@ export function Activities() {
isShared: boolean;
sharedWith: UserInfo[];
licenseCode: LicenseCode | null;
parentFolderId: number | null;
parentFolderId: string | null;
}) {
return (
<>
Expand Down Expand Up @@ -793,7 +792,7 @@ export function Activities() {
};
const justCreated = folderJustCreated === activity.id;
if (justCreated) {
folderJustCreated = -1;
folderJustCreated = "";
}
return {
ref: getCardRef,
Expand Down Expand Up @@ -832,7 +831,7 @@ export function Activities() {
};
const justCreated = folderJustCreated === activity.id;
if (justCreated) {
folderJustCreated = -1;
folderJustCreated = "";
}
return (
<ContentCard
Expand Down
99 changes: 10 additions & 89 deletions client/src/Tools/_framework/Paths/ActivityEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
contentSettingsActions,
ContentSettingsDrawer,
} from "../ToolPanels/ContentSettingsDrawer";
import { DateTime } from "luxon";
import { InfoIcon } from "@chakra-ui/icons";
import { AssignmentInvitation } from "../ToolPanels/AssignmentInvitation";
import {
Expand All @@ -45,89 +44,11 @@ import {
} from "../ToolPanels/AssignmentSettingsDrawer";
import { ShareDrawer } from "../ToolPanels/ShareDrawer";
import { sharingActions } from "../ToolPanels/ShareSettings";

export type DoenetmlVersion = {
id: number;
displayedVersion: string;
fullVersion: string;
default: boolean;
deprecated: boolean;
removed: boolean;
deprecationMessage: string;
};

export type LicenseCode = "CCDUAL" | "CCBYSA" | "CCBYNCSA";

export type License = {
code: LicenseCode;
name: string;
description: string;
imageURL: string | null;
smallImageURL: string | null;
licenseURL: string | null;
isComposition: boolean;
composedOf: {
code: LicenseCode;
name: string;
description: string;
imageURL: string | null;
smallImageURL: string | null;
licenseURL: string | null;
}[];
};

export type AssignmentStatus = "Unassigned" | "Closed" | "Open";

export type UserInfo = {
userId: number;
firstNames: string | null;
lastNames: string;
email: string;
};

export type ContentClassification = {
id: number;
code: string;
grade: string | null;
category: string;
description: string;
system: {
id: number;
name: string;
};
};

export type ContentStructure = {
id: number;
ownerId: number;
owner?: UserInfo;
name: string;
imagePath: string | null;
assignmentStatus: AssignmentStatus;
isFolder?: boolean;
classCode: string | null;
codeValidUntil: string | null;
isPublic: boolean;
isShared: boolean;
sharedWith: UserInfo[];
license: License | null;
classifications: ContentClassification[];
documents: {
id: number;
versionNum?: number;
name?: string;
source?: string;
doenetmlVersion: DoenetmlVersion;
}[];
hasScoreData: boolean;
parentFolder: {
id: number;
name: string;
isPublic: boolean;
isShared: boolean;
sharedWith: UserInfo[];
} | null;
};
import {
ContentStructure,
DoenetmlVersion,
License,
} from "../../../_utils/types";

export async function action({ params, request }) {
const formData = await request.formData();
Expand All @@ -141,7 +62,7 @@ export async function action({ params, request }) {

if (formObj._action == "update name") {
await axios.post(`/api/updateContentName`, {
id: Number(params.activityId),
id: params.activityId,
name,
});
return true;
Expand Down Expand Up @@ -180,8 +101,8 @@ export async function loader({ params }) {
);
}

let activityId = Number(params.activityId);
let docId = Number(params.docId);
let activityId = params.activityId;
let docId = params.docId;
if (!docId) {
// If docId was not supplied in the url,
// then use the first docId from the activity.
Expand Down Expand Up @@ -298,10 +219,10 @@ export function ActivityEditor() {
allLicenses,
} = useLoaderData() as {
platform: "Win" | "Mac" | "Linux";
activityId: number;
activityId: string;
doenetML: string;
doenetmlVersion: DoenetmlVersion;
docId: number;
docId: string;
activityData: ContentStructure;
allDoenetmlVersions: DoenetmlVersion[];
allLicenses: License[];
Expand Down
Loading

0 comments on commit b3929c7

Please sign in to comment.