Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 185581730-add-points
Browse files Browse the repository at this point in the history
  • Loading branch information
bgoldowsky committed Mar 12, 2024
2 parents bd785ee + 661c7c5 commit fd793f4
Show file tree
Hide file tree
Showing 8 changed files with 3,695 additions and 7,510 deletions.
11,098 changes: 3,621 additions & 7,477 deletions cms/package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion cms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"author": "Concord Consortium <> (https://concord.org)",
"license": "MIT",
"dependencies": {
"netlify-cms-app": "^2.15.72"
"@types/react": "^18.2.0",
"react": "^18.2.0",
"decap-cms-app": "^3.1.2",
"decap-cms-core": "^3.3.2"
}
}
42 changes: 21 additions & 21 deletions cms/src/cms-collections.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
import { CmsConfig, CmsField, CmsFieldSelect, CmsSelectWidgetOptionObject } from "netlify-cms-core";
import { urlParams } from "../../src/utilities/url-params";
import { CmsCollection, CmsConfig, CmsField } from "decap-cms-core";
import { urlParams } from "./cms-url-params";

const typeField = {
const typeField: CmsField = {
label: "Type",
name: "type",
widget: "string"
} as CmsField;
};

const titleField = {
const titleField: CmsField = {
label: "Title",
name: "title",
widget: "string"
} as CmsField;
};

const tagField = {
const tagField: Extract<CmsField, {widget: "select"}> = {
label: "Tag",
name: "tag",
widget: "select",
options: []
} as CmsFieldSelect;
};

const previewLinkField = {
const previewLinkField: CmsField = {
label: "Preview Link",
name: "preview-link",
required: false,
widget: "preview-link"
} as CmsField;
widget: "preview-link" as any
};

const contentField = {
const contentField: CmsField = {
label: "Content",
name: "content",
widget: "clue" as any
} as CmsField;
};

const legacyCurriculumSections = {
const legacyCurriculumSections: CmsCollection = {
name: "sections",
label: "Curriculum Sections",
label_singular: "Curriculum Section",
Expand All @@ -44,7 +44,7 @@ const legacyCurriculumSections = {
fields: [typeField, previewLinkField, contentField]
};

const curriculumSections = {
const curriculumSections: CmsCollection = {
name: "sections",
label: "Curriculum Sections",
label_singular: "Curriculum Section",
Expand All @@ -55,7 +55,7 @@ const curriculumSections = {
fields: [typeField, previewLinkField, contentField]
};

const teacherGuides = {
const teacherGuides: CmsCollection = {
name: "teacherGuides",
label: "Teacher Guides",
label_singular: "Teacher Guide",
Expand All @@ -66,7 +66,7 @@ const teacherGuides = {
fields: [typeField, previewLinkField, contentField]
};

const exemplars = {
const exemplars: CmsCollection = {
name: "exemplars",
label: "Exemplars",
label_singular: "Exemplar",
Expand All @@ -88,20 +88,20 @@ function hasSectionsFolder(myJson: any) {

export function getCmsCollections(unitJson: any): CmsConfig["collections"] {
if (unitJson.config.commentTags) {
const tags = unitJson.config.commentTags;
const tags: Record<string, string> = unitJson.config.commentTags;
const options = Object.entries(tags).map(([value, label]) => ({ label, value }));
tagField.options = options as Array<CmsSelectWidgetOptionObject>;
tagField.options = options;
}

if (unitJson && hasSectionsFolder(unitJson)) {
return [
teacherGuides,
curriculumSections,
exemplars
] as CmsConfig["collections"];
];
} else {
return [
legacyCurriculumSections
] as CmsConfig["collections"];
];
}
}
34 changes: 34 additions & 0 deletions cms/src/cms-url-params.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { parse } from "query-string";

/**
* This is related to [url-params.ts](../../src/utilities/url-params.ts).
* It is a subset of the parameters in that module so the CMS doesn't need to import
* all of the dependencies used by `url-params.ts`
*/
export interface QueryParams {
// string, e.g. "sas" for Stretching and Shrinking or "msa" for Moving Straight Ahead
unit?: string;

//
// CMS options (admin.html)
//

// change the branch used in clue-curriculum repository default is author
curriculumBranch?: string;
// work with a local checkout of the curriculum instead of github
localCMSBackend?: boolean;
// change the location of the cms-editor.html used by iframe widget to edit
// CLUE documents.
cmsEditorBase?: string;
}

export const processUrlParams = (): QueryParams => {
const params = parse(location.search);
return {
...params,
// allows use of localCMSBackend without a value
localCMSBackend: (params.localCMSBackend !== undefined),
};
};

export const urlParams = processUrlParams();
4 changes: 2 additions & 2 deletions cms/src/iframe-control.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from "react";
import { Map } from "immutable";
import { CmsWidgetControlProps } from "netlify-cms-core";
import { CmsWidgetControlProps } from "decap-cms-core";

import { urlParams } from "../../src/utilities/url-params";
import { urlParams } from "./cms-url-params";
import { DEBUG_CMS } from "../../src/lib/debug";
import { defaultCurriculumBranch } from "./cms-constants";

Expand Down
6 changes: 3 additions & 3 deletions cms/src/init-cms.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(window as any).CMS_MANUAL_INIT = true;

import CMS from "netlify-cms-app";
import { CmsBackendType, CmsConfig } from "netlify-cms-core";
import CMS from "decap-cms-app";
import { CmsBackendType, CmsConfig } from "decap-cms-core";

import { urlParams } from "../../src/utilities/url-params";
import { urlParams } from "./cms-url-params";
import { IframeControl } from "./iframe-control";
import { JsonControl } from "./json-control";
import { PreviewLinkControl } from "./preview-link-control";
Expand Down
11 changes: 5 additions & 6 deletions cms/src/preview-link-control.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React from "react";
import { CmsWidgetControlProps } from "netlify-cms-core";
import { CmsWidgetControlProps } from "decap-cms-core";

import { getGuideJson, getUnitJson } from "../../src/models/curriculum/unit-utils";
import { DocumentModelType } from "../../src/models/document/document";
import { stripPTNumberFromBranch } from "../../src/utilities/branch-utils";
import { urlParams } from "../../src/utilities/url-params";
import { defaultCurriculumBranch } from "./cms-constants";
import { urlParams } from "./cms-url-params";
import { CurriculumConfig } from "../../src/models/stores/curriculum-config";
import { defaultCurriculumBranch } from "./cms-constants";

import curriculumConfigJson from "../../src/clue/curriculum-config.json";

Expand Down Expand Up @@ -54,9 +53,9 @@ export class PreviewLinkControl extends React.Component<CmsWidgetControlProps, I
// Finish setting up the preview link after reading the unit json
this.isTeacherGuide = this.pathParts?.[2] === "teacher-guide";
if (this.isTeacherGuide) {
getGuideJson(this.unit, curriculumConfig).then((unitJson: DocumentModelType) => this.setPreviewLink(unitJson));
getGuideJson(this.unit, curriculumConfig).then((unitJson) => this.setPreviewLink(unitJson));
} else {
getUnitJson(this.unit, curriculumConfig).then((unitJson: DocumentModelType) => this.setPreviewLink(unitJson));
getUnitJson(this.unit, curriculumConfig).then((unitJson) => this.setPreviewLink(unitJson));
}

this.state = {
Expand Down
5 changes: 5 additions & 0 deletions cms/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "../tsconfig.json",
"include": ["src/**/*"],
"exclude": ["**/node_modules", "**/.*/"]
}

0 comments on commit fd793f4

Please sign in to comment.