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

Sync production with main #779

Merged
merged 40 commits into from
Jul 30, 2024
Merged

Sync production with main #779

merged 40 commits into from
Jul 30, 2024

Conversation

marc-aurele-besner
Copy link
Collaborator

@marc-aurele-besner marc-aurele-besner commented Jul 30, 2024

User description

Sync production with main

Including:


PR Type

Enhancement, Bug fix, Documentation


Description

  • Added new routes and components for Auto-ID, Domain, and Farming pages.
  • Implemented metadata generation for new pages.
  • Updated account list dropdown and block list query variables.
  • Created new headers for Domain and Farming sections with theme toggle.
  • Fixed capitalization issues in footer links.
  • Updated URL handling to use NEXTAUTH_URL if available.
  • Added image configuration for remote patterns.
  • Added limitText utility function and updated cSpell words.

Changes walkthrough 📝

Relevant files
Enhancement
23 files
oldSquidTypes.ts
Add `orderBy` parameter to `BlocksConnectionQueryVariables`

explorer/gql/oldSquidTypes.ts

  • Added orderBy parameter to BlocksConnectionQueryVariables.
+1/-0     
layout.tsx
Create layout for Auto-ID page                                                     

explorer/src/app/[chain]/autoid/layout.tsx

  • Created layout for Auto-ID page.
+7/-0     
page.tsx
Add Auto-ID page component and metadata generation             

