1
1
import { Component , h , Host , Prop , State } from "@stencil/core" ;
2
- import { gb } from "../../util/util" ;
3
-
4
- const ATLAS_LOCAL_STORAGE_KEY = "pulumi-ai-use-atlas" ;
5
-
6
2
7
3
@Component ( {
8
4
tag : "copilot-sidebar" ,
9
5
styleUrl : "copilot-sidebar.css" ,
10
6
shadow : false ,
11
7
} )
12
8
export class CopilotSidebar {
13
-
14
9
//
15
10
// Props
16
11
//
17
12
18
- // The copilotSrc is URL where the copilot sidebar is hosted
19
- @Prop ( )
20
- copilotSrc : string ;
21
-
22
13
// The atlasUrl is the URL where the Atlas web component is hosted
23
14
@Prop ( )
24
15
atlasUrl : string ;
@@ -27,26 +18,12 @@ export class CopilotSidebar {
27
18
// Internal state
28
19
//
29
20
30
- // Whether to show the sidebar (growthbook flag)
31
- @State ( )
32
- showSidebar = false ;
33
-
34
- // Whether to show the Atlas web component (local storage flag)
35
- @State ( )
36
- showAtlas = false ;
37
-
38
21
// Whether the Atlas scripts have been loaded
39
22
@State ( )
40
23
atlasScriptsLoaded = false ;
41
24
42
25
async componentWillLoad ( ) {
43
- this . showSidebar = gb . isOn ( "copilot-on-docs" ) ;
44
- gb . setRenderer ( ( ) => ( this . showSidebar = gb . isOn ( "copilot-on-docs" ) ) ) ;
45
-
46
- this . showAtlas = this . atlasUrl && window . localStorage . getItem ( ATLAS_LOCAL_STORAGE_KEY ) !== "false" ;
47
- if ( this . showAtlas ) {
48
- await this . loadAtlasScripts ( ) ;
49
- }
26
+ await this . loadAtlasScripts ( ) ;
50
27
}
51
28
52
29
private async loadAtlasScripts ( ) {
@@ -80,26 +57,13 @@ export class CopilotSidebar {
80
57
}
81
58
82
59
render ( ) {
83
- if ( this . showAtlas ) {
84
- if ( ! this . atlasScriptsLoaded ) {
85
- return < Host > </ Host > ;
86
- }
87
-
88
- return (
89
- < Host >
90
- < pulumi-copilot hostApp = "docs" apiUrl = { this . atlasUrl } />
91
- </ Host >
92
- ) ;
93
- }
94
-
95
- if ( ! this . showSidebar ) {
60
+ if ( ! this . atlasScriptsLoaded ) {
96
61
return < Host > </ Host > ;
97
62
}
98
63
99
64
return (
100
65
< Host >
101
- < aside id = "ai-sidebar-target" > </ aside >
102
- < iframe id = "ai-sidebar-host" src = { this . copilotSrc } > </ iframe >
66
+ < pulumi-copilot hostApp = "docs" apiUrl = { this . atlasUrl } />
103
67
</ Host >
104
68
) ;
105
69
}
0 commit comments