Skip to content

Commit

Permalink
GH-638 Mark sources as 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
dzikoysk committed Mar 15, 2021
1 parent fd84b9d commit cc29db3
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 27 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ Panda Hub is the module manager registry for amazing Panda (+JVM) based projects


#### 🧬 Stack
- Hub Backend: Kotlin + Ktor *(Netty)* + OAuth2 + MongoDB + JUnit
- Hub Frontend: React + Next.js + Chakra UI
2.x:
- Hub Backend: Kotlin + Ktor *(Netty)* + OAuth2 + MongoDB + JUnit
- Hub Frontend: React + Next.js + Chakra UI

1.x:
- Hub Backend: Java + Spring Boot + MongoDB + JUnit
- Hub Frontend: Vue.js + Buefy


#### 📋 Installation
Requirements:
Expand Down
2 changes: 1 addition & 1 deletion hub-backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "org.panda_lang"
version = "1.0.0"
version = "2.0.0"

repositories {
jcenter()
Expand Down
6 changes: 3 additions & 3 deletions hub-frontend/components/layout/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ const ProfileMenu = (props) => {
const { handleLogout } = useAuth()
const toast = useToast()

const { user } = useUser({redirectTo: '/'}, (user) => {
const { user } = useUser({ redirectTo: '/' }, (user) => {
if (!user.authorized) {
handleLogout()
toast({
title: 'Invalid session',
status: 'error',
duration: 6000,
position: 'top'
position: 'top',
})
}
})
Expand All @@ -139,7 +139,7 @@ const ProfileMenu = (props) => {
</MenuButton>
<MenuList border="0">
<MenuGroup>
<Link href={"/profile/" + profile.login}>
<Link href={'/profile/' + profile.login}>
<MenuItem as={ChakraLink}>My profile</MenuItem>
</Link>
<MenuItem>Settings </MenuItem>
Expand Down
107 changes: 107 additions & 0 deletions hub-frontend/components/package/PackageModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import { useEffect, useState } from 'react'
import {
Text,
Button,
Flex,
Modal,
ModalContent,
ModalFooter,
ModalHeader,
ModalOverlay,
useColorModeValue,
useDisclosure,
useToast,
Spinner,
Table,
TableCaption,
Thead,
Tr,
Th,
Tbody,
Td,
ButtonGroup,
IconButton,
ModalBody,
ModalCloseButton,
} from '@chakra-ui/react'
import { useGitHub } from '../../lib/useGitHub'
import Link from 'next/link'
import { AddIcon } from '@chakra-ui/icons'
import { FaTruckMonster } from 'react-icons/fa'

const PackageModal = (props) => {
const color = useColorModeValue('black', 'white')

const [repositories, setRepositories] = useState()
const toast = useToast()
const login = props.login

const tableScheme = useColorModeValue('blackAlpha', 'whiteAlpha')
const { isOpen, onClose } = useDisclosure({ defaultIsOpen: FaTruckMonster })

if (!repositories) {
useGitHub(`/users/${login}/repos`)
.then((response) => {
console.log(response)
setRepositories(response)
})
.catch((error) =>
toast({
title: 'Cannot fetch your repositories',
description: error.message,
status: 'error',
})
)
}

return (
<Modal isOpen="true" isOpen={isOpen} onClose={onClose} size="2xl">
<ModalOverlay />
<ModalContent>
<ModalHeader color={color}>Register package</ModalHeader>
<ModalCloseButton />
<ModalBody>
<Table variant="simple" color={color} colorScheme={tableScheme}>
<TableCaption>Available public repositories</TableCaption>
<Thead>
<Tr>
<Th>Name</Th>
<Th>Link</Th>
<Th>Action</Th>
</Tr>
</Thead>
<Tbody>
{(repositories || []).map((repository) => {
return (
<Tr key={repository.id}>
<Td>{repository.name}</Td>
<Td>
<Link href={repository.html_url}>
{`github.com/${repository.full_name}`}
</Link>
</Td>
<Td>
<ButtonGroup size="sm" isAttached variant="outline">
<IconButton
aria-label="Add to friends"
icon={<AddIcon />}
/>
</ButtonGroup>
</Td>
</Tr>
)
})}
</Tbody>
</Table>
</ModalBody>
<ModalFooter>
<Button colorScheme="blue" mr={3} onClick={onClose}>
Close
</Button>
</ModalFooter>
</ModalContent>
</Modal>
)
}

export default PackageModal
18 changes: 18 additions & 0 deletions hub-frontend/lib/useGitHub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import axios from 'axios'

const endpoint = 'https://api.github.com'

const getEndpoint = (path) => {
return endpoint + path
}

const useGitHub = async function (path) {
const response = await axios({
url: getEndpoint(path),
method: 'get',
})

return response.data
}

export { useGitHub, getEndpoint }
4 changes: 2 additions & 2 deletions hub-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion hub-frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hub-frontend",
"version": "1.0.0",
"version": "2.0.0",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
66 changes: 48 additions & 18 deletions hub-frontend/pages/profile/[name].js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@
*/

import Head from 'next/head'
import { Spinner, Box, Text, Flex, useColorModeValue, Img, Divider } from '@chakra-ui/react'
import {
Spinner,
Box,
Text,
Flex,
useColorModeValue,
Img,
Divider,
} from '@chakra-ui/react'

import Page from '../../components/layout/Page'
import Header from '../../components/layout/Header'
Expand All @@ -38,10 +46,7 @@ const Profile = () => {
<title>Hub - Profile</title>
</Head>
<Header />
<Main content={
<Description name={name} />
}>
</Main>
<Main content={<Description name={name} />}></Main>
<Footer />
</Page>
)
Expand All @@ -56,14 +61,18 @@ const Description = (props) => {

if (name && !profile) {
useClient(`/profile/${name}`)
.then((response) => setProfile({
found: true,
...response.profile
}))
.catch((error) => setProfile({
found: false,
error: error.message
}))
.then((response) =>
setProfile({
found: true,
...response.profile,
})
)
.catch((error) =>
setProfile({
found: false,
error: error.message,
})
)
}

if (!profile) {
Expand All @@ -86,16 +95,37 @@ const Description = (props) => {
<title>Hub - {profile.login}'s profile</title>
</Head>
<Flex bg={bgColor} padding="17px" shadow="sm" borderRadius="7px">
<Img src={profile.avatar_url} boxSize="128px" border={`2px solid #1d1d1d`} borderRadius="17px" />
<Img
src={profile.avatar_url}
boxSize="128px"
border={`2px solid #1d1d1d`}
borderRadius="17px"
/>
<Flex flexDirection="column" paddingX="27px">
<Flex height="52px">
<Text fontSize="3xl" fontWeight="bold">{profile.name}</Text>
<Text fontSize="2xl" fontStyle="italic" paddingX="21px" paddingTop="5px">{profile.login}</Text>
<Text fontSize="3xl" fontWeight="bold">
{profile.name}
</Text>
<Text
fontSize="2xl"
fontStyle="italic"
paddingX="21px"
paddingTop="5px"
>
{profile.login}
</Text>
</Flex>
<Text whiteSpace="pre-line" bg={bioBgColor} padding="12px" borderRadius="7px">{profile.bio}</Text>
<Text
whiteSpace="pre-line"
bg={bioBgColor}
padding="12px"
borderRadius="7px"
>
{profile.bio}
</Text>
</Flex>
</Flex>
<PackageModal login={profile.login}/>
<PackageModal login={profile.login} />
</Flex>
)
}
Expand Down

0 comments on commit cc29db3

Please sign in to comment.