Skip to content

In progress: Feature/api #28

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

Closed
wants to merge 64 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
9004e35
setup server api
ShMcK Aug 14, 2019
4bd3fad
setup apollo on web
ShMcK Aug 14, 2019
4456261
setup new page query
ShMcK Aug 14, 2019
d0f984b
npm updates
ShMcK Aug 16, 2019
a591a2d
sort-package-json
ShMcK Aug 18, 2019
5a060fd
migrate codegen graphql typings
ShMcK Aug 18, 2019
f3f9765
cleanup routes
ShMcK Aug 18, 2019
2d84fa8
setup apollo decorator
ShMcK Aug 18, 2019
1114d13
new queryTutorials loaded
ShMcK Aug 18, 2019
4b1d714
migrate latestVersion to version
ShMcK Aug 18, 2019
5d38263
remove data from version, schema change
ShMcK Aug 18, 2019
8d4d43f
ckean up new container loading
ShMcK Aug 18, 2019
64837c0
load continue container
ShMcK Aug 18, 2019
b2fcd7a
add error component
ShMcK Aug 18, 2019
0c9b0b9
clenaup level summary progress
ShMcK Aug 18, 2019
f57b367
apollo decorator with local cache
ShMcK Aug 18, 2019
2b16a0b
working LevelStage container
ShMcK Aug 18, 2019
204840f
update level stories & structure
ShMcK Aug 18, 2019
2bc96a1
cleanup gql paths
ShMcK Aug 18, 2019
372658d
add level/stage/step to gql
ShMcK Aug 18, 2019
44613b6
migrate stage page
ShMcK Aug 18, 2019
df11100
fix typing paths for storybook
ShMcK Aug 18, 2019
7bab14b
cleanup Stage story
ShMcK Aug 18, 2019
c69b868
working stage container
ShMcK Aug 18, 2019
00b3550
cleanup storybook summary
ShMcK Aug 18, 2019
223019e
cleanup step stories
ShMcK Aug 18, 2019
d0d2f07
restructure single use components into containers
ShMcK Aug 18, 2019
b022179
remove old web api
ShMcK Aug 19, 2019
24eb6a6
absolute paths not allowed
ShMcK Aug 19, 2019
be46fad
create setStatus mutation
ShMcK Aug 19, 2019
26ae887
resolve build issues
ShMcK Aug 19, 2019
c39666a
update deps
ShMcK Aug 20, 2019
6c73657
fix react webview script issue
ShMcK Aug 22, 2019
36af369
create script for styles
ShMcK Aug 22, 2019
a058eff
update deps
ShMcK Aug 22, 2019
8c72738
cleanup logs
ShMcK Aug 22, 2019
d784c57
fix use effects
ShMcK Aug 22, 2019
f4e9877
fix no route unclear object
ShMcK Aug 22, 2019
6a13fcd
update api url for src
ShMcK Aug 22, 2019
39af55d
cleanup apollo server
ShMcK Aug 22, 2019
8740c1d
migrate to graphql-request on server
ShMcK Aug 23, 2019
5776877
tutorial command progress
ShMcK Aug 23, 2019
47224c4
update deps
ShMcK Aug 25, 2019
7bbacd6
update typings
ShMcK Aug 25, 2019
0dd047f
create Tutorial model
ShMcK Aug 25, 2019
97b878a
initialize state machine with tutorial model
ShMcK Aug 25, 2019
57675e5
tutorialModel progress
ShMcK Aug 25, 2019
a92d52f
heavy refactoring
ShMcK Aug 25, 2019
46d1e27
fix launch errors
ShMcK Aug 25, 2019
98c9cc9
remove unusued loading tutorial
ShMcK Aug 25, 2019
b358130
fix send data to client
ShMcK Aug 25, 2019
b6ec3e8
cleanup env vars & fix request
ShMcK Aug 25, 2019
bf0ad9b
clenaup typings
ShMcK Aug 25, 2019
0ad9d2c
add additional logging
ShMcK Aug 26, 2019
f462b39
heavy refactor
ShMcK Aug 26, 2019
1253177
Refactor editor dispatch uses
ShMcK Sep 1, 2019
c32d670
add jest
ShMcK Sep 1, 2019
3886921
fix stateToString function
ShMcK Sep 1, 2019
63f28db
fix jest mismatch build errors
ShMcK Sep 1, 2019
0d50ab6
update deps
ShMcK Sep 1, 2019
44cf7d7
cleanup client state
ShMcK Sep 1, 2019
957d05b
rename select to start
ShMcK Sep 1, 2019
0133ab8
migrate git into tutorial model
ShMcK Sep 1, 2019
50cad58
setup initial start/loaded actions
ShMcK Sep 1, 2019
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
working LevelStage container
  • Loading branch information
