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

Fix the Host card on the VC profile #7150

Merged
merged 2 commits into from
Nov 6, 2024
Merged

Fix the Host card on the VC profile #7150

merged 2 commits into from
Nov 6, 2024

Conversation

thalacheva
Copy link
Contributor

@thalacheva thalacheva commented Nov 6, 2024

Fix the Host card on the VC profile:

  • Display the avatar
  • Display a tooltip with more info on hover
  • Make it clickable - link to the Host profile
  • The default profile is not needed any more, so the HostCard component is replaced with ContributorCardHorizontal component.

Summary by CodeRabbit

  • New Features

    • Enhanced VirtualContributor profiles with new fields: url, location (city and country), and updated avatar format.
    • Introduced tagsets under provider for better categorization.
    • Updated profile display with a new layout using ContributorCardHorizontal.
  • Bug Fixes

    • Removed redundant HostCard component, streamlining profile display.
  • Documentation

    • Improved structure and organization of profile sections for better user experience.

As the DEFAULT_PROFILE is not needed any more, the component seems
useless as other components are used to display the card.
@thalacheva thalacheva requested a review from bobbykolev November 6, 2024 11:50
@CLAassistant
Copy link

CLAassistant commented Nov 6, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

coderabbitai bot commented Nov 6, 2024

Walkthrough

The changes in this pull request involve modifications to the GraphQL queries and mutations for the VirtualContributor and related profiles. Key updates include the addition of new fields such as url, location, and tagsets, while the description field has been removed from the provider profile. Additionally, the HostCard component has been removed and replaced with a ContributorCardHorizontal in the VCProfilePageView. The structure of the VirtualContributor type has also been altered to reflect these changes.

Changes

File Path Change Summary
src/domain/community/virtualContributor/VirtualContributor.graphql Updated VirtualContributor, VirtualContributorProfile, and BodyOfKnowledgeProfile queries to include new fields (url, location, avatar, tagsets). UpdateVirtualContributor and refreshBodyOfKnowledge mutations remain unchanged.
src/domain/community/virtualContributor/components/HostCard.tsx Removed HostCard component, which displayed host profile information.
src/domain/community/virtualContributor/vcProfilePage/VCProfilePageView.tsx Replaced HostCard with ContributorCardHorizontal, added new icons, and restructured component layout. Introduced SectionTitle and SectionContent methods.
src/domain/community/virtualContributor/vcProfilePage/model.ts Modified VirtualContributor type: removed description from provider.profile, added avatar, location, and url.

Possibly related PRs

Suggested labels

client, translations

Suggested reviewers

  • ccanos

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.

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

@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)
src/domain/community/virtualContributor/vcProfilePage/model.ts (1)

18-25: Consider adding URL validation and making the field optional.

A few suggestions for the new fields:

  1. The url field being non-optional might cause issues with existing data. Consider making it optional (url?: string) for backward compatibility.
  2. Consider adding a URL format validation pattern or using a more specific type for the URL field.
  3. For consistency, the optionality of fields between VirtualContributor.profile and provider.profile should match.
      avatar?: {
        uri: string;
      };
      location?: {
        city?: string;
        country?: string;
      };
-     url: string;
+     url?: string;
src/domain/community/virtualContributor/VirtualContributor.graphql (1)

15-18: Consider adding input validation for location fields.

The location fields (country and city) might benefit from input validation to ensure data consistency. Consider:

  • Using standardized country codes (e.g., ISO 3166)
  • Adding length constraints for city names

Example validation directives:

location {
  country @pattern(regexp: "^[A-Z]{2}$")  # ISO 3166-1 alpha-2
  city @maxLength(value: 100)
}
src/domain/community/virtualContributor/vcProfilePage/VCProfilePageView.tsx (2)

1-19: Consider organizing imports by category

The imports could be better organized into these groups:

  1. MUI components and icons
  2. Third-party utilities (i18n)
  3. Core UI components
  4. Domain components
+ // MUI
import BookIcon from '@mui/icons-material/Book';
import CloudDownloadIcon from '@mui/icons-material/CloudDownload';
import RecordVoiceOverIcon from '@mui/icons-material/RecordVoiceOver';
import ShieldIcon from '@mui/icons-material/Shield';
import useTheme from '@mui/material/styles/useTheme';

+ // Third-party
import { Trans, useTranslation } from 'react-i18next';

+ // Core UI
import PageContent from '../../../../core/ui/content/PageContent';
import PageContentBlock from '../../../../core/ui/content/PageContentBlock';
import PageContentColumn from '../../../../core/ui/content/PageContentColumn';
import Spacer from '../../../../core/ui/content/Spacer';
import WrapperMarkdown from '../../../../core/ui/markdown/WrapperMarkdown';
import { BlockTitle, Text } from '../../../../core/ui/typography';
import ContributorCardHorizontal from '../../../../core/ui/card/ContributorCardHorizontal';
import PageContentBlockHeader from '../../../../core/ui/content/PageContentBlockHeader';
import { gutters } from '../../../../core/ui/grid/utils';

+ // Domain
import ProfileDetail from '../../profile/ProfileDetail/ProfileDetail';
import BasicSpaceCard from '../components/BasicSpaceCard';
import { type VCProfilePageViewProps } from './model';

