@@ -21,6 +21,7 @@ import { teamsService } from "../service/public-api";
21
21
import { gitpodHostUrl } from "../service/service" ;
22
22
import { useCurrentUser } from "../user-context" ;
23
23
import { OrgSettingsPage } from "./OrgSettingsPage" ;
24
+ import { useToast } from "../components/toasts/Toasts" ;
24
25
25
26
export default function TeamSettingsPage ( ) {
26
27
const user = useCurrentUser ( ) ;
@@ -33,21 +34,31 @@ export default function TeamSettingsPage() {
33
34
const updateOrg = useUpdateOrgMutation ( ) ;
34
35
const { data : settings , isLoading } = useOrgSettingsQuery ( ) ;
35
36
const updateTeamSettings = useUpdateOrgSettingsMutation ( ) ;
37
+ const [ defaultWorkspaceImage , setDefaultWorkspaceImage ] = useState ( settings ?. defaultWorkspaceImage ?? "" ) ;
38
+ const { toast } = useToast ( ) ;
36
39
37
40
const handleUpdateTeamSettings = useCallback (
38
- ( newSettings : Partial < OrganizationSettings > ) => {
41
+ async ( newSettings : Partial < OrganizationSettings > ) => {
39
42
if ( ! org ?. id ) {
40
43
throw new Error ( "no organization selected" ) ;
41
44
}
42
45
if ( ! org . isOwner ) {
43
46
throw new Error ( "no organization settings change permission" ) ;
44
47
}
45
- updateTeamSettings . mutate ( {
46
- ...settings ,
47
- ...newSettings ,
48
- } ) ;
48
+ try {
49
+ await updateTeamSettings . mutateAsync ( {
50
+ ...settings ,
51
+ ...newSettings ,
52
+ } ) ;
53
+ if ( newSettings . defaultWorkspaceImage ) {
54
+ toast ( "Default workspace image has been updated." ) ;
55
+ }
56
+ } catch ( error ) {
57
+ console . error ( error ) ;
58
+ toast ( error . message || "Oh no, there was a problem with our service." ) ;
59
+ }
49
60
} ,
50
- [ updateTeamSettings , org ?. id , org ?. isOwner , settings ] ,
61
+ [ updateTeamSettings , org ?. id , org ?. isOwner , settings , toast ] ,
51
62
) ;
52
63
53
64
const close = ( ) => setModal ( false ) ;
@@ -132,8 +143,14 @@ export default function TeamSettingsPage() {
132
143
Update Organization
133
144
</ Button >
134
145
) }
146
+ </ form >
135
147
148
+ < form onSubmit = { ( ) => handleUpdateTeamSettings ( { defaultWorkspaceImage } ) } >
136
149
< Heading2 className = "pt-12" > Collaboration & Sharing </ Heading2 >
150
+ < Subheading className = "max-w-2xl" >
151
+ Choose which workspace images you want to use for your workspaces.
152
+ </ Subheading >
153
+
137
154
< CheckboxInputField
138
155
label = "Workspace Sharing"
139
156
hint = "Allow workspaces created within an Organization to share the workspace with any authenticated user."
@@ -145,13 +162,25 @@ export default function TeamSettingsPage() {
145
162
< Heading2 className = "pt-12" > Workspace Settings</ Heading2 >
146
163
< TextInputField
147
164
label = "Default Image"
148
- hint = "Default image of organization workspaces"
149
- value = { settings ?. defaultWorkspaceImage ?? "" }
150
- onChange = { ( value ) => handleUpdateTeamSettings ( { defaultWorkspaceImage : value } ) }
165
+ // TODO: ECR is dedicated only now
166
+ // TODO: Provide document links
167
+ hint = "Use any workspace image from Gitpod, or any image from your private ECR registry, e.g. <xyz>.amazonaws.com/<your-image-name:tag>. "
168
+ value = { defaultWorkspaceImage }
169
+ onChange = { setDefaultWorkspaceImage }
151
170
disabled = { isLoading || ! org ?. isOwner }
152
171
/>
153
- </ form >
154
172
173
+ { org ?. isOwner && (
174
+ < Button
175
+ htmlType = "submit"
176
+ size = "block"
177
+ className = "mt-4"
178
+ disabled = { ! org . isOwner || defaultWorkspaceImage . trim ( ) === "" }
179
+ >
180
+ Save
181
+ </ Button >
182
+ ) }
183
+ </ form >
155
184
{ user ?. organizationId !== org ?. id && org ?. isOwner && (
156
185
< >
157
186
< Heading2 className = "pt-12" > Delete Organization</ Heading2 >
0 commit comments