ShMcK committed Aug 18, 2019
commit 2b16a0b9d9cc3c10e1ad58005bf33eae2063a8ec
3 changes: 3 additions & 0 deletions typings/graphql.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export type Level = {
text?: Maybe<Scalars['String']>,
stages?: Maybe<Array<Maybe<Stage>>>,
setup?: Maybe<StepActions>,
status?: 'INCOMPLETE' | 'COMPLETE' | 'ACTIVE',
};

export type Mutation = {
Expand Down Expand Up @@ -125,6 +126,7 @@ export type Stage = {
text?: Maybe<Scalars['String']>,
steps?: Maybe<Array<Maybe<Step>>>,
setup?: Maybe<StepActions>,
status?: 'INCOMPLETE' | 'COMPLETE' | 'ACTIVE',
};

export type Step = {
Expand All @@ -134,6 +136,7 @@ export type Step = {
text?: Maybe<Scalars['String']>,
setup?: Maybe<StepActions>,
solution?: Maybe<StepActions>,
status?: 'INCOMPLETE' | 'COMPLETE' | 'ACTIVE'
};

export type StepActions = {
Expand Down
8 changes: 4 additions & 4 deletions web-app/src/components/Level/LevelStageSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Icon } from '@alifd/next'
import * as React from 'react'
import CC from '../../../../typings/context'
import * as T from '../../../../typings/graphql'

import Markdown from '../Markdown'

Expand All @@ -24,17 +24,17 @@ const styles = {
}

interface Props {
stage: CC.StageWithStatus
stage: T.Stage
onNext(): void
}

const LevelStageSummary = (props: Props) => {
const { stage, onNext } = props
const { active } = stage.status
const active = stage.status === 'ACTIVE'
return (
<div style={styles.card} className={active ? 'hover-select' : ''} onClick={onNext}>
<div style={styles.left}>
<Markdown>{stage.content.text}</Markdown>
<Markdown>{stage.text || ''}</Markdown>
</div>
<div style={styles.right}>{active && <Icon type="arrow-right" style={styles.continueIcon} />}</div>
</div>
Expand Down
44 changes: 22 additions & 22 deletions web-app/src/components/Level/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Button, Step } from '@alifd/next'
import * as React from 'react'
import CR from 'typings'
import CC from '../../../../typings/context'
import * as T from '../../../../typings/graphql'

import Markdown from '../Markdown'
import LevelStageSummary from './LevelStageSummary'
Expand All @@ -25,45 +24,46 @@ const styles = {
}

interface Props {
level: CR.TutorialLevel
stages: {
[stageId: string]: any // CC.StageWithStatus
}
level: T.Level
onNext(): void
onBack(): void
}

const Level = ({ level, stages, onNext, onBack }: Props) => {
const { content, stageList } = level
const { title, text } = content
const activeIndex = stageList.findIndex((stageId: string) => {
return stages[stageId].status.active
})

const Level = ({ level, onNext, onBack }: Props) => {
if (!level || !level.stages) {
throw new Error('No level stages found')
}
const activeIndex = level.stages.findIndex((stage: T.Stage | null) => stage && stage.status === 'ACTIVE') || 0
return (
<div style={styles.card}>
<div style={styles.content}>
<h2 style={styles.title}>{title}</h2>
<Markdown>{text}</Markdown>
<h2 style={styles.title}>{level.title}</h2>
<Markdown>{level.text || ''}</Markdown>
</div>
<div style={styles.steps}>
<Step current={activeIndex} direction="ver" animation={false}>
{stageList.map((stageId: string, index: number) => {
const stage: CC.StageWithStatus = stages[stageId]
const { active } = stage.status
const clickHandler = active ? onNext : () => {}
{level.stages.map((stage: T.Stage | null, index: number) => {
if (!stage) {
return null
}
const active = stage.status === 'ACTIVE'
const clickHandler = active
? onNext
: () => {
/* empty */
}
// note - must add click handler to title, content & step.item
// as all are separted components
return (
<Step.Item
key={stageId}
key={stage.id}
style={{ backgroundColor: 'blue' }}
title={
<span className={active ? 'hover-select' : ''} onClick={clickHandler}>
{stage.content.title || `Stage ${index + 1}`}
{stage.title || `Stage ${index + 1}`}
</span>
}
content={<LevelStageSummary key={stageId} stage={stage} onNext={clickHandler} />}
content={<LevelStageSummary key={stage.id} stage={stage} onNext={clickHandler} />}
onClick={clickHandler}
/>
)
Expand Down
43 changes: 14 additions & 29 deletions web-app/src/containers/Tutorial/LevelSummaryPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,32 @@ import * as React from 'react'
import { useQuery } from '@apollo/react-hooks'

import ErrorView from '../../../components/Error'
// import Level from '../../../components/Level'
import Level from '../../../components/Level'
import * as T from '../../../../../typings/graphql'
import queryLevels from './queryLevels'
import queryLevel from './queryLevel'

interface LevelProps {
levels: T.Level[]
level: T.Level
send(action: string): void
}

export const LevelSummaryPage = (props: LevelProps) => {
// const { levelId } = position
// const level = data.levels[levelId]
// const onNext = (): void => {
// props.send('NEXT')
// }
// const onBack = (): void => {
// props.send('BACK')
// }

// const stages: { [stageId: string]: any } = {}
// for (const stageId of level.stageList) {
// stages[stageId] = {
// ...data.stages[stageId],
// status: {
// complete: progress.stages[stageId] || false,
// active: position.stageId === stageId,
// },
// }
// }

return <div>LevelSummaryPage</div>

// return <Level level={level} stages={stages} onNext={onNext} onBack={onBack} />
const onNext = (): void => {
props.send('NEXT')
}
const onBack = (): void => {
props.send('BACK')
}
console.log('props', props)
return <Level level={props.level} onNext={onNext} onBack={onBack} />
}

interface ContainerProps {
send(action: string): void
}

const LevelSummaryPageContainer = (props: ContainerProps) => {
const { loading, error, data } = useQuery(queryLevels, {
const { loading, error, data } = useQuery(queryLevel, {
variables: {
tutorialId: '1',
version: '0.1.0',
Expand All @@ -58,9 +43,9 @@ const LevelSummaryPageContainer = (props: ContainerProps) => {
return <ErrorView error={error} />
}

const { levels } = data.tutorial.version
const { level } = data.tutorial.version

return <LevelSummaryPage levels={levels} send={props.send} />
return <LevelSummaryPage level={level} send={props.send} />
}

export default LevelSummaryPageContainer
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export default gql`
id
title
text

status @client
stages {
id
title
text

status @client
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions web-app/src/services/apollo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ const client = new ApolloClient({
return null
},
},
Level: {
status() {
return 'INCOMPLETE'
}
},
Stage: {
status() {
return 'INCOMPLETE'
}
},
Step: {
status() {
return 'INCOMPLETE'
}
}
},
})

Expand Down