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/on reset#388

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 9 commits intomasterfromfeature/on-reset
Jul 12, 2020
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: 15 additions & 3 deletionssrc/channel/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,14 +8,15 @@ import saveCommit from '../actions/saveCommit'
import { setupActions, solutionActions } from '../actions/setupActions'
import tutorialConfig from '../actions/tutorialConfig'
import { COMMANDS } from '../editor/commands'
import logger from '../services/logger'
import Context from './context'
import { version, compareVersions } from '../services/dependencies'
import { openWorkspace, checkWorkspaceEmpty } from '../services/workspace'
import { readFile } from 'fs'
import { join } from 'path'
import { promisify } from 'util'
import logger from '../services/logger'
import { version, compareVersions } from '../services/dependencies'
import { openWorkspace, checkWorkspaceEmpty } from '../services/workspace'
import { showOutput } from '../services/testRunner/output'
import { exec } from '../services/node'
import { WORKSPACE_ROOT, TUTORIAL_URL } from '../environment'

const readFileAsync = promisify(readFile)
Expand DownExpand Up@@ -319,6 +320,17 @@ class Channel implements Channel {
case 'EDITOR_RUN_TEST':
vscode.commands.executeCommand(COMMANDS.RUN_TEST, action?.payload)
return
case 'EDITOR_RUN_RESET_SCRIPT':
const tutorial: TT.Tutorial | null = this.context.tutorial.get()
// if tutorial.config.reset.command, run it
if (tutorial?.config?.reset?.command) {
await exec({ command: tutorial.config.reset.command })
}
return
case 'EDITOR_RUN_RESET_TO_LAST_PASS':
return
case 'EDITOR_RUN_RESET_TO_TIMELINE':
return
default:
logger(`No match for action type: ${actionType}`)
return
Expand Down
12 changes: 12 additions & 0 deletionssrc/services/git/lastPass.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
import*asTTfrom'../../../typings/tutorial'
import*asTfrom'../../../typings'

constgetLastPassCommitHash=(position:T.Position,levels:TT.Level[])=>{
// get previous position
const{ levelId, stepId}=position

// get solution hash if it exists
// else get setup hash
}

exportdefaultgetLastPassCommitHash
7 changes: 6 additions & 1 deletiontypings/tutorial.d.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,11 +2,16 @@ import { ProgressStatus } from './index'

export type Maybe<T> = T | null

export type ConfigReset = {
command?: string
}

export type TutorialConfig = {
appVersions: TutorialAppVersions
appVersions?: TutorialAppVersions
testRunner: TestRunnerConfig
repo: TutorialRepo
dependencies?: TutorialDependency[]
reset?: ConfigReset
}

/** Logical groupings of tasks */
Expand Down
1 change: 1 addition & 0 deletionsweb-app/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,6 +39,7 @@
"react-addons-css-transition-group": "^15.6.2",
"react-dom": "^16.13.1",
"reselect": "^4.0.0",
"use-media": "^1.4.0",
"xstate": "^4.11.0"
},
"devDependencies": {
Expand Down
57 changes: 57 additions & 0 deletionsweb-app/src/containers/Tutorial/components/Reset.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
import*asReactfrom'react'
import{Dialog}from'@alifd/next'
importButtonfrom'../../../components/Button'
importMarkdownfrom'../../../components/Markdown'

interfaceProps{
disabled:boolean
onReset():void
}

constReset=(props:Props)=>{
const[modalState,setModalState]=React.useState<'none'|'confirm'|'progress'>('none')

constonClose=()=>{
setModalState('none')
}

constonOk=()=>{
setModalState('progress')
props.onReset()
returnsetTimeout(()=>{
setModalState('none')
},3000)
}

return(
<>
<Buttontype="secondary"size="medium"onClick={()=>setModalState('confirm')}disabled={props.disabled}>
Reset
</Button>
<Dialog
title="Reset"
visible={modalState==='confirm'}
onOk={onOk}
onCancel={onClose}
onClose={onClose}
footerActions={['ok','cancel']}
>
<Markdown>
{`Are you sure you want to reset your progress?
Resetting progress will remove the commits you have made and replace them with the tutorial commit timeline. Your code may look different after resetting.`}
</Markdown>
</Dialog>
<Dialog
title="Resetting..."
visible={modalState==='progress'}
footer={false}
onClose={onClose}
closeable={false}
>
Reverting progress to an earlier commit...
</Dialog>
</>
)
}

exportdefaultReset
48 changes: 48 additions & 0 deletionsweb-app/src/containers/Tutorial/components/StepProgress.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
import*asReactfrom'react'
import{Progress}from'@alifd/next'
importuseMediafrom'use-media'

conststyles={
progress:{
display:'flex'as'flex',
justifyContent:'flex-end'as'flex-end',
alignItems:'center'as'center',
width:'10rem',
color:'white',
},
text:{color:'white'},
}

interfaceProps{
current:number
max:number
}

constStepProgress=(props:Props)=>{
constText=(
<spanstyle={styles.text}>
{props.current} of{props.max}
</span>
)

constisWide=useMedia({minWidth:'340px'})

if(isWide){
return(
<Progress
state="success"
progressive
percent={(props.current/props.max)*100}
shape="line"
color="rgb(85, 132, 255)"
css={styles.progress}
textRender={()=>{
returnText
}}
/>
)
}
return<divcss={{marginRight:'0.5rem',fontSize:'80%'}}>{Text}</div>
}

exportdefaultStepProgress
52 changes: 19 additions & 33 deletionsweb-app/src/containers/Tutorial/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,14 +4,15 @@ import * as selectors from '../../services/selectors'
importSideMenufrom'./components/SideMenu'
importLevelfrom'./components/Level'
importIconfrom'../../components/Icon'
importSettingsPagefrom'./containers/Settings'
importReviewPagefrom'./containers/Review'
importButtonfrom'../../components/Button'
importProcessMessagesfrom'../../components/ProcessMessages'
importTestMessagefrom'../../components/TestMessage'
import{Progress}from'@alifd/next'
importStepProgressfrom'./components/StepProgress'
import{DISPLAY_RUN_TEST_BUTTON}from'../../environment'
importformatLevelsfrom'./formatLevels'
// import SettingsPage from './containers/Settings'
// import Reset from './components/Reset'

conststyles={
header:{
Expand DownExpand Up@@ -47,13 +48,6 @@ const styles = {
right:0,
color:'white',
},
taskProgress:{
display:'flex'as'flex',
justifyContent:'flex-end'as'flex-end',
alignItems:'center'as'center',
width:'10rem',
color:'white',
},
processes:{
padding:'0 1rem',
position:'fixed'as'fixed',
Expand DownExpand Up@@ -100,6 +94,10 @@ const TutorialPage = (props: PageProps) => {
props.send({type:'RUN_TEST'})
}

constonReset=():void=>{
// TODO
}

const[menuVisible,setMenuVisible]=React.useState(false)

const[page,setPage]=React.useState<'level'|'settings'|'review'>('level')
Expand DownExpand Up@@ -140,39 +138,27 @@ const TutorialPage = (props: PageProps) => {
</div>
)}
{/* Left */}
{DISPLAY_RUN_TEST_BUTTON&&level.status!=='COMPLETE' ?(
<Buttonstyle={{marginLeft:'1rem'}}type="primary"onClick={onRunTest}disabled={processes.length>0}>
Run
</Button>
) :(
<div/>
)}
<divcss={{flex:1}}>
{DISPLAY_RUN_TEST_BUTTON&&level.status!=='COMPLETE' ?(
<Buttonstyle={{marginLeft:'1rem'}}type="primary"onClick={onRunTest}disabled={processes.length>0}>
Run
</Button>
) :null}
</div>

{/* Center */}
<div/>
<divcss={{flex:1,display:'flex',justifyContent:'center'}}>
{/* <Reset onReset={onReset} disabled={processes.length > 0} /> */}
</div>

{/* Right */}
<div>
<divcss={{flex:1,display:'flex',justifyContent:'flex-end'}}>
{level.status==='COMPLETE'||!level.steps.length ?(
<Buttonstyle={{marginRight:'1rem'}}type="primary"onClick={onContinue}>
Continue
</Button>
) :(
<Progress
state="success"
progressive
percent={(stepIndex/level.steps.length)*100}
shape="line"
color="rgb(85, 132, 255)"
css={styles.taskProgress}
textRender={()=>{
return(
<spanstyle={{color:'white'}}>
{stepIndex} of{level.steps.length}
</span>
)
}}
/>
<StepProgresscurrent={stepIndex}max={level.steps.length}/>
)}
</div>
</div>
Expand Down
5 changes: 5 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@@ -117,4 +117,9 @@ export default (editorSend: any) => ({
payload:{position:context.position},
})
},
runResetScript(){
editorSend({
type:'EDITOR_RUN_RESET_SCRIPT',
})
},
})
3 changes: 3 additions & 0 deletionsweb-app/src/services/state/machine.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -168,6 +168,9 @@ export const createMachine = (options: any) => {
RUN_TEST:{
actions:['runTest'],
},
RESET_SCRIPT:{
actions:['runResetScript'],
},
},
},
TestRunning:{
Expand Down
13 changes: 1 addition & 12 deletionsweb-app/stories/Review.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -142,16 +142,5 @@ storiesOf('Review', module)
.addDecorator(SideBarDecorator)
.addDecorator(withKnobs)
.add('Example',()=>{
constprogress={
levels:{
'1':true,
},
steps:{
'1.1':true,
'1.2':true,
'1.3':true,
'2.1':true,
},
}
return<Reviewlevels={levels}progress={progress}/>
return<Reviewlevels={levels}/>
})
2 changes: 1 addition & 1 deletionweb-app/stories/Tests.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,4 +5,4 @@ import SideBarDecorator from './utils/SideBarDecorator'

storiesOf('Test Message',module)
.addDecorator(SideBarDecorator)
.add('Fail',()=><TestMessagecontent={'Test failed for some reason'}/>)
.add('Fail',()=><TestMessagemessage={'Test failed for some reason'}/>)
Loading

[8]ページ先頭

©2009-2025 Movatter.jp