Skip to content
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

Open
wants to merge 3 commits into
base: gpl/org-settings-refresh
Choose a base branch
from

Conversation

filiptronicek
Copy link
Member

Description

This PR contains the following fixes on top of #20603:

  • Cleaning up frontend for partial updates to org settings
  • Fixing a bug with public api shape conversion to make partial updates work for org welcome messages
  • Shift resolving of avatars to a special resolveWelcomeMessage fn
  • When updating org settings, we get the new data back in the response. We used to throw it out and re-fetch fresh data, which was wasteful. Now, we just set the org setting query's data to the data we get from the update mutation.

How to test

https://ft-gpl-org7e7f3fc03d.preview.gitpod-dev.com/settings/onboarding

/hold

Tool: gitpod/catfood.gitpod.cloud

fix for getting settings (also resolve avatar)

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
@filiptronicek filiptronicek force-pushed the ft/gpl/org-settings-refresh branch from 3334f6d to 8b563ec Compare February 24, 2025 16:45
@filiptronicek filiptronicek changed the title Separate feature member avatar resolution to new method Org settings partial updates improvements Feb 24, 2025
@@ -27,13 +28,12 @@ export type SuggestedOrgRepository = PlainMessage<SuggestedRepository> & {

export function useOrgSuggestedRepos() {
const organizationId = useCurrentOrg().data?.id;
const orgSettings = useOrgSettingsQuery();
Copy link
Member

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",
);
}

Copy link
Member

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 (
Copy link
Member

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);
Copy link
Member

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.

Copy link
Member

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(
Copy link
Member

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.

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants