Skip to content

Commit 8065e81

Browse files
rajat1saxenaRajat
andauthored
Small feature requests, enhancements and bug fixes (#750)
* open content by default * bugfix: Left alignment on mobile for FAQ block * wider community post popup for better reading * invalidate domain cache on theme switch * Better error handling when media operations fail while updating page * bug fix: lists don't render in text block of email editor * Code injection blocks can be completely reset * Preview is disabled for Quiz lessons * Page model repo made private * workflow script upgrade to remove NPM token * bugfix: Left alignment on mobile for Content page block * changeset for email-editor * Added migration for disabling preview of quizzes * Re-worked social image management --------- Co-authored-by: Rajat <hi@rajatsaxena.dev>
1 parent ef0c85b commit 8065e81

File tree

27 files changed

+411
-182
lines changed

27 files changed

+411
-182
lines changed

.changeset/config.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
"@courselit/common-logic",
2121
"@courselit/page-primitives",
2222
"@courselit/common-models",
23-
"@courselit/docs"
23+
"@courselit/docs",
24+
"@courselit/orm-models",
25+
"@courselit/page-models",
26+
"@courselit/scripts"
2427
]
2528
}

.changeset/empty-rockets-allow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@courselit/email-editor": patch
3+
---
4+
5+
Bug fix: Lists don't render

.github/workflows/publish-packages.yaml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ env:
1515
jobs:
1616
publish-packages:
1717
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
id-token: write
21+
pull-requests: write
1822
steps:
1923
- name: checkout
20-
uses: actions/checkout@v1
24+
uses: actions/checkout@v4
2125

2226
- name: Configure CI Git User
2327
run: |
2428
git config --global user.name 'Rajat Saxena'
2529
git config --global user.email 'hi@sub.rajatsaxena.dev'
26-
git remote set-url origin https://$GITHUB_ACTOR:$GITHUB_PAT@github.com/codelitdev/courselit
30+
git remote set-url origin https://x-access-token:${{ secrets.PAT }}@github.com/${{ github.repository }}
2731
env:
2832
GITHUB_PAT: ${{ secrets.PAT }}
2933

@@ -33,20 +37,13 @@ jobs:
3337
git pull origin ${{ github.ref_name }}
3438
3539
- name: Setup pnpm
36-
uses: pnpm/action-setup@v2
40+
uses: pnpm/action-setup@v4
3741
with:
38-
version: 8
42+
version: latest
3943

4044
- name: Install Packages
4145
run: pnpm install
4246

43-
- name: Authenticate with Registry
44-
run: |
45-
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
46-
pnpm whoami
47-
env:
48-
NPM_TOKEN: ${{ secrets.NPM }}
49-
5047
- name: Create and publish versions
5148
id: changesets
5249
uses: changesets/action@v1
@@ -56,7 +53,6 @@ jobs:
5653
publish: pnpm ci:publish
5754
env:
5855
GITHUB_TOKEN: ${{ secrets.PAT }}
59-
NPM_TOKEN: ${{ secrets.NPM }}
6056

6157
- name: Echo changeset output
6258
run: echo "${{ steps.changesets.outputs.hasChangesets }}"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Sets `requiresEnrollment` to true for all quiz lessons.
3+
*
4+
* Usage:
5+
* DB_CONNECTION_STRING=<mongodb-connection-string> node 28-03-26_00-00-set-quiz-requires-enrollment.js
6+
*/
7+
import mongoose from "mongoose";
8+
9+
const DB_CONNECTION_STRING = process.env.DB_CONNECTION_STRING;
10+
11+
if (!DB_CONNECTION_STRING) {
12+
throw new Error("DB_CONNECTION_STRING is not set");
13+
}
14+
15+
(async () => {
16+
try {
17+
await mongoose.connect(DB_CONNECTION_STRING);
18+
19+
const db = mongoose.connection.db;
20+
if (!db) {
21+
throw new Error("Could not connect to database");
22+
}
23+
24+
const result = await db.collection("lessons").updateMany(
25+
{ type: "quiz" },
26+
{
27+
$set: {
28+
requiresEnrollment: true,
29+
},
30+
},
31+
);
32+
33+
console.log(
34+
`✅ Updated quiz lessons. Matched: ${result.matchedCount}, Modified: ${result.modifiedCount}`,
35+
);
36+
} finally {
37+
await mongoose.connection.close();
38+
}
39+
})();

