Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions moon/apps/web/components/CodeView/CodeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ const CodeTable = ({ directory, loading, readmeContent}: any) => {
key: 'name',
render: (_, record) => (
<>
<div className='flex'>
{record.content_type === 'directory' && <FolderIcon className='size-6' />}
{record.content_type === 'file' && <DocumentIcon className='size-6' />}
<a className='cursor-pointer transition-colors duration-300 hover:text-[#69b1ff]'>{record.name}</a>
<div className='flex items-center'>
{record.content_type === 'directory' && <FolderIcon className='size-4 text-gray-600' />}
{record.content_type === 'file' && <DocumentIcon className='size-4 text-gray-600' />}
<a className='cursor-pointer transition-colors duration-300 hover:text-[#69b1ff] pl-2'>{record.name}</a>
</div>
</>
)
Expand Down
24 changes: 18 additions & 6 deletions moon/apps/web/components/CodeView/TreeView/RepoTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,14 @@ const CustomTreeItem = React.forwardRef(function CustomTreeItem(
);
});

const RepoTree = ({ directory }: { directory: any[] }) => {
const RepoTree = ( {flag, directory }: {flag:string, directory: any[] }) => {
const router = useRouter();
const scope = router.query.org as string;
const pathname = usePathname();
const basePath = pathname?.replace(`/${scope}/code/tree`, '');
const basePath = pathname?.replace(
new RegExp(`\\/${scope}\\/code\\/(tree|blob)`),
''
);

const [treeData, setTreeData] = useState<MuiTreeNode[]>([]);

Expand All @@ -168,8 +171,11 @@ const RepoTree = ({ directory }: { directory: any[] }) => {

return sortProjectsByType(directory).map((item) => {

const currentPath = `${parentBasePath}/${item.name}`.replace('//', '/') || '/';
// console.log('生成节点路径:', item.name, '=>', currentPath);
const nodeName = item?.name ?? '';
const currentPath = `${parentBasePath}/${nodeName}`.replace('//', '/') || '/';

// eslint-disable-next-line no-console
// console.log('生成节点路径:', nodeName, '=>', currentPath);

return {
id: uuidv4(),
Expand Down Expand Up @@ -277,6 +283,12 @@ const RepoTree = ({ directory }: { directory: any[] }) => {
? targetNode.path
: `/${targetNode?.path}`;

// eslint-disable-next-line no-console
// console.log(targetNode?.path, 'reqPath=1')

// eslint-disable-next-line no-console
// console.log(reqPath,'reqPath=reqPath')

if (
targetNode &&
targetNode.content_type === 'directory' &&
Expand Down Expand Up @@ -341,12 +353,12 @@ const RepoTree = ({ directory }: { directory: any[] }) => {
}

fullPath = fullPath?.replace(/^\//, '');
if (node?.isLeaf) {
if (flag ==='contents' && node?.isLeaf) {
router.push(`/${scope}/code/blob${basePath}/${fullPath}`);
Comment on lines +356 to 357

Copilot AI Jun 25, 2025

Copy link

Choose a reason for hiding this comment

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

Navigation on leaf click only happens when flag === 'contents'. The detail flag case is unhandled, so clicking in the blob page won't navigate—please adjust logic for both modes.

Suggested change
if (flag ==='contents' && node?.isLeaf) {
router.push(`/${scope}/code/blob${basePath}/${fullPath}`);
if (flag === 'contents' && node?.isLeaf) {
router.push(`/${scope}/code/blob${basePath}/${fullPath}`);
} else if (flag === 'detail' && node?.isLeaf) {
router.push(`/${scope}/code/detail${basePath}/${fullPath}`);

Copilot uses AI. Check for mistakes.
}

},
[pathname, router, treeData, scope, findNode],
[findNode, treeData, pathname, scope, flag, router],
);

return (
Expand Down
14 changes: 9 additions & 5 deletions moon/apps/web/components/DiffView/FileDiff.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { DiffFile, DiffModeEnum, DiffView } from '@git-diff-view/react'
import { ExpandIcon, SparklesIcon } from '@gitmono/ui/Icons'
import { cn } from '@gitmono/ui/src/utils'
import { parsedDiffs } from '@/components/DiffView/parsedDiffs'
import TreeView from './TreeView'

function calculateDiffStatsFromRawDiff(diffText: string): { additions: number; deletions: number } {
const lines = diffText.split('\n');
Expand Down Expand Up @@ -51,7 +52,7 @@ export default function FileDiff({ diffs }: { diffs: string }) {

const parsedFiles = useMemo(() => generateParsedFiles(diffFiles), [diffFiles]);

const [selectedPath, setSelectedPath] = useState<string | null>(null);
// const [selectedPath, setSelectedPath] = useState<string | null>(null);

const [expandedMap, setExpandedMap] = useState<Record<string, boolean>>(() =>
Object.fromEntries(diffFiles.map((f) => [f.path, false]))
Expand Down Expand Up @@ -89,9 +90,9 @@ export default function FileDiff({ diffs }: { diffs: string }) {
return (
<div className='flex font-sans'>
<div
className='rounded-lg bg-gray-100 w-[300px] h-[85vh] border border-[#ddd] p-2 overflow-y-auto sticky top-5'
className='rounded-lg w-[300px] h-[85vh] p-2 overflow-y-auto sticky top-5'
>
<ul>
{/* <ul>

Copilot AI Jun 25, 2025

Copy link

Choose a reason for hiding this comment

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

There’s a large commented‐out block of list code with mismatched braces. Please remove or properly format this dead code to keep the component clean.

Copilot uses AI. Check for mistakes.
{parsedFiles.map(({ file }) => (
<li
key={file.path}
Expand All @@ -108,8 +109,11 @@ export default function FileDiff({ diffs }: { diffs: string }) {
>
{file.path}
</li>
))}
</ul>
))
}

</ul> */}
<TreeView directory={parsedFiles} />
</div>

<div className='flex-1 overflow-y-auto px-4'>
Expand Down
Loading