Skip to content

feat: Refactor the tree component, add a file type icon library, and …#1204

Merged
benjamin-747 merged 3 commits into
gitmono-dev:mainfrom
larissa-la:main
Jul 8, 2025
Merged

feat: Refactor the tree component, add a file type icon library, and …#1204
benjamin-747 merged 3 commits into
gitmono-dev:mainfrom
larissa-la:main

Conversation

@larissa-la

Copy link
Copy Markdown
Contributor

…refactor the cloneTab.

@vercel

vercel Bot commented Jul 8, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mega ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 8, 2025 6:12am

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the tree and table components to add dynamic loading, file-type icons, and improved clone UI, and wires path-change callbacks through the tree and code views.

  • Introduces a newPath state and onCommitInfoChange callbacks in tree and table pages
  • Replaces AntD popover/tabs with Radix UI components in CloneTabs, adds skeletons in tables
  • Adds a FileIcon component backed by material-file-icons and updates dependencies

Reviewed Changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
moon/pnpm-workspace.yaml Add material-file-icons dependency
moon/apps/web/pages/[org]/code/tree/[...path]/index.tsx Use newPath state and pass onCommitInfoChange to child components
moon/apps/web/pages/[org]/code/blob/[...path].tsx Remove redundant tree-fetch logic, simplify RepoTree usage
moon/apps/web/package.json Add Radix context-menu/primitive and material-file-icons
moon/apps/web/components/CodeView/TreeView/RepoTree.tsx Major rewrite for lazy-loading tree nodes and navigation callbacks
moon/apps/web/components/CodeView/TreeView/CloneTabs.tsx Swap AntD popover/tabs for Radix UI, update styling
moon/apps/web/components/CodeView/Table/index.tsx Add skeleton rows, memoize column config
moon/apps/web/components/CodeView/FileIcon/FileIcon.tsx New FileIcon component using material-file-icons
moon/apps/web/components/CodeView/CodeTable.tsx Integrate FileIcon, support path-change callbacks
Files not reviewed (1)
  • moon/pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (2)

moon/apps/web/components/CodeView/TreeView/CloneTabs.tsx:13

  • [nitpick] The state variable active_tab uses snake_case; rename it to activeTab for consistency with camelCase conventions.
  const [active_tab, setActiveTab] = useState<string>('1')

moon/apps/web/components/CodeView/TreeView/RepoTree.tsx:153

  • In the App Router context, useRouter().query isn't supported. Use useParams() from next/navigation to access the org route parameter.
  const scope = router.query.org as string;

const directory: DirectoryType = useMemo(() => TreeCommitInfo?.data ?? [], [TreeCommitInfo])
// const [newDirectory,setNewDirectory] = useState(directory)

const { data: canClone } = useGetTreePathCanClone({ path: new_path })

Copilot AI Jul 8, 2025

Copy link

Choose a reason for hiding this comment

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

The canClone hook still uses new_path instead of the updated newPath state, so it won't re-fetch when newPath changes. Update the argument to { path: newPath }.

Suggested change
const { data: canClone } = useGetTreePathCanClone({ path: new_path })
const { data: canClone } = useGetTreePathCanClone({ path: newPath })

Copilot uses AI. Check for mistakes.

type DirectoryType = NonNullable<CommonResultVecTreeCommitItem['data']>
const directory: DirectoryType = useMemo(() => TreeCommitInfo?.data ?? [], [TreeCommitInfo])
// const [newDirectory,setNewDirectory] = useState(directory)

Copilot AI Jul 8, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] This commented-out state is no longer used and can be removed to keep the code clean.

Suggested change
// const [newDirectory,setNewDirectory] = useState(directory)

Copilot uses AI. Check for mistakes.
const pathname = usePathname()
const [text, setText] = useState<string>(pathname || '')
const [copied, setCopied] = useState<boolean>(false)
const [active_tab, setActiveTab] = useState<string>('1')

Copilot AI Jul 8, 2025

Copy link

Choose a reason for hiding this comment

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

The default value '1' doesn't match the 'HTTP' and 'SSH' tab values, so the initial active tab styling is incorrect. Change it to useState<string>('HTTP').

Suggested change
const [active_tab, setActiveTab] = useState<string>('1')
const [active_tab, setActiveTab] = useState<string>('HTTP')

Copilot uses AI. Check for mistakes.
@benjamin-747
benjamin-747 added this pull request to the merge queue Jul 8, 2025
Merged via the queue into gitmono-dev:main with commit cd29fa4 Jul 8, 2025
2 checks passed
yyk808 pushed a commit to yyk808/mega that referenced this pull request Jul 9, 2025
gitmono-dev#1204)

* feat: Refactor the tree component, add a file type icon library, and refactor the cloneTab.

* fix: fix eslint

* fix: fix eslint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants