Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: organization feature-set #160

Open
wants to merge 4 commits into
base: development
Choose a base branch
from
Open
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 public/placeholder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 15 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Toaster } from 'react-hot-toast'
import { HashRouter, Route, Routes } from 'react-router-dom'

import OrgRepoWrapper from './components/OrgRepoWrapper'
import AppLayout from './layouts/AppLayout'
import Article from './pages/blog/Article'
import Blog from './pages/blog/BlogList'
Expand All @@ -12,10 +13,10 @@ import SubmissionDetails from './pages/hackathon/SubmissionDetails'
import SubmitHackathon from './pages/hackathon/SubmitHackathon'
import Home from './pages/home/Home'
import { CreateIssuePage, ReadIssuePage } from './pages/issue'
import OrganizationPage from './pages/organization/Organization'
import Profile from './pages/profile/Profile'
import { NewPullRequest, ReadPullRequest } from './pages/pull'
import Repository from './pages/repository/Repository'
import RepositoryWrapper from './pages/repository/RepositoryWrapper'

const repositoryRoutes = [
{ path: '/repository/:id/:tabName?/*?', element: <Repository /> },
Expand All @@ -25,6 +26,11 @@ const repositoryRoutes = [
{ path: '/repository/:id/issue/:issueId', element: <ReadIssuePage /> }
]

const organizationRoutes = [
{ path: '/organization/:username/:tabName?', element: <OrganizationPage /> },
// { path: '/organization/:id/:tabName?', element: <OrganizationPage /> }
]

const hackathonRoutes = [
{ path: '/hackathon', element: <Hackathon /> },
{ path: '/hackathon/create', element: <CreateHackathon /> },
Expand All @@ -46,12 +52,19 @@ function App() {
<Route
key={index}
path={path}
element={<AppLayout Component={() => <RepositoryWrapper element={element} />} />}
element={<AppLayout Component={() => <OrgRepoWrapper element={element} />} />}
/>
))}
{hackathonRoutes.map(({ path, element }, index) => (
<Route key={index} path={path} element={<AppLayout Component={() => element} />} />
))}
{organizationRoutes.map(({ path, element }, index) => (
<Route
key={index}
path={path}
element={<AppLayout Component={() => <OrgRepoWrapper element={element} />} />}
/>
))}
</Routes>

<Toaster position="bottom-center" />
Expand Down
8 changes: 4 additions & 4 deletions src/components/Navbar/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ export default function SearchBar() {
initial={{ width: '25%' }}
animate={{ width: isFocused ? '65%' : '25%' }}
transition={{ duration: 0.5 }}
className="relative rounded-[8px] ml-20 bg-white border-primary-300 hover:border-primary-600 focus-within:shadow-[0px_2px_4px_0px_rgba(0,0,0,0.10)] hover:shadow-[0px_2px_4px_0px_rgba(0,0,0,0.10)] hover:bg-primary-50 border-[1px]"
className="relative rounded-md ml-20 bg-white border-primary-300 hover:border-primary-600 focus-within:shadow-[0px_2px_4px_0px_rgba(0,0,0,0.10)] hover:shadow-[0px_2px_4px_0px_rgba(0,0,0,0.10)] hover:bg-primary-50 border-[1px]"
onAnimationComplete={handleInputAnimationComplete}
>
<div className="rounded flex items-center w-full p-2 shadow-sm">
<BiSearch className="w-6 h-6 text-primary-600 relative top-[1px]" />
<div className="rounded flex items-center w-full h-10 p-2 shadow-sm">
<BiSearch className="w-5 h-5 text-primary-600 relative top-[1px]" />
{/* <RiGitRepositoryFill className={`w-5 h-5 ${searchValue.length > 0 ? 'text-gray-900' : 'text-gray-500'}`} /> */}

<input
Expand All @@ -116,7 +116,7 @@ export default function SearchBar() {
value={searchValue}
onChange={handleInputChange}
onFocus={() => setIsFocused(true)}
className="w-full pl-2 text-base outline-none focus:outline-none bg-transparent text-primary-900 placeholder:text-primary-600"
className="w-full pl-2 text-sm font-medium outline-none focus:outline-none bg-transparent text-primary-900 placeholder:text-primary-600"
/>
{searchValue && (
<RiCloseCircleLine onClick={handleSearchReset} className="w-5 h-5 text-primary-600 cursor-pointer" />
Expand Down
4 changes: 2 additions & 2 deletions src/components/Navbar/UserProfileButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ export default function UserProfileButton({ isOfLandingPage = false }: { isOfLan
<>
<div>
<Menu.Button
className={`w-[178px] border-[1.5px] border-primary-600 rounded-[8px] shadow-[0px_2px_4px_0px_rgba(0,0,0,0.05)] inline-flex justify-between items-center px-4 h-10 ${
className={`w-[178px] border-[1.5px] border-primary-600 rounded-md shadow-[0px_2px_4px_0px_rgba(0,0,0,0.05)] inline-flex justify-between items-center px-4 h-10 ${
open ? 'bg-primary-50' : 'bg-white'
} tracking-wide text-primary-700 font-medium focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75`}
>
<div>
<FaUser className="h-4 w-4" />
</div>
<span className="ml-2 truncate">{resolveUsernameOrShorten(authState.address!, 4)}</span>
<span className="ml-2 text-sm font-medium truncate">{resolveUsernameOrShorten(authState.address!, 4)}</span>
<div>
{open && <FiChevronDown className="ml-2 -mr-1 h-5 w-5 rotate-180" aria-hidden="true" />}
{!open && <FiChevronDown className="ml-2 -mr-1 h-5 w-5" aria-hidden="true" />}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function Navbar() {
}

return (
<div className="flex justify-between py-4 px-6 border-b-[1px] border-gray-200">
<div className="flex justify-between py-4 px-6 border-b-[1px] border-gray-300">
<div className="flex items-center gap-2">
<SVG className='text-primary-600' src={LogoLight} width={21} height={32} />
<h2 onClick={handleLogoClick} className="cursor-pointer text-primary-600 font-bold text-2xl leading-[32px]">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { validate as isUuid } from 'uuid'

import PageNotFound from '@/components/PageNotFound'

export default function RepositoryWrapper({ element }: { element: React.ReactNode }) {
export default function OrgRepoWrapper({ element }: { element: React.ReactNode }) {
const { id } = useParams()

if (id && !isUuid(id)) return <PageNotFound />
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/buttons/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function Button<C extends React.ElementType = 'button'>(props: Bu
const Component = as || 'button'

const buttonClasses =
'px-4 py-[10px] rounded-[8px] disabled:bg-[#E0E0E0] disabled:shadow-[0px_2px_4px_0px_rgba(0,0,0,0.05)] disabled:text-[#A6A6A6] flex items-center'
'px-4 py-[10px] rounded-md disabled:bg-[#E0E0E0] disabled:shadow-[0px_2px_4px_0px_rgba(0,0,0,0.05)] disabled:text-[#A6A6A6] flex items-center'

return (
<Component className={clsx(buttonClasses, variant && VARIANTS[variant], className)} {...buttonProps}>
Expand Down
4 changes: 1 addition & 3 deletions src/helpers/aoconnect/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { connect, createDataItemSigner } from '@permaweb/aoconnect'

const { result, results, message, spawn, monitor, unmonitor, dryrun } = connect({
MU_URL: 'https://mu.ao-testnet.xyz',
CU_URL: 'https://cu63.ao-testnet.xyz',
GATEWAY_URL: 'https://arweave.net'
GATEWAY_URL: 'https://g8way.io'
})

export { createDataItemSigner, dryrun, message, monitor, result, results, spawn, unmonitor }
2 changes: 1 addition & 1 deletion src/helpers/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const AOS_PROCESS_ID = 'yJZ3_Yrc-qYRt1zHmY7YeNvpmQwuqyK3dT0-gxWftew'
export const AOS_PROCESS_ID = 'fvOElkbX-XbIUzvMRBqEb2uCzrjoeGw5SiPKJLzL6Jk'
export const VITE_GA_TRACKING_ID = 'G-L433HSR0D0'
export const AMPLITUDE_TRACKING_ID = '92a463755ed8c8b96f0f2353a37b7b2'
export const PL_REPO_ID = '6ace6247-d267-463d-b5bd-7e50d98c3693'
Expand Down
19 changes: 15 additions & 4 deletions src/helpers/resolveUsername.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useGlobalStore } from '@/stores/globalStore'

import { shortenAddress } from './shortenAddress'
import { shortenAddress, shortenUUID } from './shortenAddress'

/**
* Retrieves the username for a given address or returns the address itself if the username is not found.
Expand All @@ -24,10 +24,21 @@ export function resolveUsername(address: string): string {
* @returns {string} The username if found; otherwise, a shortened version of the address.
*/
export function resolveUsernameOrShorten(address: string, range: number = 4): string {
const user = useGlobalStore.getState().userState.allUsers.get(address)
if (user?.username) {
return user.username
const arweaveAddressPattern = /^[a-zA-Z0-9_-]{43}$/
const uuidPattern = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/
if (arweaveAddressPattern.test(address)) {
const user = useGlobalStore.getState().userState.allUsers.get(address)
if (user?.username) {
return user.username
}

return shortenAddress(address, range)
}

if (uuidPattern.test(address)) {
return shortenUUID(address, range)
}

return shortenAddress(address, range)
}

5 changes: 5 additions & 0 deletions src/helpers/shortenAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ export function shortenAddress(address: string, range = 4) {
if (address.length !== 43) return address
return address.slice(0, range) + '...' + address.slice(-range)
}

export function shortenUUID(uuid: string, range = 4) {
if (uuid.length !== 36) return uuid
return uuid.slice(0, range) + '...' + uuid.slice(-range)
}
2 changes: 1 addition & 1 deletion src/lib/decentralize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { sendMessage } from '../contract'
import { generateSteps } from '../discrete-bonding-curve/curve'

const arweave = new Arweave({
host: 'arweave-search.goldsky.com',
host: 'g8way.io',
port: 443,
protocol: 'https'
})
Expand Down
42 changes: 30 additions & 12 deletions src/lib/git/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,17 @@ const arweave = new Arweave({
protocol: 'https'
})

export async function postNewRepo({ id, title, description, file, owner, visibility,tokenProcessId }: any) {
export async function postNewRepo({
id,
title,
description,
file,
owner,
visibility,
tokenProcessId,
creator,
orgId
}: any) {
const userSigner = await getSigner()

const data = (await toArrayBuffer(file)) as ArrayBuffer
Expand All @@ -46,7 +56,8 @@ export async function postNewRepo({ id, title, description, file, owner, visibil
{ name: 'Description', value: description },
{ name: 'Repo-Id', value: id },
{ name: 'Type', value: 'repo-create' },
{ name: 'Visibility', value: visibility }
{ name: 'Visibility', value: visibility },
{ name: 'Scope', value: creator }
] as Tag[]

await waitFor(500)
Expand All @@ -57,17 +68,24 @@ export async function postNewRepo({ id, title, description, file, owner, visibil
throw new Error('Failed to post Git repository')
}

const tags: Record<string, string> = {
Action: 'Initialize-Repo',
Id: id,
Name: title,
Description: description,
'Data-TxId': dataTxResponse,
Visibility: 'public',
'Private-State-TxId': '',
'Token-Process-Id': tokenProcessId,
Creator: creator
}

if (orgId) {
tags['OrgId'] = orgId
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
tags['OrgId'] = orgId
tags['Organization-Id'] = orgId

Shouldn't this tag be HTTP Header compliant?

}

await sendMessage({
tags: getTags({
Action: 'Initialize-Repo',
Id: id,
Name: title,
Description: description,
'Data-TxId': dataTxResponse,
Visibility: 'public',
'Private-State-TxId': '',
'Token-Process-Id': tokenProcessId
})
tags: getTags(tags)
})

return { txResponse: dataTxResponse }
Expand Down
Loading