Line range hint 134-146: Add TypeScript types and prop validation

The utility components need proper TypeScript typing and prop validation.

+ interface SectionTitleProps {
+   children: React.ReactNode;
+ }

- function SectionTitle({ children }) {
+ function SectionTitle({ children }: SectionTitleProps) {
  return (
    <BlockTitle display={'flex'} alignItems={'center'} gap={gutters(0.5)}>
      {children}
    </BlockTitle>
  );
}

+ interface SectionContentProps {
+   children: React.ReactNode;
+ }

- function SectionContent({ children }) {
+ function SectionContent({ children }: SectionContentProps) {
  return <Text>{children}</Text>;
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8d21ed2 and 18807e7.

⛔ Files ignored due to path filters (2)
  • src/core/apollo/generated/apollo-hooks.ts is excluded by !**/generated/**
  • src/core/apollo/generated/graphql-schema.ts is excluded by !**/generated/**
📒 Files selected for processing (4)
  • src/domain/community/virtualContributor/VirtualContributor.graphql (1 hunks)
  • src/domain/community/virtualContributor/components/HostCard.tsx (0 hunks)
  • src/domain/community/virtualContributor/vcProfilePage/VCProfilePageView.tsx (2 hunks)
  • src/domain/community/virtualContributor/vcProfilePage/model.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • src/domain/community/virtualContributor/components/HostCard.tsx
🧰 Additional context used
📓 Path-based instructions (3)
src/domain/community/virtualContributor/VirtualContributor.graphql (1)

Pattern src/**/*.{graphql,gql}: Review the GraphQL schema and queries for best practices, potential bugs, and adherence to the project's GraphQL standards.
Ensure that the schema is well-defined and queries are optimized.
Check for security vulnerabilities.

src/domain/community/virtualContributor/vcProfilePage/VCProfilePageView.tsx (1)

Pattern src/**/*.{ts,tsx,js}: Review the React.js/TypeScript/JavaScript code for best practices and potential bugs.
Ensure that the code adheres to TypeScript's typing system and modern standards.
Ensure sufficient error handling and logging is present.
Check for common security vulnerabilities such as:

  • SQL Injection
  • XSS (Cross-Site Scripting)
  • CSRF (Cross-Site Request Forgery)
  • Insecure dependencies
  • Sensitive data exposure
src/domain/community/virtualContributor/vcProfilePage/model.ts (1)

Pattern src/**/*.{ts,tsx,js}: Review the React.js/TypeScript/JavaScript code for best practices and potential bugs.
Ensure that the code adheres to TypeScript's typing system and modern standards.
Ensure sufficient error handling and logging is present.
Check for common security vulnerabilities such as:

  • SQL Injection
  • XSS (Cross-Site Scripting)
  • CSRF (Cross-Site Request Forgery)
  • Insecure dependencies
  • Sensitive data exposure
🔇 Additional comments (2)
src/domain/community/virtualContributor/vcProfilePage/model.ts (1)

18-25: Verify the impact of type changes.

Let's verify:

  1. That the removed description field isn't being used elsewhere
  2. That the new required url field is properly handled in all components
✅ Verification successful

Let me try a different approach to find potential usages and type definitions. The previous pattern might have been too specific. This script will:

  1. Look for any description-related usage in profile contexts
  2. Find URL usages in profile contexts
  3. Locate Profile type/interface definitions to understand the structure

Based on the search results, I can now provide a definitive response about the type changes:

Type changes appear safe to proceed with.

  1. The removed description field is still being used in many places across the codebase, but these usages are for different profile types (spaces, organizations, posts, etc.) and not for the virtual contributor profile being modified.

  2. The url field is consistently treated as a required field throughout the codebase, with no null checks needed, as it's used directly in navigation, links and routing. The change to make it non-optional aligns with its actual usage pattern.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any remaining usage of provider.profile.description
rg "provider\.profile\.description" 

# Check for direct usage of provider.profile.url without null checks
ast-grep --pattern 'provider.profile.url'

Length of output: 79


Script:

#!/bin/bash
# Search for description field usage in a more generic way
rg "description.*profile" -A 2 -B 2

# Search for profile url usage patterns
rg "\.profile\.url" -A 2 -B 2

# Search for profile type usage to see implementation
fd "Profile" --type f --exec rg -l "Profile.*{" {}

Length of output: 114529

src/domain/community/virtualContributor/VirtualContributor.graphql (1)

14-25: LGTM! Changes align well with PR objectives.

The new fields support the Host card enhancements:

  • url enables card clickability
  • avatar adds visual representation
  • Additional fields (location, tagsets) enrich the profile information

Copy link
Contributor

@bobbykolev bobbykolev left a comment

Choose a reason for hiding this comment

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

Good job, congrats on your first PR, and thank you for your contribution, @thalacheva 👏

@bobbykolev bobbykolev merged commit 7f38177 into develop Nov 6, 2024
3 checks passed
Copy link

welcome bot commented Nov 6, 2024

Congrats on merging your first pull request! We at Alkemio thank you for your contribution!

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