From 97ae60ffc83f179fa719af177348fbe84a89c120 Mon Sep 17 00:00:00 2001 From: Huiwen Date: Mon, 18 Sep 2023 19:06:08 +0000 Subject: [PATCH] Allow empty image to set to default one --- components/gitpod-db/src/typeorm/entity/db-team-settings.ts | 4 ++-- components/gitpod-db/src/typeorm/team-db-impl.ts | 5 ++++- components/gitpod-protocol/go/gitpod-service.go | 4 ++-- components/gitpod-protocol/src/teams-projects-protocol.ts | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/components/gitpod-db/src/typeorm/entity/db-team-settings.ts b/components/gitpod-db/src/typeorm/entity/db-team-settings.ts index f4945189125655..8848b94fd9512c 100644 --- a/components/gitpod-db/src/typeorm/entity/db-team-settings.ts +++ b/components/gitpod-db/src/typeorm/entity/db-team-settings.ts @@ -18,8 +18,8 @@ export class DBOrgSettings implements OrganizationSettings { }) workspaceSharingDisabled?: boolean; - @Column() - defaultWorkspaceImage?: string; // TODO: migration + @Column("varchar", { nullable: true }) + defaultWorkspaceImage?: string | null; // TODO: migration @Column() deleted: boolean; diff --git a/components/gitpod-db/src/typeorm/team-db-impl.ts b/components/gitpod-db/src/typeorm/team-db-impl.ts index af6b4b77d7b9d9..74b2f29aa26ae5 100644 --- a/components/gitpod-db/src/typeorm/team-db-impl.ts +++ b/components/gitpod-db/src/typeorm/team-db-impl.ts @@ -381,7 +381,10 @@ export class TeamDBImpl extends TransactionalDBImpl implements TeamDB { if (settings.workspaceSharingDisabled != undefined) { update.workspaceSharingDisabled = settings.workspaceSharingDisabled; } - if (settings.defaultWorkspaceImage) { + // Set to null if defaultWorkspaceImage is empty string, so that we can fallback to default when getting org settings + if (settings.defaultWorkspaceImage?.trim() === "") { + update.defaultWorkspaceImage = null; + } else if (settings.defaultWorkspaceImage != undefined) { update.defaultWorkspaceImage = settings.defaultWorkspaceImage; } if (!team) { diff --git a/components/gitpod-protocol/go/gitpod-service.go b/components/gitpod-protocol/go/gitpod-service.go index 9d1dea0d722def..eac97d4841c235 100644 --- a/components/gitpod-protocol/go/gitpod-service.go +++ b/components/gitpod-protocol/go/gitpod-service.go @@ -2256,8 +2256,8 @@ type TeamMembershipInvite struct { } type OrganizationSettings struct { - WorkspaceSharingDisabled bool `json:"workspaceSharingDisabled,omitempty"` - DefaultWorkspaceImage string `json:"defaultWorkspaceImage,omitempty"` + WorkspaceSharingDisabled bool `json:"workspaceSharingDisabled,omitempty"` + DefaultWorkspaceImage *string `json:"defaultWorkspaceImage,omitempty"` } type Project struct { diff --git a/components/gitpod-protocol/src/teams-projects-protocol.ts b/components/gitpod-protocol/src/teams-projects-protocol.ts index 6f5044c6f4429c..0a0c54f2947b88 100644 --- a/components/gitpod-protocol/src/teams-projects-protocol.ts +++ b/components/gitpod-protocol/src/teams-projects-protocol.ts @@ -168,7 +168,7 @@ export interface Organization { export interface OrganizationSettings { workspaceSharingDisabled?: boolean; - defaultWorkspaceImage?: string; + defaultWorkspaceImage?: string | null; } export type TeamMemberRole = OrgMemberRole;