diff --git a/packages/canyon-platform/package.json b/packages/canyon-platform/package.json index 5b0eb430..336ba955 100644 --- a/packages/canyon-platform/package.json +++ b/packages/canyon-platform/package.json @@ -7,7 +7,6 @@ "dev-platform": "vite", "do-build": "node --max_old_space_size=16384 ./node_modules/vite/bin/vite.js build", "preview": "vite preview", - "postinstall": "npm run codegen", "codegen": "graphql-codegen --config codegen.ts" }, "dependencies": { @@ -22,7 +21,7 @@ "antd": "5.14.1", "axios": "^1.7.2", "canyon-ui": "0.0.10-alpha.20", - "canyon-ui-old": "0.0.9", + "canyon-ui-old": "workspace:^", "copy-to-clipboard": "^3.3.3", "dayjs": "^1.11.11", "echarts": "^5.5.1", diff --git a/packages/canyon-platform/vite.config.ts b/packages/canyon-platform/vite.config.ts index 89d4de5e..f6b32344 100644 --- a/packages/canyon-platform/vite.config.ts +++ b/packages/canyon-platform/vite.config.ts @@ -35,6 +35,12 @@ export default defineConfig({ build: { sourcemap: true, }, + resolve: { + alias: { + 'canyon-ui-old': path.resolve('../canyon-ui-old/src'), + // '@': path.resolve(__dirname, './src'), + }, + }, server: { port: 8000, host: '0.0.0.0', diff --git a/packages/canyon-ui-old/.gitignore b/packages/canyon-ui-old/.gitignore new file mode 100644 index 00000000..ea02b6de --- /dev/null +++ b/packages/canyon-ui-old/.gitignore @@ -0,0 +1,28 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? + +pnpm-lock.yaml + +src/helpers/backend/gen diff --git a/packages/canyon-ui-old/index.html b/packages/canyon-ui-old/index.html new file mode 100644 index 00000000..df2a96a1 --- /dev/null +++ b/packages/canyon-ui-old/index.html @@ -0,0 +1,18 @@ + + + + + + + + Canyon + + +
+ + + diff --git a/packages/canyon-ui-old/languages.json b/packages/canyon-ui-old/languages.json new file mode 100644 index 00000000..20c6b5b3 --- /dev/null +++ b/packages/canyon-ui-old/languages.json @@ -0,0 +1,14 @@ +[ + { + "code": "en", + "file": "en.json", + "iso": "en-US", + "name": "English" + }, + { + "code": "cn", + "file": "cn.json", + "iso": "zh-CN", + "name": "简体中文" + } +] diff --git a/packages/canyon-ui-old/locales/cn.json b/packages/canyon-ui-old/locales/cn.json new file mode 100644 index 00000000..d8c4e7d6 --- /dev/null +++ b/packages/canyon-ui-old/locales/cn.json @@ -0,0 +1,72 @@ +{ + "welcome": { + "hello": "你好,", + "copywriter": "欢迎来到Canyon。", + "desc": "您将被重定向到源代码控制管理系统进行身份验证。", + "continue": "继续" + }, + "menus": { + "projects": "项目", + "settings": "设置", + "docs": "文档" + }, + "projects": { + "create": "创建项目", + "desc": "查看与您的账户相关的所有项目", + "name": "名称", + "report_times": "次数", + "report_time": "上报时间", + "max_coverage": "最大覆盖率", + "latest_report_time": "最近上报时间", + "latest_report_coverage": "最近上报覆盖率", + "no_data": "{{msg}}个项目没数据", + "total_times": "总次数", + "trends_in_coverage": "覆盖率趋势", + "records": "记录", + "overview": "概览", + "branch": "分支", + "compare_target": "对比目标", + "message": "提交信息", + "functions": "函数", + "branches": "分支", + "statements": "语句", + "lines": "行", + "newlines": "新增行", + "reported_details": "上报细节", + "reporter": "上报人", + "search_keywords": "按项目 ID 或名称搜索", + "overview_search_keywords": "输入 \"Commit Sha \"或 \"分支 \"或 \"比较目标 \"关键词进行搜索", + "coverage_details": "覆盖率详情", + "report_id": "上报 ID", + "coverage_id": "覆盖率 ID", + "view_detail": "查看详情", + "max_coverage_tooltip": "近30天的最大覆盖率", + "statements_tooltip": "语句覆盖率也是总体覆盖率", + "newlines_tooltip": "变更代码行覆盖率", + "statements_tour_title": "语句覆盖率", + "newlines_tour_title": "变更代码行覆盖率", + "statements_tour_description": "点击此列中的百分比数字以跳转至全量覆盖详情页面。", + "newlines_tour_description": "点击此列中的百分比数字以跳转至变更行覆盖详情页面。" + }, + "settings": { + "desc": "设置您的账户信息", + "preference": "偏好", + "user_auth_tokens": "用户授权令牌", + "copied_to_clipboard": "已复制到剪贴板" + }, + "common": { + "option": "操作", + "detail": "详情", + "configure": "配置", + "delete": "删除", + "language": "语言", + "theme": "主题", + "light": "光明", + "dark": "黑暗", + "created_at": "创建时间", + "total_items": "共计 {{total}} 项" + }, + "app": { + "logout": "退出登录" + } +} diff --git a/packages/canyon-ui-old/locales/en.json b/packages/canyon-ui-old/locales/en.json new file mode 100644 index 00000000..f8309c71 --- /dev/null +++ b/packages/canyon-ui-old/locales/en.json @@ -0,0 +1,72 @@ +{ + "welcome": { + "hello": "Hello,", + "copywriter": "Welcome to Canyon.", + "desc": "You will be redirected to the source code control management system for authentication.", + "continue": "Continue" + }, + "menus": { + "projects": "Projects", + "settings": "Settings", + "docs": "Docs" + }, + "projects": { + "create": "Create a Project", + "desc": "View all projects related to your account", + "name": "Name", + "report_times": "Times", + "report_time": "Report Time", + "max_coverage": "Max Coverage", + "latest_report_time": "Last Reported", + "latest_report_coverage": "Latest Report Coverage", + "no_data": "{{msg}} projects have no data", + "total_times": "Total Times", + "trends_in_coverage": "Trends in coverage", + "records": "Records", + "overview": "Overview", + "branch": "Branch", + "compare_target": "Compare Target", + "message": "Commit Message", + "functions": "Functions", + "branches": "Branches", + "statements": "Statements", + "lines": "Lines", + "newlines": "New Lines", + "reported_details": "Logs", + "reporter": "Reporter", + "search_keywords": "Search by project id or name", + "overview_search_keywords": "Enter the \"Commit Sha\" or \"Branch\" or \"Compare Target\" keyword for search", + "coverage_details": "Coverage Details", + "report_id": "Report ID", + "coverage_id": "Coverage ID", + "view_detail": "View Detail", + "max_coverage_tooltip": "Maximum coverage for the last 30 days", + "statements_tooltip": "Statement coverage is also overall coverage", + "newlines_tooltip": "Change code line coverage", + "statements_tour_title": "Statement Coverage", + "newlines_tour_title": "New Line Coverage", + "statements_tour_description": "Click on the percentage number in this column to jump to the full coverage details page.", + "newlines_tour_description": "Click on the percentage number in this column to jump to the changed line coverage details page." + }, + "settings": { + "desc": "Set up your account information", + "preference": "Preferences", + "user_auth_tokens": "User Authorization Tokens", + "copied_to_clipboard": "Copied to clipboard" + }, + "common": { + "option": "Option", + "detail": "Detail", + "configure": "Configure", + "delete": "Delete", + "language": "Language", + "theme": "Theme", + "light": "Light", + "dark": "Dark", + "created_at": "Created At", + "total_items": "Total {{total}} Items" + }, + "app": { + "logout": "Logout" + } +} diff --git a/packages/canyon-ui-old/package.json b/packages/canyon-ui-old/package.json new file mode 100644 index 00000000..32b308da --- /dev/null +++ b/packages/canyon-ui-old/package.json @@ -0,0 +1,41 @@ +{ + "name": "canyon-ui-old", + "version": "0.0.14", + "type": "module", + "main": "dist/canyon-ui-old.cjs", + "module": "dist/canyon-ui-old.js", + "types": "./dist/index.d.ts", + "files": [ + "dist/*" + ], + "scripts": { + "dev-ui": "vite", + "build": "vite build" + }, + "dependencies": { + "@ant-design/icons": "^5.3.0", + "ahooks": "^3.7.10", + "antd": "^5.14.1", + "axios": "^1.6.7", + "i18next": "^23.8.2", + "i18next-browser-languagedetector": "^7.2.0", + "react": "^18.3.1", + "react-dom": "^18.3.1", + "react-i18next": "^14.0.5", + "swr": "^2.2.5" + }, + "devDependencies": { + "@types/react": "^18.2.56", + "@types/react-dom": "^18.2.19", + "@vitejs/plugin-react": "^4.2.1", + "autoprefixer": "^10.4.17", + "postcss": "^8.4.35", + "react-router-dom": "^6.22.1", + "tailwindcss": "^3.4.1", + "typescript": "^5.3.3", + "vite": "^5.3.2", + "vite-plugin-dts": "^3.5.3", + "vite-plugin-pages": "^0.32.0", + "vite-plugin-svgr": "^4.2.0" + } +} diff --git a/packages/canyon-ui-old/postcss.config.js b/packages/canyon-ui-old/postcss.config.js new file mode 100644 index 00000000..2e7af2b7 --- /dev/null +++ b/packages/canyon-ui-old/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/packages/canyon-ui-old/public/light-logo.svg b/packages/canyon-ui-old/public/light-logo.svg new file mode 100644 index 00000000..8fca65d1 --- /dev/null +++ b/packages/canyon-ui-old/public/light-logo.svg @@ -0,0 +1 @@ + diff --git a/packages/canyon-ui-old/public/logo.svg b/packages/canyon-ui-old/public/logo.svg new file mode 100644 index 00000000..3c78311c --- /dev/null +++ b/packages/canyon-ui-old/public/logo.svg @@ -0,0 +1 @@ + diff --git a/packages/canyon-ui-old/public/welcome-bg.svg b/packages/canyon-ui-old/public/welcome-bg.svg new file mode 100644 index 00000000..cf73914e --- /dev/null +++ b/packages/canyon-ui-old/public/welcome-bg.svg @@ -0,0 +1,25 @@ + diff --git a/packages/canyon-ui-old/src/assets/icons/EpTopRight.tsx b/packages/canyon-ui-old/src/assets/icons/EpTopRight.tsx new file mode 100644 index 00000000..231975b1 --- /dev/null +++ b/packages/canyon-ui-old/src/assets/icons/EpTopRight.tsx @@ -0,0 +1,6 @@ +// import React from 'react'; +import type { SVGProps } from 'react'; + +export function EpTopRight(props: SVGProps) { + return (); +} diff --git a/packages/canyon-ui-old/src/assets/img/github.svg b/packages/canyon-ui-old/src/assets/img/github.svg new file mode 100644 index 00000000..6eeeace6 --- /dev/null +++ b/packages/canyon-ui-old/src/assets/img/github.svg @@ -0,0 +1 @@ + diff --git a/packages/canyon-ui-old/src/assets/img/gitlab.svg b/packages/canyon-ui-old/src/assets/img/gitlab.svg new file mode 100644 index 00000000..f5556c4b --- /dev/null +++ b/packages/canyon-ui-old/src/assets/img/gitlab.svg @@ -0,0 +1 @@ + diff --git a/packages/canyon-ui-old/src/assets/img/google.svg b/packages/canyon-ui-old/src/assets/img/google.svg new file mode 100644 index 00000000..6f895153 --- /dev/null +++ b/packages/canyon-ui-old/src/assets/img/google.svg @@ -0,0 +1 @@ + diff --git a/packages/canyon-ui-old/src/assets/img/img.png b/packages/canyon-ui-old/src/assets/img/img.png new file mode 100644 index 00000000..fc5292a6 Binary files /dev/null and b/packages/canyon-ui-old/src/assets/img/img.png differ diff --git a/packages/canyon-ui-old/src/components/card/Primary.tsx b/packages/canyon-ui-old/src/components/card/Primary.tsx new file mode 100644 index 00000000..37576f1f --- /dev/null +++ b/packages/canyon-ui-old/src/components/card/Primary.tsx @@ -0,0 +1,26 @@ +// import { CanyonCardPrimary } from './index.ts'; +import { StockOutlined } from '@ant-design/icons'; +import { Button, Col, Divider, Row, Space, Statistic, theme, Typography } from 'antd'; +import { FC } from 'react'; +const { useToken } = theme; +const { Title } = Typography; +const CanyonCardPrimary: FC<{ + theme?: any; + language?: any; + children: any; +}> = ({ theme, language, children }) => { + const { token } = useToken(); + return ( +
+ {children} +
+ ); +}; + +export default CanyonCardPrimary; diff --git a/packages/canyon-ui-old/src/components/card/index.ts b/packages/canyon-ui-old/src/components/card/index.ts new file mode 100644 index 00000000..b1274f7d --- /dev/null +++ b/packages/canyon-ui-old/src/components/card/index.ts @@ -0,0 +1 @@ +export { default as CanyonCardPrimary } from './Primary'; diff --git a/packages/canyon-ui-old/src/components/index.ts b/packages/canyon-ui-old/src/components/index.ts new file mode 100644 index 00000000..cb9d0c90 --- /dev/null +++ b/packages/canyon-ui-old/src/components/index.ts @@ -0,0 +1,4 @@ +export * from './card'; +export * from './layout'; +export * from './modal'; +export * from './page'; diff --git a/packages/canyon-ui-old/src/components/layout/Base.tsx b/packages/canyon-ui-old/src/components/layout/Base.tsx new file mode 100644 index 00000000..26c33b16 --- /dev/null +++ b/packages/canyon-ui-old/src/components/layout/Base.tsx @@ -0,0 +1,205 @@ +// import { ArrowRightOutlined, MoreOutlined } from '@ant-design/icons'; +// import { Avatar, Breadcrumb, Dropdown, Menu, Tooltip } from 'antd'; +// import { Outlet } from 'react-router-dom'; + +import { + ArrowRightOutlined, + FolderOutlined, + MoreOutlined, + SearchOutlined, + SettingOutlined, +} from '@ant-design/icons'; +import { + Avatar, + Button, + Dropdown, + Menu, + MenuProps, + Select, + theme, + Tooltip, + Typography, +} from 'antd'; +import { FC, ReactNode } from 'react'; + +import { CanyonCardPrimary } from '../card'; +import Footer from './footer.tsx'; +import ScrollBasedLayout from './ScrollBasedLayout.tsx'; +const { useToken } = theme; +const { Text, Title } = Typography; +interface CanyonLayoutBaseProps { + title?: string; + logo?: ReactNode; + mainTitleRightNode?: ReactNode; + menuSelectedKey?: string; + onSelectMenu?: (selectInfo: { key: string }) => void; + menuItems: MenuProps['items']; + renderMainContent?: ReactNode; + onClickGlobalSearch?: () => void; + MeData: any; + itemsDropdown: any; + search: any; + account: any; + breadcrumb: any; + footerName?: string; +} +const CanyonLayoutBase: FC = ({ + title = 'Canyon', + logo, + mainTitleRightNode, + menuSelectedKey = '', + onSelectMenu, + menuItems, + renderMainContent, + onClickGlobalSearch, + MeData, + itemsDropdown, + search, + account, + breadcrumb, + footerName = 'CANYON', +}) => { + const { token } = useToken(); + + return ( +
+ <> + +
+
+
{ + window.location.href = '/'; + }} + > + {logo} + + {title} + +
+ +
{mainTitleRightNode}
+
+
+ {search && ( +
+ + + +
+ )} + + {account && ( +
+ + Account + + + + + + + label='Password' + name='password' + rules={[{ required: true, message: 'Please input your password!' }]} + > + + + + + + + + ); +}; + +export default LoginForm; diff --git a/packages/canyon-ui-old/src/components/page/login/index.tsx b/packages/canyon-ui-old/src/components/page/login/index.tsx new file mode 100644 index 00000000..8c9647b8 --- /dev/null +++ b/packages/canyon-ui-old/src/components/page/login/index.tsx @@ -0,0 +1,77 @@ +import Icon from '@ant-design/icons'; +import { Divider, Tabs, Typography } from 'antd'; +import { FC } from 'react'; + +import { EpTopRight } from '../../../assets/icons/EpTopRight.tsx'; +import img from '../../../assets/img/img.png'; +import { CanyonCardPrimary } from '../../card'; +import LoginBtn from './LoginBtn.tsx'; +import LoginForm from './LoginForm.tsx'; + +const { Title } = Typography; + +const CanyonPageLogin: FC<{ + onLoginSuccess: () => void; + oauthUrl: { gitlab: string }; + logo: React.ReactNode; + register?: string; +}> = ({ onLoginSuccess, oauthUrl, logo, register }) => { + return ( +
+
+ +
+
+ + {logo} + +
+ +
+
+ Log in and continue +
+ + + Register + + +
+ ) + } + items={[ + { + label: 'Sign In', + key: 'login', + children: ( +
+ + + +
+ ), + }, + ]} + /> +
+
+ +
+ +
+
+ ); +}; + +export default CanyonPageLogin; diff --git a/packages/canyon-ui-old/src/index.ts b/packages/canyon-ui-old/src/index.ts new file mode 100644 index 00000000..07635cbb --- /dev/null +++ b/packages/canyon-ui-old/src/index.ts @@ -0,0 +1 @@ +export * from './components'; diff --git a/packages/canyon-ui-old/src/vite-env.d.ts b/packages/canyon-ui-old/src/vite-env.d.ts new file mode 100644 index 00000000..26064990 --- /dev/null +++ b/packages/canyon-ui-old/src/vite-env.d.ts @@ -0,0 +1,2 @@ +/// +// vite-env.d.ts diff --git a/packages/canyon-ui-old/tailwind.config.js b/packages/canyon-ui-old/tailwind.config.js new file mode 100644 index 00000000..65490f9b --- /dev/null +++ b/packages/canyon-ui-old/tailwind.config.js @@ -0,0 +1,12 @@ +/** @type {import('tailwindcss').Config} */ +export default { + darkMode: 'class', + content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'], + theme: { + extend: {}, + }, + plugins: [], + corePlugins: { + preflight: false, + }, +}; diff --git a/packages/canyon-ui-old/tsconfig.node.json b/packages/canyon-ui-old/tsconfig.node.json new file mode 100644 index 00000000..42872c59 --- /dev/null +++ b/packages/canyon-ui-old/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/packages/canyon-ui-old/vite.config.ts b/packages/canyon-ui-old/vite.config.ts new file mode 100644 index 00000000..8995c42d --- /dev/null +++ b/packages/canyon-ui-old/vite.config.ts @@ -0,0 +1,22 @@ +import { resolve } from 'path'; +import { defineConfig } from 'vite'; +import dts from 'vite-plugin-dts'; +import Pages from 'vite-plugin-pages'; +export default defineConfig({ + plugins: [ + Pages({ + exclude: ['**/helper/**'], + }), + dts(), + ], + build: { + outDir: './dist', + emptyOutDir: true, + commonjsOptions: {}, + lib: { + entry: resolve(__dirname, 'src/index.ts'), + fileName: 'canyon-ui-old', + name: 'CanyonUiOld', + } + }, +});