Skip to content

Commit f158d13

Browse files
authored
Revert "Add XP to Profile (#318)" (#322)
This reverts commit ed14771.
1 parent ed14771 commit f158d13

File tree

6 files changed

+65
-252
lines changed

6 files changed

+65
-252
lines changed

src/components/assessment/__tests__/__snapshots__/index.tsx.snap

Lines changed: 16 additions & 224 deletions
Large diffs are not rendered by default.

src/components/assessment/index.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { NavLink } from 'react-router-dom'
2323

2424
import defaultCoverImage from '../../assets/default_cover_image.jpg'
2525
import AssessmentWorkspaceContainer from '../../containers/assessment/AssessmentWorkspaceContainer'
26+
import { IS_XP_IMPLEMENTED } from '../../utils/constants'
2627
import { beforeNow, getPrettyDate } from '../../utils/dateHelpers'
2728
import { assessmentCategoryLink, stringParamToInt } from '../../utils/paramParseHelpers'
2829
import {
@@ -311,14 +312,16 @@ const makeOverviewCardTitle = (
311312
setBetchaAssessment: (assessment: IAssessmentOverview | null) => void
312313
) => (
313314
<div className="row listing-title">
314-
<Text ellipsize={true} className={'col-xs-10'}>
315+
<Text ellipsize={true} className={IS_XP_IMPLEMENTED ? 'col-xs-10' : 'col-xs-12'}>
315316
<h4>{overview.title}</h4>
316317
</Text>
317-
<div className="col-xs-2">
318-
<Popover content={makeMenu(overview, index, setBetchaAssessment)}>
319-
<Button icon={IconNames.MENU} minimal={true} />
320-
</Popover>
321-
</div>
318+
{IS_XP_IMPLEMENTED ? (
319+
<div className="col-xs-2">
320+
<Popover content={makeMenu(overview, index, setBetchaAssessment)}>
321+
<Button icon={IconNames.MENU} minimal={true} />
322+
</Popover>
323+
</div>
324+
) : null}
322325
</div>
323326
)
324327

src/components/dropdown/Profile.tsx

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
import { Classes, Dialog, NonIdealState, ProgressBar, Spinner } from '@blueprintjs/core'
1+
import { Classes, Dialog, NonIdealState, ProgressBar, Spinner, Tooltip } from '@blueprintjs/core'
22
import { IconNames } from '@blueprintjs/icons'
33
import * as React from 'react'
44

55
import { Role } from '../../reducers/states'
6+
import { IS_XP_IMPLEMENTED } from '../../utils/constants'
67

78
type ProfileProps = OwnProps & StateProps
89

910
export type StateProps = {
10-
grade: number
11-
maxGrade: number
12-
maxXp: number
11+
grade?: number
12+
maxGrade?: number
13+
maxXp?: number
1314
name?: string
1415
role?: Role
15-
xp: number
16+
xp?: number
1617
}
1718

1819
type OwnProps = {
@@ -36,14 +37,31 @@ class Profile extends React.Component<ProfileProps> {
3637
<div className="progress">
3738
<div className="grade">
3839
<span className="label">Grade</span>
39-
<span className="value">{this.props.grade}</span>
40+
<span className="value">
41+
{this.props.grade !== undefined ? this.props.grade : '???'}
42+
</span>
4043
</div>
41-
<ProgressBar className="grade" animate={false} stripes={false} />
42-
<div className="xp">
43-
<span className="label">XP</span>
44-
<span className="value">{this.props.xp}</span>
45-
</div>
46-
<ProgressBar className="xp" animate={false} stripes={false} />
44+
{IS_XP_IMPLEMENTED ? (
45+
<>
46+
{/* TODO: Move tooltip out of this tenary once max grade for a
47+
user is implemented in GET /user.
48+
https://github.com/source-academy/cadet/issues/205 */}
49+
<Tooltip content="Sorry, the grade progress bar is not ready yet">
50+
<ProgressBar className="grade" animate={false} stripes={false} />
51+
</Tooltip>
52+
<div className="xp">
53+
<span className="label">XP</span>
54+
<span className="value">
55+
<Tooltip content="Sorry, the XP display is not ready yet">
56+
{this.props.xp ? this.props.xp : '???'}
57+
</Tooltip>
58+
</span>
59+
</div>
60+
<Tooltip content="Sorry, the XP progress bar is not ready yet">
61+
<ProgressBar className="xp" animate={false} stripes={false} />
62+
</Tooltip>
63+
</>
64+
) : null}
4765
</div>
4866
</>
4967
)

src/containers/ProfileContainer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import { connect, MapStateToProps } from 'react-redux'
33
import Profile, { StateProps } from '../components/dropdown/Profile'
44
import { IState } from '../reducers/states'
55

6+
// TODO: connect to actual state once backend implements these features
67
const mapStateToProps: MapStateToProps<StateProps, {}, IState> = state => ({
78
grade: state.session.grade,
8-
maxGrade: state.session.maxGrade,
9-
maxXp: state.session.maxXp,
9+
maxGrade: undefined,
10+
maxXp: undefined,
1011
name: state.session.name,
1112
role: state.session.role,
12-
xp: state.session.xp
13+
xp: undefined
1314
})
1415

1516
export default connect(mapStateToProps)(Profile)

src/reducers/states.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,10 @@ export interface ISessionState {
7878
readonly gradingOverviews?: GradingOverview[]
7979
readonly gradings: Map<number, Grading>
8080
readonly historyHelper: HistoryHelper
81-
readonly maxGrade: number
82-
readonly maxXp: number
8381
readonly refreshToken?: string
8482
readonly role?: Role
8583
readonly story?: Story
8684
readonly name?: string
87-
readonly xp: number
8885
}
8986

9087
type ReplHistory = {
@@ -250,11 +247,8 @@ export const defaultSession: ISessionState = {
250247
lastAcademyLocations: [null, null],
251248
lastGeneralLocations: [null, null]
252249
},
253-
maxGrade: 0,
254-
maxXp: 0,
255250
refreshToken: undefined,
256-
name: undefined,
257-
xp: 0
251+
name: undefined
258252
}
259253

260254
export const defaultState: IState = {

src/utils/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import * as dotenv from 'dotenv'
22

33
dotenv.config()
44

5+
/* Remove this variable entirely when implemented. DO NOT just set to true;
6+
* also check that the CSS looks acceptable, since there will be className
7+
* changes. */
8+
export const IS_XP_IMPLEMENTED = false
9+
510
export const IVLE_KEY = process.env.REACT_APP_IVLE_KEY
611
export const VERSION = process.env.REACT_APP_VERSION
712
export const BACKEND_URL = process.env.REACT_APP_BACKEND_URL

0 commit comments

Comments
 (0)