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

[WEB-2431] chore: profile settings page UI improvement #5838

Merged
merged 5 commits into from
Oct 17, 2024

Conversation

prateekshourya29
Copy link
Member

@prateekshourya29 prateekshourya29 commented Oct 15, 2024

Before

image

After

image

Issue link: WEB-2431

Summary by CodeRabbit

  • New Features
    • Added a timezone selection feature for projects.
    • Introduced a language selection tooltip in profile settings.
  • Improvements
    • Enhanced styling and usability of the dropdown options in the custom search component.
    • Updated profile settings layout to a grid format for better organization.
    • Improved responsiveness of the project details form.
    • Added a method for formatting timezone information in profile settings.
  • Bug Fixes
    • Added error handling for existing project identifiers during form submission.

Copy link
Contributor

coderabbitai bot commented Oct 15, 2024

Walkthrough

The changes in this pull request involve updates to several components and interfaces across the codebase. Key modifications include the addition of a timezone property to the IProject interface, enhancements to the CustomSearchSelect component's styling, updates to the ProfileSettingsPage component to incorporate timezone selection functionality, and improvements to the ProjectDetailsForm component's layout and logic. These alterations aim to improve user experience and organization within the application.

Changes

File Path Change Summary
packages/types/src/project/projects.d.ts Added property timezone: string; to IProject interface.
packages/ui/src/dropdowns/custom-search-select.tsx Adjusted styling and structure of dropdown options in CustomSearchSelect.
web/app/profile/page.tsx Added Tooltip for language selection, updated TIME_ZONES import, introduced getTimeZoneLabel, and modified layout to grid.
web/core/components/project/form.tsx Updated ProjectDetailsForm with new state variables, submission logic, and layout changes to grid.

Possibly related PRs

Suggested labels

🌟enhancement, 🌐frontend, 🧹chore

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham

Poem

In the fields where projects grow,
A timezone added, now we know.
Dropdowns styled with care and grace,
User profiles find their place.
With grids and tools, our work's a dance,
Enhancements made, let's take a chance! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (5)
packages/ui/src/dropdowns/custom-search-select.tsx (2)

138-140: LGTM! Consider adding a comment for the z-index change.

The changes to the class names look good. Removing px-2 from the outer div and adding z-20 to increase the z-index are valid improvements. These modifications will likely enhance the layout and visibility of the dropdown.

Consider adding a brief comment explaining the reason for the z-20 class addition, as it might not be immediately obvious to other developers why a specific z-index value was chosen.


Line range hint 145-152: LGTM! Consider adding an aria-label for accessibility.

The addition of a styled container for the search input, including the search icon, is a great improvement to the component's visual appeal and usability. The mx-2 class ensures proper spacing within the dropdown.

To enhance accessibility, consider adding an aria-label to the search input. For example:

 <Combobox.Input
   className="w-full bg-transparent py-1 text-xs text-custom-text-200 placeholder:text-custom-text-400 focus:outline-none"
   value={query}
   onChange={(e) => setQuery(e.target.value)}
   placeholder="Search"
   displayValue={(assigned: any) => assigned?.name}
+  aria-label="Search options"
 />
web/core/components/project/form.tsx (1)

384-408: Do you need assistance with implementing the timezone selection feature?

The code for the timezone selection (lines 384-408) is currently commented out, indicating that this feature might be pending implementation or deferred. If you require help in integrating the timezone functionality into the form, I can assist by providing code suggestions or handling the implementation.

Would you like me to help implement the timezone selection feature or open a new GitHub issue to track this task?

web/app/profile/page.tsx (2)

300-303: Add missing 'rounded-md' class to 'display_name' input for consistent styling

The rounded-md class is missing in the className of the display_name input field, leading to inconsistent styling compared to other input fields.

Apply this diff to include the class:

- className={`w-full ${errors?.display_name ? "border-red-500" : ""}`}
+ className={`w-full rounded-md ${errors?.display_name ? "border-red-500" : ""}`}

Line range hint 140-153: Clarify the usage of 'url' parameter in 'handleDelete' function

The handleDelete function accepts a url parameter but doesn't use it within the function body. This can lead to confusion about the function's intent.

If url is unnecessary, consider removing it:

