@@ -2,7 +2,7 @@ import { FC, useEffect, useRef } from 'react';
2
2
import { shallow } from 'zustand/shallow' ;
3
3
import { Braces , Plus } from 'lucide-react' ;
4
4
import { Tree , UncontrolledTreeEnvironment } from '@firecamp/ui/src/tree' ;
5
- import { Notes , Button } from '@firecamp/ui' ;
5
+ import { Notes } from '@firecamp/ui' ;
6
6
import { EEnvironmentScope } from '@firecamp/types' ;
7
7
import { Container , ProgressBar , Pane , ToolBar } from '@firecamp/ui' ;
8
8
import treeRenderer from './tree/itemRenderer' ;
@@ -30,7 +30,7 @@ export default EnvironmentSidebar;
30
30
const ProgressBarContainer = ( ) => {
31
31
const { isProgressing } = useEnvStore (
32
32
( s ) => ( {
33
- isProgressing : s . isProgressing ,
33
+ isProgressing : s . isProgressing
34
34
} ) ,
35
35
shallow
36
36
) ;
@@ -40,13 +40,11 @@ const ProgressBarContainer = () => {
40
40
const EnvironmentCollection = ( ) => {
41
41
const treeRef = useRef ( ) ;
42
42
const { open : openTab } = useTabStore . getState ( ) ;
43
- const { envTdpInstance, registerTDP, unRegisterTDP } = useEnvStore (
44
- ( s : IEnvironmentStore ) => ( {
45
- envTdpInstance : s . envTdpInstance ,
46
- registerTDP : s . registerTDP_ ,
47
- unRegisterTDP : s . unRegisterTDP_ ,
48
- } )
49
- ) ;
43
+ const { envTdpInstance, registerTDP, unRegisterTDP } = useEnvStore ( ( s : IEnvironmentStore ) => ( {
44
+ envTdpInstance : s . envTdpInstance ,
45
+ registerTDP : s . registerTDP_ ,
46
+ unRegisterTDP : s . unRegisterTDP_
47
+ } ) ) ;
50
48
const { createEnvironmentPrompt } = platformContext . platform ;
51
49
useEffect ( ( ) => {
52
50
registerTDP ( ) ;
@@ -55,8 +53,8 @@ const EnvironmentCollection = () => {
55
53
const openEnv = ( env ) => {
56
54
openTab ( env , { id : env . __ref . id , type : ETabEntityTypes . Environment } ) ;
57
55
} ;
58
- const openCreateColEnv = ( ) => { } ;
59
- const deleteEnv = ( ) => { } ;
56
+ const openCreateColEnv = ( ) => { } ;
57
+ const deleteEnv = ( ) => { } ;
60
58
61
59
if ( ! envTdpInstance ) return < > </ > ;
62
60
return (
@@ -94,16 +92,11 @@ const EnvironmentCollection = () => {
94
92
...props ,
95
93
openEnv : openEnv ,
96
94
openCreateEnv : openCreateColEnv ,
97
- deleteEnv,
95
+ deleteEnv
98
96
} )
99
97
}
100
98
>
101
- < Tree
102
- treeId = "tree-1"
103
- rootItem = "root"
104
- treeLabel = "Tree Example"
105
- ref = { treeRef }
106
- />
99
+ < Tree treeId = "tree-1" rootItem = "root" treeLabel = "Tree Example" ref = { treeRef } />
107
100
</ UncontrolledTreeEnvironment >
108
101
</ div >
109
102
) ;
@@ -114,13 +107,14 @@ const EnvironmentCollection = () => {
114
107
115
108
const CollectionScopedEnvCollection = ( ) => {
116
109
const treeRef = useRef ( ) ;
117
- const { envTdpInstance, registerTDP, unRegisterTDP, deleteEnvironment } =
118
- useEnvStore ( ( s : IEnvironmentStore ) => ( {
110
+ const { envTdpInstance, registerTDP, unRegisterTDP, deleteEnvironment } = useEnvStore (
111
+ ( s : IEnvironmentStore ) => ( {
119
112
envTdpInstance : s . colEnvTdpInstance ,
120
113
registerTDP : s . registerTDP ,
121
114
unRegisterTDP : s . unRegisterTDP ,
122
- deleteEnvironment : s . deleteEnvironment ,
123
- } ) ) ;
115
+ deleteEnvironment : s . deleteEnvironment
116
+ } )
117
+ ) ;
124
118
useEffect ( ( ) => {
125
119
registerTDP ( ) ;
126
120
return ( ) => unRegisterTDP ( ) ;
@@ -130,27 +124,25 @@ const CollectionScopedEnvCollection = () => {
130
124
platformContext . app . modals . openCloneEnvironment ( {
131
125
scope : EEnvironmentScope . Collection ,
132
126
collectionId : colId ,
133
- envId,
127
+ envId
134
128
} ) ;
135
129
} ;
136
130
137
- const openCreateColEnv = ( ) => { } ;
131
+ const openCreateColEnv = ( ) => { } ;
138
132
139
133
const deleteEnv = ( envId : string ) => {
140
134
platformContext . window
141
135
. confirm ( {
142
136
message : 'Are you sure to delete the environment?' ,
143
- labels : { confirm : 'Yes, delete it.' } ,
137
+ labels : { confirm : 'Yes, delete it.' }
144
138
} )
145
139
. then ( ( ) => {
146
140
deleteEnvironment ( envId )
147
141
. then ( ( r ) => {
148
142
return r ;
149
143
} )
150
144
. catch ( ( e ) => {
151
- platformContext . app . notify . alert (
152
- e . response ?. data ?. message || e . message
153
- ) ;
145
+ platformContext . app . notify . alert ( e . response ?. data ?. message || e . message ) ;
154
146
} ) ;
155
147
} ) ;
156
148
} ;
@@ -195,16 +187,11 @@ const CollectionScopedEnvCollection = () => {
195
187
...props ,
196
188
openEnv : openColEnv ,
197
189
openCreateEnv : openCreateColEnv ,
198
- deleteEnv,
190
+ deleteEnv
199
191
} )
200
192
}
201
193
>
202
- < Tree
203
- treeId = "tree-1"
204
- rootItem = "root"
205
- treeLabel = "Tree Example"
206
- ref = { treeRef }
207
- />
194
+ < Tree treeId = "tree-1" rootItem = "root" treeLabel = "Tree Example" ref = { treeRef } />
208
195
</ UncontrolledTreeEnvironment >
209
196
</ >
210
197
) ;
@@ -217,31 +204,19 @@ const Globals = () => {
217
204
const globalEnv = useEnvStore ( ( s ) => s . globalEnv , shallow ) ;
218
205
const { open : openTab } = useTabStore . getState ( ) ;
219
206
const openEnv = ( env ) => {
220
- openTab (
221
- { ...env } ,
222
- { id : env . __ref . id , type : ETabEntityTypes . Environment }
223
- ) ;
207
+ openTab ( { ...env } , { id : env . __ref . id , type : ETabEntityTypes . Environment } ) ;
224
208
} ;
225
209
226
210
return (
227
211
< div className = "rct-tree-item-li focus:rct-tree-item-li-focused border-b border-app-border" >
228
- < div className = "px-2 mt-5 mb-1 rct-tree-item-title-container focus:rct-tree-item-title-container-focused hover:rct-tree-item-title-container-focused !opacity-100 cursor-pointer" >
212
+ < div
213
+ className = "px-2 mt-5 mb-1 rct-tree-item-title-container focus:rct-tree-item-title-container-focused hover:rct-tree-item-title-container-focused !opacity-100 cursor-pointer"
214
+ onClick = { ( ) => openEnv ( globalEnv ) }
215
+ >
229
216
< Braces className = "flex-none my-0.5" size = { 18 } opacity = { 1 } />
230
217
< span className = "w-full overflow-hidden text-ellipsis items-center block pl-1 text-base" >
231
218
{ globalEnv ?. name }
232
219
</ span >
233
- < div className = "flex ml-auto rct-tree-item-li-action items-center" >
234
- < Button
235
- text = { 'Open' }
236
- onClick = { ( ) => openEnv ( globalEnv ) }
237
- classNames = { {
238
- root : 'hover:!bg-focusColor !text-app-foreground-inactive'
239
- } }
240
- ghost
241
- compact
242
- xs
243
- />
244
- </ div >
245
220
</ div >
246
221
</ div >
247
222
) ;
0 commit comments