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

5899 display a banner to alert users which need to reconnect their account #6301

Conversation

bosiraphael
Copy link
Contributor

@bosiraphael bosiraphael commented Jul 17, 2024

Closes #5899

Index - banner

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

  • Added userVars field to CurrentUser type in /packages/twenty-front/src/modules/auth/states/currentUserState.ts
  • Introduced InformationBanner component in /packages/twenty-front/src/modules/object-record/information-banner/InformationBanner.tsx
  • Integrated InformationBanner into multiple settings pages, including /packages/twenty-front/src/pages/settings/SettingsAppearance.tsx, /packages/twenty-front/src/pages/settings/SettingsBilling.tsx, and others
  • Updated USER_QUERY_FRAGMENT to include userVars in /packages/twenty-front/src/modules/users/graphql/fragments/userQueryFragment.ts
  • Removed unused import in /packages/twenty-front/src/modules/users/components/UserProviderEffect.tsx

29 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings


const userVars = currentUser?.userVars;

const accountsToReconnect = userVars?.['ACCOUNTS_TO_RECONNECT'] ?? [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: Consider adding a type check for userVars to ensure it is an object.


return (
<Banner>
Sync lost with mailbox {accountsToReconnect[0]}. Please reconnect for
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic: Ensure accountsToReconnect[0] is defined before accessing it to avoid potential runtime errors.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

(updates since last review)

  • Updated fieldMetadataItemSchema.ts to accept existingLabels for dynamic validation
  • Enhanced metadataLabelSchema.ts for label uniqueness and improved error messages
  • Modified SettingsDataModelFieldAboutForm.tsx for better error handling and validation
  • Added error handling in TextInputV2.tsx and updated styling for error states
  • Updated database commands in 0-22-upgrade-version.command.ts for new address field and enum updates

27 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, I've left a some comments!

@@ -0,0 +1,136 @@
import { formatUserVars } from 'src/engine/core-modules/user/utils/format-user-vars.util';

describe('formatUserVars', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice! Bravo!


accountsToReconnect.push(connectedAccountId);

await this.keyValuePairService.set({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use the userVar service!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we don't have to pass the 'type' (here you are relying on userVar to be the defaultValue which does not seem to be right!)

await this.addToAccountsToReconnect(messageChannelId, workspaceId);
}

private async addToAccountsToReconnect(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like to be duplicated logic. I would put it in a connectedAccount service (we need to double check the dependencies) that would take { workspaceId, connectedAccountId } as parameters

Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I've push a few modifications:

  • keep KeyValuePair service as simple and agnostic as possible
  • enforce usage of userVarsService (no direct access to KeyValuePair service)
  • add allowList on userVars resolver
  • move userVars from user entity to a resolve field in user.resolver
  • rework typings


const userVars = currentUser?.userVars;

const accountIdToReconnect =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

firstAccountIdToReconnect

@charlesBochet charlesBochet merged commit 6728e40 into main Jul 27, 2024
14 checks passed
@charlesBochet charlesBochet deleted the 5899-display-a-banner-to-alert-users-which-need-to-reconnect-their-account branch July 27, 2024 16:34
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.

Display a banner to alert users which need to reconnect their account
2 participants