Skip to content
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

Remove non PUBLISHED comment stage restrictions #228

Merged
merged 1 commit into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions backend/python/app/services/implementations/comment_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ def create_comment(self, comment, user_id):
except Exception as error:
self.logger.error(str(error))
raise error

if (story_translation_stage == "TRANSLATE" and is_translator) or (
story_translation_stage == "REVIEW" and is_reviewer
):
if story_translation_stage == "PUBLISH" and (is_translator or is_reviewer):
raise Exception(
"Comments cannot be left after the story has been published."
)
elif is_translator or is_reviewer:
try:
new_comment.time = datetime.utcnow()
new_comment.resolved = False
Expand Down Expand Up @@ -85,18 +86,6 @@ def create_comment(self, comment, user_id):
)

return new_comment
elif story_translation_stage == "TRANSLATE" and is_reviewer:
raise Exception(
"Comments cannot be left by reviewers while the story is being translated."
)
elif story_translation_stage == "REVIEW" and is_translator:
raise Exception(
"Comments cannot be left by translators while the story is being reviewed."
)
elif story_translation_stage == "PUBLISH" and (is_translator or is_reviewer):
raise Exception(
"Comments cannot be left after the story has been published."
)
else:
raise Exception("You are not authorized to leave comments on this story.")

Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/pages/ReviewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,12 @@ const ReviewPage = () => {
</Flex>
</Flex>
<CommentsPanel
disabled={stage === "TRANSLATE"}
storyTranslationContentId={storyTranslationContentId}
commentLine={commentLine}
storyTranslationId={storyTranslationId}
setCommentLine={setCommentLine}
setTranslatedStoryLines={setTranslatedStoryLines}
translatedStoryLines={translatedStoryLines}
reviewPage
/>
{returnToTranslator && (
<ConfirmationModal
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/pages/TranslationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ const TranslationPage = () => {
</Flex>
{!isTest && (
<CommentsPanel
disabled={!editable}
storyTranslationContentId={storyTranslationContentId}
commentLine={commentLine}
storyTranslationId={storyTranslationId}
Expand Down
38 changes: 11 additions & 27 deletions frontend/src/components/review/CommentsPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
import React, { useState } from "react";
import { useQuery } from "@apollo/client";
import { Box, Button, Flex, Select, Text, Tooltip } from "@chakra-ui/react";
import { Box, Button, Flex, Select, Text } from "@chakra-ui/react";
import {
CommentResponse,
buildCommentsQuery,
} from "../../APIClients/queries/CommentQueries";
import WIPComment from "./WIPComment";
import { StoryLine } from "../translation/Autosave";
import {
TRANSLATION_PAGE_TOOL_TIP_COPY,
REVIEW_PAGE_TOOL_TIP_COPY,
} from "../../utils/Copy";
import ExistingComment from "./ExistingComment";

export type CommentPanelProps = {
storyTranslationId: number;
commentLine: number;
setCommentLine: (line: number) => void;
storyTranslationContentId: number;
disabled: boolean;
setTranslatedStoryLines: (storyLines: StoryLine[]) => void;
translatedStoryLines: StoryLine[];
reviewPage?: boolean;
};

const CommentsPanel = ({
storyTranslationId,
commentLine,
storyTranslationContentId,
setCommentLine,
disabled,
setTranslatedStoryLines,
translatedStoryLines,
reviewPage = false,
}: CommentPanelProps) => {
const [comments, setComments] = useState<CommentResponse[]>([]);
const [filterIndex, setFilterIndex] = useState(2);
Expand Down Expand Up @@ -103,10 +95,6 @@ const CommentsPanel = ({
else setCommentLine(-1);
};

const tooltipLabel = reviewPage
? REVIEW_PAGE_TOOL_TIP_COPY
: TRANSLATION_PAGE_TOOL_TIP_COPY;

return (
<Box
backgroundColor="gray.100"
Expand All @@ -116,27 +104,23 @@ const CommentsPanel = ({
width="450px"
>
<Flex marginBottom="50px">
<Tooltip hasArrow label={tooltipLabel} isDisabled={!disabled}>
<Box>
<Button
colorScheme="blue"
size="secondary"
marginRight="10px"
onClick={handleCommentButton}
disabled={disabled}
>
Comment
</Button>
</Box>
</Tooltip>
<Box>
<Button
colorScheme="blue"
size="secondary"
marginRight="10px"
onClick={handleCommentButton}
>
Comment
</Button>
</Box>
<Select
name="comment filter"
id="comment filter"
value={filterOptions[filterIndex]}
variant="commentsFilter"
onChange={handleCommentFilterSelectChange}
width="160px"
disabled={disabled}
>
{filterOptionsComponent}
</Select>
Expand Down