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
1 change: 1 addition & 0 deletions moon/.env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_MEGA_API_URL=http://localhost:8000
2 changes: 1 addition & 1 deletion moon/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ yarn-debug.log*
yarn-error.log*

# local env files
.env*.local
# .env*.local

# vercel
.vercel
Expand Down
47 changes: 47 additions & 0 deletions moon/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/** @type {import('next').NextConfig} */

const nextConfig = {
reactStrictMode: true,
transpilePackages: [
// antd & deps
// https://github.com/vercel/next.js/issues/65707
// https://github.com/ant-design/ant-design/issues/46053#issuecomment-1905553667
"@ant-design",
"@rc-component",
"antd",
"rc-cascader",
"rc-checkbox",
"rc-collapse",
"rc-dialog",
"rc-drawer",
"rc-dropdown",
"rc-field-form",
"rc-image",
"rc-input",
"rc-input-number",
"rc-mentions",
"rc-menu",
"rc-motion",
"rc-notification",
"rc-pagination",
"rc-picker",
"rc-progress",
"rc-rate",
"rc-resize-observer",
"rc-segmented",
"rc-select",
"rc-slider",
"rc-steps",
"rc-switch",
"rc-table",
"rc-tabs",
"rc-textarea",
"rc-tooltip",
"rc-tree",
"rc-tree-select",
"rc-upload",
"rc-util",
],
}

module.exports = nextConfig
4 changes: 0 additions & 4 deletions moon/next.config.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion moon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"github-markdown-css": "^5.6.1",
"highlight.js": "^11.9.0",
"lexical": "^0.16.0",
"next": "14.2.4",
"next": "^14.2.5",
"prism-react-renderer": "^2.3.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
85 changes: 0 additions & 85 deletions moon/src/components/CodeTable.module.css
Original file line number Diff line number Diff line change
@@ -1,86 +1,9 @@
.projectName {
display: flex;
}

.fileTableIcon {
width: 23px;
height: 23px;
margin-right: 8px;
}


.innerTable {
overflow: hidden;
--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);
border-radius: 0.5rem;
}

.dirShowTable {
min-width: 100%;
min-width: 100%;
--tw-divide-y-reverse: 0;
border-bottom-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
--tw-divide-opacity: 1;
border-color: rgb(209 213 219 / var(--tw-divide-opacity));
border-collapse: collapse;

}

.dirShowTableThead {
background-color: rgb(249 250 251);
}

.dirShowTableTr {
padding-top: 0.875rem;
padding-bottom: 0.875rem;
padding-left: 1rem;
padding-right: 0.75rem;
text-align: left;
font-size: 0.875rem;
line-height: 1.25rem;
font-weight: 600;
--tw-text-opacity: 1;
color: rgb(17 24 39 / var(--tw-text-opacity));
}

.dirShowTableTbody> :not([hidden])~ :not([hidden]) {
--tw-divide-y-reverse: 0;
border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
border-bottom-width: calc(1px * var(--tw-divide-y-reverse));
border-color: rgb(229 231 235);
background-color: rgb(255 255 255);
}

.projectName {
white-space: nowrap;
padding-top: 1rem;
padding-bottom: 1rem;
padding-right: 0.75rem;
font-size: 0.875rem;
line-height: 1.25rem;
font-weight: 500;
--tw-text-opacity: 1;
color: rgb(17 24 39 / var(--tw-text-opacity));
padding-left: 1rem;
}

.projectCommitMsg {
white-space: nowrap;
padding-left: 1rem;
padding-right: 0.75rem;
padding-top: 1rem;
padding-bottom: 1rem;
font-size: 0.875rem;
line-height: 1.25rem;

--tw-text-opacity: 1;
color: rgb(107 114 128 / var(--tw-text-opacity));
}

.readmeContainer {
margin-top: 2rem;
margin-left: 1rem;
Expand All @@ -99,11 +22,3 @@
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);

}



/*

.token-line .comment {
white-space: pre-wrap;
} */
116 changes: 61 additions & 55 deletions moon/src/components/CodeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,69 @@ import folderPic from '../../public/icons/folder.svg'
import filePic from '../../public/icons/file.svg'
import Image from 'next/image'
import styles from './CodeTable.module.css'
import { Space, Table, TableProps } from 'antd/lib'

export interface DataType {
oid: string;
name: string;
content_type: string;
message: string;
date: number;
}