- const handleDelete = async (url: string | null | undefined) => {
+ const handleDelete = async () => {
    if (!currentUser?.avatar_url) return;

    await updateCurrentUser({
      avatar_url: "",
    })
    // ...

Alternatively, if you intend to generalize the function, use the url parameter:

await updateCurrentUser({
  avatar_url: url ? "" : undefined,
})
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4e70e89 and 1987129.

📒 Files selected for processing (4)
  • packages/types/src/project/projects.d.ts (1 hunks)
  • packages/ui/src/dropdowns/custom-search-select.tsx (2 hunks)
  • web/app/profile/page.tsx (4 hunks)
  • web/core/components/project/form.tsx (9 hunks)
🧰 Additional context used
🔇 Additional comments (3)
packages/ui/src/dropdowns/custom-search-select.tsx (1)

Line range hint 156-161: Great improvements to the scrollable options list!

The addition of vertical-scrollbar and scrollbar-xs classes enhances the appearance and usability of the scrollable options list. The space-y-1 class improves readability by adding consistent vertical spacing between options. These changes will contribute to a better user experience when interacting with the dropdown.

web/app/profile/page.tsx (2)

168-172: Verify calling 'handleSubmit(onSubmit)' within 'onSuccess' handler

Calling handleSubmit(onSubmit)() inside the onSuccess handler may lead to unexpected behavior, such as multiple form submissions or state inconsistencies. Ensure that this approach aligns with React Hook Form's best practices.

Consider reviewing the documentation or testing to confirm this doesn't introduce any issues.


378-392: Confirm 'getTimeZoneLabel' integration with 'CustomSearchSelect'

The getTimeZoneLabel function is used to render the content of each timezone option. Verify that it correctly displays the timezone information within the CustomSearchSelect component and handles all possible timezone values, including undefined or null cases.

packages/types/src/project/projects.d.ts Show resolved Hide resolved
Comment on lines +97 to 102
// handlers
const handleIdentifierChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const { value } = event.target;
const alphanumericValue = value.replace(/[^a-zA-Z0-9]/g, "");
const formattedValue = alphanumericValue.toUpperCase();
setValue("identifier", formattedValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix inconsistency between Project ID input handling and validation

The handleIdentifierChange function currently strips out all characters except a-z, A-Z, and 0-9, removing non-Latin characters like Ç, Ş, Ğ, İ, Ö, Ü. However, your validation rules for the identifier field allow these characters, as specified by the regex /^[ÇŞĞIİÖÜA-Z0-9]+$/. This inconsistency can lead to confusion and prevent users from inputting valid characters.

To ensure consistency between the input handling and validation, update the regex in handleIdentifierChange to include the non-Latin characters allowed by the validation.

Apply this diff to fix the inconsistency:

- const alphanumericValue = value.replace(/[^a-zA-Z0-9]/g, "");
+ const alphanumericValue = value.replace(/[^ÇŞĞIİÖÜa-zA-Z0-9]/gi, "");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// handlers
const handleIdentifierChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const { value } = event.target;
const alphanumericValue = value.replace(/[^a-zA-Z0-9]/g, "");
const formattedValue = alphanumericValue.toUpperCase();
setValue("identifier", formattedValue);
// handlers
const handleIdentifierChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const { value } = event.target;
const alphanumericValue = value.replace(/[^ÇŞĞIİÖÜa-zA-Z0-9]/gi, "");
const formattedValue = alphanumericValue.toUpperCase();
setValue("identifier", formattedValue);

web/app/profile/page.tsx Outdated Show resolved Hide resolved
web/app/profile/page.tsx Outdated Show resolved Hide resolved
web/app/profile/page.tsx Outdated Show resolved Hide resolved
web/app/profile/page.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (4)
web/app/profile/page.tsx (4)

219-220: LGTM: Improved form layout with comprehensive fields

The new grid layout enhances the organization of the form, making it more visually appealing and easier to navigate. The additional fields provide a more comprehensive user profile.

Consider adding some vertical spacing between the two grid sections for better visual separation:

-            <div className="flex flex-col gap-2 pt-4">
+            <div className="flex flex-col gap-2 pt-8">

This will create a clearer distinction between the two sets of form fields.

Also applies to: 365-368


396-409: Enhance disabled state for language selection

The "Coming soon" tooltip for the language selection is a good way to indicate future functionality. To make the disabled state more visually apparent, consider adjusting the styling:

       <CustomSearchSelect
         value="English (US)"
         label="English (US)"
         options={[]}
         onChange={() => {}}
-        className="rounded-md bg-custom-background-90"
+        className="rounded-md bg-custom-background-90 opacity-60 cursor-not-allowed"
         input
         disabled
       />

This change will make it clearer to users that the language selection is currently unavailable.


Line range hint 419-449: Enhance warning for account deactivation

The use of the Disclosure component for the "Deactivate account" section is a good choice, as it helps prevent accidental actions. To make the warning more emphatic, consider updating the text:

       <span className="text-sm tracking-tight">
-        When deactivating an account, all of the data and resources within that account will be
-        permanently removed and cannot be recovered.
+        WARNING: Deactivating your account is irreversible. All data and resources associated with this account will be permanently deleted and cannot be recovered. Please ensure you want to proceed with this action.
       </span>

This change emphasizes the permanence and seriousness of the action, helping users make an informed decision.


Line range hint 41-453: Consider memoization for performance optimization

The profile settings page has been significantly improved with new functionality and better layout. To potentially enhance performance, consider memoizing some of the more complex rendered elements or computations. For example:

const MemoizedCustomSearchSelect = React.memo(CustomSearchSelect);

Then use MemoizedCustomSearchSelect instead of CustomSearchSelect in your render method. This could help prevent unnecessary re-renders, especially for the timezone selection component which has complex options.

Additionally, you might want to memoize the timeZoneOptions array:

const memoizedTimeZoneOptions = React.useMemo(() => 
  TIME_ZONES.map((timeZone) => ({
    value: timeZone.value,
    query: timeZone.name + " " + timeZone.gmtOffset + " " + timeZone.value,
    content: getTimeZoneLabel(timeZone),
  })),
  [] // Empty dependency array as TIME_ZONES is likely constant
);

These optimizations could help improve the overall performance of the component, especially if it's rendered frequently or as part of a larger, more complex page.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1987129 and 5b5b81e.

📒 Files selected for processing (1)
  • web/app/profile/page.tsx (4 hunks)
🧰 Additional context used
🔇 Additional comments (2)
web/app/profile/page.tsx (2)

9-18: LGTM: Import changes look good

The new imports, including Tooltip from @plane/ui and the addition of TTimezone to the TIME_ZONES import, align well with the new functionality introduced in this update.

Also applies to: 25-25


119-127: LGTM: Well-implemented timezone label formatter

The getTimeZoneLabel function provides a consistent way to format timezone information for display. It handles undefined input gracefully and returns a nicely formatted label combining GMT offset and timezone name.

Comment on lines +373 to +394
<Controller
name="user_timezone"
control={control}
rules={{ required: "Please select a timezone" }}
render={({ field: { value, onChange } }) => (
<CustomSearchSelect
value={value}
label={
value
? (getTimeZoneLabel(TIME_ZONES.find((t) => t.value === value)) ?? value)
: "Select a timezone"
}
options={timeZoneOptions}
onChange={onChange}
buttonClassName={errors.user_timezone ? "border-red-500" : ""}
className="rounded-md border-[0.5px] !border-custom-border-200"
optionsClassName="w-72"
input
/>
)}
/>
{errors.user_timezone && <span className="text-xs text-red-500">{errors.user_timezone.message}</span>}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix error handling for timezone field

The timezone selection implementation looks good overall, providing a user-friendly way to select timezones. However, there's a potential issue with the error handling:

-                        buttonClassName={errors.user_timezone ? "border-red-500" : ""}
+                        buttonClassName={errors.user_timezone ? "border-red-500" : "border-custom-border-200"}

This change ensures that the button always has a border, improving consistency in the UI.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Controller
name="user_timezone"
control={control}
rules={{ required: "Please select a timezone" }}
render={({ field: { value, onChange } }) => (
<CustomSearchSelect
value={value}
label={
value
? (getTimeZoneLabel(TIME_ZONES.find((t) => t.value === value)) ?? value)
: "Select a timezone"
}
options={timeZoneOptions}
onChange={onChange}
buttonClassName={errors.user_timezone ? "border-red-500" : ""}
className="rounded-md border-[0.5px] !border-custom-border-200"
optionsClassName="w-72"
input
/>
)}
/>
{errors.user_timezone && <span className="text-xs text-red-500">{errors.user_timezone.message}</span>}
<Controller
name="user_timezone"
control={control}
rules={{ required: "Please select a timezone" }}
render={({ field: { value, onChange } }) => (
<CustomSearchSelect
value={value}
label={
value
? (getTimeZoneLabel(TIME_ZONES.find((t) => t.value === value)) ?? value)
: "Select a timezone"
}
options={timeZoneOptions}
onChange={onChange}
buttonClassName={errors.user_timezone ? "border-red-500" : "border-custom-border-200"}
className="rounded-md border-[0.5px] !border-custom-border-200"
optionsClassName="w-72"
input
/>
)}
/>
{errors.user_timezone && <span className="text-xs text-red-500">{errors.user_timezone.message}</span>}

@pushya22 pushya22 merged commit 173b49b into preview Oct 17, 2024
14 of 15 checks passed
@pushya22 pushya22 deleted the chore/timezone-and-language branch October 17, 2024 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants