File tree Expand file tree Collapse file tree 3 files changed +35
-5
lines changed
flows/pipes/RawFluxEditor Expand file tree Collapse file tree 3 files changed +35
-5
lines changed Original file line number Diff line number Diff line change @@ -82,10 +82,22 @@ const Query: FC<PipeProp> = ({Context}) => {
8282 text = ` |> ${ fn . example } `
8383 }
8484
85+ const getHeader = fn => {
86+ let importStatement = null
87+
88+ if ( fn . package ) {
89+ importStatement = `import "${ fn . package } "`
90+ if ( isFlagEnabled ( 'fluxDynamicDocs' ) && fn . path . includes ( '/' ) ) {
91+ importStatement = `import "${ fn . path } "`
92+ }
93+ }
94+ return importStatement
95+ }
96+
8597 const options = {
8698 text,
8799 type : InjectionType . OnOwnLine ,
88- header : ! ! fn . package ? `import " ${ fn . package } "` : null ,
100+ header : getHeader ( fn ) ,
89101 }
90102 inject ( options )
91103 } ,
Original file line number Diff line number Diff line change @@ -143,7 +143,8 @@ const TimeMachineFluxEditor: FC = () => {
143143 ]
144144 const importStatement = generateImport (
145145 func . package ,
146- editorInstance . getValue ( )
146+ editorInstance . getValue ( ) ,
147+ func as FluxFunction
147148 )
148149 if ( importStatement ) {
149150 edits . unshift ( {
Original file line number Diff line number Diff line change 11// Constants
2+ import { CLOUD } from 'src/shared/constants'
23import { FROM , UNION } from 'src/shared/constants/fluxFunctions'
34
5+ // Types
6+ import { FluxFunction } from 'src/types/shared'
7+
8+ // Utils
9+ import { isFlagEnabled } from 'src/shared/utils/featureFlag'
10+
411export const functionRequiresNewLine = ( funcName : string ) : boolean => {
512 switch ( funcName ) {
613 case FROM . name :
@@ -14,9 +21,19 @@ export const functionRequiresNewLine = (funcName: string): boolean => {
1421
1522export const generateImport = (
1623 funcPackage : string ,
17- script : string
18- ) : false | string => {
19- const importStatement = `import "${ funcPackage } "`
24+ script : string ,
25+ func ?: FluxFunction
26+ ) : false | string | FluxFunction => {
27+ let importStatement
28+
29+ importStatement = `import "${ funcPackage } "`
30+
31+ if ( CLOUD && isFlagEnabled ( 'fluxDynamicDocs' ) ) {
32+ // if package is nested, use func.path to import.
33+ if ( func . path . includes ( '/' ) ) {
34+ importStatement = `import "${ func . path } "`
35+ }
36+ }
2037
2138 if ( ! funcPackage || script . includes ( importStatement ) ) {
2239 return false
You can’t perform that action at this time.
0 commit comments