3
3
* License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
4
4
*/
5
5
6
- import { Alert , Divider } from "antd" ;
6
+ import { Alert , Button , Divider } from "antd" ;
7
7
import { join } from "path" ;
8
8
import {
9
9
Col ,
@@ -16,6 +16,7 @@ import {
16
16
} from "react-bootstrap" ;
17
17
18
18
import {
19
+ CSS ,
19
20
React ,
20
21
redux ,
21
22
useMemo ,
@@ -27,6 +28,7 @@ import {
27
28
Gap ,
28
29
Icon ,
29
30
Markdown ,
31
+ Paragraph ,
30
32
SearchInput ,
31
33
} from "@cocalc/frontend/components" ;
32
34
import {
@@ -49,22 +51,22 @@ import {
49
51
50
52
const BINDER_URL = "https://mybinder.readthedocs.io/en/latest/" ;
51
53
52
- const cs_list_style : Readonly < React . CSSProperties > = Object . freeze ( {
54
+ const CS_LIST_STYLE : CSS = {
53
55
height : "250px" ,
54
56
overflowX : "hidden" as "hidden" ,
55
57
overflowY : "scroll" as "scroll" ,
56
58
border : `1px solid ${ COLORS . GRAY_LL } ` ,
57
59
borderRadius : "5px" ,
58
60
marginBottom : "0px" ,
59
- } ) ;
61
+ } as const ;
60
62
61
- const entries_item_style : Readonly < React . CSSProperties > = Object . freeze ( {
63
+ const ENTRIES_ITEM_STYLE : CSS = {
62
64
width : "100%" ,
63
65
margin : "2px 0px" ,
64
66
padding : "5px" ,
65
67
border : "none" ,
66
68
textAlign : "left" as "left" ,
67
- } ) ;
69
+ } as const ;
68
70
69
71
export interface SoftwareEnvironmentState {
70
72
image_selected ?: string ;
@@ -109,7 +111,9 @@ export const SoftwareEnvironment: React.FC<Props> = (props: Props) => {
109
111
"compute_images" ,
110
112
"images" ,
111
113
) ;
114
+
112
115
const customize_kucalc = useTypedRedux ( "customize" , "kucalc" ) ;
116
+ const onCoCalcCom = customize_kucalc === KUCALC_COCALC_COM ;
113
117
const customize_software = useTypedRedux ( "customize" , "software" ) ;
114
118
const [ dflt_software_img , software_images ] = useMemo (
115
119
( ) => [
@@ -188,7 +192,7 @@ export const SoftwareEnvironment: React.FC<Props> = (props: Props) => {
188
192
key = { id }
189
193
active = { image_selected === id }
190
194
onClick = { ( ) => set_state ( id , display , image_type ) }
191
- style = { entries_item_style }
195
+ style = { ENTRIES_ITEM_STYLE }
192
196
bsSize = { "small" }
193
197
>
194
198
{ display }
@@ -198,7 +202,7 @@ export const SoftwareEnvironment: React.FC<Props> = (props: Props) => {
198
202
. toArray ( ) ;
199
203
200
204
if ( entries . length > 0 ) {
201
- return < ListGroup style = { cs_list_style } > { entries } </ ListGroup > ;
205
+ return < ListGroup style = { CS_LIST_STYLE } > { entries } </ ListGroup > ;
202
206
} else {
203
207
if ( search_img . length > 0 ) {
204
208
return < div > No search hits.</ div > ;
@@ -322,8 +326,55 @@ export const SoftwareEnvironment: React.FC<Props> = (props: Props) => {
322
326
) ;
323
327
}
324
328
329
+ function render_onprem ( ) {
330
+ const selected = image_selected ?? dflt_software_img ;
331
+ return (
332
+ < >
333
+ < Paragraph >
334
+ Select the software enviornment. Either go with the default
335
+ environment, or select one of the more specialized ones. Whatever you
336
+ pick, you can change it later in Project Settings → Control → Software
337
+ Environment at any time.
338
+ </ Paragraph >
339
+ < Paragraph >
340
+ < ComputeImageSelector
341
+ size = { "middle" }
342
+ selected_image = { selected }
343
+ layout = { "horizontal" }
344
+ onSelect = { ( img ) => {
345
+ const display = software_images . get ( img ) ?. get ( "title" ) ;
346
+ set_state ( img , display , "standard" ) ;
347
+ } }
348
+ />
349
+ </ Paragraph >
350
+ < Paragraph >
351
+ { selected !== dflt_software_img ? (
352
+ < Alert
353
+ type = "info"
354
+ banner
355
+ message = {
356
+ < >
357
+ You've selected a non-standard image:{ " " }
358
+ < Button
359
+ size = "small"
360
+ type = "link"
361
+ onClick = { ( ) => {
362
+ set_state ( dflt_software_img , undefined , "standard" ) ;
363
+ } }
364
+ >
365
+ Reset
366
+ </ Button >
367
+ </ >
368
+ }
369
+ />
370
+ ) : undefined }
371
+ </ Paragraph >
372
+ </ >
373
+ ) ;
374
+ }
375
+
325
376
function render_default_explanation ( ) : JSX . Element {
326
- if ( customize_kucalc === KUCALC_COCALC_COM ) {
377
+ if ( onCoCalcCom ) {
327
378
return (
328
379
< >
329
380
< b > Default</ b > : large repository of software, well tested – maintained
@@ -365,7 +416,7 @@ export const SoftwareEnvironment: React.FC<Props> = (props: Props) => {
365
416
}
366
417
367
418
function render_standard_explanation ( ) : JSX . Element {
368
- if ( customize_kucalc === KUCALC_COCALC_COM ) {
419
+ if ( onCoCalcCom ) {
369
420
return (
370
421
< >
371
422
< b > Standard</ b > : upcoming and archived versions of the "Default"
@@ -466,13 +517,19 @@ export const SoftwareEnvironment: React.FC<Props> = (props: Props) => {
466
517
function render_type_selection ( ) {
467
518
return (
468
519
< >
469
- { showTitle && < ControlLabel > Software environment</ ControlLabel > }
470
-
471
- < FormGroup >
472
- { render_default ( ) }
473
- { render_standard ( ) }
474
- { render_custom ( ) }
475
- </ FormGroup >
520
+ { showTitle ? (
521
+ < ControlLabel > Software environment</ ControlLabel >
522
+ ) : undefined }
523
+
524
+ { onCoCalcCom ? (
525
+ < FormGroup >
526
+ { render_default ( ) }
527
+ { render_standard ( ) }
528
+ { render_custom ( ) }
529
+ </ FormGroup >
530
+ ) : (
531
+ render_onprem ( )
532
+ ) }
476
533
</ >
477
534
) ;
478
535
}
@@ -492,11 +549,15 @@ export const SoftwareEnvironment: React.FC<Props> = (props: Props) => {
492
549
{ render_type_selection ( ) }
493
550
</ Col >
494
551
495
- { render_divider ( ) }
496
- { render_standard_image_selector ( ) }
497
- < Col sm = { 6 } > { render_custom_images ( ) } </ Col >
498
- < Col sm = { 6 } > { render_selected_custom_image_info ( ) } </ Col >
499
- < Col sm = { 12 } > { render_custom_images_info ( ) } </ Col >
552
+ { onCoCalcCom ? (
553
+ < >
554
+ { render_divider ( ) }
555
+ { render_standard_image_selector ( ) }
556
+ < Col sm = { 6 } > { render_custom_images ( ) } </ Col >
557
+ < Col sm = { 6 } > { render_selected_custom_image_info ( ) } </ Col >
558
+ < Col sm = { 12 } > { render_custom_images_info ( ) } </ Col >
559
+ </ >
560
+ ) : undefined }
500
561
</ Row >
501
562
) ;
502
563
} ;
0 commit comments