-
Notifications
You must be signed in to change notification settings - Fork 168
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
Assessments & Grading Workspace: Add folders mode #2765
base: master
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 7817133053
💛 - Coveralls |
Is this PR ready or still in draft state? |
It is PR ready. The draft means we plan to expand on it. |
Update: Sorry, it is not PR ready yet. |
…end into read-only-workspace
@accountexeregister what is the status of this PR? |
Sorry prof, I just saw this message. We will still have to work on the backend before integrating it fully. |
…nto read-only-workspace
…nto read-only-workspace
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.
Hi, thanks for working on this, I did a quick run through and have the following comments, thanks!
/** | ||
* @prop fileMode an integer for the mode of the file where | ||
* 0 = read-only and 1 = read-write. | ||
*/ | ||
type ControlBarFileModeButtonProps = { | ||
fileMode: number | null; | ||
}; |
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.
Why are we using an integer when we can use an enum?
export const ControlBarFileModeButton: React.FC<ControlBarFileModeButtonProps> = ({ fileMode }) => { | ||
if (fileMode === 0) { | ||
return <ControlButton label={'Read-Only'} icon={IconNames.LOCK} isDisabled />; | ||
} | ||
return <ControlButton label={'Read-Write'} icon={IconNames.UNLOCK} isDisabled />; | ||
}; |
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.
If the button is always disabled, is a button the most appropriate?
|
||
/* | ||
? props.readOnly | ||
? 'Evaluation is disabled in read-only mode' | ||
: '...or press shift-enter in the editor' | ||
: 'Open a file to evaluate the program with the file as the entrypoint'; | ||
*/ |
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.
Is this still needed? If not, please remove the commented code.
isSupportedSource: boolean; | ||
toggleFolderMode: () => void; | ||
}; | ||
|
||
export const ControlBarToggleFolderModeButton: React.FC<Props> = ({ | ||
isFolderModeEnabled, | ||
isSessionActive, | ||
isPersistenceActive, | ||
isSupportedSource, | ||
toggleFolderMode | ||
}) => { | ||
const tooltipContent = isSessionActive | ||
? 'Currently unsupported while a collaborative session is active' | ||
: isPersistenceActive | ||
? 'Currently unsupported while a persistence method is active' | ||
: !isSupportedSource | ||
? 'Folder mode is not available for this version of Source' | ||
: `${isFolderModeEnabled ? 'Disable' : 'Enable'} Folder mode`; | ||
return ( | ||
<Tooltip content={tooltipContent}> |
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.
I'd argue that if the language does not support it, the button should just be hidden (not disabled), like on the Playground.
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.
What do you think?
@@ -24,6 +25,10 @@ const EditorTab: React.FC<Props> = ({ filePath, isActive, setActive, remove }) = | |||
})} | |||
onClick={setActive} | |||
> | |||
{' '} |
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.
Is this space intentional?
: editorTab | ||
); | ||
|
||
if (isEqual(editorTabs, newEditorTabs)) { |
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.
Equality does not work properly with drafts. See https://immerjs.github.io/immer/pitfalls/#drafts-arent-referentially-equal
return { | ||
...state, | ||
[workspaceLocation]: { | ||
...state[workspaceLocation], | ||
editorTabs: newEditorTabs | ||
} | ||
}; |
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.
Try to use mutation instead of returning a new object.
); | ||
|
||
if (isEqual(editorTabs, newEditorTabs)) { | ||
return state; |
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.
Instead of doing this very expensive computation, just read the old state (O(1) time), and read its readOnly
old value (also O(1) time). Then compare it with the payload. If they are equal, return the old state. If they are not equal, compute the new state and return it.
QuestionTypes, | ||
Testcase | ||
} from '../assessment/AssessmentTypes'; | ||
import { ControlBarProps } from '../controlBar/ControlBar'; | ||
import { ControlBarChapterSelect } from '../controlBar/ControlBarChapterSelect'; | ||
import { ControlBarClearButton } from '../controlBar/ControlBarClearButton'; | ||
import { ControlBarEvalButton } from '../controlBar/ControlBarEvalButton'; | ||
// import { ControlBarFileModeButton } from '../controlBar/ControlBarFileModeButton'; |
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.
Commented code should be removed in unused.
}, []); | ||
setIsEditable(false); | ||
dispatch(updateTabReadOnly(workspaceLocation, activeEditorTabIndex, true)); | ||
}, [activeEditorTabIndex, editorTabs, questionId]); |
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.
Please fix the lint warnings.
…nto read-only-workspace
Description
To be merged with Grader #319 and Backend #1110
Type of change
Note: This PR might break "Teams" functionality. The
shouldDisableSaveButton()
function on line805
insrc\commons\assessmentWorkspace\AssessmentWorkspace.tsx
causes the save button to always be disabled in Assessments. Hence we had to comment it out.How to test
Checklist