1- import { Component , useEffect } from 'react' ;
1+ import { Component , useEffect , FunctionComponent } from 'react' ;
22import {
33 CodeOutlined ,
44 CodeSandboxOutlined ,
@@ -45,37 +45,82 @@ const StyledCard: any = styled(Card)`
4545 }
4646` ;
4747
48+ type UnsupportedPlaceholder = FunctionComponent < { framework : string } > ;
4849type FrameworkDescriptor = {
4950 id : string ;
5051 title : string ;
5152 docsLink ?: string ;
52- supported ?: boolean ;
53+ placeholder ?: UnsupportedPlaceholder ;
5354 scaffoldingSupported ?: boolean ;
5455} ;
5556
57+ const UnsupportedFrameworkPlaceholder : UnsupportedPlaceholder = ( { framework } ) => (
58+ < h2 style = { { padding : 24 , textAlign : 'center' } } >
59+ We do not support
60+ Vanilla JavaScript
61+ code generation here yet.
62+ < br />
63+ Please refer to
64+ < a
65+ href = "https://cube.dev/docs/@cubejs-client-core"
66+ target = "_blank"
67+ rel = "noopener noreferrer"
68+ onClick = { ( ) =>
69+ playgroundAction ( 'Unsupported Framework Docs' , { framework } )
70+ }
71+ >
72+ Vanilla JavaScript
73+ docs
74+ </ a >
75+ to see on how to use it with Cube.js.
76+ </ h2 >
77+ ) ;
78+
79+ const BIPlaceholder : UnsupportedPlaceholder = ( ) => (
80+ < h2 style = { { padding : 24 , textAlign : 'center' } } >
81+ You can connect Cube to any Business Intelligence tool through the Cube SQL API.
82+ < br />
83+ Please refer to
84+ < a
85+ href = "https://cube.dev/docs/backend/sql"
86+ target = "_blank"
87+ rel = "noopener noreferrer"
88+ onClick = { ( ) =>
89+ playgroundAction ( 'BI Docs' )
90+ }
91+ >
92+ Cube SQL
93+ docs
94+ </ a >
95+ to learn more.
96+ </ h2 >
97+ ) ;
98+
5699export const frameworks : FrameworkDescriptor [ ] = [
57100 {
58101 id : 'react' ,
59102 title : 'React' ,
60- supported : true ,
61103 scaffoldingSupported : true ,
62104 } ,
63105 {
64106 id : 'angular' ,
65107 title : 'Angular' ,
66- supported : true ,
67108 scaffoldingSupported : true ,
68109 } ,
69110 {
70111 id : 'vue' ,
71112 title : 'Vue' ,
72- supported : true ,
73113 scaffoldingSupported : true ,
74114 } ,
75115 {
76116 id : 'vanilla' ,
77117 title : 'Vanilla JavaScript' ,
78- docsLink : 'https://cube.dev/docs/@cubejs-client-core' ,
118+ placeholder : UnsupportedFrameworkPlaceholder ,
119+ } ,
120+ {
121+ id : 'bi' ,
122+ title : 'BI' ,
123+ placeholder : BIPlaceholder ,
79124 } ,
80125] ;
81126
@@ -275,7 +320,7 @@ class ChartContainer extends Component<
275320 { chartLibrariesMenu ? (
276321 < Dropdown
277322 overlay = { chartLibrariesMenu }
278- disabled = { ! frameworkItem ?. supported || isFetchingMeta }
323+ disabled = { ! ! frameworkItem ?. placeholder || isFetchingMeta }
279324 >
280325 < Button data-testid = "charting-library-btn" size = "small" >
281326 { currentLibraryItem ?. title }
@@ -290,7 +335,7 @@ class ChartContainer extends Component<
290335 data-testid = "chart-btn"
291336 size = "small"
292337 type = { ! showCode ? 'primary' : 'default' }
293- disabled = { ! frameworkItem ?. supported || isFetchingMeta }
338+ disabled = { ! ! frameworkItem ?. placeholder || isFetchingMeta }
294339 onClick = { ( ) => {
295340 playgroundAction ( 'Show Chart' ) ;
296341 this . setState ( {
@@ -305,7 +350,7 @@ class ChartContainer extends Component<
305350 data-testid = "json-query-btn"
306351 size = "small"
307352 type = { showCode === 'query' ? 'primary' : 'default' }
308- disabled = { ! frameworkItem ?. supported || isFetchingMeta }
353+ disabled = { ! ! frameworkItem ?. placeholder || isFetchingMeta }
309354 onClick = { ( ) => {
310355 playgroundAction ( 'Show Query' ) ;
311356 this . setState ( {
@@ -321,7 +366,7 @@ class ChartContainer extends Component<
321366 icon = { < CodeOutlined /> }
322367 size = "small"
323368 type = { showCode === 'code' ? 'primary' : 'default' }
324- disabled = { ! frameworkItem ?. supported || isFetchingMeta }
369+ disabled = { ! ! frameworkItem ?. placeholder || isFetchingMeta }
325370 onClick = { ( ) => {
326371 playgroundAction ( 'Show Code' ) ;
327372 this . setState ( { showCode : 'code' } ) ;
@@ -335,7 +380,7 @@ class ChartContainer extends Component<
335380 icon = { < QuestionCircleOutlined /> }
336381 size = "small"
337382 type = { showCode === 'sql' ? 'primary' : 'default' }
338- disabled = { ! frameworkItem ?. supported || isFetchingMeta }
383+ disabled = { ! ! frameworkItem ?. placeholder || isFetchingMeta }
339384 onClick = { ( ) => {
340385 playgroundAction ( 'Show SQL' ) ;
341386 this . setState ( { showCode : 'sql' } ) ;
@@ -349,7 +394,7 @@ class ChartContainer extends Component<
349394 icon = { < SyncOutlined /> }
350395 size = "small"
351396 type = { showCode === 'cache' ? 'primary' : 'default' }
352- disabled = { ! frameworkItem ?. supported || isFetchingMeta }
397+ disabled = { ! ! frameworkItem ?. placeholder || isFetchingMeta }
353398 onClick = { ( ) => {
354399 playgroundAction ( 'Show Cache' ) ;
355400 this . setState ( {
@@ -366,7 +411,7 @@ class ChartContainer extends Component<
366411 icon = { < CodeSandboxOutlined /> }
367412 size = "small"
368413 htmlType = "submit"
369- disabled = { ! frameworkItem ?. supported || isFetchingMeta }
414+ disabled = { ! ! frameworkItem ?. placeholder || isFetchingMeta }
370415 onClick = { ( ) => playgroundAction ( 'Open Code Sandbox' ) }
371416 >
372417 Edit
@@ -409,7 +454,7 @@ class ChartContainer extends Component<
409454 icon = { < PlusOutlined /> }
410455 size = "small"
411456 loading = { addingToDashboard }
412- disabled = { ! frameworkItem ?. supported || isFetchingMeta }
457+ disabled = { ! ! frameworkItem ?. placeholder || isFetchingMeta }
413458 type = "primary"
414459 >
415460 { addingToDashboard
@@ -424,28 +469,9 @@ class ChartContainer extends Component<
424469 const queryText = JSON . stringify ( query , null , 2 ) ;
425470
426471 const renderChart = ( ) => {
427- if ( ! frameworkItem ?. supported ) {
428- return (
429- < h2 style = { { padding : 24 , textAlign : 'center' } } >
430- We do not support
431- { frameworkItem ?. title }
432- code generation here yet.
433- < br />
434- Please refer to
435- < a
436- href = { frameworkItem ?. docsLink }
437- target = "_blank"
438- rel = "noopener noreferrer"
439- onClick = { ( ) =>
440- playgroundAction ( 'Unsupported Framework Docs' , { framework } )
441- }
442- >
443- { frameworkItem ?. title }
444- docs
445- </ a >
446- to see on how to use it with Cube.js.
447- </ h2 >
448- ) ;
472+ if ( frameworkItem ?. placeholder ) {
473+ const Placeholder = frameworkItem . placeholder ;
474+ return < Placeholder framework = { framework } /> ;
449475 } else if ( showCode === 'code' ) {
450476 if ( error ) {
451477 return < FatalError error = { error } /> ;
0 commit comments