-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/source-academy/cadet-fron…
…tend into P2Fancy
- Loading branch information
Showing
99 changed files
with
8,573 additions
and
416 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ terraform* | |
.env.test.local | ||
.env.production.local | ||
.idea/ | ||
.vscode/ | ||
cadet-frontend.iml | ||
|
||
npm-debug.log* | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { IconNames } from '@blueprintjs/icons'; | ||
|
||
import controlButton from '../ControlButton'; | ||
|
||
type ControlBarCloseButtonProps = OwnProps; | ||
|
||
type OwnProps = { | ||
key: string; | ||
handleClose: () => void; | ||
}; | ||
|
||
export function ControlBarCloseButton(props: ControlBarCloseButtonProps) { | ||
return controlButton('Close', IconNames.CROSS, props.handleClose); | ||
} |
15 changes: 15 additions & 0 deletions
15
src/commons/controlBar/ControlBarShowDependenciesButton.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,15 @@ | ||
import { IconNames } from '@blueprintjs/icons'; | ||
|
||
import controlButton from '../ControlButton'; | ||
|
||
type ControlBarShowDependenciesButtonProps = OwnProps; | ||
|
||
type OwnProps = { | ||
key: string; | ||
buttonText: string; | ||
handleShowDependencies: () => void; | ||
}; | ||
|
||
export function ControlBarShowDependenciesButton(props: ControlBarShowDependenciesButtonProps) { | ||
return controlButton(props.buttonText, IconNames.CODE, props.handleShowDependencies); | ||
} |
22 changes: 22 additions & 0 deletions
22
src/commons/controlBar/github/ControlBarDisplayMCQButton.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,22 @@ | ||
import { IconNames } from '@blueprintjs/icons'; | ||
|
||
import controlButton from '../../ControlButton'; | ||
|
||
type ControlBarDisplayMCQButtonProps = DispatchProps & StateProps; | ||
|
||
type DispatchProps = { | ||
displayMCQInEditor: () => void; | ||
displayTextInEditor: () => void; | ||
}; | ||
|
||
type StateProps = { | ||
mcqDisplayed: boolean; | ||
key: string; | ||
}; | ||
|
||
export const ControlBarDisplayMCQButton: React.FC<ControlBarDisplayMCQButtonProps> = props => { | ||
const label = props.mcqDisplayed ? 'Show MCQ Text' : 'Hide MCQ Text'; | ||
const behaviour = props.mcqDisplayed ? props.displayTextInEditor : props.displayMCQInEditor; | ||
|
||
return controlButton(label, IconNames.REFRESH, behaviour); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { IconNames } from '@blueprintjs/icons'; | ||
|
||
import controlButton from '../../ControlButton'; | ||
import { maximumTasksPerMission } from '../../githubAssessments/GitHubMissionDataUtils'; | ||
import { showWarningMessage } from '../../utils/NotificationsHelper'; | ||
|
||
export type ControlBarTaskAddButtonProps = { | ||
addNewQuestion: () => void; | ||
numberOfTasks: number; | ||
key: string; | ||
}; | ||
|
||
export const ControlBarTaskAddButton: React.FC<ControlBarTaskAddButtonProps> = props => { | ||
function onClickAdd() { | ||
if (props.numberOfTasks === maximumTasksPerMission) { | ||
showWarningMessage( | ||
'Cannot have more than ' + maximumTasksPerMission + ' Tasks in a Mission!' | ||
); | ||
return; | ||
} | ||
|
||
props.addNewQuestion(); | ||
} | ||
|
||
return controlButton('Add Task', IconNames.ADD, onClickAdd); | ||
}; |
39 changes: 39 additions & 0 deletions
39
src/commons/controlBar/github/ControlBarTaskDeleteButton.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,39 @@ | ||
import { IconNames } from '@blueprintjs/icons'; | ||
|
||
import controlButton from '../../ControlButton'; | ||
import { showSimpleConfirmDialog } from '../../utils/DialogHelper'; | ||
import { showWarningMessage } from '../../utils/NotificationsHelper'; | ||
|
||
export type ControlBarTaskDeleteButtonProps = { | ||
deleteCurrentQuestion: () => void; | ||
numberOfTasks: number; | ||
key: string; | ||
}; | ||
|
||
export const ControlBarTaskDeleteButton: React.FC<ControlBarTaskDeleteButtonProps> = props => { | ||
async function onClickDelete() { | ||
if (props.numberOfTasks <= 1) { | ||
showWarningMessage('Cannot delete the only remaining task!'); | ||
return; | ||
} | ||
|
||
const confirmDelete = await showSimpleConfirmDialog({ | ||
contents: ( | ||
<div> | ||
<p>Warning: you are about to delete a task.</p> | ||
<p>This action cannot be undone.</p> | ||
<p>Please click 'Confirm' to continue, or 'Cancel' to go back.</p> | ||
</div> | ||
), | ||
negativeLabel: 'Cancel', | ||
positiveIntent: 'primary', | ||
positiveLabel: 'Confirm' | ||
}); | ||
|
||
if (confirmDelete) { | ||
props.deleteCurrentQuestion(); | ||
} | ||
} | ||
|
||
return controlButton('Delete Current Task', IconNames.DELETE, onClickDelete); | ||
}; |
76 changes: 76 additions & 0 deletions
76
src/commons/githubAssessments/GitHubMissionCreateDialog.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,76 @@ | ||
import { AnchorButton, Button, Classes, Dialog, InputGroup, Intent } from '@blueprintjs/core'; | ||
import classNames from 'classnames'; | ||
import React, { useState } from 'react'; | ||
|
||
import { showWarningMessage } from '../utils/NotificationsHelper'; | ||
|
||
export type GitHubMissionCreateDialogResolution = { | ||
confirmSave: boolean; | ||
repoName: string; | ||
}; | ||
|
||
export type GitHubMissionCreateDialogProps = { | ||
filesToCreate: string[]; | ||
userLogin: string; | ||
resolveDialog: (arg: GitHubMissionCreateDialogResolution) => void; | ||
}; | ||
|
||
export const GitHubMissionCreateDialog: React.FC<GitHubMissionCreateDialogProps> = props => { | ||
const [repositoryName, setrepositoryName] = useState('sa-new-mission-repository'); | ||
|
||
return ( | ||
<Dialog className="missionBrowser" isOpen={true}> | ||
<div className={classNames('githubDialogHeader', Classes.DIALOG_HEADER)}> | ||
<h3>Please confirm your save</h3> | ||
</div> | ||
<div className={classNames('githubDialogBody', Classes.DIALOG_BODY)}> | ||
<div> | ||
<h4>This will create a repository owned by {props.userLogin} with the title:</h4> | ||
<InputGroup | ||
onChange={handleTitleChange} | ||
placeholder={'Enter Repository Title'} | ||
value={repositoryName} | ||
/> | ||
</div> | ||
<div> | ||
<h4>This repository will be created with following files:</h4> | ||
{props.filesToCreate.map(filepath => ( | ||
<li key={filepath}>{filepath}</li> | ||
))} | ||
</div> | ||
</div> | ||
|
||
<div className={classNames(Classes.DIALOG_FOOTER)}> | ||
<div className={classNames(Classes.DIALOG_FOOTER_ACTIONS)}> | ||
<Button onClick={handleClose}>Close</Button> | ||
<AnchorButton onClick={handleConfirm} intent={Intent.PRIMARY}> | ||
Confirm | ||
</AnchorButton> | ||
</div> | ||
</div> | ||
</Dialog> | ||
); | ||
|
||
function handleTitleChange(event: any) { | ||
setrepositoryName(event.target.value); | ||
} | ||
|
||
function handleClose() { | ||
props.resolveDialog({ | ||
confirmSave: false, | ||
repoName: '' | ||
}); | ||
} | ||
|
||
function handleConfirm() { | ||
if (repositoryName === '') { | ||
showWarningMessage('Cannot create repository without title!', 2000); | ||
return; | ||
} | ||
|
||
props.resolveDialog({ | ||
confirmSave: true, | ||
repoName: repositoryName | ||
}); | ||
} | ||
}; |
Oops, something went wrong.