Skip to content

Commit

Permalink
Fix default workspace image setup
Browse files Browse the repository at this point in the history
  • Loading branch information
mustard-mh committed Sep 18, 2023
1 parent 1941376 commit c2df290
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import { getGitpodService } from "../../service/service";
import { getOrgSettingsQueryKey, OrgSettingsResult } from "./org-settings-query";
import { useCurrentOrg } from "./orgs-query";

type UpdateOrganizationSettingsArgs = Pick<OrganizationSettings, "workspaceSharingDisabled" | "defaultWorkspaceImage">;
type UpdateOrganizationSettingsArgs = Partial<
Pick<OrganizationSettings, "workspaceSharingDisabled" | "defaultWorkspaceImage">
>;

export const useUpdateOrgSettingsMutation = () => {
const queryClient = useQueryClient();
Expand Down
5 changes: 3 additions & 2 deletions components/dashboard/src/teams/TeamSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ function OrgSettingsForm(props: { org?: OrganizationInfo }) {
}
try {
await updateTeamSettings.mutateAsync({
...settings,
// We don't want to have original setting passed, since defaultWorkspaceImage could be undefined
// to bring compatibility when we're going to change Gitpod install value's defaultImage setting
...newSettings,
});
if (newSettings.defaultWorkspaceImage) {
Expand All @@ -205,7 +206,7 @@ function OrgSettingsForm(props: { org?: OrganizationInfo }) {
);
}
},
[updateTeamSettings, org?.id, org?.isOwner, settings, toast],
[updateTeamSettings, org?.id, org?.isOwner, toast],
);

return (
Expand Down
8 changes: 6 additions & 2 deletions components/gitpod-db/src/typeorm/team-db-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,12 @@ export class TeamDBImpl extends TransactionalDBImpl<TeamDB> implements TeamDB {
orgId,
});
} else {
team.workspaceSharingDisabled = settings.workspaceSharingDisabled;
team.defaultWorkspaceImage = settings.defaultWorkspaceImage;
if (settings.workspaceSharingDisabled) {
team.workspaceSharingDisabled = settings.workspaceSharingDisabled;
}
if (settings.defaultWorkspaceImage) {
team.defaultWorkspaceImage = settings.defaultWorkspaceImage;
}
repo.save(team);
}
}
Expand Down
3 changes: 0 additions & 3 deletions components/server/src/orgs/organization-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,6 @@ export class OrganizationService {

async updateSettings(userId: string, orgId: string, settings: OrganizationSettings): Promise<OrganizationSettings> {
await this.auth.checkPermissionOnOrganization(userId, "write_settings", orgId);
if (!settings.defaultWorkspaceImage) {
settings.defaultWorkspaceImage = this.config.workspaceDefaults.workspaceImage;
}
await this.teamDB.setOrgSettings(orgId, settings);
return settings;
}
Expand Down

0 comments on commit c2df290

Please sign in to comment.