Skip to content

Commit

Permalink
Merge pull request #1285 from AletheiaFact/enable-reviewers-to-update…
Browse files Browse the repository at this point in the history
…-report-and-display-previews

Enable reviewers to update report and display previews
  • Loading branch information
thesocialdev authored Jul 30, 2024
2 parents d1f9883 + 8367e53 commit 5b55e2c
Show file tree
Hide file tree
Showing 39 changed files with 775 additions and 354 deletions.
4 changes: 3 additions & 1 deletion public/locales/en/claimReviewForm.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@
"groupLabel": "Group verification requests",
"groupPlaceholder": "Select verification requests",
"isSensitiveLabel": "Sensitve content",
"isSensitive": "This verification request contains sensitve content"
"isSensitive": "This verification request contains sensitve content",
"viewPreview": "View preview",
"hidePreview": "Hide preview"
}
4 changes: 3 additions & 1 deletion public/locales/pt/claimReviewForm.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@
"groupLabel": "Agrupar denúncias",
"groupPlaceholder": "Selecione denúncias",
"isSensitiveLabel": "Conteúdo confidencial",
"isSensitive": "Esta denúncia contém conteúdo confidencial"
"isSensitive": "Esta denúncia contém conteúdo confidencial",
"viewPreview": "Visualizar pré-visualização",
"hidePreview": "Ocultar pré-visualização"
}
30 changes: 30 additions & 0 deletions server/claim/claim.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ export class ClaimController {
this.featureFlagService.isEnableEditorAnnotations();
const enableAddEditorSourcesWithoutSelecting =
this.featureFlagService.isEnableAddEditorSourcesWithoutSelecting();
const enableReviewersUpdateReport =
this.featureFlagService.isEnableReviewersUpdateReport();
const enableViewReportPreview =
this.featureFlagService.isEnableViewReportPreview();

hideDescriptions[TargetModel.Claim] =
await this.historyService.getDescriptionForHide(
Expand Down Expand Up @@ -390,6 +394,8 @@ export class ClaimController {
enableEditorAnnotations,
enableCopilotChatBot,
enableAddEditorSourcesWithoutSelecting,
enableReviewersUpdateReport,
enableViewReportPreview,
websocketUrl: this.configService.get<string>("websocketUrl"),
nameSpace: req.params.namespace,
})
Expand Down Expand Up @@ -579,6 +585,10 @@ export class ClaimController {
this.featureFlagService.isEnableEditorAnnotations();
const enableAddEditorSourcesWithoutSelecting =
this.featureFlagService.isEnableAddEditorSourcesWithoutSelecting();
const enableReviewersUpdateReport =
this.featureFlagService.isEnableReviewersUpdateReport();
const enableViewReportPreview =
this.featureFlagService.isEnableViewReportPreview();

this.redirectBasedOnPersonality(res, claim, namespace);

Expand All @@ -593,6 +603,8 @@ export class ClaimController {
enableEditorAnnotations,
enableCopilotChatBot,
enableAddEditorSourcesWithoutSelecting,
enableReviewersUpdateReport,
enableViewReportPreview,
websocketUrl: this.configService.get<string>("websocketUrl"),
nameSpace: namespace,
})
Expand All @@ -616,6 +628,10 @@ export class ClaimController {
this.featureFlagService.isEnableEditorAnnotations();
const enableAddEditorSourcesWithoutSelecting =
this.featureFlagService.isEnableAddEditorSourcesWithoutSelecting();
const enableReviewersUpdateReport =
this.featureFlagService.isEnableReviewersUpdateReport();
const enableViewReportPreview =
this.featureFlagService.isEnableViewReportPreview();

const claim = await this.claimService.getByClaimSlug(
claimSlug,
Expand All @@ -633,6 +649,8 @@ export class ClaimController {
enableEditorAnnotations,
enableCopilotChatBot: enableCopilotChatBot,
enableAddEditorSourcesWithoutSelecting,
enableReviewersUpdateReport,
enableViewReportPreview,
websocketUrl: this.configService.get<string>("websocketUrl"),
nameSpace: namespace,
})
Expand All @@ -659,6 +677,10 @@ export class ClaimController {
this.featureFlagService.isEnableEditorAnnotations();
const enableAddEditorSourcesWithoutSelecting =
this.featureFlagService.isEnableAddEditorSourcesWithoutSelecting();
const enableReviewersUpdateReport =
this.featureFlagService.isEnableReviewersUpdateReport();
const enableViewReportPreview =
this.featureFlagService.isEnableViewReportPreview();

const personality =
await this.personalityService.getClaimsByPersonalitySlug(
Expand Down Expand Up @@ -692,6 +714,8 @@ export class ClaimController {
enableEditorAnnotations,
enableCopilotChatBot,
enableAddEditorSourcesWithoutSelecting,
enableReviewersUpdateReport,
enableViewReportPreview,
websocketUrl: this.configService.get<string>("websocketUrl"),
hideDescriptions,
nameSpace: namespace,
Expand Down Expand Up @@ -725,6 +749,10 @@ export class ClaimController {
this.featureFlagService.isEnableEditorAnnotations();
const enableAddEditorSourcesWithoutSelecting =
this.featureFlagService.isEnableAddEditorSourcesWithoutSelecting();
const enableReviewersUpdateReport =
this.featureFlagService.isEnableReviewersUpdateReport();
const enableViewReportPreview =
this.featureFlagService.isEnableViewReportPreview();

const claim = await this.claimService.getByPersonalityIdAndClaimSlug(
personality._id,
Expand All @@ -743,6 +771,8 @@ export class ClaimController {
enableEditorAnnotations,
enableCopilotChatBot: enableCopilotChatBot,
enableAddEditorSourcesWithoutSelecting,
enableReviewersUpdateReport,
enableViewReportPreview,
websocketUrl: this.configService.get<string>("websocketUrl"),
nameSpace: namespace,
})
Expand Down
16 changes: 16 additions & 0 deletions server/feature-flag/feature-flag.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,20 @@ export class FeatureFlagService {
)
: false;
}

isEnableReviewersUpdateReport() {
const config = this.configService.get<string>("feature_flag");

return config
? this.unleash.isEnabled("enable_reviewers_update_report")
: false;
}

isEnableViewReportPreview() {
const config = this.configService.get<string>("feature_flag");

return config
? this.unleash.isEnabled("enable_view_report_preview")
: false;
}
}
6 changes: 6 additions & 0 deletions server/review-task/review-task.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ export class ReviewTaskController {
this.featureFlagService.isEnableEditorAnnotations();
const enableAddEditorSourcesWithoutSelecting =
this.featureFlagService.isEnableAddEditorSourcesWithoutSelecting();
const enableReviewersUpdateReport =
this.featureFlagService.isEnableReviewersUpdateReport();
const enableViewReportPreview =
this.featureFlagService.isEnableViewReportPreview();

await this.viewService.getNextServer().render(
req,
Expand All @@ -182,6 +186,8 @@ export class ReviewTaskController {
enableEditorAnnotations,
enableCopilotChatBot,
enableAddEditorSourcesWithoutSelecting,
enableReviewersUpdateReport,
enableViewReportPreview,
websocketUrl: this.configService.get<string>("websocketUrl"),
nameSpace: req.params.namespace,
})
Expand Down
53 changes: 15 additions & 38 deletions server/source/source.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { TargetModel } from "../history/schema/history.schema";
import { HistoryService } from "../history/history.service";
import { ReviewTaskService } from "../review-task/review-task.service";
import { ClaimReviewService } from "../claim-review/claim-review.service";
import { FeatureFlagService } from "../feature-flag/feature-flag.service";

@Controller(":namespace?")
export class SourceController {
Expand All @@ -38,6 +39,7 @@ export class SourceController {
private claimReviewService: ClaimReviewService,
private reviewTaskService: ReviewTaskService,
private historyService: HistoryService,
private featureFlagService: FeatureFlagService,
@Optional() private readonly unleash: UnleashService
) {}

Expand Down Expand Up @@ -163,12 +165,18 @@ export class SourceController {
source.data_hash
);

const enableCollaborativeEditor = this.isEnableCollaborativeEditor();
const enableCopilotChatBot = this.isEnableCopilotChatBot();
const enableEditorAnnotations = this.isEnableEditorAnnotations();
const enableCollaborativeEditor =
this.featureFlagService.isEnableCollaborativeEditor();
const enableCopilotChatBot =
this.featureFlagService.isEnableCopilotChatBot();
const enableEditorAnnotations =
this.featureFlagService.isEnableEditorAnnotations();
const enableAddEditorSourcesWithoutSelecting =
this.isEnableAddEditorSourcesWithoutSelecting();

this.featureFlagService.isEnableAddEditorSourcesWithoutSelecting();
const enableReviewersUpdateReport =
this.featureFlagService.isEnableReviewersUpdateReport();
const enableViewReportPreview =
this.featureFlagService.isEnableViewReportPreview();
const hideDescriptions = {};

hideDescriptions[TargetModel.Source] =
Expand Down Expand Up @@ -199,42 +207,11 @@ export class SourceController {
enableEditorAnnotations,
enableCopilotChatBot,
enableAddEditorSourcesWithoutSelecting,
enableReviewersUpdateReport,
enableViewReportPreview,
websocketUrl: this.configService.get<string>("websocketUrl"),
nameSpace: req.params.namespace,
})
);
}

//TODO: Create service to get feature flags config
private isEnableCollaborativeEditor() {
const config = this.configService.get<string>("feature_flag");

return config
? this.unleash.isEnabled("enable_collaborative_editor")
: false;
}

private isEnableCopilotChatBot() {
const config = this.configService.get<string>("feature_flag");

return config ? this.unleash.isEnabled("copilot_chat_bot") : false;
}

private isEnableEditorAnnotations() {
const config = this.configService.get<string>("feature_flag");

return config
? this.unleash.isEnabled("enable_editor_annotations")
: false;
}

private isEnableAddEditorSourcesWithoutSelecting() {
const config = this.configService.get<string>("feature_flag");

return config
? this.unleash.isEnabled(
"enable_add_editor_sources_without_selecting"
)
: false;
}
}
2 changes: 2 additions & 0 deletions server/source/source.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { CaptchaModule } from "../captcha/captcha.module";
import { HistoryModule } from "../history/history.module";
import { ClaimReviewModule } from "../claim-review/claim-review.module";
import { ReviewTaskModule } from "../review-task/review-task.module";
import { FeatureFlagModule } from "../feature-flag/feature-flag.module";

const SourceModel = MongooseModule.forFeature([
{
Expand All @@ -26,6 +27,7 @@ const SourceModel = MongooseModule.forFeature([
HistoryModule,
forwardRef(() => ClaimReviewModule),
ReviewTaskModule,
FeatureFlagModule,
],
providers: [SourceService],
exports: [SourceService],
Expand Down
8 changes: 0 additions & 8 deletions src/components/ClaimReview/ClaimReviewHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import React, { useContext } from "react";
import { ReviewTaskMachineContext } from "../../machines/reviewTask/ReviewTaskMachineProvider";
import { ClassificationEnum, TargetModel } from "../../types/enums";
import { publishedSelector } from "../../machines/reviewTask/selectors";
import { useAppSelector } from "../../store/store";
import colors from "../../styles/colors";
import SentenceReportCard from "../SentenceReport/SentenceReportCard";
import TopicInput from "./TopicInput";
Expand All @@ -32,13 +31,6 @@ const ClaimReviewHeader = ({
componentStyle,
target,
}: ClaimReviewHeaderProps) => {
const { reviewDrawerCollapsed } = useAppSelector((state) => ({
reviewDrawerCollapsed:
state?.reviewDrawerCollapsed !== undefined
? state?.reviewDrawerCollapsed
: true,
}));

const { machineService, publishedReview, reviewTaskType } = useContext(
ReviewTaskMachineContext
);
Expand Down
70 changes: 43 additions & 27 deletions src/components/ClaimReview/ClaimReviewView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import ReviewTaskAdminToolBar from "../Toolbar/ReviewTaskAdminToolBar";
import { useAppSelector } from "../../store/store";
import { ReviewTaskStates } from "../../machines/reviewTask/enums";
import { generateReviewContentPath } from "../../utils/GetReviewContentHref";
import SentenceReportPreviewView from "../SentenceReport/SentenceReportPreviewView";

export interface ClaimReviewViewProps {
content: Content;
Expand All @@ -31,21 +32,22 @@ const ClaimReviewView = (props: ClaimReviewViewProps) => {
const { machineService, publishedReview, reviewTaskType } = useContext(
ReviewTaskMachineContext
);
const { reviewDrawerCollapsed } = useAppSelector((state) => ({
reviewDrawerCollapsed:
state?.reviewDrawerCollapsed !== undefined
? state?.reviewDrawerCollapsed
: true,
}));
const { vw, enableViewReportPreview, reviewDrawerCollapsed } =
useAppSelector((state) => ({
vw: state?.vw,
enableViewReportPreview: state?.enableViewReportPreview,
reviewDrawerCollapsed:
state?.reviewDrawerCollapsed !== undefined
? state?.reviewDrawerCollapsed
: true,
}));
const { review } = publishedReview || {};
const reviewData = useSelector(machineService, reviewDataSelector);
const [role] = useAtom(currentUserRole);
const [userId] = useAtom(currentUserId);
const [nameSpace] = useAtom(currentNameSpace);
const userIsNotRegular = !(role === Roles.Regular || role === null);
const userIsReviewer = reviewData.reviewerId === userId;
const userIsCrossChecker = reviewData.crossCheckerId === userId;
const userIsAssignee = reviewData.usersId.includes(userId);
const hasStartedTask =
machineService.state.value !== ReviewTaskStates.unassigned;
const origin = window.location.origin ? window.location.origin : "";
Expand Down Expand Up @@ -90,25 +92,39 @@ const ClaimReviewView = (props: ClaimReviewViewProps) => {
)}
</>
)}
<ClaimReviewHeader
classification={
review?.report?.classification || reviewData?.classification
}
hideDescription={hideDescriptions}
userIsNotRegular={userIsNotRegular}
componentStyle={componentStyle}
{...props}
/>
<SentenceReportView
context={review?.report || reviewData}
userIsNotRegular={userIsNotRegular}
userIsReviewer={userIsReviewer}
userIsAssignee={userIsAssignee}
userIsCrossChecker={userIsCrossChecker}
isHidden={review?.isHidden}
href={href}
componentStyle={componentStyle}
/>
{!vw?.sm && (
<ClaimReviewHeader
classification={
review?.report?.classification ||
reviewData?.classification
}
hideDescription={hideDescriptions}
userIsNotRegular={userIsNotRegular}
componentStyle={componentStyle}
{...props}
/>
)}

{enableViewReportPreview ? (
<SentenceReportPreviewView
context={review?.report || reviewData}
userIsNotRegular={userIsNotRegular}
userIsReviewer={userIsReviewer}
isHidden={review?.isHidden}
href={href}
componentStyle={componentStyle}
{...props}
/>
) : (
<SentenceReportView
context={review?.report || reviewData}
userIsNotRegular={userIsNotRegular}
userIsReviewer={userIsReviewer}
isHidden={review?.isHidden}
href={href}
componentStyle={componentStyle}
/>
)}

{!review?.isPublished && (
<ClaimReviewForm
Expand Down
Loading

0 comments on commit 5b55e2c

Please sign in to comment.