From ff6f4e09f1acca621c5e64a66fa6ccf615db7328 Mon Sep 17 00:00:00 2001 From: Vignesh Date: Fri, 24 Aug 2018 11:41:27 +0800 Subject: [PATCH] Revert "Add XP to Profile (#318)" This reverts commit ed14771ad0b582adce0c8b35e972ad62c80da1e9. --- .../__tests__/__snapshots__/index.tsx.snap | 240 ++---------------- src/components/assessment/index.tsx | 15 +- src/components/dropdown/Profile.tsx | 42 ++- src/containers/ProfileContainer.ts | 7 +- src/reducers/states.ts | 8 +- src/utils/constants.ts | 5 + 6 files changed, 65 insertions(+), 252 deletions(-) diff --git a/src/components/assessment/__tests__/__snapshots__/index.tsx.snap b/src/components/assessment/__tests__/__snapshots__/index.tsx.snap index b5631c9349..aa7d5349d2 100644 --- a/src/components/assessment/__tests__/__snapshots__/index.tsx.snap +++ b/src/components/assessment/__tests__/__snapshots__/index.tsx.snap @@ -80,39 +80,13 @@ exports[`Assessment page does not show attempt Button for upcoming assessments f
- -
+ +

An Odessey to Runes (Duplicate)

-
- - - - -
- - - -
-
- -
-
-
-
@@ -173,39 +147,13 @@ exports[`Assessment page does not show attempt Button for upcoming assessments f
- -
+ +

An Odessey to Runes

-
- - - - -
- - - -
-
- -
-
-
-
@@ -268,39 +216,13 @@ exports[`Assessment page does not show attempt Button for upcoming assessments f
- -
+ +

The Secret to Streams

-
- - - - -
- - - -
-
- -
-
-
-
@@ -363,39 +285,13 @@ exports[`Assessment page does not show attempt Button for upcoming assessments f
- -
+ +

A sample Sidequest

-
- - - - -
- - - -
-
- -
-
-
-
@@ -566,39 +462,13 @@ exports[`Assessment page with multiple loaded missions renders correctly 1`] = `
- -
+ +

An Odessey to Runes (Duplicate)

-
- - - - -
- - - -
-
- -
-
-
-
@@ -683,39 +553,13 @@ exports[`Assessment page with multiple loaded missions renders correctly 1`] = `
- -
+ +

An Odessey to Runes

-
- - - - -
- - - -
-
- -
-
-
-
@@ -778,39 +622,13 @@ exports[`Assessment page with multiple loaded missions renders correctly 1`] = `
- -
+ +

The Secret to Streams

-
- - - - -
- - - -
-
- -
-
-
-
@@ -873,39 +691,13 @@ exports[`Assessment page with multiple loaded missions renders correctly 1`] = `
- -
+ +

A sample Sidequest

-
- - - - -
- - - -
-
- -
-
-
-
diff --git a/src/components/assessment/index.tsx b/src/components/assessment/index.tsx index b1973ec5ab..621b61f0af 100644 --- a/src/components/assessment/index.tsx +++ b/src/components/assessment/index.tsx @@ -23,6 +23,7 @@ import { NavLink } from 'react-router-dom' import defaultCoverImage from '../../assets/default_cover_image.jpg' import AssessmentWorkspaceContainer from '../../containers/assessment/AssessmentWorkspaceContainer' +import { IS_XP_IMPLEMENTED } from '../../utils/constants' import { beforeNow, getPrettyDate } from '../../utils/dateHelpers' import { assessmentCategoryLink, stringParamToInt } from '../../utils/paramParseHelpers' import { @@ -311,14 +312,16 @@ const makeOverviewCardTitle = ( setBetchaAssessment: (assessment: IAssessmentOverview | null) => void ) => (
- +

{overview.title}

-
- -
+ {IS_XP_IMPLEMENTED ? ( +
+ +
+ ) : null}
) diff --git a/src/components/dropdown/Profile.tsx b/src/components/dropdown/Profile.tsx index 083eb1efc2..e53b40d9d9 100644 --- a/src/components/dropdown/Profile.tsx +++ b/src/components/dropdown/Profile.tsx @@ -1,18 +1,19 @@ -import { Classes, Dialog, NonIdealState, ProgressBar, Spinner } from '@blueprintjs/core' +import { Classes, Dialog, NonIdealState, ProgressBar, Spinner, Tooltip } from '@blueprintjs/core' import { IconNames } from '@blueprintjs/icons' import * as React from 'react' import { Role } from '../../reducers/states' +import { IS_XP_IMPLEMENTED } from '../../utils/constants' type ProfileProps = OwnProps & StateProps export type StateProps = { - grade: number - maxGrade: number - maxXp: number + grade?: number + maxGrade?: number + maxXp?: number name?: string role?: Role - xp: number + xp?: number } type OwnProps = { @@ -36,14 +37,31 @@ class Profile extends React.Component {
Grade - {this.props.grade} + + {this.props.grade !== undefined ? this.props.grade : '???'} +
- -
- XP - {this.props.xp} -
- + {IS_XP_IMPLEMENTED ? ( + <> + {/* TODO: Move tooltip out of this tenary once max grade for a + user is implemented in GET /user. + https://github.com/source-academy/cadet/issues/205 */} + + + +
+ XP + + + {this.props.xp ? this.props.xp : '???'} + + +
+ + + + + ) : null}
) diff --git a/src/containers/ProfileContainer.ts b/src/containers/ProfileContainer.ts index c5298057e7..a18f4ba99e 100644 --- a/src/containers/ProfileContainer.ts +++ b/src/containers/ProfileContainer.ts @@ -3,13 +3,14 @@ import { connect, MapStateToProps } from 'react-redux' import Profile, { StateProps } from '../components/dropdown/Profile' import { IState } from '../reducers/states' +// TODO: connect to actual state once backend implements these features const mapStateToProps: MapStateToProps = state => ({ grade: state.session.grade, - maxGrade: state.session.maxGrade, - maxXp: state.session.maxXp, + maxGrade: undefined, + maxXp: undefined, name: state.session.name, role: state.session.role, - xp: state.session.xp + xp: undefined }) export default connect(mapStateToProps)(Profile) diff --git a/src/reducers/states.ts b/src/reducers/states.ts index eff90a88f5..9a0c85949c 100644 --- a/src/reducers/states.ts +++ b/src/reducers/states.ts @@ -78,13 +78,10 @@ export interface ISessionState { readonly gradingOverviews?: GradingOverview[] readonly gradings: Map readonly historyHelper: HistoryHelper - readonly maxGrade: number - readonly maxXp: number readonly refreshToken?: string readonly role?: Role readonly story?: Story readonly name?: string - readonly xp: number } type ReplHistory = { @@ -250,11 +247,8 @@ export const defaultSession: ISessionState = { lastAcademyLocations: [null, null], lastGeneralLocations: [null, null] }, - maxGrade: 0, - maxXp: 0, refreshToken: undefined, - name: undefined, - xp: 0 + name: undefined } export const defaultState: IState = { diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 85c264beea..da3d9ed628 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -2,6 +2,11 @@ import * as dotenv from 'dotenv' dotenv.config() +/* Remove this variable entirely when implemented. DO NOT just set to true; + * also check that the CSS looks acceptable, since there will be className + * changes. */ +export const IS_XP_IMPLEMENTED = false + export const IVLE_KEY = process.env.REACT_APP_IVLE_KEY export const VERSION = process.env.REACT_APP_VERSION export const BACKEND_URL = process.env.REACT_APP_BACKEND_URL