const CodeTable = ({ directory, readmeContent, showTree }) => {

const router = useRouter();
const currentProjectDir = directory || [];
const fileCodeContainerStyle = showTree ? { width: '80%', marginLeft: '17%', borderRadius: '0.5rem', marginTop: '10px' } : { width: '90%', margin: '0 auto', borderRadius: '0.5rem', marginTop: '10px' };
const dirShowTrStyle = { borderBottom: '1px solid rgba(0, 0, 0, 0.1)', }

var columns: TableProps<DataType>['columns'] = [
{
title: 'Name',
dataIndex: ['name', 'content_type'],
key: 'name',
render: (_, record) => {
return <>
{record.content_type === "file" &&
<Space>
<Image src={filePic} alt="File icon" className={styles.fileTableIcon} />
<span onClick={() => handleFileClick(record)}>{record.name}</span>
</Space>
}
{record.content_type === "directory" &&
<Space>
<Image src={folderPic} alt="File icon" className={styles.fileTableIcon} />
<a onClick={() => handleDirectoryClick(record)}>{record.name}</a>
</Space>}
</>
}
},
{
title: 'Message',
dataIndex: 'message',
key: 'message',
render: (text) => <a>{text}</a>,
},
{
title: 'Date',
dataIndex: 'date',
key: 'date',
render: (_, { date }) => (
<>
{date && formatDistance(fromUnixTime(date), new Date(), { addSuffix: true })}
</>
)
},
{
title: 'Action',
key: 'action',
render: (_, record) => (
<Space size="middle">
<a>Publish {record.name}</a>
<a>Revoke</a>
</Space>
),
},
];

const handleFileClick = (file) => {
const { path } = router.query;
Expand Down Expand Up @@ -44,12 +100,11 @@ const CodeTable = ({ directory, readmeContent, showTree }) => {
router.push('/')
} else {
router.push(`/tree/${safePath.slice(0, -1).join('/')}`);

}
};

// sort by file type, render folder type first
const sortedProjects = currentProjectDir.sort((a, b) => {
const sortedDir = directory.sort((a, b) => {
if (a.content_type === 'directory' && b.content_type === 'file') {
return -1;
} else if (a.content_type === 'file' && b.content_type === 'directory') {
Expand All @@ -60,57 +115,8 @@ const CodeTable = ({ directory, readmeContent, showTree }) => {
});

return (
<div className= {styles.dirTable} style={fileCodeContainerStyle}>
<div className={styles.innerTable}>
<table className={styles.dirShowTable}>
<thead className={styles.dirShowTableThead}>
<tr>
<th scope="col" className={styles.dirShowTableTr}>
Name
</th>
<th scope="col" className={styles.dirShowTableTr}>
Message
</th>
<th scope="col" className={styles.dirShowTableTr}>
Date
</th>
</tr>
</thead>
<tbody className={styles.dirShowTableTbody}>
{showTree && (
<tr style={dirShowTrStyle} className={styles.dirShowTr} key="back">
<td className={styles.projectName}>
<Image src={folderPic} alt="File icon" className={styles.fileTableIcon} />
<span onClick={() => handleGoBack()}>..</span>
</td>
<td></td>
<td></td>
</tr>
)}

{sortedProjects.map((project) => (
<tr style={dirShowTrStyle} className={styles.dirShowTr} key={project.id}>
{project.content_type === 'file' && (
<td className={styles.projectName} >
<Image src={filePic} alt="File icon" className={styles.fileTableIcon} />
<span onClick={() => handleFileClick(project)}>{project.name}</span>
</td>
)}
{project.content_type === 'directory' && (
<td className={styles.projectName} >
<Image src={folderPic} alt="File icon" className={styles.fileTableIcon} />
<span onClick={() => handleDirectoryClick(project)}>{project.name}</span>
</td>
)}
<td className={styles.projectCommitMsg} >{project.message}</td>
<td className={styles.projectCommitMsg}>
{project.date && formatDistance(fromUnixTime(project.date), new Date(), { addSuffix: true })}
</td>
</tr>
))}
</tbody>
</table>
</div>
<div className={styles.dirTable} style={fileCodeContainerStyle}>
<Table style={{ clear: "none" }} rowClassName={styles.dirShowTr} pagination={false} columns={columns} dataSource={sortedDir} />
{readmeContent && (
<div className={styles.markdownContent}>
<div className="markdown-body">
Expand Down
Loading