Skip to content

Commit 0e3fba2

Browse files
committed
Refactor organization welcome message type definitions
Restructure the protobuf definitions for organization onboarding settings and welcome messages, including: - Separate OnboardingSettings from OrganizationSettings - Clarify field descriptions - Add validation for featuredMemberResolvedAvatarUrl - Update type references across multiple components Tool: gitpod/catfood.gitpod.cloud
1 parent f35abe8 commit 0e3fba2

File tree

9 files changed

+7881
-9878
lines changed

9 files changed

+7881
-9878
lines changed

components/dashboard/src/data/organizations/update-org-settings-mutation.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ export const useUpdateOrgSettingsMutation = () => {
7373
onboardingSettings: {
7474
...onboardingSettings,
7575
updateRecommendedRepositories: !!onboardingSettings?.recommendedRepositories,
76+
welcomeMessage: {
77+
...onboardingSettings?.welcomeMessage,
78+
featuredMemberResolvedAvatarUrl: undefined, // This field is not allowed to be set in the request.
79+
},
7680
},
7781
annotateGitCommits,
7882
});

components/dashboard/src/teams/onboarding/OrgMemberAvatarInput.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
import { useState } from "react";
88
import { useListOrganizationMembers } from "../../data/organizations/members-query";
99

10-
import type { OrganizationSettings_OnboardingSettings_WelcomeMessage } from "@gitpod/public-api/lib/gitpod/v1/organization_pb";
10+
import type { OnboardingSettings_WelcomeMessage } from "@gitpod/public-api/lib/gitpod/v1/organization_pb";
1111
import { Button } from "@podkit/buttons/Button";
1212
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@podkit/dropdown/DropDown";
1313

1414
type Props = {
15-
settings: OrganizationSettings_OnboardingSettings_WelcomeMessage | undefined;
15+
settings: OnboardingSettings_WelcomeMessage | undefined;
1616
setFeaturedMemberId: (featuredMemberId: string | undefined) => void;
1717
};
1818
export const OrgMemberAvatarInput = ({ settings, setFeaturedMemberId }: Props) => {

components/dashboard/src/teams/onboarding/WelcomeMessageConfigurationField.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import { PlainMessage } from "@bufbuild/protobuf";
8-
import type { OrganizationSettings_OnboardingSettings_WelcomeMessage } from "@gitpod/public-api/lib/gitpod/v1/organization_pb";
8+
import type { OnboardingSettings_WelcomeMessage } from "@gitpod/public-api/lib/gitpod/v1/organization_pb";
99
import { SwitchInputField } from "@podkit/switch/Switch";
1010
import { Heading3, Subheading } from "@podkit/typography/Headings";
1111
import { useCallback, useState } from "react";
@@ -40,10 +40,7 @@ export const WelcomeMessageConfigurationField = ({ handleUpdateTeamSettings }: P
4040
const [welcomeMessageEditorOpen, setWelcomeMessageEditorOpen] = useState(false);
4141

4242
const handleUpdateWelcomeMessage = useCallback(
43-
async (
44-
newSettings: PlainMessage<OrganizationSettings_OnboardingSettings_WelcomeMessage>,
45-
options?: UpdateTeamSettingsOptions,
46-
) => {
43+
async (newSettings: PlainMessage<OnboardingSettings_WelcomeMessage>, options?: UpdateTeamSettingsOptions) => {
4744
await handleUpdateTeamSettings(
4845
{
4946
onboardingSettings: {

components/dashboard/src/teams/onboarding/WelcomeMessageEditor.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import { PlainMessage } from "@bufbuild/protobuf";
8-
import type { OrganizationSettings_OnboardingSettings_WelcomeMessage } from "@gitpod/public-api/lib/gitpod/v1/organization_pb";
8+
import type { OnboardingSettings_WelcomeMessage } from "@gitpod/public-api/lib/gitpod/v1/organization_pb";
99
import { Button } from "@podkit/buttons/Button";
1010
import { LoadingButton } from "@podkit/buttons/LoadingButton";
1111
import { Textarea } from "@podkit/forms/TextArea";
@@ -19,12 +19,12 @@ import { OrgMemberAvatarInput } from "./OrgMemberAvatarInput";
1919
import { gitpodWelcomeSubheading } from "./WelcomeMessageConfigurationField";
2020

2121
type Props = {
22-
settings: OrganizationSettings_OnboardingSettings_WelcomeMessage | undefined;
22+
settings: OnboardingSettings_WelcomeMessage | undefined;
2323
isLoading: boolean;
2424
isOwner: boolean;
2525
isOpen: boolean;
2626
handleUpdateWelcomeMessage: (
27-
newSettings: PlainMessage<OrganizationSettings_OnboardingSettings_WelcomeMessage>,
27+
newSettings: PlainMessage<OnboardingSettings_WelcomeMessage>,
2828
options?: UpdateTeamSettingsOptions,
2929
) => Promise<void>;
3030
setIsOpen: (isOpen: boolean) => void;

components/public-api/gitpod/v1/organization.proto

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ enum OrganizationRole {
3434
ORGANIZATION_ROLE_COLLABORATOR = 3;
3535
}
3636

37-
// OrganizationPermissions define permissions that are restrictable using RoleRestrictions
37+
// OrganizationPermissions define permissions that are restrictable using
38+
// RoleRestrictions
3839
enum OrganizationPermission {
3940
ORGANIZATION_PERMISSION_UNSPECIFIED = 0;
4041
ORGANIZATION_PERMISSION_START_ARBITRARY_REPOS = 1;
@@ -48,33 +49,43 @@ message RoleRestrictionEntry {
4849
repeated OrganizationPermission permissions = 2;
4950
}
5051

51-
message OrganizationSettings {
52-
// onboarding_settings are the settings for the organization's onboarding
53-
message OnboardingSettings {
54-
message WelcomeMessage {
55-
// enabled specifies whether the welcome message is enabled
56-
bool enabled = 1;
52+
// onboarding_settings are the settings for the organization's onboarding
53+
message OnboardingSettings {
54+
message WelcomeMessage {
55+
// enabled specifies whether the welcome message is enabled
56+
bool enabled = 1;
5757

58-
// message is the welcome message for the organization
59-
optional string message = 2;
58+
// message is the welcome message for the organization
59+
optional string message = 2;
6060

61-
// featured_member_id is the ID of the member to show in the welcome message
62-
optional string featured_member_id = 4;
61+
// featured_member_id is the ID of the member to show in the welcome message
62+
optional string featured_member_id = 4;
6363

64-
// featured_member_resolved_avatar_url is the avatar URL that is resolved from the featured_member_id by the server
65-
optional string featured_member_resolved_avatar_url = 5;
66-
}
64+
// featured_member_resolved_avatar_url is the avatar URL that is resolved
65+
// from the featured_member_id by the server
66+
// This field **can not** be set in the request.
67+
optional string featured_member_resolved_avatar_url = 5;
68+
}
6769

68-
// internal_link is the link to an internal onboarding page for the organization, possibly featuring a custom onboarding guide and other resources
69-
optional string internal_link = 1;
70+
// internal_link is the link to an internal onboarding page for the
71+
// organization, possibly featuring a custom onboarding guide and other
72+
// resources
73+
optional string internal_link = 1;
7074

71-
// recommended_repositories are the repositories that are recommended for new org members
72-
repeated string recommended_repositories = 2;
75+
// recommended_repositories are the repositories that are recommended for new
76+
// org members
77+
repeated string recommended_repositories = 2;
7378

74-
// welcome_message is the welcome message for the organization
75-
optional WelcomeMessage welcome_message = 3;
76-
}
79+
// update_recommended_repositories specifies whether recommended_repositories
80+
// should be updated.
81+
// This field **will not** be specified in server responses.
82+
optional bool update_recommended_repositories = 3;
7783

84+
// welcome_message is the welcome message for the organization
85+
optional WelcomeMessage welcome_message = 4;
86+
}
87+
88+
message OrganizationSettings {
7889
bool workspace_sharing_disabled = 1;
7990
string default_workspace_image = 2;
8091
repeated string allowed_workspace_classes = 3;
@@ -83,9 +94,10 @@ message OrganizationSettings {
8394
string default_role = 6;
8495
TimeoutSettings timeout_settings = 7;
8596
repeated RoleRestrictionEntry role_restrictions = 8;
86-
// max_parallel_running_workspaces is the maximum number of workspaces that a single user can run in parallel. 0 resets to the default, which depends on the org plan
97+
// max_parallel_running_workspaces is the maximum number of workspaces that a
98+
// single user can run in parallel. 0 resets to the default, which depends on
99+
// the org plan
87100
int32 max_parallel_running_workspaces = 9;
88-
// this is nested under OrganizationSettings because of the differences between the request & response shapes (see `featured_member_resolved_avatar_url` and `update_recommended_repositories`)
89101
OnboardingSettings onboarding_settings = 10;
90102
bool annotate_git_commits = 11;
91103
}
@@ -166,28 +178,12 @@ message TimeoutSettings {
166178
// inactivity is the duration of inactivity after which a workspace is stopped
167179
optional google.protobuf.Duration inactivity = 1;
168180

169-
// deny_user_timeout specifies whether applying custom timeouts is denied for organization members
181+
// deny_user_timeout specifies whether applying custom timeouts is denied for
182+
// organization members
170183
optional bool deny_user_timeouts = 2;
171184
}
172185

173186
message UpdateOrganizationSettingsRequest {
174-
message OnboardingSettings {
175-
message WelcomeMessage {
176-
optional bool enabled = 1;
177-
optional string message = 2;
178-
optional string featured_member_id = 3;
179-
}
180-
181-
optional string internal_link = 1;
182-
183-
// update_recommended_repositories specifies whether recommended_repositories should be updated
184-
// this is necessary because proto 3 doesn't support optional repeated fields. Will not be specified in server responses.
185-
optional bool update_recommended_repositories = 2;
186-
repeated string recommended_repositories = 3;
187-
188-
optional WelcomeMessage welcome_message = 4;
189-
}
190-
191187
// organization_id is the ID of the organization to update the settings for
192188
string organization_id = 1;
193189

@@ -225,16 +221,20 @@ message UpdateOrganizationSettingsRequest {
225221

226222
repeated RoleRestrictionEntry role_restrictions = 12;
227223

228-
// update_role_restrictions specifies whether role_restrictions should be updated
224+
// update_role_restrictions specifies whether role_restrictions should be
225+
// updated
229226
optional bool update_role_restrictions = 13;
230227

231-
// max_parallel_running_workspaces is the maximum number of workspaces that a single user can run in parallel. 0 resets to the default, which depends on the org plan
228+
// max_parallel_running_workspaces is the maximum number of workspaces that a
229+
// single user can run in parallel. 0 resets to the default, which depends on
230+
// the org plan
232231
optional int32 max_parallel_running_workspaces = 15;
233232

234233
// onboarding_settings are the settings for the organization's onboarding
235234
optional OnboardingSettings onboarding_settings = 16;
236235

237-
// annotate_git_commits specifies whether to annotate git commits created in Gitpod workspaces with the gitpod host
236+
// annotate_git_commits specifies whether to annotate git commits created in
237+
// Gitpod workspaces with the gitpod host
238238
optional bool annotate_git_commits = 17;
239239
}
240240

0 commit comments

Comments
 (0)