Skip to content

Commit f18ff33

Browse files
committed
Reorganize applet start dialog
1 parent 5ee29ef commit f18ff33

File tree

1 file changed

+40
-26
lines changed

1 file changed

+40
-26
lines changed

src/ui/failsboard.jsx

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export class FailsBoard extends FailsBasis {
6969
this.onHidePictDialog = this.onHidePictDialog.bind(this)
7070
this.onHideIpynbDialog = this.onHideIpynbDialog.bind(this)
7171
this.onAddPicture = this.onAddPicture.bind(this)
72-
this.onStartApplet = this.onStartApplet.bind(this)
7372
this.onOpenNewScreen = this.onOpenNewScreen.bind(this)
7473
this.onOpenNewNotepad = this.onOpenNewNotepad.bind(this)
7574
this.onNewWriting = this.onNewWriting.bind(this)
@@ -83,6 +82,7 @@ export class FailsBoard extends FailsBasis {
8382
this.onStartPoll = this.onStartPoll.bind(this)
8483
this.onStartSelPoll = this.onStartSelPoll.bind(this)
8584
this.onFinishSelPoll = this.onFinishSelPoll.bind(this)
85+
this.ipynbTemplate = this.ipynbTemplate.bind(this)
8686
}
8787

8888
componentDidMount() {
@@ -475,21 +475,16 @@ export class FailsBoard extends FailsBasis {
475475
}
476476
}
477477

478-
async onStartApplet() {
479-
console.log('onStartApplet', this.state.selipynb)
480-
if (this.noteref && this.state.selipynb) {
481-
const [id = undefined, sha = undefined, appid = undefined] =
482-
this.state.selipynb.split(':')
483-
if (
484-
typeof id !== 'undefined' &&
485-
typeof sha !== 'undefined' &&
486-
typeof appid !== 'undefined'
487-
)
488-
this.noteref.onAppStart(id, sha, appid)
478+
async onStartApplet({
479+
appid = undefined,
480+
id = undefined,
481+
sha = undefined
482+
} = {}) {
483+
if (this.noteref && appid && id && sha) {
484+
this.noteref.onAppStart(id, sha, appid)
489485
}
490486
this.setState({
491487
ipynbs: undefined,
492-
selipynb: undefined,
493488
ipynbbuttondialog: false
494489
})
495490
}
@@ -576,6 +571,37 @@ export class FailsBoard extends FailsBasis {
576571
return { data: tpolldata, numballots }
577572
}
578573

574+
ipynbTemplate(node) {
575+
if (node.appid) {
576+
const { appid, id, sha } = node
577+
// it is a app
578+
return (
579+
<React.Fragment>
580+
<b>{node.label}</b>{' '}
581+
<Button
582+
icon='pi pi-send'
583+
className='p-button-text p-button-sm'
584+
tooltip={'Start applet'}
585+
tooltipOptions={{
586+
className: 'teal-tooltip',
587+
position: 'top',
588+
showDelay: 1000
589+
}}
590+
iconPos='right'
591+
onClick={() => {
592+
this.onStartApplet({
593+
appid,
594+
id,
595+
sha
596+
})
597+
}}
598+
/>{' '}
599+
</React.Fragment>
600+
)
601+
}
602+
return <b>{node.label}</b>
603+
}
604+
579605
render() {
580606
let polldata = {}
581607
const pollanswers = []
@@ -769,22 +795,10 @@ export class FailsBoard extends FailsBasis {
769795
<div className='p-col-12'>
770796
<Tree
771797
value={this.state.ipynbs}
798+
nodeTemplate={this.ipynbTemplate}
772799
selectionMode='single'
773-
selectionKeys={this.state.selipynb}
774-
onSelectionChange={(e) =>
775-
this.setState({ selipynb: e.value })
776-
}
777800
/>
778801
</div>
779-
{this.state.selipynb && (
780-
<div className='p-col-6'>
781-
<Button
782-
label='Start applet'
783-
icon='pi pi-send'
784-
onClick={this.onStartApplet}
785-
/>
786-
</div>
787-
)}
788802
</div>
789803
)}
790804
{(!this.state.ipynbs || this.state.ipynbs.length === 0) && (

0 commit comments

Comments
 (0)