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

Documentation site page #6861

Merged
merged 9 commits into from
Sep 26, 2024
Merged

Documentation site page #6861

merged 9 commits into from
Sep 26, 2024

Conversation

bobbykolev
Copy link
Contributor

@bobbykolev bobbykolev commented Sep 10, 2024

As part of the new documentation initiative: https://github.com/alkem-io/documentation
Relates to: alkem-io/documentation#1
Depends on: alkem-io/server#4567

this PR provides a simple page for loading the stand-alone documentation site under an iframe.

The documentation can be accessed under [env domain]/docs. The iframe is with the source [env domain]/documentation*.
e.g. https://dev-alkem.io/docs which would load internally an iframe under https://dev-alkem.io/documentation

image

Summary by CodeRabbit

  • New Features

    • Introduced a dedicated documentation page within the application.
    • Added a new route for accessing documentation content.
    • Enhanced internationalization support with a new translation entry for documentation titles.
  • Bug Fixes

    • Improved routing logic to ensure seamless navigation to documentation.
  • Documentation

    • Updated translation files to include documentation-related entries.

@bobbykolev bobbykolev changed the title Documentation site Documentation site page Sep 10, 2024
Copy link

coderabbitai bot commented Sep 26, 2024

Walkthrough

The changes introduce a new documentation feature within the application. This includes the addition of a dedicated documentation page component, updates to the GraphQL configuration schema, and routing modifications to support the new documentation path. A new translation entry for documentation has also been added, enhancing internationalization support. Overall, these updates create a structured way to access and display documentation content within the application.

Changes

Files Change Summary
src/core/i18n/en/translation.en.json Added a new entry for documentation: "documentation": { "title": "Documentation" }.
src/domain/documentation/DocumentationPage.tsx Introduced a new React component DocumentationPage for rendering the documentation page.
src/domain/platform/config/configuration.graphql Added a new field documentation to the Configuration fragment in the GraphQL schema.
src/domain/platform/config/configuration.ts Added a new property documentation: string; to the Configuration interface.
src/main/routing/TopLevelRoutePath.ts Added a new enum entry Docs = 'docs' for documentation routing.
src/main/routing/TopLevelRoutes.tsx Introduced a new route for the documentation page using React.lazy for dynamic import.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Router
    participant DocumentationPage

    User->>Router: Navigate to /docs
    Router->>DocumentationPage: Load DocumentationPage
    DocumentationPage->>User: Render documentation content
Loading

🐰 In the meadow, where knowledge grows,
A page for docs, now everyone knows!
With routes and paths, we hop with glee,
A place for learning, come see, come see!
So gather 'round, both big and small,
The documentation's here, let's share it all! 📚✨


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.

@bobbykolev bobbykolev marked this pull request as ready for review September 26, 2024 11:55
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: 2

🧹 Outside diff range and nitpick comments (6)
src/domain/platform/config/configuration.ts (1)

28-28: LGTM! Consider adding a comment for clarity.

The addition of the documentation property to the locations object in the Configuration interface aligns well with the PR objectives. It provides a way to store the documentation URL or path, which is essential for the iframe implementation described in the PR summary.

Consider adding a brief comment above this property to describe its purpose, similar to:

// URL or path to the documentation site
documentation: string;

This would enhance code readability and provide context for other developers.

src/domain/documentation/DocumentationPage.tsx (2)

12-16: Component definition and hooks usage look good, with a minor suggestion.

The component is well-defined, and the hooks are used appropriately. However, consider handling the case where the URL doesn't contain the /docs/ path segment.

Consider adding a fallback for cases where the URL doesn't contain the /docs/ path:

- const docsInternalPath = pathname.split(`/${TopLevelRoutePath.Docs}/`)[1] ?? '';
+ const pathParts = pathname.split(`/${TopLevelRoutePath.Docs}/`);
+ const docsInternalPath = pathParts.length > 1 ? pathParts[1] : '';

This ensures docsInternalPath is always a string, even if the URL structure is unexpected.


20-38: Component rendering looks good, with a suggestion for enhancement.

The component structure and iframe implementation align well with the PR objectives and application conventions. The use of translations and accessibility considerations (iframe title) are commendable.

Consider adding a loading state or error handling for the iframe:

  <Gutters height={'100vh'}>
+   {src ? (
      <iframe
        src={src}
        title={t('pages.documentation.title')}
        style={{ width: '100%', height: '100%', border: 'none' }}
+       onLoad={() => {/* Handle successful load */}}
+       onError={() => {/* Handle load error */}}
      />
+   ) : (
+     <div>Loading documentation...</div>
+   )}
  </Gutters>

This would improve user experience by providing feedback during loading or in case of errors.

src/main/routing/TopLevelRoutes.tsx (2)

35-35: LGTM: Lazy loading of DocumentationPage.

The use of React.lazy for DocumentationPage is a good practice for code splitting and improving initial load time.

Consider adding a type annotation for consistency with other lazy-loaded components:

const DocumentationPage = React.lazy(() => import('../../domain/documentation/DocumentationPage')) as React.LazyExoticComponent<React.ComponentType<any>>;

