Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronshiel committed Sep 28, 2023
2 parents bf78e38 + b5adc63 commit 67e32af
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 12 deletions.
12 changes: 12 additions & 0 deletions client/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,10 @@ export async function fetchUsers(
welcomeSlideText
disableMyGoalSlide
disableFollowups
disableKeywordsRecommendation
disableThumbnailRecommendation
disableLevelProgressDisplay
completeSubjectsNotificationText
}
orgPermissions {
orgId
Expand Down Expand Up @@ -1072,6 +1076,10 @@ export async function fetchMentorById(
welcomeSlideText
disableMyGoalSlide
disableFollowups
disableKeywordsRecommendation
disableThumbnailRecommendation
disableLevelProgressDisplay
completeSubjectsNotificationText
}
orgPermissions {
orgId
Expand Down Expand Up @@ -1244,6 +1252,10 @@ export async function fetchMentorConfig(
welcomeSlideText
disableMyGoalSlide
disableFollowups
disableKeywordsRecommendation
disableThumbnailRecommendation
disableLevelProgressDisplay
completeSubjectsNotificationText
}
}
`,
Expand Down
32 changes: 31 additions & 1 deletion client/src/components/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ function HomePage(props: {
const mentorConfig: MentorConfig | undefined = getData(
(m) => m.data?.mentorConfig
);
const lockedToConfig: boolean = getData((m) => m.data?.lockedToConfig);
const defaultMentor = props.user.defaultMentor._id;
const { classes } = useStyles();
const [showSetupAlert, setShowSetupAlert] = useState(true);
Expand Down Expand Up @@ -190,7 +191,8 @@ function HomePage(props: {
useState<ConfirmSave>();
const [confirmSaveOnRecordOne, setConfirmSaveOnRecordOne] =
useState<ConfirmSave>();

const [notifyCompleteAllQuestions, setNotifyCompleteAllQuestions] =
useState<boolean>(false);
const loginState = useWithLogin();

const [localHasSeenSplash, setLocalHasSeenSplash] = useState(false);
Expand Down Expand Up @@ -273,6 +275,26 @@ function HomePage(props: {
mentorId,
]);

useEffect(() => {
const lockedToSubjects = mentorConfig?.subjects.length;
if (
!lockedToConfig ||
!mentorConfig ||
!lockedToSubjects ||
!mentorConfig.completeSubjectsNotificationText
) {
return;
}
if (
reviewAnswerState.progress.total != 0 &&
reviewAnswerState.progress.complete ===
reviewAnswerState.progress.total &&
!notifyCompleteAllQuestions
) {
setNotifyCompleteAllQuestions(true);
}
}, [reviewAnswerState.progress, mentorConfig, lockedToConfig]);

// memoized train mentor
const startTrainingMentor = useCallback(() => {
startTraining(mentorId);
Expand Down Expand Up @@ -745,6 +767,14 @@ function HomePage(props: {
</DialogContent>
</Dialog>

<NotificationDialog
title={mentorConfig?.completeSubjectsNotificationText}
open={notifyCompleteAllQuestions}
closeDialog={() => {
setNotifyCompleteAllQuestions(false);
}}
/>

<TwoOptionDialog
open={Boolean(confirmSaveBeforeCallback)}
title={confirmSaveBeforeCallback?.message || ""}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import parseMentor, { defaultMentorInfo } from "../mentor-info";
import CloseIcon from "@mui/icons-material/Close";
import { TooltipStep } from "components/home";
import useQuestions from "store/slices/questions/useQuestions";
import { MentorConfig } from "types-gql";

const ColorTooltip = withStyles(Tooltip, {
tooltip: {
Expand All @@ -31,6 +32,9 @@ function MentorStatus(props: {
const mentorInfo = getData((ms) =>
ms.data ? parseMentor(ms.data, allQuestions) : defaultMentorInfo
);
const mentorConfig: MentorConfig | undefined = getData(
(ms) => ms.data?.mentorConfig
);

const leftColumnAlign = "left";

Expand Down Expand Up @@ -59,13 +63,14 @@ function MentorStatus(props: {
</span>
</Typography>

{mentorInfo.currentStage.floor != 1000 && (
<StageProgress
value={mentorInfo.value}
max={mentorInfo.currentStage.max || 0}
percent={mentorInfo.currentStage.percent || 0}
/>
)}
{mentorInfo.currentStage.floor != 1000 &&
!mentorConfig?.disableLevelProgressDisplay && (
<StageProgress
value={mentorInfo.value}
max={mentorInfo.currentStage.max || 0}
percent={mentorInfo.currentStage.percent || 0}
/>
)}
</Grid>
);

Expand Down
3 changes: 3 additions & 0 deletions client/src/components/record/video-recorder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function VideoRecorder(props: {
const canvasRef = useRef<HTMLCanvasElement>(null);
const { segmentVideoAndDrawToCanvas } = useWithVideoSegmentation();
const { aspectRatio: vbgAspectRatio } = useWithImage(virtualBackgroundUrl);
const [uploadCounter, setUploaderCounter] = useState(0);
const videoRecordMimeType = isVirtualBgMentor
? "video/webm;codecs=vp9"
: "video/mp4";
Expand Down Expand Up @@ -525,10 +526,12 @@ function VideoRecorder(props: {
{recordState.isRecording ? "Stop" : "Record"}
</Button>
<input
key={uploadCounter}
data-cy="upload-file"
type="file"
accept="audio/*,video/*"
onChange={(e) => {
setUploaderCounter((prevState) => prevState + 1);
if (!e.target.files?.length) {
return;
} else {
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/setup/welcome-slide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ export function WelcomeSlide(props: {
>
{"If you'd like to view a walkthrough, "}
<a data-cy="click-here-url" href={docSetupUrl} target="blank">
click here.
click here
</a>
.
</Typography>
</div>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ export function useWithMentorRecommender(
);
};
const keywordsMissing = (state: RecommenderState) => {
return !state.mentorData.keywords.length;
return (
!state.mentorData.keywords.length &&
!state.mentorData.mentorConfig?.disableKeywordsRecommendation
);
};
const noSubject = (state: RecommenderState) => {
return !state.mentorData.subjects.length;
Expand Down Expand Up @@ -138,7 +141,10 @@ export function useWithMentorRecommender(
);
};
const thumbnailMissing = (state: RecommenderState) => {
return !state.mentorData.thumbnail;
return (
!state.mentorData.thumbnail &&
!state.mentorData.mentorConfig?.disableThumbnailRecommendation
);
};

// Note: All reccomendations have same weights in this phase, but other phases rec's have different weights
Expand Down Expand Up @@ -724,7 +730,7 @@ export function useWithMentorRecommender(
"Preview your mentor",
RecommendationName.PREVIEW_MENTOR,
"Preview your mentor to review its current status.",
() => launchMentor(mentorData?._id || "")
() => launchMentor(mentorData?._id || "", true)
);
const activeCondition = (state: RecommenderState) => {
const lastPreviewedDate = state.mentorData.lastPreviewedAt
Expand Down
4 changes: 4 additions & 0 deletions client/src/types-gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export interface MentorConfig {
welcomeSlideText: string;
disableMyGoalSlide: boolean;
disableFollowups: boolean;
disableKeywordsRecommendation: boolean;
disableThumbnailRecommendation: boolean;
disableLevelProgressDisplay: boolean;
completeSubjectsNotificationText: string;
}

export interface MentorGQL {
Expand Down

0 comments on commit 67e32af

Please sign in to comment.