apps/web/app/(with-contexts)/dashboard/(sidebar)/product/[id]/content/section/[section]/lesson/page.tsx

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -604,32 +604,34 @@ export default function LessonPage() {
604604
/>
605605
</>
606606
)}
607-
{product?.type?.toLowerCase() !==
608-
UIConstants.COURSE_TYPE_DOWNLOAD && (
609-
<div className="flex items-center justify-between">
610-
<div className="space-y-0.5">
611-
<Label
612-
htmlFor="preview"
613-
className="font-semibold"
614-
>
615-
{LESSON_PREVIEW}
616-
</Label>
617-
<p className="text-sm text-muted-foreground">
618-
Allow students to preview this
619-
lesson without enrolling
620-
</p>
607+
{product?.type?.toLowerCase() ===
608+
Constants.CourseType.COURSE &&
609+
lesson.type !== Constants.LessonType.QUIZ && (
610+
<div className="flex items-center justify-between">
611+
<div className="space-y-0.5">
612+
<Label
613+
htmlFor="preview"
614+
className="font-semibold"
615+
>
616+
{LESSON_PREVIEW}
617+
</Label>
618+
<p className="text-sm text-muted-foreground">
619+
Allow students to preview this
620+
lesson without enrolling
621+
</p>
622+
</div>
623+
<Switch
624+
id="preview"
625+
checked={!lesson.requiresEnrollment}
626+
onCheckedChange={(checked) =>
627+
updateLesson({
628+
requiresEnrollment:
629+
!checked,
630+
})
631+
}
632+
/>
621633
</div>
622-
<Switch
623-
id="preview"
624-
checked={!lesson.requiresEnrollment}
625-
onCheckedChange={(checked) =>
626-
updateLesson({
627-
requiresEnrollment: !checked,
628-
})
629-
}
630-
/>
631-
</div>
632-
)}
634+
)}
633635
<div className="flex items-center justify-between">
634636
<div className="space-y-0.5">
635637
<Label

apps/web/components/admin/blogs/new-blog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default function NewBlog() {
8181
>
8282
{BTN_CONTINUE}
8383
</Button>
84-
<Link href={`/dashboard/blogs`} legacyBehavior>
84+
<Link href="/dashboard/blogs">
8585
<Button variant="soft">{BUTTON_CANCEL_TEXT}</Button>
8686
</Link>
8787
</div>

apps/web/components/admin/page-editor/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default function PageEditor({
9090
Page & {
9191
draftTitle?: string;
9292
draftDescription?: string;
93-
draftSocialImage?: Media;
93+
draftSocialImage?: Media | null;
9494
draftRobotsAllowed?: boolean;
9595
}
9696
>
@@ -595,7 +595,9 @@ export default function PageEditor({
595595
: true
596596
}
597597
socialImage={
598-
page.draftSocialImage ?? page.socialImage ?? null
598+
page.draftSocialImage !== undefined
599+
? page.draftSocialImage
600+
: (page.socialImage ?? null)
599601
}
600602
onClose={(e) => setLeftPaneContent("none")}
601603
onSave={({

apps/web/components/admin/settings/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,10 @@ const Settings = (props: SettingsProps) => {
365365
) => {
366366
event.preventDefault();
367367

368-
if (!newSettings.codeInjectionHead && !newSettings.codeInjectionBody) {
368+
if (
369+
newSettings.codeInjectionHead === settings.codeInjectionHead &&
370+
newSettings.codeInjectionBody === settings.codeInjectionBody
371+
) {
369372
return;
370373
}
371374

apps/web/components/community/comment-section.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ export default function CommentSection({
594594

595595
return (
596596
<div className="flex flex-col gap-4">
597-
<div className="space-y-4 max-h-[300px] overflow-y-auto">
597+
<div className="space-y-4 overflow-y-auto">
598598
{comments.map((comment) => (
599599
<Comment
600600
communityId={communityId}

apps/web/components/community/create-post-dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ export default function CreatePostDialog({
336336
</div>
337337
</DialogTrigger>
338338
))}
339-
<DialogContent className="sm:max-w-[90vw] md:max-w-[600px] w-full overflow-y-auto max-h-[calc(100vh-4rem)] my-8">
339+
<DialogContent className="sm:max-w-4xl w-full overflow-y-auto max-h-[90vh] my-8">
340340
<DialogHeader>
341341
<DialogTitle>
342342
<div className="flex items-center gap-2 mb-4">

0 commit comments

Comments
 (0)