157-164: LGTM: New route for DocumentationPage.

The implementation of the new route for DocumentationPage is well-structured and correctly uses Suspense for the lazy-loaded component.

For consistency with other routes in this file, consider wrapping the DocumentationPage with a WithApmTransaction component:

<Route
  path={`${TopLevelRoutePath.Docs}/*`}
  element={
    <WithApmTransaction path={TopLevelRoutePath.Docs}>
      <Suspense fallback={<Loading />}>
        <DocumentationPage />
      </Suspense>
    </WithApmTransaction>
  }
/>

This ensures that the documentation page is also tracked in your Application Performance Monitoring system.

src/core/i18n/en/translation.en.json (1)

2689-2691: LGTM! Consider adding more keys for future expansion.

The addition of the "documentation" section looks good. It's correctly placed within the "pages" object and follows the existing formatting conventions. For future-proofing, you might want to consider adding more keys that could be useful for the documentation page, such as a subtitle or description.

You could expand the section like this:

 "documentation": {
-  "title": "Documentation"
+  "title": "Documentation",
+  "subtitle": "Explore our comprehensive guides",
+  "description": "Find detailed information about using our platform"
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ff2d69c and c8ca905.

⛔ Files ignored due to path filters (3)
  • src/core/apollo/generated/apollo-helpers.ts is excluded by !**/generated/**
  • 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 (6)
  • src/core/i18n/en/translation.en.json (1 hunks)
  • src/domain/documentation/DocumentationPage.tsx (1 hunks)
  • src/domain/platform/config/configuration.graphql (1 hunks)
  • src/domain/platform/config/configuration.ts (1 hunks)
  • src/main/routing/TopLevelRoutePath.ts (1 hunks)
  • src/main/routing/TopLevelRoutes.tsx (3 hunks)
🔇 Additional comments (7)
src/main/routing/TopLevelRoutePath.ts (1)

16-16: LGTM! The new Docs route aligns with the PR objectives.

The addition of Docs = 'docs' to the TopLevelRoutePath enum is correct and consistent with the existing entries. This change supports the PR objective of creating a simple page for the documentation site, accessible at [env domain]/docs.

A few points to consider:

  1. The placement of the new entry is appropriate, maintaining alphabetical order within the enum.
  2. The reservedTopLevelRoutePaths constant will automatically include this new route, which is the desired behavior.
  3. Ensure that corresponding changes have been made in the routing configuration to handle this new path (this should be verified in other files).

To confirm that the routing for the new docs page has been properly set up, you can run the following script:

This script will help verify that the necessary routing configurations and component imports for the new docs page are in place.

src/domain/platform/config/configuration.graphql (1)

48-48: LGTM! The addition of the documentation field is appropriate and aligns with the PR objectives.

The new documentation field in the locations object of the Configuration fragment is a suitable addition. It provides a way to query the documentation URL through the GraphQL API, which can be used to set the iframe source as described in the PR objectives.

To ensure consistency, let's verify if this change is reflected in other parts of the codebase:

Please review the output of these commands to ensure that all necessary parts of the codebase are updated to include the new documentation field.

src/domain/documentation/DocumentationPage.tsx (3)

1-10: LGTM: Imports are well-organized and relevant.

The import statements are concise, follow a consistent style, and include all necessary components and utilities for the DocumentationPage component.


40-40: LGTM: Component export is correct.

The default export of the DocumentationPage component follows React best practices.


1-40: Overall implementation successfully achieves PR objectives.

The DocumentationPage component effectively implements the requirement of loading the stand-alone documentation site within an iframe. The code is well-structured, follows React best practices, and integrates well with the existing application architecture.

Key points:

  1. Correct use of layout components and hooks.
  2. Proper integration with the application's routing and configuration.
  3. Implementation of internationalization.

While the core functionality is sound, consider implementing the suggested improvements for enhanced robustness and user experience:

  1. Handle edge cases in URL parsing.
  2. Add safeguards for potential configuration issues.
  3. Implement loading state and error handling for the iframe.

These enhancements will further improve the component's reliability and user experience.

src/main/routing/TopLevelRoutes.tsx (2)

33-33: LGTM: Import statement for Loading component.

The addition of the Loading component import is appropriate. It will be used as a fallback for the lazy-loaded DocumentationPage.


Line range hint 1-238: Summary: Well-implemented documentation route addition.

The changes to introduce the new documentation route are well-structured and align with the existing routing implementation. The use of lazy loading and Suspense is a good practice for optimizing performance. The placement of the new route within the existing structure is appropriate.

A few minor suggestions have been made for consistency and improved monitoring, but overall, the implementation is solid and achieves the goal of integrating the documentation page into the application.

src/core/i18n/en/translation.en.json Show resolved Hide resolved
@valentinyanakiev valentinyanakiev merged commit 881ac66 into develop Sep 26, 2024
3 checks passed
@valentinyanakiev valentinyanakiev deleted the client-6284-docs branch September 26, 2024 15:12
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.

2 participants