-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(programming): expose programming language dependencies
- Loading branch information
adi-herwana-nus
committed
Jan 21, 2025
1 parent
6a5144c
commit 71d3fce
Showing
13 changed files
with
257 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
.../course/assessment/question/programming/components/common/InstalledDependenciesPrompt.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Typography } from '@mui/material'; | ||
import { LanguageDependencyData } from 'types/course/assessment/question/programming'; | ||
|
||
import Prompt from 'lib/components/core/dialogs/Prompt'; | ||
import useTranslation from 'lib/hooks/useTranslation'; | ||
import formTranslations from 'lib/translations/form'; | ||
|
||
import InstalledDependenciesTable from './InstalledDependenciesTable'; | ||
|
||
interface InstalledDependenciesProps { | ||
disabled?: boolean; | ||
open: boolean; | ||
onClose: () => void; | ||
title: string; | ||
description: string; | ||
dependencies: LanguageDependencyData[]; | ||
} | ||
|
||
const InstalledDependenciesPrompt = ( | ||
props: InstalledDependenciesProps, | ||
): JSX.Element => { | ||
const { t } = useTranslation(); | ||
return ( | ||
<Prompt | ||
cancelColor="info" | ||
cancelLabel={t(formTranslations.close)} | ||
disabled={props.disabled} | ||
maxWidth="lg" | ||
onClose={props.onClose} | ||
open={props.open} | ||
title={props.title} | ||
> | ||
<Typography variant="body2"> {props.description} </Typography> | ||
|
||
<InstalledDependenciesTable | ||
className="mt-2" | ||
dependencies={props.dependencies} | ||
/> | ||
</Prompt> | ||
); | ||
}; | ||
|
||
export default InstalledDependenciesPrompt; |
72 changes: 72 additions & 0 deletions
72
...s/course/assessment/question/programming/components/common/InstalledDependenciesTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { LanguageDependencyData } from 'types/course/assessment/question/programming'; | ||
|
||
import translations from 'course/assessment/translations'; | ||
import Link from 'lib/components/core/Link'; | ||
import Table, { ColumnTemplate } from 'lib/components/table'; | ||
import useTranslation from 'lib/hooks/useTranslation'; | ||
import tableTranslations from 'lib/translations/table'; | ||
|
||
interface InstalledDependenciesTableProps { | ||
className?: string; | ||
dependencies: LanguageDependencyData[]; | ||
} | ||
|
||
const InstalledDependenciesTable = ( | ||
props: InstalledDependenciesTableProps, | ||
): JSX.Element => { | ||
const { dependencies } = props; | ||
const { t } = useTranslation(); | ||
|
||
const columns: ColumnTemplate<LanguageDependencyData>[] = [ | ||
{ | ||
of: 'name', | ||
title: t(tableTranslations.name), | ||
sortable: true, | ||
searchable: true, | ||
cell: (dependency: LanguageDependencyData): string | JSX.Element => { | ||
const title = dependency.title ?? dependency.name; | ||
if (dependency.href) { | ||
return ( | ||
<Link href={dependency.href} opensInNewTab underline="hover"> | ||
{title} | ||
</Link> | ||
); | ||
} | ||
return title; | ||
}, | ||
searchProps: { | ||
getValue: (datum: LanguageDependencyData): string => { | ||
const keywords = [datum.name]; | ||
if (datum.title) keywords.push(datum.title); | ||
if (datum.aliases) keywords.push(...datum.aliases); | ||
return keywords.join(', '); | ||
}, | ||
}, | ||
}, | ||
{ | ||
of: 'version', | ||
title: t(translations.dependencyVersionTableHeading), | ||
cell: (dependency) => dependency.version, | ||
}, | ||
]; | ||
|
||
return ( | ||
<Table | ||
className={props.className} | ||
columns={columns} | ||
data={dependencies} | ||
getRowId={(dependency): string => | ||
`${dependency.name} ${dependency.version}` | ||
} | ||
indexing={{ indices: false }} | ||
search={{ | ||
searchPlaceholder: t(translations.dependencySearchText), | ||
}} | ||
toolbar={{ | ||
show: true, | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default InstalledDependenciesTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
client/app/bundles/course/assessment/submission/components/SubmissionWorkflowState.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
client/app/lib/components/table/TanStackTableBuilder/csvGenerator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.