Skip to content

Commit

Permalink
Adjusting labels and icons for comment threads.
Browse files Browse the repository at this point in the history
  • Loading branch information
krulis-martin committed Jul 12, 2022
1 parent 469d0db commit 313ab64
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ class AssignmentsTable extends Component {
/>
</>
}
additionalPublicSwitchNote={
<FormattedMessage
id="app.assignments.discussionModal.additionalSwitchNote"
defaultMessage="(supervisors and students of this group)"
/>
}
inModal
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,15 @@ class ReferenceSolutionDetail extends Component {
download={download}
/>

<CommentThreadContainer threadId={id} />
<CommentThreadContainer
threadId={id}
additionalPublicSwitchNote={
<FormattedMessage
id="app.referenceSolutionDetail.comments.additionalSwitchNote"
defaultMessage="(teachers who can see this reference solution)"
/>
}
/>
</Col>

{evaluations && (
Expand Down
10 changes: 9 additions & 1 deletion src/components/Solutions/SolutionDetail/SolutionDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,15 @@ class SolutionDetail extends Component {
/>
)}

<CommentThreadContainer threadId={id} />
<CommentThreadContainer
threadId={id}
additionalPublicSwitchNote={
<FormattedMessage
id="app.solutionDetail.comments.additionalSwitchNote"
defaultMessage="(author of the solution and supervisors of this group)"
/>
}
/>
</Col>

{evaluations && (
Expand Down
4 changes: 2 additions & 2 deletions src/components/forms/EditAssignmentForm/EditAssignmentForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ class EditAssignmentForm extends Component {
<span>
<FormattedMessage
id="app.editExerciseForm.solutionFilesLimit"
defaultMessage="Soluition files limit:"
defaultMessage="Solution files limit:"
/>
<Explanation id="solutionFilesLimitExplanation">
<FormattedMessage
Expand All @@ -600,7 +600,7 @@ class EditAssignmentForm extends Component {
<span>
<FormattedMessage
id="app.editExerciseForm.solutionSizeLimit"
defaultMessage="Soluition total size [KiB] limit:"
defaultMessage="Solution total size [KiB] limit:"
/>
<Explanation id="solutionSizeLimitExplanation">
<FormattedMessage
Expand Down
4 changes: 2 additions & 2 deletions src/components/forms/EditExerciseForm/EditExerciseForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const EditExerciseForm = ({
nullable
label={
<span>
<FormattedMessage id="app.editExerciseForm.solutionFilesLimit" defaultMessage="Soluition files limit:" />
<FormattedMessage id="app.editExerciseForm.solutionFilesLimit" defaultMessage="Solution files limit:" />
<Explanation id="solutionFilesLimitExplanation">
<FormattedMessage
id="app.exercise.solutionFilesLimitExplanation"
Expand Down Expand Up @@ -134,7 +134,7 @@ const EditExerciseForm = ({
<span>
<FormattedMessage
id="app.editExerciseForm.solutionSizeLimit"
defaultMessage="Soluition total size [KiB] limit:"
defaultMessage="Solution total size [KiB] limit:"
/>
<Explanation id="solutionSizeLimitExplanation">
<FormattedMessage
Expand Down
39 changes: 20 additions & 19 deletions src/components/widgets/Comments/AddComment/AddComment.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class AddComment extends Component {
const { text, isPrivate } = this.state;
const {
addComment,
additionalPublicSwitchNote = null,
intl: { formatMessage },
} = this.props;

Expand Down Expand Up @@ -106,26 +107,25 @@ class AddComment extends Component {
disabled={!addComment}
noShadow
className="mr-2">
{isPrivate ? <Icon icon="lock" /> : <Icon icon="unlock-alt" />}
{isPrivate ? <Icon icon="eye-slash" /> : <Icon icon="eye" />}
</Button>
{isPrivate && (
<FormattedMessage
id="app.comments.warnings.isPrivate"
defaultMessage="<strong>Only you will see this comment.</strong>"
values={{
strong: text => <strong>{text}</strong>,
}}
/>
)}
{!isPrivate && (
<FormattedMessage
id="app.comments.warnings.isPublic"
defaultMessage="<strong>Everyone on this page will see this comment.</strong>"
values={{
strong: text => <strong>{text}</strong>,
}}
/>
)}

<strong>
{isPrivate && (
<FormattedMessage
id="app.comments.warnings.isPrivate"
defaultMessage="This will be a private comment visible only to you."
/>
)}
{!isPrivate && (
<FormattedMessage
id="app.comments.warnings.isPublic"
defaultMessage="This will be a public comment visible to everyone who can see this thread."
/>
)}
</strong>

{!isPrivate && additionalPublicSwitchNote && <> {additionalPublicSwitchNote}</>}
</Form.Text>
</FormGroup>
</Form>
Expand All @@ -135,6 +135,7 @@ class AddComment extends Component {

AddComment.propTypes = {
addComment: PropTypes.func,
additionalPublicSwitchNote: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
intl: PropTypes.object.isRequired,
};

Expand Down
24 changes: 16 additions & 8 deletions src/components/widgets/Comments/Comment/Comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const Comment = ({
isToggling = false,
togglePrivacy,
deleteComment,
additionalPublicSwitchNote = null,
links: { USER_URI_FACTORY },
}) => (
<div
Expand Down Expand Up @@ -63,7 +64,6 @@ const Comment = ({
gapLeft
className={classnames({ 'float-right': true, [styles.iconButton]: true, [styles.iconButtonDelete]: true })}
onClick={() => deleteComment(id)}
timid
/>
)}
{isFromCurrentUser && togglePrivacy && (
Expand All @@ -77,19 +77,26 @@ const Comment = ({
defaultMessage="Only you can see this comment"
/>
) : (
<FormattedMessage
id="app.comments.everyoneCanSeeThisComment"
defaultMessage="This comment is visible to everyone."
/>
<>
<FormattedMessage
id="app.comments.everyoneCanSeeThisComment"
defaultMessage="This comment is visible to everyone who can see this thread."
/>
{additionalPublicSwitchNote && <> {additionalPublicSwitchNote}</>}
</>
)}
</Tooltip>
}>
<Icon
icon={isToggling ? 'circle-notch' : isPrivate ? 'lock' : 'unlock-alt'}
icon={isToggling ? 'circle-notch' : isPrivate ? 'eye-slash' : 'eye'}
onClick={() => togglePrivacy(id)}
className={classnames({ 'float-right': true, [styles.iconButton]: true, [styles.iconButtonLock]: true })}
className={classnames({
'float-right': true,
[styles.iconButton]: true,
[styles.iconButtonLock]: !isPrivate,
[styles.iconButtonUnlock]: isPrivate,
})}
spin={isToggling}
timid
/>
</OverlayTrigger>
)}
Expand Down Expand Up @@ -122,6 +129,7 @@ Comment.propTypes = {
isToggling: PropTypes.bool,
togglePrivacy: PropTypes.func,
deleteComment: PropTypes.func,
additionalPublicSwitchNote: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
links: PropTypes.object,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { RefreshIcon } from '../../../icons';

const CommentThread = ({
title = <FormattedMessage id="app.comments.title" defaultMessage="Comments and Notes" />,
additionalPublicSwitchNote = null,
comments = [],
currentUserId,
addComment,
Expand All @@ -21,7 +22,9 @@ const CommentThread = ({
<CommentBox
title={title}
commentsCount={comments.length}
footer={addComment && <AddComment addComment={addComment} />}
footer={
addComment && <AddComment addComment={addComment} additionalPublicSwitchNote={additionalPublicSwitchNote} />
}
inModal={inModal}>
<div>
{comments.map((comment, i) =>
Expand All @@ -32,6 +35,7 @@ const CommentThread = ({
repost={repostComment}
togglePrivacy={togglePrivacy}
deleteComment={deleteComment}
additionalPublicSwitchNote={additionalPublicSwitchNote}
/>
) : (
<SomebodyElsesComment {...comment} key={comment.id} />
Expand Down Expand Up @@ -64,6 +68,7 @@ const CommentThread = ({

CommentThread.propTypes = {
title: PropTypes.oneOfType([PropTypes.element, PropTypes.string]),
additionalPublicSwitchNote: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
comments: PropTypes.array,
currentUserId: PropTypes.string.isRequired,
addComment: PropTypes.func,
Expand Down
4 changes: 4 additions & 0 deletions src/components/widgets/Comments/comments.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
color: #ff6;
}

.iconButtonUnlock {
color: #28a745;
}

.iconButtonDelete {
color: #f88;
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class CommentThreadContainer extends Component {
render() {
const {
title = <FormattedMessage id="app.comments.title" defaultMessage="Comments and Notes" />,
additionalPublicSwitchNote = null,
thread,
user,
addComment,
Expand All @@ -53,6 +54,7 @@ class CommentThreadContainer extends Component {
{(thread, user) => (
<CommentThread
title={title}
additionalPublicSwitchNote={additionalPublicSwitchNote}
comments={thread.comments.sort((a, b) => a.postedAt - b.postedAt)}
currentUserId={user.id}
addComment={(text, isPrivate) => addComment(user, text, isPrivate)}
Expand All @@ -71,6 +73,7 @@ class CommentThreadContainer extends Component {
CommentThreadContainer.propTypes = {
threadId: PropTypes.string.isRequired,
title: PropTypes.oneOfType([PropTypes.element, PropTypes.string]),
additionalPublicSwitchNote: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
inModal: PropTypes.bool,
thread: PropTypes.object,
user: PropTypes.object,
Expand Down
11 changes: 7 additions & 4 deletions src/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"app.assignmentStats.onlyBestSolutionsCheckbox": "Pouze nejlepší řešení",
"app.assignmentStats.title": "Všechna řešení zadané úlohy",
"app.assignments.deadline": "Termín odevzdání",
"app.assignments.discussionModal.additionalSwitchNote": "(vedoucí a studenti této skupiny)",
"app.assignments.discussionModalTitle": "Veřejná diskuse",
"app.assignments.group": "Zadáno ve skupině",
"app.assignments.hidePastAssignments": "Celkem {count} {count, plural, one {zadaná úloha má} =2 {zadané úlohy mají} =3 {zadané úlohy mají} =4 {zadané úlohy mají} other {zadaných úloh má}} termín v minulosti. <a>Skrýt staré úlohy.</a>",
Expand Down Expand Up @@ -198,15 +199,15 @@
"app.changePasswordForm.validation.passwordsDontMatch": "Hesla se neshodují.",
"app.comments.addComment": "Odeslat",
"app.comments.commentPlaceholder": "Váš komentář...",
"app.comments.everyoneCanSeeThisComment": "Tento komentář je veřejný.",
"app.comments.everyoneCanSeeThisComment": "Tento komentář vidí všichni uživatelé, kteří vidí toto vlákno.",
"app.comments.loadingCommentThread": "Načítají se komentáře...",
"app.comments.noCommentsYet": "V tomto vláknu zatím nejsou žádné komentáře.",
"app.comments.onlyYouCanSeeThisComment": "Pouze vy vidíte tento komentář.",
"app.comments.onlyYouCanSeeThisComment": "Tento komentář vidíte pouze vy.",
"app.comments.publishing": "Publikuji...",
"app.comments.publishingFailed": "Zveřejnění selhalo",
"app.comments.title": "Komentáře a poznámky",
"app.comments.warnings.isPrivate": "<strong>Tento komentář uvidíte pouze vy - nebude veřejný.</strong>",
"app.comments.warnings.isPublic": "<strong>Tento komentář bude veřejný.</strong>",
"app.comments.warnings.isPrivate": "Tento komentář bude soukromý, takže jej uvidíte pouze vy.",
"app.comments.warnings.isPublic": "Tento komentář bude veřejný, takže jej uvidí každý, kdo může číst toto vlákno.",
"app.confirm.no": "Ne",
"app.confirm.yes": "Ano",
"app.createExerciseForm.selectGroupFirst": "... nejprve vyberte domovskou skupinu ...",
Expand Down Expand Up @@ -1311,6 +1312,7 @@
"app.referenceSolution.exerciseBroken": "Úloha je rozbitá, a proto není v tuto chvíli možné nechat toto vzorové řešení znovu vyhodnotit.",
"app.referenceSolution.exerciseNoLongerHasEnvironment": "Úloha již nepodporuje běhové prostředí, pod kterým bylo toto řešení odevzdáno. Řešení není možné znovu vyhodnotit.",
"app.referenceSolution.title": "Podrobnosti referenčního řešení",
"app.referenceSolutionDetail.comments.additionalSwitchNote": "(učitelé, kteří smí vidět toto referenční řešení)",
"app.referenceSolutionDetail.exercise": "Úloha",
"app.referenceSolutionDetail.title.details": "Detail referenčního řešení",
"app.referenceSolutionTable.evaluationFailed": "Poslední vyhodnocení selhalo",
Expand Down Expand Up @@ -1572,6 +1574,7 @@
"app.solution.submittedBeforeSecondDeadline": "Řešení bylo odevzdáno po prvním termínu, ale stále ještě před druhým termínem",
"app.solution.title": "Řešení",
"app.solutionArchiveInfoBox.description": "Všechny soubory v ZIPu",
"app.solutionDetail.comments.additionalSwitchNote": "(autor tohoto řešení a vedoucí této skupiny)",
"app.solutionFiles.countLimitExceeded": "Celkový počet souborů řešení překročil výchozí limit ({limit}).",
"app.solutionFiles.downloadButton": "Stáhnout soubor",
"app.solutionFiles.entryPoint": "Vstupní bod (zaváděcí soubor aplikace)",
Expand Down
13 changes: 8 additions & 5 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"app.assignmentStats.onlyBestSolutionsCheckbox": "Best solutions only",
"app.assignmentStats.title": "All Submissions of The Assignment",
"app.assignments.deadline": "Deadline",
"app.assignments.discussionModal.additionalSwitchNote": "(supervisors and students of this group)",
"app.assignments.discussionModalTitle": "Public Discussion",
"app.assignments.group": "Assigned in group",
"app.assignments.hidePastAssignments": "Total {count} {count, plural, one {assignment} other {assignments}} {count, plural, one {is past its} other {are past their}} deadline. <a>Hide old assignments.</a>",
Expand Down Expand Up @@ -198,15 +199,15 @@
"app.changePasswordForm.validation.passwordsDontMatch": "Passwords do not match.",
"app.comments.addComment": "Send",
"app.comments.commentPlaceholder": "Your comment...",
"app.comments.everyoneCanSeeThisComment": "This comment is visible to everyone.",
"app.comments.everyoneCanSeeThisComment": "This comment is visible to everyone who can see this thread.",
"app.comments.loadingCommentThread": "Loading comments...",
"app.comments.noCommentsYet": "There are no comments in this thread yet.",
"app.comments.onlyYouCanSeeThisComment": "Only you can see this comment",
"app.comments.publishing": "Publishing...",
"app.comments.publishingFailed": "Publishing Failed",
"app.comments.title": "Comments and Notes",
"app.comments.warnings.isPrivate": "<strong>Only you will see this comment.</strong>",
"app.comments.warnings.isPublic": "<strong>Everyone on this page will see this comment.</strong>",
"app.comments.warnings.isPrivate": "This will be a private comment visible only to you.",
"app.comments.warnings.isPublic": "This will be a public comment visible to everyone who can see this thread.",
"app.confirm.no": "No",
"app.confirm.yes": "Yes",
"app.createExerciseForm.selectGroupFirst": "... select group of residence first ...",
Expand Down Expand Up @@ -383,8 +384,8 @@
"app.editExerciseForm.isPublic": "Exercise is public",
"app.editExerciseForm.medium": "Medium",
"app.editExerciseForm.mergeJudgeLogs": "Merge judge logs in one",
"app.editExerciseForm.solutionFilesLimit": "Soluition files limit:",
"app.editExerciseForm.solutionSizeLimit": "Soluition total size [KiB] limit:",
"app.editExerciseForm.solutionFilesLimit": "Solution files limit:",
"app.editExerciseForm.solutionSizeLimit": "Solution total size [KiB] limit:",
"app.editExerciseForm.title": "Edit exercise {name}",
"app.editExerciseForm.validation.difficulty": "Please select the difficulty of the exercise.",
"app.editExerciseForm.validation.emptyName": "Please fill the name of the exercise.",
Expand Down Expand Up @@ -1311,6 +1312,7 @@
"app.referenceSolution.exerciseBroken": "The exercise is broken. This reference solution may not be resubmitted at the moment.",
"app.referenceSolution.exerciseNoLongerHasEnvironment": "The exercise no longer supports the environment for which this solution was evaluated. Resubmission is not possible.",
"app.referenceSolution.title": "Reference Solution Detail",
"app.referenceSolutionDetail.comments.additionalSwitchNote": "(teachers who can see this reference solution)",
"app.referenceSolutionDetail.exercise": "Exercise",
"app.referenceSolutionDetail.title.details": "Reference Solution Detail",
"app.referenceSolutionTable.evaluationFailed": "Last evaluation failed",
Expand Down Expand Up @@ -1572,6 +1574,7 @@
"app.solution.submittedBeforeSecondDeadline": "The solution was submitted after the first but still before the second deadline",
"app.solution.title": "The Solution",
"app.solutionArchiveInfoBox.description": "All files in a ZIP archive",
"app.solutionDetail.comments.additionalSwitchNote": "(author of the solution and supervisors of this group)",
"app.solutionFiles.countLimitExceeded": "The total number of submitted files exceeds the default solution files limit ({limit}).",
"app.solutionFiles.downloadButton": "Download file",
"app.solutionFiles.entryPoint": "Execution entry point (bootstrap)",
Expand Down
6 changes: 6 additions & 0 deletions src/pages/Assignment/Assignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ class Assignment extends Component {
defaultMessage="Public Discussion"
/>
}
additionalPublicSwitchNote={
<FormattedMessage
id="app.assignments.discussionModal.additionalSwitchNote"
defaultMessage="(supervisors and students of this group)"
/>
}
/>
</Col>
</Row>
Expand Down
6 changes: 6 additions & 0 deletions src/pages/AssignmentStats/AssignmentStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,12 @@ class AssignmentStats extends Component {
: <LocalizedExerciseName entity={{ name: '??', localizedTexts: assignment.localizedTexts }} />
</>
}
additionalPublicSwitchNote={
<FormattedMessage
id="app.assignments.discussionModal.additionalSwitchNote"
defaultMessage="(supervisors and students of this group)"
/>
}
inModal
/>
</Modal>
Expand Down

0 comments on commit 313ab64

Please sign in to comment.