Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feature/solution actions#38

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 6 commits intomasterfromfeature/solution-actions
Sep 29, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletionssrc/actions/solutionActions.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
// import * as CR from 'typings'
import*asGfrom'typings/graphql'
// import {TutorialModel} from '../services/tutorial'
// import {gitLoadCommits, gitClear} from '../services/git'

constsolutionActions=async(stepActions:G.StepActions):Promise<void>=>{
// TODO: should load same as commits

// const step: G.Step = tutorialModel.step()
// const solution = step.solution

// await gitClear()
// await gitLoadCommits(solution, dispatch)
import*asvscodefrom'vscode'
import*asgitfrom'../services/git'
importsetupActionsfrom'./setupActions'

constsolutionActions=async(workspaceRoot:vscode.WorkspaceFolder,stepActions:G.StepActions):Promise<void>=>{
awaitgit.clear()
returnsetupActions(workspaceRoot,stepActions)
}

exportdefaultsolutionActions
4 changes: 3 additions & 1 deletionsrc/channel/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -105,7 +105,9 @@ class Channel implements Channel {
return
// load solution step actions (git commits, commands, open files)
case'SOLUTION_ACTIONS':
solutionActions(action.payload)
awaitsolutionActions(this.workspaceRoot,action.payload)
// run test following solution to update position
vscode.commands.executeCommand('coderoad.run_test',action.payload)
return

default:
Expand Down
2 changes: 1 addition & 1 deletionsrc/channel/state/Progress.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,7 @@ class Progress {
publicset=(value:CR.Progress)=>{
this.value=value
if(!this.storage){
thrownewError('Tutorial storage not found')
returndefaultValue
}
this.storage.set(value)
returnthis.value
Expand Down
6 changes: 3 additions & 3 deletionstypings/graphql.d.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -136,7 +136,7 @@ export type Stage = {
step?:Maybe<Step>,
steps:Array<Step>,
setup?:Maybe<StepActions>,
status:string
status:'ACTIVE'|'COMPLETE'|'INCOMPLETE'
};


Expand All@@ -151,8 +151,8 @@ export type Step = {
text:Scalars['String'],
setup:StepActions,
solution:StepActions,
status:string
};
status:'ACTIVE'|'COMPLETE'|'INCOMPLETE'
}

exporttypeStepActions={
__typename?:'StepActions',
Expand Down
9 changes: 6 additions & 3 deletionsweb-app/src/App.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
import*asReactfrom'react'
import{ApolloProvider}from'@apollo/react-hooks'

importErrorBoundaryfrom'./components/ErrorBoundary'
importclientfrom'./services/apollo'
importRoutesfrom'./Routes'

constApp=()=>(
<ApolloProviderclient={client}>
<Routes/>
</ApolloProvider>
<ErrorBoundary>
<ApolloProviderclient={client}>
<Routes/>
</ApolloProvider>
</ErrorBoundary>
)

exportdefaultApp
23 changes: 23 additions & 0 deletionsweb-app/src/components/ErrorBoundary/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
import*asReactfrom'react'

classErrorBoundaryextendsReact.Component{
publicstate={hasError:false}

publiccomponentDidCatch(error:Error,info:any){
// Display fallback UI
this.setState({hasError:true})
// You can also log the error to an error reporting service
console.error(error)
console.log(info)
}

publicrender(){
if(this.state.hasError){
// You can render any custom fallback UI
return<h1>Something went wrong.</h1>
}
returnthis.props.children
}
}

exportdefaultErrorBoundary
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
import*asReactfrom'react'
importMarkdownfrom'../../../../../components/Markdown'
import{Button}from'@alifd/next'

conststyles={
// active: {
Expand All@@ -12,16 +13,29 @@ const styles = {

interfaceProps{
text?:string|null
hide:boolean
mode:'INCOMPLETE'|'ACTIVE'|'COMPLETE'
onLoadSolution():void
}

constStepDescription=({ text, hide}:Props)=>{
if(hide){
constStepDescription=({ text, mode, onLoadSolution}:Props)=>{
const[loadedSolution,setLoadedSolution]=React.useState()

constonClickHandler=()=>{
if(!loadedSolution){
setLoadedSolution(true)
onLoadSolution()
}
}

if(mode==='INCOMPLETE'){
returnnull
}

constshowLoadSolution=mode==='ACTIVE'&&!loadedSolution
return(
<divstyle={styles.card}>
<Markdown>{text||''}</Markdown>
{showLoadSolution&&<ButtononClick={onClickHandler}>Load Solution</Button>}
</div>
)
}
Expand Down
14 changes: 7 additions & 7 deletionsweb-app/src/containers/Tutorial/StagePage/Stage/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,11 +24,12 @@ const styles = {

interfaceProps{
stage:T.Stage
onContinue():void
onSave():void
onContinue():void
onSave():void
onLoadSolution():void
}

constStage=({ stage, onContinue, onSave}:Props)=>{
constStage=({ stage, onContinue, onSave, onLoadSolution}:Props)=>{
if(!stage.steps){
thrownewError('No Stage steps found')
}
Expand All@@ -50,12 +51,11 @@ const Stage = ({ stage, onContinue, onSave }: Props) => {
if(!step){
returnnull
}
consthide=step.status==='INCOMPLETE'
return(
<Step.Item
key={step.id}
title={step.title||`Step${index+1}`}
content={<StepDescriptiontext={step.text}hide={hide}/>}
content={<StepDescriptiontext={step.text}mode={step.status}onLoadSolution={onLoadSolution}/>}
/>
)
})}
Expand All@@ -67,10 +67,10 @@ const Stage = ({ stage, onContinue, onSave }: Props) => {
<ButtononClick={onContinue}>Continue</Button>
</div>
) :(
<divstyle={styles.options}>
<divstyle={styles.options}>
<ButtononClick={onSave}>Save</Button>
</div>
)}
)}
</div>
)
}
Expand Down
6 changes: 5 additions & 1 deletionweb-app/src/containers/Tutorial/StagePage/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,6 +33,10 @@ const StageSummaryPageContainer = (props: PageProps) => {
})
}

constonLoadSolution=():void=>{
props.send({type:'STEP_SOLUTION_LOAD'})
}

stage.steps.forEach((step:G.Step)=>{
if(progress.steps[step.id]){
step.status='COMPLETE'
Expand All@@ -44,7 +48,7 @@ const StageSummaryPageContainer = (props: PageProps) => {
})
stage.status=progress.stages[position.stageId] ?'COMPLETE' :'ACTIVE'

return<Stagestage={stage}onContinue={onContinue}onSave={onSave}/>
return<Stagestage={stage}onContinue={onContinue}onSave={onSave}onLoadSolution={onLoadSolution}/>
}

exportdefaultStageSummaryPageContainer
11 changes: 11 additions & 0 deletionsweb-app/src/services/state/actions/editor.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -97,6 +97,17 @@ export default {
})
}
},
editorLoadSolution(context:CR.MachineContext):void{
conststep:G.Step=selectors.currentStep(context)
// tell editor to load solution commit
channel.editorSend({
type:'SOLUTION_ACTIONS',
payload:{
stepId:step.id,
...step.solution,
}
})
},
clearStorage():void{
channel.editorSend({type:'TUTORIAL_CLEAR'})
}
Expand Down
2 changes: 1 addition & 1 deletionweb-app/src/services/state/machine.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -113,7 +113,7 @@ export const machine = Machine<CR.MachineContext, CR.MachineStateSchema, CR.Mach
on:{
TEST_RUN:'TestRunning',
STEP_SOLUTION_LOAD:{
actions:['callSolution'],
actions:['editorLoadSolution'],
},
},
},
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp