-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Org settings partial updates improvements #20626
base: gpl/org-settings-refresh
Are you sure you want to change the base?
Org settings partial updates improvements #20626
Conversation
Tool: gitpod/catfood.gitpod.cloud fix for getting settings (also resolve avatar) Tool: gitpod/catfood.gitpod.cloud
Tool: gitpod/catfood.gitpod.cloud
The hack was introduced in #20620 - Update welcome message configuration to handle optional enabled field - Simplify welcome message update logic in various components - Modify protobuf definitions to make enabled field optional - Remove redundant checks and simplify type handling in converters and components Tool: gitpod/catfood.gitpod.cloud
3334f6d
to
8b563ec
Compare
@@ -27,13 +28,12 @@ export type SuggestedOrgRepository = PlainMessage<SuggestedRepository> & { | |||
|
|||
export function useOrgSuggestedRepos() { | |||
const organizationId = useCurrentOrg().data?.id; | |||
const orgSettings = useOrgSettingsQuery(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧡
throw new ApplicationError( | ||
ErrorCodes.BAD_REQUEST, | ||
"featuredMemberResolvedAvatarUrl is not allowed to be set", | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ok to extract the code, but it should still be called here, not anywhere else: This is the one-and-only spot in our code base where we do domain-level validations. Also helps writing tests for it. 🙂
settings.onboardingSettings.welcomeMessage.featuredMemberId = undefined; | ||
settings.onboardingSettings.welcomeMessage.featuredMemberResolvedAvatarUrl = undefined; | ||
} | ||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block should move out of the mergeSettings
, and merged with the other welcomeMessage validation.
@@ -658,6 +639,45 @@ export class OrganizationService { | |||
return this.toSettings(await this.teamDB.setOrgSettings(orgId, settings, mergeSettings)); | |||
} | |||
|
|||
async getSettingsWithResolvedWelcomeMessage(userId: string, orgId: string): Promise<OrganizationSettings> { | |||
const settings = await this.getSettings(userId, orgId); | |||
return this.resolveWelcomeMessage(settings, orgId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the resolution of the welcomeMessage should never fail or block the retrieval of the org settings. Rather, we should return undefined
for avatarUrl.
In general it might make sense to only extract the resolveFeaturedMemberAvatarURL
functionality, and keep the rest where it was.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this method lags a comment. 🤝
return this.resolveWelcomeMessage(settings, orgId); | ||
} | ||
|
||
async updateSettingsWithResolvedWelcomeMessage( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this, if we call the resolveFeaturedMemberAvatarURL()
inside the update function above. That way only the retrieval path is special, which a) keeps variance low, and b) aligns nicely with user expectations IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked being explicit with both the update
and get
methods, but you're right — for the update case, we'd just be rolling out another layer, which can be bundled into updateSettings
.
Description
This PR contains the following fixes on top of #20603:
resolveWelcomeMessage
fnHow to test
https://ft-gpl-org7e7f3fc03d.preview.gitpod-dev.com/settings/onboarding
/hold