explorer/src/app/[chain]/autoid/page.tsx

  • Added Auto-ID page component.
  • Implemented metadata generation for Auto-ID page.
  • +29/-0   
    layout.tsx
    Create layout for Domain page                                                       

    explorer/src/app/[chain]/domain/layout.tsx

    • Created layout for Domain page.
    +7/-0     
    page.tsx
    Add Domain page component and metadata generation               

    explorer/src/app/[chain]/domain/page.tsx

  • Added Domain page component.
  • Implemented metadata generation for Domain page.
  • +29/-0   
    layout.tsx
    Create layout for Farming page                                                     

    explorer/src/app/[chain]/farming/layout.tsx

    • Created layout for Farming page.
    +7/-0     
    page.tsx
    Add Farming page component and metadata generation             

    explorer/src/app/[chain]/farming/page.tsx

  • Added Farming page component.
  • Implemented metadata generation for Farming page.
  • +38/-0   
    AccountRewardList.tsx
    Update AccountRewardList component with conditional rendering and
    query variables

    explorer/src/components/Account/AccountRewardList.tsx

  • Added conditional rendering for AccountDetailsCard.
  • Updated query variables for account rewards.
  • +7/-2     
    index.tsx
    Create Auto-ID page component                                                       

    explorer/src/components/AutoId/index.tsx

    • Created Auto-ID page component.
    +27/-0   
    BlockList.tsx
    Add `orderBy` parameter to block list query variables       

    explorer/src/components/Block/BlockList.tsx

    • Added orderBy parameter to block list query variables.
    +4/-1     
    query.ts
    Update GraphQL query to include `orderBy` parameter           

    explorer/src/components/Block/query.ts

    • Updated GraphQL query to include orderBy parameter.
    +2/-2     
    index.tsx
    Create Domain page component                                                         

    explorer/src/components/Domain/index.tsx

    • Created Domain page component.
    +95/-0   
    index.tsx
    Create Farming page component with download functionality

    explorer/src/components/Farming/index.tsx

    • Created Farming page component with download functionality.
    +238/-0 
    AccountListDropdown.tsx
    Improve account list dropdown address formatting                 

    explorer/src/components/WalletButton/AccountListDropdown.tsx

    • Improved account list dropdown address formatting.
    +11/-15 
    OutOfSyncBanner.tsx
    Hide out-of-sync banner for domain chains                               

    explorer/src/components/common/OutOfSyncBanner.tsx

    • Added condition to hide out-of-sync banner for domain chains.
    +2/-1     
    DomainHeader.tsx
    Update DomainHeader component with new menu structure and theme toggle

    explorer/src/components/layout/DomainHeader.tsx

  • Updated DomainHeader component with new menu structure and theme
    toggle.
  • +101/-84
    FarmingHeader.tsx
    Create FarmingHeader component with new menu structure and theme
    toggle

    explorer/src/components/layout/FarmingHeader.tsx

  • Created FarmingHeader component with new menu structure and theme
    toggle.
  • +121/-0 
    Layout.tsx
    Replace DomainHeader with SectionHeader in MainLayout       

    explorer/src/components/layout/Layout.tsx

    • Replaced DomainHeader with SectionHeader in MainLayout.
    +2/-2     
    SectionHeader.tsx
    Create SectionHeader component                                                     

    explorer/src/components/layout/SectionHeader.tsx

    • Created SectionHeader component.
    +100/-0 
    metadata.ts
    Update URL to use NEXTAUTH_URL if available                           

    explorer/src/constants/metadata.ts

    • Updated URL to use NEXTAUTH_URL if available.
    +1/-1     
    routes.ts
    Add new routes and update external routes                               

    explorer/src/constants/routes.ts

  • Added new routes for farming, domains, nova, and autoid.
  • Updated external routes for academy, forum, and YouTube.
  • +29/-11 
    WalletProvider.tsx
    Update wallet account type handling                                           

    explorer/src/providers/WalletProvider.tsx

    • Updated wallet account type handling.
    +3/-3     
    string.ts
    Add `limitText` utility function                                                 

    explorer/src/utils/string.ts

    • Added limitText utility function.
    +3/-0     
    Bug fix
    1 files
    Footer.tsx
    Fix capitalization for GitHub and YouTube links                   

    explorer/src/components/layout/Footer.tsx

    • Fixed capitalization for GitHub and YouTube links.
    +2/-2     
    Configuration changes
    3 files
    next.config.js
    Add image configuration for remote patterns                           

    explorer/next.config.js

    • Added image configuration for remote patterns.
    +11/-0   
    astral.code-workspace
    Add `autoid` to cSpell words                                                         

    .vscode/astral.code-workspace

    • Added autoid to cSpell words.
    +1/-0     
    settings.json
    Add `autoid` to cSpell words                                                         

    .vscode/settings.json

    • Added autoid to cSpell words.
    +1/-0     
    Documentation
    1 files
    README.md
    Fix build badge URL                                                                           

    README.md

    • Fixed build badge URL.
    +1/-1     

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    marc-aurele-besner and others added 30 commits July 17, 2024 15:40
    Co-authored-by: Emil Fattakhov <66026548+EmilFattakhov@users.noreply.github.com>
    Copy link

    netlify bot commented Jul 30, 2024

    Deploy Preview for astral-prod ready!

    Name Link
    🔨 Latest commit fec4bee
    🔍 Latest deploy log https://app.netlify.com/sites/astral-prod/deploys/66a908bb545bb200086448ef
    😎 Deploy Preview https://deploy-preview-779--astral-prod.netlify.app
    📱 Preview on mobile
    Toggle QR Code...

    QR Code

    Use your smartphone camera to open QR code link.

    To edit notification comments on pull requests, go to your Netlify site configuration.

    Copy link

    netlify bot commented Jul 30, 2024

    Deploy Preview for dev-astral ready!

    Name Link
    🔨 Latest commit fec4bee
    🔍 Latest deploy log https://app.netlify.com/sites/dev-astral/deploys/66a908bb2a332e00085afab9
    😎 Deploy Preview https://deploy-preview-779--dev-astral.netlify.app
    📱 Preview on mobile
    Toggle QR Code...

    QR Code

    Use your smartphone camera to open QR code link.

    To edit notification comments on pull requests, go to your Netlify site configuration.

    @github-actions github-actions bot added documentation Improvements or additions to documentation enhancement New feature or request Bug fix Review effort [1-5]: 4 labels Jul 30, 2024
    Copy link

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Key issues to review

    Code Duplication
    The DomainHeader and FarmingHeader components have a significant amount of duplicated code, particularly in the rendering logic for desktop and mobile headers. Consider abstracting common functionalities into reusable components or hooks to reduce duplication and improve maintainability.

    Code Duplication
    The FarmingHeader component contains duplicated code from DomainHeader. This duplication could be reduced by abstracting shared logic into a common component or utility functions.

    Missing Dependency
    The useMemo for orderBy is missing dependencies. It should include dependencies that determine the value of orderBy to ensure that it recalculates correctly when dependencies change.

    Conditional Rendering
    The conditional rendering logic for AccountDetailsCard might be incorrect or unclear. It checks for convertedAddress but does not handle cases where convertedAddress might be undefined or null explicitly.

    Dependency Array
    The useMemo for outOfSyncBanner is missing selectedChain.isDomain in its dependency array. This could lead to stale renders if selectedChain.isDomain changes but the component does not re-render.

    Copy link

    github-actions bot commented Jul 30, 2024

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Enhancement
    Make the orderBy field optional for flexibility

    Ensure that the orderBy field in BlocksConnectionQueryVariables is optional to
    maintain consistency with the existing fields and to handle cases where no order is
    specified.

    explorer/gql/oldSquidTypes.ts [2605]

    -orderBy: Array<BlockOrderByInput> | BlockOrderByInput;
    +orderBy?: Array<BlockOrderByInput> | BlockOrderByInput;
     
    Suggestion importance[1-10]: 9

    Why: Making the orderBy field optional increases the flexibility of the query variables and maintains consistency with other optional fields. This change is logical and improves the robustness of the code.

    9
    Add a default value for the orderBy parameter in the GraphQL query

    Add a default value for orderBy in the GraphQL query to ensure it always has a valid
    value even if not provided, enhancing the robustness of the query.

    explorer/src/components/Block/query.ts [4-5]

    -query BlocksConnection($first: Int!, $after: String, $orderBy: [BlockOrderByInput!]!) {
    +query BlocksConnection($first: Int!, $after: String, $orderBy: [BlockOrderByInput!]! = [BlockOrderByInput.HeightDesc]) {
       blocksConnection(orderBy: $orderBy, first: $first, after: $after) {
     
    Suggestion importance[1-10]: 8

    Why: Adding a default value for the orderBy parameter ensures that the query always has a valid value, enhancing the robustness and reliability of the query. This is a valuable improvement.

    8
    Refactor the conditional logic for wallet type determination to enhance clarity and maintainability

    Simplify the conditional logic for determining the type of the wallet by removing
    redundant checks and ensuring clarity in the conditional structure.

    explorer/src/providers/WalletProvider.tsx [81-83]

    -account.type === WalletType.subspace || (account as { type: string }).type === 'sr25519'
    +['subspace', 'sr25519'].includes(account.type)
       ? WalletType.subspace
       : WalletType.ethereum
     
    Suggestion importance[1-10]: 8

    Why: The suggested refactor simplifies the conditional logic, making it more readable and maintainable without changing functionality.

    8
    Possible bug
    Add a type guard to ensure safe access to the type property of account

    Use a more specific type guard to ensure account has a type property before
    accessing it, which can prevent potential runtime errors if account does not conform
    to the expected structure.

    explorer/src/components/WalletButton/AccountListDropdown.tsx [51-52]

    -account.type === WalletType.subspace ||
    -(account as { type: string }).type === 'sr25519'
    +'type' in account && (account.type === WalletType.subspace || account.type === 'sr25519')
     
    Suggestion importance[1-10]: 9

    Why: Adding a type guard is crucial for preventing potential runtime errors, significantly improving the robustness of the code.

    9
    Possible issue
    Add null-check to prevent errors in the limitText function

    Add a check for null or undefined values in the limitText function to prevent
    potential runtime errors when text is not provided.

    explorer/src/utils/string.ts [9-10]

    -text.length > limit ? text.slice(0, limit) + '...' : text
    +text && text.length > limit ? text.slice(0, limit) + '...' : text
     
    Suggestion importance[1-10]: 9

    Why: Adding a null-check is a good practice to prevent potential runtime errors, making the function more robust.

    9
    Maintainability
    Refactor complex conditional rendering into a separate function for clarity and maintainability

    Simplify the conditional rendering logic by extracting complex conditions into a
    well-named function, improving code readability and maintainability.

    explorer/src/components/common/OutOfSyncBanner.tsx [65-69]

    -!selectedChain.isDomain &&
    -data &&
    -lastBlock &&
    -lastChainBlock !== null &&
    -lastBlock + NORMAL_BLOCKS_DIVERGENCE < lastChainBlock ? (
    -  <OutOfSyncBanner />
    -) : null,
    +shouldShowOutOfSyncBanner() ? <OutOfSyncBanner /> : null
     
    Suggestion importance[1-10]: 8

    Why: Extracting complex conditions into a separate function significantly improves readability and maintainability, making the code easier to understand and manage.

    8
    Refactor repeated logic into a utility function

    Extract the logic for generating the chainTitle into a separate function or utility
    to reduce duplication and improve maintainability, as similar logic appears in
    multiple files.

    explorer/src/app/[chain]/autoid/page.tsx [9]

    -const chainTitle = chains.find((c) => c.urls.page === chain)?.title || 'Unknown chain';
    +const chainTitle = getChainTitle(chain);
     
    Suggestion importance[1-10]: 7

    Why: Extracting the logic for generating the chainTitle into a separate function would reduce code duplication and improve maintainability. However, this is a minor improvement and not critical to the functionality.

    7
    Improve readability and consistency by using a ternary operator for conditional class assignment

    Consider using a ternary operator for conditional class assignment to improve
    readability and maintain consistency with other parts of your codebase.

    explorer/src/components/WalletButton/AccountListDropdown.tsx [43-45]

    -`w-120 relative cursor-pointer select-none py-2 text-gray-900 dark:text-white ${
    -  active && 'bg-gray-100 dark:bg-blueDarkAccent'
    -}`
    +`w-120 relative cursor-pointer select-none py-2 text-gray-900 dark:text-white ${active ? 'bg-gray-100 dark:bg-blueDarkAccent' : ''}`
     
    Suggestion importance[1-10]: 7

    Why: The suggestion improves readability and consistency by using a ternary operator, which is a minor but useful enhancement for maintainability.

    7
    Refactor the conditional rendering of theme icons into a separate component to improve code cleanliness and reusability

    Extract the inline styles and conditions into a separate function or use CSS classes
    to manage styles, enhancing the maintainability and scalability of the component.

    explorer/src/components/layout/DomainHeader.tsx [75-91]

    -{isDark ? (
    -  <SunIcon
    -    viewBox='0 0 24 24'
    -    strokeWidth={1}
    -    fill='black'
    -    stroke='black'
    -    className='size-6'
    -  />
    -) : (
    -  <MoonIcon
    -    viewBox='0 0 24 24'
    -    strokeWidth={1}
    -    fill='white'
    -    stroke='white'
    -    className='size-6'
    -  />
    -)}
    +<ThemeIcon isDark={isDark} />
     
    Suggestion importance[1-10]: 6

    Why: While refactoring the conditional rendering into a separate component improves code cleanliness and reusability, it is a minor enhancement and not critical.

    6
    Best practice
    Standardize enum naming convention to all uppercase

    Consider using a consistent naming convention for enum values in Routes. It's common
    practice to use either all uppercase or all lowercase for enum values to enhance
    readability and maintainability.

    explorer/src/constants/routes.ts [3-8]

    -farming = 'farming',
    -leaderboard = 'leaderboard',
    -domains = 'domains',
    -nova = 'nova',
    -autoid = 'autoid',
    +FARMING = 'farming',
    +LEADERBOARD = 'leaderboard',
    +DOMAINS = 'domains',
    +NOVA = 'nova',
    +AUTOID = 'autoid',
     
    Suggestion importance[1-10]: 7

    Why: Using a consistent naming convention for enum values improves readability and maintainability. However, this is a stylistic improvement rather than a functional one.

    7
    Reliability
    Improve error handling in the release fetching function

    Use a more specific error handling approach in the fetchLatestRelease function, such
    as retrying the fetch or providing user feedback, to enhance user experience and
    reliability.

    explorer/src/components/Farming/index.tsx [40-42]

     } catch (error) {
    -  console.error('Error fetching latest release:', error)
    +  console.error('Error fetching latest release:', error);
    +  // Implement retry logic or user feedback here
     }
     
    Suggestion importance[1-10]: 6

    Why: Enhancing error handling by adding retry logic or user feedback would improve the user experience and reliability of the function. However, the suggestion is somewhat vague and could be more specific.

    6

    @marc-aurele-besner marc-aurele-besner merged commit b7a340a into production Jul 30, 2024
    25 of 26 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Bug fix documentation Improvements or additions to documentation enhancement New feature or request Review effort [1-5]: 4
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant