-
Notifications
You must be signed in to change notification settings - Fork 0
Feat: Introduce content display to practice #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: canary
Are you sure you want to change the base?
Changes from all commits
19d77f3
b8e45ee
ea18cc8
d4e3df6
54c9de9
2b33167
d96ff4d
4a3d5ed
1b4d162
ff90fc8
601b3da
66b7468
58d59f9
63da904
97676fa
4b36885
ea02cfe
9a3c110
4b5e470
3dd0674
eccc8a3
347b178
7a39842
cd68b4a
1ac22cb
4490572
6a3899f
4d76e01
4efdeb8
08b9173
47ced7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| #!/usr/bin/env sh | ||
| . "$(dirname -- "$0")/_/husky.sh" | ||
|
|
||
| yarn sync-translations | ||
| git add src/i18n/locales/*.ts | ||
| npx lint-staged --allow-empty | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import Link from 'next/link' | ||
| import { notFound } from 'next/navigation' | ||
| import { getCourseById } from '@/database/course/select' | ||
| import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from '@/src/components/shadcn/breadcrumb' | ||
|
|
||
| export default async function EditLayout({ children, params }: { children: React.ReactNode; params: Promise<{ id: string }> }) { | ||
| const { id } = await params | ||
| const course = await getCourseById(id) | ||
|
|
||
| if (!course) notFound() | ||
|
|
||
| return ( | ||
| <> | ||
| <Breadcrumb> | ||
| <BreadcrumbList> | ||
| <BreadcrumbLink asChild> | ||
| <Link href={`/`}>Home</Link> | ||
| </BreadcrumbLink> | ||
| <BreadcrumbSeparator /> | ||
|
|
||
| <BreadcrumbItem> | ||
| <BreadcrumbLink asChild> | ||
| <Link href={`/courses`}>Courses</Link> | ||
| </BreadcrumbLink> | ||
| </BreadcrumbItem> | ||
| <BreadcrumbSeparator /> | ||
| <BreadcrumbItem>Edit</BreadcrumbItem> | ||
|
|
||
| <BreadcrumbSeparator /> | ||
| <BreadcrumbPage>{course.name}</BreadcrumbPage> | ||
| </BreadcrumbList> | ||
| </Breadcrumb> | ||
| {children} | ||
| </> | ||
| ) | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,11 +5,13 @@ import Link from 'next/link' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { usePathname } from 'next/navigation' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Fragment } from 'react/jsx-runtime' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from '@/src/components/shadcn/breadcrumb' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useCurrentLocale } from '@/src/i18n/client-localization' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useCurrentLocale, useScopedI18n } from '@/src/i18n/client-localization' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { cn } from '@/src/lib/Shared/utils' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Any } from '@/types' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export function GenericBreadcrumb({ show = true }: { show?: boolean }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [breadcrumbExists, setBreadcrumbExists] = useState(false) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const t = useScopedI18n('Shared.Breadcrumbs') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const locale = useCurrentLocale() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const pathname = usePathname() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const pages = pathname.split('?').at(0)!.split('/')! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -34,20 +36,20 @@ export function GenericBreadcrumb({ show = true }: { show?: boolean }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <BreadcrumbItem> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <BreadcrumbLink asChild> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Link href={'/'} className='capitalize'> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {t('root')} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Link> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </BreadcrumbLink> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </BreadcrumbItem> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {pages?.map((p, i) => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Fragment key={p + i}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {pages?.map((segment, i) => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Fragment key={segment + i}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <BreadcrumbSeparator /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <BreadcrumbItem className='capitalize'> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {isCurrentPage(i) ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <BreadcrumbPage>{p}</BreadcrumbPage> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <BreadcrumbPage>{t(segment as Any)}</BreadcrumbPage> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) : ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <BreadcrumbLink asChild> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Link href={'/' + pages.slice(0, i + 1).join('/')}>{p}</Link> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Link href={'/' + pages.slice(0, i + 1).join('/')}>{t(segment as Any)}</Link> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </BreadcrumbLink> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+44
to
53
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n src/components/Shared/Breadcrumb/GenericBreadcrumb.tsxRepository: Master-Thesis-188199/KnowledgeCheckr Length of output: 2679 🏁 Script executed: # Search for i18n configuration files
find . -type f \( -name "i18n*" -o -name "*i18n*" -o -name "*.config*" -o -name "next-i18next*" \) 2>/dev/null | head -20Repository: Master-Thesis-188199/KnowledgeCheckr Length of output: 837 🏁 Script executed: # Look for the i18n setup or locale files
fd -type f -name "*.json" | xargs grep -l "courses\|discover\|practice" 2>/dev/null | head -10Repository: Master-Thesis-188199/KnowledgeCheckr Length of output: 250 🏁 Script executed: # Check for i18n usage patterns in the project
rg "useTranslation|t\(" src/ -A 2 -B 2 --max-count=5Repository: Master-Thesis-188199/KnowledgeCheckr Length of output: 50393 🏁 Script executed: cat -n src/i18n/i18nConfig.tsRepository: Master-Thesis-188199/KnowledgeCheckr Length of output: 557 🏁 Script executed: # Find breadcrumb translation files
find . -path ./node_modules -prune -o -type f \( -name "*.json" -o -name "*.ts" -o -name "*.js" \) -print | xargs grep -l "Shared.Breadcrumbs\|Breadcrumbs" 2>/dev/null | head -20Repository: Master-Thesis-188199/KnowledgeCheckr Length of output: 183 🏁 Script executed: # Check client-localization implementation
cat -n src/i18n/client-localization.ts | head -100Repository: Master-Thesis-188199/KnowledgeCheckr Length of output: 617 🏁 Script executed: # Look for translation file directories
find . -path ./node_modules -prune -o -type d -name "locales" -o -name "translations" -o -name "messages" -print 2>/dev/nullRepository: Master-Thesis-188199/KnowledgeCheckr Length of output: 62 🏁 Script executed: cat -n src/i18n/locales/en.json | grep -A 50 "Breadcrumb\|breadcrumb" -iRepository: Master-Thesis-188199/KnowledgeCheckr Length of output: 2172 🏁 Script executed: # Check en.ts file for breadcrumb translations
cat -n src/i18n/locales/en.ts | head -200Repository: Master-Thesis-188199/KnowledgeCheckr Length of output: 9166 🏁 Script executed: # Look for the actual structure of breadcrumb keys
rg "Shared.*Breadcrumb" src/i18n/locales/ -A 5 -B 5Repository: Master-Thesis-188199/KnowledgeCheckr Length of output: 62 🏁 Script executed: # Search for usages of GenericBreadcrumb to see what paths contain
rg "GenericBreadcrumb|breadcrumb" src/ -A 3 -B 3 --type tsx --type ts | head -100Repository: Master-Thesis-188199/KnowledgeCheckr Length of output: 107 🏁 Script executed: # Look for usages of breadcrumb and what paths might contain
rg "GenericBreadcrumb" src/ -lRepository: Master-Thesis-188199/KnowledgeCheckr Length of output: 209 🏁 Script executed: # Check what pages might have IDs or slugs in their breadcrumbs
rg "courses/\|practice/\|edit/" src/app src/components --type ts --type js -A 2 -B 2 | head -80Repository: Master-Thesis-188199/KnowledgeCheckr Length of output: 62 🏁 Script executed: # Look at next-international behavior for missing keys
rg "next-international\|useScopedI18n" src/ -A 3 -B 1 | head -150Repository: Master-Thesis-188199/KnowledgeCheckr Length of output: 62 🏁 Script executed: # Search for examples of dynamic segments in breadcrumbs (like IDs, slugs)
find src/app -type f -name "page.tsx" -o -name "layout.tsx" | xargs grep -l "courses\|practice" 2>/dev/null | head -10Repository: Master-Thesis-188199/KnowledgeCheckr Length of output: 581 🏁 Script executed: # Check the actual routes to understand what segments appear
cat -n src/app/[locale]/courses/edit/[id]/page.tsx | head -30Repository: Master-Thesis-188199/KnowledgeCheckr Length of output: 981 🏁 Script executed: # Check one of the share_token pages
cat -n src/app/[locale]/courses/[share_token]/page.tsx | head -30Repository: Master-Thesis-188199/KnowledgeCheckr Length of output: 1981 🏁 Script executed: # Look at how next-international handles missing keys - check documentation or implementation
find . -path ./node_modules/next-international -prune -o -type f -name "*.ts" -o -name "*.js" | xargs grep -l "missing.*key\|defaultValue" 2>/dev/null | grep -v node_modules | head -5Repository: Master-Thesis-188199/KnowledgeCheckr Length of output: 328 🏁 Script executed: # Check if there's a fallback mechanism or if missing keys are logged
rg "defaultValue\|fallback\|missing" src/i18n/ -A 2 -B 2Repository: Master-Thesis-188199/KnowledgeCheckr Length of output: 62 🏁 Script executed: # Look for how next-international handles missing translation keys
rg "key" node_modules/next-international -A 2 -B 2 --max-count=3 2>/dev/null | head -40Repository: Master-Thesis-188199/KnowledgeCheckr Length of output: 12198 🏁 Script executed: # Search for any custom i18n setup or handling
find src/i18n -type f -name "*.ts" -o -name "*.js" | xargs cat -n 2>/dev/nullRepository: Master-Thesis-188199/KnowledgeCheckr Length of output: 50392 🏁 Script executed: # Check if there are any error boundaries or fallback handlers for translations
rg "Breadcrumb\|translation\|fallback" src/components/Shared/Breadcrumb/ -A 5 -B 5Repository: Master-Thesis-188199/KnowledgeCheckr Length of output: 62 🏁 Script executed: # Look at actual test or usage to see what happens with dynamic segments
rg "GenericBreadcrumb" src/ -A 10 -B 5Repository: Master-Thesis-188199/KnowledgeCheckr Length of output: 5052 Translate only known breadcrumb segments; fall back to decoded segment text for dynamic values. On lines 49 and 52, all path segments are unconditionally translated via Maintain a set of known static breadcrumb keys and fall back to 💡 Proposed fix- {pages?.map((segment, i) => (
+ {pages?.map((segment, i) => (
<Fragment key={segment + i}>
<BreadcrumbSeparator />
<BreadcrumbItem className='capitalize'>
+ {/** translate only known breadcrumb keys */}
+ {(() => {
+ const knownKeys = new Set([
+ 'courses',
+ 'discover',
+ 'practice',
+ 'edit',
+ 'create',
+ 'account',
+ 'start',
+ 'results',
+ 'contents',
+ 'not-allowed',
+ 'attempt-limit',
+ 'attempt-not-possible',
+ ])
+ const label = knownKeys.has(segment) ? t(segment as Any) : decodeURIComponent(segment)
+
+ return isCurrentPage(i) ? (
+ <BreadcrumbPage>{label}</BreadcrumbPage>
+ ) : (
+ <BreadcrumbLink asChild>
+ <Link href={'/' + pages.slice(0, i + 1).join('/')}>{label}</Link>
+ </BreadcrumbLink>
+ )
+ })()}
- {isCurrentPage(i) ? (
- <BreadcrumbPage>{t(segment as Any)}</BreadcrumbPage>
- ) : (
- <BreadcrumbLink asChild>
- <Link href={'/' + pages.slice(0, i + 1).join('/')}>{t(segment as Any)}</Link>
- </BreadcrumbLink>
- )}
</BreadcrumbItem>
</Fragment>
))}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </BreadcrumbItem> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,7 +165,11 @@ export default function CourseActionMenu({ id, questions, share_key, owner_id, c | |
| {t('clone_course.label')} | ||
| <CopyPlusIcon className='size-4 text-neutral-600 group-data-disabled:text-inherit dark:text-neutral-400 dark:group-data-disabled:text-inherit' /> | ||
| </DropdownMenuItem> | ||
| <DropdownMenuItem disabled>{t('inspect_statistics.label')}</DropdownMenuItem> | ||
| <DropdownMenuItem> | ||
| <Link href={`/checks/${share_key}/results`} className='flex flex-1 justify-between'> | ||
| {t('inspect_statistics.label')} | ||
|
Comment on lines
+168
to
+170
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard nullable On Line 169, 💡 Proposed fix- <DropdownMenuItem>
- <Link href={`/checks/${share_key}/results`} className='flex flex-1 justify-between'>
- {t('inspect_statistics.label')}
- </Link>
- </DropdownMenuItem>
+ <DropdownMenuItem
+ disabled={share_key === null}
+ enableTooltip={share_key === null}
+ tooltipOptions={{ ...baseTooltipOptions, content: t('remove_share_token.tooltip') }}
+ onClick={() => {
+ if (!share_key) return
+ router.push(`/checks/${share_key}/results`)
+ }}>
+ {t('inspect_statistics.label')}
+ </DropdownMenuItem>🤖 Prompt for AI Agents |
||
| </Link> | ||
| </DropdownMenuItem> | ||
| </DropdownMenuGroup> | ||
| <DropdownMenuSeparator /> | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing
*.jsonfiles in git add pattern.The
sync-translationsscript can modify both.tsand.jsonfiles when base keys are missing (the 'update-both' mode inprepare-i18n_ally-locales.ts). The currentgit addonly stages*.tsfiles, leaving modified.jsonfiles unstaged.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents