1
1
import { AppState } from "../reducers" ;
2
+ import { Environment } from "api/enterpriseApi" ;
2
3
3
4
export const selectEnterpriseEditionStatus = ( state : AppState ) =>
4
5
state . ui . enterprise ?. enterprise ?. eeActive ?? false ;
@@ -25,3 +26,44 @@ export const getGlobalBrandingSetting = (state: AppState) => {
25
26
export const getWorkspaceBrandingSetting = ( state : AppState ) => {
26
27
return state . ui . enterprise ?. workspaceBranding ;
27
28
}
29
+
30
+ /* ==============================================
31
+ Environment selectors
32
+ ==============================================
33
+ */
34
+
35
+ // Select all environments
36
+ export const selectEnvironments = ( state : AppState ) : Environment [ ] =>
37
+ state . ui . enterprise ?. environments ?. list || [ ] ;
38
+
39
+ // Select loading state for environments
40
+ export const selectEnvironmentsLoading = ( state : AppState ) : boolean =>
41
+ state . ui . enterprise ?. environments ?. loading || false ;
42
+
43
+ // Select any error that occurred while fetching environments
44
+ export const selectEnvironmentsError = ( state : AppState ) : any =>
45
+ state . ui . enterprise ?. environments ?. error ;
46
+
47
+ // Select the currently selected environment
48
+ export const selectCurrentEnvironment = ( state : AppState ) : Environment | null =>
49
+ state . ui . enterprise ?. environments ?. currentEnvironment ;
50
+
51
+ // Select a specific environment by ID
52
+ export const selectEnvironmentById = ( state : AppState , environmentId : string ) : Environment | undefined =>
53
+ state . ui . enterprise ?. environments ?. list . find ( env => env . environmentId === environmentId ) ;
54
+
55
+ // Select environment creation status
56
+ export const selectEnvironmentCreating = ( state : AppState ) : boolean =>
57
+ state . ui . enterprise ?. environments ?. creating || false ;
58
+
59
+ // Select environment update status
60
+ export const selectEnvironmentUpdating = ( state : AppState ) : boolean =>
61
+ state . ui . enterprise ?. environments ?. updating || false ;
62
+
63
+ // Select environment deletion status
64
+ export const selectEnvironmentDeleting = ( state : AppState ) : boolean =>
65
+ state . ui . enterprise ?. environments ?. deleting || false ;
66
+
67
+ // Select API key update status
68
+ export const selectApiKeyUpdating = ( state : AppState ) : boolean =>
69
+ state . ui . enterprise ?. environments ?. updatingApiKey || false ;
0 commit comments