-
Notifications
You must be signed in to change notification settings - Fork 542
feat: make frontend modular and add config #92
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @JNLei, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request focuses on modularizing the frontend code and introducing a configuration file (config.ts
) to manage various frontend settings. The changes involve moving components into separate files, adding configurable options for advanced settings, wiki page ask section positions, and enabling/disabling export buttons. Text sizes for wiki content are also made configurable. The landing page is also updated to support configurable advanced options.
Highlights
- Frontend Modularization: Components are now separated into individual files for better organization and maintainability.
- Configuration File: A
config.ts
file is introduced to manage frontend configurations, including advanced options positions (modal or embed), ask section positions (top, bottom, or embed), and export button visibility. - Text Size Configuration: Text sizes within the wiki content are now configurable via the
config.ts
file, allowing customization of paragraph, heading, and list text sizes. - Advanced Options Placement: The advanced options section on the landing page can now be configured to appear either as a modal or embedded directly within the page.
Changelog
Click here to see the changelog
- package-lock.json
- Added
clsx
andtailwind-merge
as dependencies.
- Added
- package.json
- Added
clsx
andtailwind-merge
as dependencies.
- Added
- src/app/[owner]/[repo]/page.tsx
- Moved
Ask
component tosrc/components/wiki/Ask.tsx
. - Imported
Footer
,RepoInfo
,WikiPage
,WikiStructure
,cn
,getRepoUrl
,AskSection
,WikiDocLoading
, andgetConfig
. - Replaced direct usage of configuration values with
getConfig
calls. - Implemented conditional rendering of
AskSection
based on configuration. - Replaced inline loading UI with
WikiDocLoading
component. - Added conditional class names using
cn
for dynamic styling. - Removed
isAskSectionVisible
state and logic, replaced with config-driven approach. - Moved
getRepoUrl
tosrc/utils/utils.ts
- Moved
- src/app/page.tsx
- Imported
cn
,t
,Footer
,AdvancedOptions
,AccessTokens
,getConfig
, andAdvancedOptionsModal
. - Replaced direct usage of configuration values with
getConfig
calls. - Implemented conditional rendering of
AdvancedOptions
based on configuration. - Added
AdvancedOptionsModal
for modal display of advanced options. - Moved the translation function
t
tosrc/utils/utils.ts
- Imported
- src/app/types/types.ts
- Added interfaces
WikiPage
,WikiStructure
, and typeRepoInfo
.
- Added interfaces
- src/components/Markdown.tsx
- Imported
getConfig
and used it to configure text sizes for markdown elements. - Modified class names for markdown elements to use configurable text sizes.
- Imported
- src/components/common/Footer.tsx
- Created new
Footer
component to standardize footer across the app.
- Created new
- src/components/landing/AccessTokens.tsx
- Created new
AccessTokens
component to encapsulate access token input fields and logic. - Conditionally renders based on config.
- Created new
- src/components/landing/AdvancedOptions.tsx
- Created new
AdvancedOptions
component to encapsulate advanced options selection. - Conditionally renders based on config.
- Created new
- src/components/landing/AdvancedOptionsModal.tsx
- Created new
AdvancedOptionsModal
component to encapsulate advanced options in a modal.
- Created new
- src/components/wiki/Ask.tsx
- Updated import paths for
Markdown
anduseLanguage
. - Added
isAskSectionVisible
prop to conditionally render the component. - Used
cn
to conditionally apply styles based on config.
- Updated import paths for
- src/components/wiki/AskSection.tsx
- Created new
AskSection
component to encapsulate the ask section logic. - Conditionally renders based on config.
- Created new
- src/components/wiki/WikiDocLoading.tsx
- Created new
WikiDocLoading
component to encapsulate the loading state UI.
- Created new
- src/config.ts
- Created new
config.ts
file to manage configuration settings for the landing page and wiki page.
- Created new
- src/messages/en.json
- Added new translation keys for advanced options and updated export button labels.
- src/messages/es.json
- Added new translation keys for advanced options and updated export button labels.
- src/messages/ja.json
- Added new translation keys for advanced options and updated export button labels.
- src/messages/kr.json
- Added new translation keys for advanced options and updated export button labels.
- src/messages/vi.json
- Added new translation keys for advanced options and updated export button labels.
- src/messages/zh.json
- Added new translation keys for advanced options and updated export button labels.
- src/utils/utils.ts
- Added utility functions
cn
,t
, andgetRepoUrl
.
- Added utility functions
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A config file's gentle hand,
Shapes the app across the land.
From modal's display,
To text's array,
Customization, close at command.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces modularity and configuration options to the frontend, enhancing flexibility and maintainability. The changes include component separation and the addition of a configuration file for various frontend settings. Overall, the changes are well-structured and contribute positively to the project. However, there are some areas that could be improved for better clarity and adherence to best practices.
Summary of Findings
- Configuration Structure: The configuration structure could benefit from a more robust validation mechanism to ensure that the values provided are within the expected range or type. This would prevent unexpected behavior due to misconfiguration.
- Translation Key Usage: In several components, translation keys are directly used as fallback values. It's better to provide a default string directly in the
t
function to ensure that something meaningful is displayed even if the translation key is missing. - Component Props: Consider using more specific types for component props instead of relying solely on
Messages
fromnext-intl
. This would improve type safety and make the code easier to understand.
Merge Readiness
The pull request is almost ready for merging. Addressing the identified issues, particularly those related to configuration validation and translation key usage, would significantly improve the quality and robustness of the code. I am unable to approve this pull request, and recommend that others review and approve this code before merging. It is recommended that the pull request not be merged until the high severity issues are addressed.
@@ -1395,28 +1341,32 @@ IMPORTANT: | |||
</div> | |||
|
|||
{/* Export buttons */} | |||
{Object.keys(generatedPages).length > 0 && ( | |||
{Object.keys(generatedPages).length > 0 && (config.exportWiki.markdown || config.exportWiki.json) && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<div className="flex flex-col md:flex-row md:items-center md:justify-between gap-4 bg-[var(--card-bg)] rounded-lg shadow-custom border border-[var(--border-color)] p-4"> | ||
<div className="flex items-center"> | ||
<div className="bg-[var(--accent-primary)] p-2 rounded-lg mr-3"> | ||
<FaWikipediaW className="text-2xl text-white" /> | ||
</div> | ||
<div className="mr-6"> | ||
<h1 className="text-xl md:text-2xl font-bold text-[var(--accent-primary)]">{t('common.appName')}</h1> | ||
<h1 className="text-xl md:text-2xl font-bold text-[var(--accent-primary)]">{t('common.appName', messages)}</h1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the translation key directly as a fallback might not be ideal. Consider providing a default string directly in the t
function to ensure that something meaningful is displayed even if the translation key is missing.
<h1 className="text-xl md:text-2xl font-bold text-[var(--accent-primary)]">{t('common.appName', messages) || 'DeepWiki'}</h1>
<div className="flex flex-wrap items-baseline gap-x-2 md:gap-x-3 mt-0.5"> | ||
<p className="text-xs text-[var(--muted)] whitespace-nowrap">{t('common.tagline')}</p> | ||
<p className="text-xs text-[var(--muted)] whitespace-nowrap">{t('common.tagline', messages)}</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the translation key directly as a fallback might not be ideal. Consider providing a default string directly in the t
function to ensure that something meaningful is displayed even if the translation key is missing.
<p className="text-xs text-[var(--muted)] whitespace-nowrap">{t('common.tagline', messages) || 'AI-powered documentation'}</p>
@@ -5,6 +5,9 @@ import rehypeRaw from 'rehype-raw'; | |||
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; | |||
import { tomorrow } from 'react-syntax-highlighter/dist/cjs/styles/prism'; | |||
import Mermaid from './Mermaid'; | |||
import { getConfig } from '@/config'; | |||
|
|||
const config = getConfig('wikiPage.wikiContent.sizes'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onClick={() => setShowTokenInputs(!showTokenInputs)} | ||
className="text-sm text-[var(--accent-primary)] hover:text-[var(--highlight)] flex items-center transition-colors border-b border-[var(--border-color)] hover:border-[var(--accent-primary)] pb-0.5" | ||
> | ||
{showTokenInputs ? t('form.hideTokens', messages) : t('form.addTokens', messages)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the translation key directly as a fallback might not be ideal. Consider providing a default string directly in the t
function to ensure that something meaningful is displayed even if the translation key is missing.
{showTokenInputs ? t('form.hideTokens', messages) || 'Hide access tokens' : t('form.addTokens', messages) || 'Add access tokens'}
config.ts
as frontend configuration file.a. Advanced options position can be
modal
orembed
b. Wiki page ask section position can be
top
|bottom
|embed
c. Export wiki as markdown and json buttons can be enabled or disabled
d. Wiki content text size can be configured
Examples:
modal
embed