Skip to content

Commit 128a34a

Browse files
Merge branch 'folders-public-wip' of github.com:source-academy/frontend into folders-public-wip
2 parents 740d14e + c4b1277 commit 128a34a

File tree

71 files changed

+4098
-3084
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+4098
-3084
lines changed

craco.config.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// eslint-disable-next-line @typescript-eslint/no-var-requires
1+
/* eslint-disable @typescript-eslint/no-var-requires */
22
const webpack = require('webpack');
33

4-
const cracoConfig = (module.exports = {
4+
const cracoConfig = {
55
webpack: {
66
configure: webpackConfig => {
77
// avoid the entire process.env being inserted into the service worker
@@ -62,11 +62,16 @@ const cracoConfig = (module.exports = {
6262
},
6363
});
6464

65-
// Ignore warnings for dependencies that do not ship with a source map.
66-
// This is because we cannot do anything about our dependencies.
67-
webpackConfig.ignoreWarnings = [{
65+
webpackConfig.ignoreWarnings = [{
66+
// Ignore warnings for dependencies that do not ship with a source map.
67+
// This is because we cannot do anything about our dependencies.
6868
module: /node_modules/,
6969
message: /Failed to parse source map/
70+
}, {
71+
// Ignore the warnings that occur because js-slang uses dynamic imports
72+
// to load Source modules
73+
module: /js-slang\/dist\/modules\/loader\/loaders.js/,
74+
message: /Critical dependency: the request of a dependency is an expression/
7075
}];
7176

7277
webpackConfig.plugins = [
@@ -78,7 +83,7 @@ const cracoConfig = (module.exports = {
7883
// Make the 'buffer' Node.js module available in the browser.
7984
new webpack.ProvidePlugin({
8085
Buffer: ['buffer', 'Buffer'],
81-
})
86+
}),
8287
];
8388

8489
// Workaround to suppress warnings caused by ts-morph in js-slang
@@ -153,7 +158,7 @@ const cracoConfig = (module.exports = {
153158
['@babel/preset-typescript']
154159
]
155160
}
156-
});
161+
}
157162

158163
const ignoreModulePaths = (...paths) => {
159164
const moduleRoot = replaceSlashes('/node_modules/');
@@ -166,3 +171,5 @@ const ignoreModulePaths = (...paths) => {
166171
const replaceSlashes = target => {
167172
return target.replaceAll('/', '[/\\\\]');
168173
};
174+
175+
module.exports = cracoConfig

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
"@blueprintjs/icons": "^5.5.0",
3232
"@blueprintjs/popover2": "^2.0.0",
3333
"@blueprintjs/select": "^5.0.0",
34+
"@mantine/hooks": "^7.7.0",
3435
"@octokit/rest": "^20.0.0",
3536
"@reduxjs/toolkit": "^1.9.7",
3637
"@sentry/browser": "^7.57.0",
37-
"@sourceacademy/c-slang": "^1.0.18",
38+
"@sourceacademy/c-slang": "^1.0.19",
3839
"@sourceacademy/sharedb-ace": "^2.0.2",
3940
"@sourceacademy/sling-client": "^0.1.0",
4041
"@szhsin/react-menu": "^4.0.0",
@@ -51,7 +52,8 @@
5152
"flexboxgrid-helpers": "^1.1.3",
5253
"google-oauth-gsi": "^4.0.0",
5354
"hastscript": "^9.0.0",
54-
"js-slang": "^1.0.52",
55+
"java-slang": "^1.0.6",
56+
"js-slang": "^1.0.66",
5557
"js-yaml": "^4.1.0",
5658
"konva": "^9.2.0",
5759
"lodash": "^4.17.21",
@@ -92,10 +94,9 @@
9294
"rehype-react": "^8.0.0",
9395
"showdown": "^2.1.0",
9496
"sourceror": "^0.8.5",
95-
"typesafe-actions": "^5.1.0",
9697
"unified": "^11.0.0",
9798
"uuid": "^9.0.0",
98-
"xlsx": "0.18.5",
99+
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz",
99100
"xml2js": "^0.6.0",
100101
"yareco": "^0.1.5"
101102
},

src/commons/application/ApplicationTypes.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,15 @@ export enum SupportedLanguage {
122122
JAVASCRIPT = 'JavaScript',
123123
SCHEME = 'Scheme',
124124
PYTHON = 'Python',
125+
JAVA = 'Java',
125126
C = 'C'
126127
}
127128

128129
export const SUPPORTED_LANGUAGES = [
129130
SupportedLanguage.JAVASCRIPT,
130131
SupportedLanguage.SCHEME,
131132
SupportedLanguage.PYTHON,
133+
SupportedLanguage.JAVA,
132134
SupportedLanguage.C
133135
];
134136

@@ -211,6 +213,15 @@ export const pyLanguages: SALanguage[] = pySubLanguages.map(sublang => {
211213
return { ...sublang, mainLanguage: SupportedLanguage.PYTHON, supports: { repl: true } };
212214
});
213215

216+
export const javaLanguages: SALanguage[] = [
217+
{
218+
chapter: Chapter.FULL_JAVA,
219+
variant: Variant.DEFAULT,
220+
displayName: 'Java',
221+
mainLanguage: SupportedLanguage.JAVA,
222+
supports: {}
223+
}
224+
];
214225
export const cLanguages: SALanguage[] = [
215226
{
216227
chapter: Chapter.FULL_C,
@@ -290,6 +301,7 @@ export const ALL_LANGUAGES: readonly SALanguage[] = [
290301
htmlLanguage,
291302
...schemeLanguages,
292303
...pyLanguages,
304+
...javaLanguages,
293305
...cLanguages
294306
];
295307
// TODO: Remove this function once logic has been fully migrated

src/commons/assessment/AssessmentTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export type AssessmentOverview = {
6464
isPublished?: boolean;
6565
hasVotingFeatures: boolean;
6666
hasTokenCounter?: boolean;
67+
isVotingPublished?: boolean;
6768
maxXp: number;
6869
earlySubmissionXp: number;
6970
number?: string; // For mission control

src/commons/assessmentWorkspace/__tests__/__snapshots__/AssessmentWorkspace.tsx.snap

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,34 @@ exports[`AssessmentWorkspace AssessmentWorkspace page with ContestVoting questio
333333
<div
334334
class="right-parent"
335335
>
336+
<span
337+
class="fullscreen-button bp5-popover-target"
338+
>
339+
<button
340+
aria-expanded="false"
341+
class="bp5-button bp5-minimal"
342+
tabindex="0"
343+
type="button"
344+
>
345+
<span
346+
aria-hidden="true"
347+
class="bp5-icon bp5-icon-maximize"
348+
>
349+
<svg
350+
data-icon="maximize"
351+
height="16"
352+
role="img"
353+
viewBox="0 0 16 16"
354+
width="16"
355+
>
356+
<path
357+
d="M5.99 8.99c-.28 0-.53.11-.71.29l-3.29 3.29v-1.59c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H3.41L6.7 10.7a1.003 1.003 0 00-.71-1.71zm9-9h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.59l-3.3 3.3a.99.99 0 00-.29.7 1.003 1.003 0 001.71.71l3.29-3.29V5c0 .55.45 1 1 1s1-.45 1-1V1c0-.56-.45-1.01-1-1.01z"
358+
fill-rule="evenodd"
359+
/>
360+
</svg>
361+
</span>
362+
</button>
363+
</span>
336364
<div
337365
class="resize-side-content"
338366
style="position: relative; user-select: auto; width: auto; height: auto; box-sizing: border-box; flex-shrink: 0;"
@@ -1583,6 +1611,34 @@ exports[`AssessmentWorkspace AssessmentWorkspace page with MCQ question renders
15831611
<div
15841612
class="right-parent"
15851613
>
1614+
<span
1615+
class="fullscreen-button bp5-popover-target"
1616+
>
1617+
<button
1618+
aria-expanded="false"
1619+
class="bp5-button bp5-minimal"
1620+
tabindex="0"
1621+
type="button"
1622+
>
1623+
<span
1624+
aria-hidden="true"
1625+
class="bp5-icon bp5-icon-maximize"
1626+
>
1627+
<svg
1628+
data-icon="maximize"
1629+
height="16"
1630+
role="img"
1631+
viewBox="0 0 16 16"
1632+
width="16"
1633+
>
1634+
<path
1635+
d="M5.99 8.99c-.28 0-.53.11-.71.29l-3.29 3.29v-1.59c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H3.41L6.7 10.7a1.003 1.003 0 00-.71-1.71zm9-9h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.59l-3.3 3.3a.99.99 0 00-.29.7 1.003 1.003 0 001.71.71l3.29-3.29V5c0 .55.45 1 1 1s1-.45 1-1V1c0-.56-.45-1.01-1-1.01z"
1636+
fill-rule="evenodd"
1637+
/>
1638+
</svg>
1639+
</span>
1640+
</button>
1641+
</span>
15861642
<div
15871643
class="resize-side-content"
15881644
style="position: relative; user-select: auto; width: auto; height: auto; box-sizing: border-box; flex-shrink: 0;"
@@ -2363,6 +2419,34 @@ exports[`AssessmentWorkspace AssessmentWorkspace page with overdue assessment re
23632419
<div
23642420
class="right-parent"
23652421
>
2422+
<span
2423+
class="fullscreen-button bp5-popover-target"
2424+
>
2425+
<button
2426+
aria-expanded="false"
2427+
class="bp5-button bp5-minimal"
2428+
tabindex="0"
2429+
type="button"
2430+
>
2431+
<span
2432+
aria-hidden="true"
2433+
class="bp5-icon bp5-icon-maximize"
2434+
>
2435+
<svg
2436+
data-icon="maximize"
2437+
height="16"
2438+
role="img"
2439+
viewBox="0 0 16 16"
2440+
width="16"
2441+
>
2442+
<path
2443+
d="M5.99 8.99c-.28 0-.53.11-.71.29l-3.29 3.29v-1.59c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H3.41L6.7 10.7a1.003 1.003 0 00-.71-1.71zm9-9h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.59l-3.3 3.3a.99.99 0 00-.29.7 1.003 1.003 0 001.71.71l3.29-3.29V5c0 .55.45 1 1 1s1-.45 1-1V1c0-.56-.45-1.01-1-1.01z"
2444+
fill-rule="evenodd"
2445+
/>
2446+
</svg>
2447+
</span>
2448+
</button>
2449+
</span>
23662450
<div
23672451
class="resize-side-content"
23682452
style="position: relative; user-select: auto; width: auto; height: auto; box-sizing: border-box; flex-shrink: 0;"
@@ -3137,6 +3221,22 @@ exports[`AssessmentWorkspace AssessmentWorkspace page with programming question
31373221
<div
31383222
class="right-parent"
31393223
>
3224+
<span
3225+
class="fullscreen-button bp5-popover-target"
3226+
>
3227+
<button
3228+
aria-expanded="false"
3229+
class="bp5-button bp5-minimal"
3230+
tabindex="0"
3231+
type="button"
3232+
>
3233+
<span
3234+
aria-hidden="true"
3235+
class="bp5-icon bp5-icon-standard bp5-icon-maximize"
3236+
data-icon="maximize"
3237+
/>
3238+
</button>
3239+
</span>
31403240
<div
31413241
class="resize-side-content"
31423242
style="position: relative; user-select: auto; width: auto; height: auto; box-sizing: border-box; flex-shrink: 0;"
@@ -3863,6 +3963,34 @@ exports[`AssessmentWorkspace AssessmentWorkspace renders Grading tab correctly i
38633963
<div
38643964
class="right-parent"
38653965
>
3966+
<span
3967+
class="fullscreen-button bp5-popover-target"
3968+
>
3969+
<button
3970+
aria-expanded="false"
3971+
class="bp5-button bp5-minimal"
3972+
tabindex="0"
3973+
type="button"
3974+
>
3975+
<span
3976+
aria-hidden="true"
3977+
class="bp5-icon bp5-icon-maximize"
3978+
>
3979+
<svg
3980+
data-icon="maximize"
3981+
height="16"
3982+
role="img"
3983+
viewBox="0 0 16 16"
3984+
width="16"
3985+
>
3986+
<path
3987+
d="M5.99 8.99c-.28 0-.53.11-.71.29l-3.29 3.29v-1.59c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H3.41L6.7 10.7a1.003 1.003 0 00-.71-1.71zm9-9h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.59l-3.3 3.3a.99.99 0 00-.29.7 1.003 1.003 0 001.71.71l3.29-3.29V5c0 .55.45 1 1 1s1-.45 1-1V1c0-.56-.45-1.01-1-1.01z"
3988+
fill-rule="evenodd"
3989+
/>
3990+
</svg>
3991+
</span>
3992+
</button>
3993+
</span>
38663994
<div
38673995
class="resize-side-content"
38683996
style="position: relative; user-select: auto; width: auto; height: auto; box-sizing: border-box; flex-shrink: 0;"

src/commons/controlBar/ControlBarGoogleDriveButtons.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type Props = {
1717
isFolderModeEnabled: boolean;
1818
loggedInAs?: string;
1919
accessToken?: string;
20-
currentObject?: PersistenceFile;
20+
currPersistenceFile?: PersistenceFile;
2121
isDirty?: boolean;
2222
onClickOpen?: () => any;
2323
onClickSave?: () => any;
@@ -30,14 +30,14 @@ type Props = {
3030

3131
export const ControlBarGoogleDriveButtons: React.FC<Props> = props => {
3232
const { isMobileBreakpoint } = useResponsive();
33-
const state: PersistenceState = props.currentObject
33+
const state: PersistenceState = props.currPersistenceFile
3434
? props.isDirty
3535
? 'DIRTY'
3636
: 'SAVED'
3737
: 'INACTIVE';
3838
const mainButton = (
3939
<ControlButton
40-
label={(props.currentObject && props.currentObject.name) || 'Google Drive'}
40+
label={(props.currPersistenceFile && props.currPersistenceFile.name) || 'Google Drive'}
4141
icon={IconNames.CLOUD}
4242
options={{ intent: stateToIntent[state] }}
4343
//isDisabled={props.isFolderModeEnabled}

src/commons/controlBar/github/ControlBarGitHubButtons.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import { useResponsive } from 'src/commons/utils/Hooks';
77

88
import { GitHubSaveInfo } from '../../../features/github/GitHubTypes';
99
import ControlButton from '../../ControlButton';
10+
import { PersistenceFile } from 'src/features/persistence/PersistenceTypes';
1011

1112
type Props = {
1213
isFolderModeEnabled: boolean;
14+
currPersistenceFile?: PersistenceFile;
1315
loggedInAs?: Octokit;
1416
githubSaveInfo: GitHubSaveInfo;
1517
isDirty: boolean;
@@ -31,14 +33,13 @@ export const ControlBarGitHubButtons: React.FC<Props> = props => {
3133
const { isMobileBreakpoint } = useResponsive();
3234

3335
const filePath = props.githubSaveInfo.filePath || '';
34-
const fileName = (filePath.split('\\').pop() || '').split('/').pop() || '';
3536

3637
const isLoggedIn = props.loggedInAs !== undefined;
3738
const shouldDisableButtons = !isLoggedIn;
3839
const hasFilePath = filePath !== '';
3940
const hasOpenFile = isLoggedIn && hasFilePath;
4041

41-
const mainButtonDisplayText = hasOpenFile ? fileName : 'GitHub';
42+
const mainButtonDisplayText = (props.currPersistenceFile && props.currPersistenceFile.name) || 'GitHub';
4243
let mainButtonIntent: Intent = Intent.NONE;
4344
if (hasOpenFile) {
4445
mainButtonIntent = props.isDirty ? Intent.WARNING : Intent.PRIMARY;

src/commons/editor/Editor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,8 @@ const EditorBase = React.memo((props: EditorProps & LocalStateProps) => {
435435
session.on('changeAnnotation' as any, makeHandleAnnotationChange(session));
436436

437437
// Start autocompletion
438-
if (props.sourceChapter === Chapter.FULL_C) {
439-
// for C language, use the default autocomplete provided by ace editor
438+
if (props.sourceChapter === Chapter.FULL_C || props.sourceChapter === Chapter.FULL_JAVA) {
439+
// for C, Java language, use the default autocomplete provided by ace editor
440440
const { textCompleter, keyWordCompleter, setCompleters } = acequire('ace/ext/language_tools');
441441
setCompleters([textCompleter, keyWordCompleter]);
442442
} else {

0 commit comments

Comments
 (0)