Skip to content

Commit

Permalink
Merge branch 'main' into updated-templates-view
Browse files Browse the repository at this point in the history
  • Loading branch information
mishushakov authored Dec 9, 2024
2 parents 3d4751f + 407f330 commit 4765dd5
Show file tree
Hide file tree
Showing 27 changed files with 8,186 additions and 339 deletions.
4 changes: 2 additions & 2 deletions apps/web/src/app/(dashboard)/dashboard/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Toaster } from '@/components/ui/toaster'

export default async function Layout({ children }) {
return (
<div className="h-full w-full">
<main className="w-full h-full flex flex-col">
<div className="h-full w-full flex flex-col">
<main className="w-full flex flex-col flex-1">
{children}
<Toaster />
</main>
Expand Down
66 changes: 52 additions & 14 deletions apps/web/src/app/(dashboard)/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
'use client'

import { Suspense, useEffect, useState } from 'react'
import { useLocalStorage } from 'usehooks-ts'

import {
BarChart,
CreditCard,
FileText,
Key,
LucideIcon,
PackageIcon,
PencilRuler,
Settings,
Users,
} from 'lucide-react'
Expand All @@ -23,6 +26,7 @@ import { useRouter, useSearchParams } from 'next/navigation'
import { PersonalContent } from '@/components/Dashboard/Personal'
import { TemplatesContent } from '@/components/Dashboard/Templates'
import { SandboxesContent } from '@/components/Dashboard/Sandboxes'
import { DeveloperContent } from '@/components/Dashboard/Developer'

function redirectToCurrentURL() {
const url = typeof window !== 'undefined' ? window.location.href : undefined
Expand All @@ -43,6 +47,7 @@ const menuLabels = [
'usage',
'billing',
'team',
'developer',
] as const
type MenuLabel = (typeof menuLabels)[number]

Expand All @@ -65,7 +70,7 @@ export default function Page() {

if (user) {
return (
<div className="flex min-h-screen flex-col md:flex-row pt-16 md:pt-32 px-2 md:px-32">
<div className="flex flex-col md:flex-row pt-16 md:pt-32 px-2 md:px-32">
<Suspense>
<Dashboard user={user} />
</Suspense>
Expand All @@ -82,6 +87,15 @@ const Dashboard = ({ user }) => {
const [teams, setTeams] = useState<Team[]>([])
const [currentTeam, setCurrentTeam] = useState<Team | null>(null)

const apiUrlState = useLocalStorage(
'apiUrl',
process.env.NEXT_PUBLIC_API_URL || ''
)
const billingUrlState = useLocalStorage(
'billingUrl',
process.env.NEXT_PUBLIC_BILLING_API_URL || ''
)

const initialTab =
tab && menuLabels.includes(tab as MenuLabel)
? (tab as MenuLabel)
Expand Down Expand Up @@ -140,7 +154,7 @@ const Dashboard = ({ user }) => {
setCurrentTeam={setCurrentTeam}
setTeams={setTeams}
/>
<div className="flex-1 md:pl-10">
<div className="flex-1 md:pl-10 pb-16">
<h2 className="text-2xl mb-2 font-bold">
{selectedItem[0].toUpperCase() + selectedItem.slice(1)}
</h2>
Expand All @@ -152,6 +166,8 @@ const Dashboard = ({ user }) => {
teams={teams}
setTeams={setTeams}
setCurrentTeam={setCurrentTeam}
apiUrlState={apiUrlState}
billingUrlState={billingUrlState}
/>
</div>
</>
Expand Down Expand Up @@ -199,6 +215,7 @@ const iconMap: { [key in MenuLabel]: LucideIcon } = {
team: Users,
templates: FileText,
sandboxes: PackageIcon,
developer: PencilRuler,
}

const MenuItem = ({
Expand All @@ -213,18 +230,16 @@ const MenuItem = ({
onClick: () => void
}) => (
<div
className={`flex w-fit md:w-full hover:bg-[#995100] hover:cursor-pointer rounded-lg items-center p-2 space-x-2 ${
selected ? 'bg-[#995100]' : ''
}`}
className={`flex w-fit md:w-full hover:bg-[#995100] hover:cursor-pointer rounded-lg items-center p-2 space-x-2 ${selected ? 'bg-[#995100]' : ''
}`}
onClick={onClick}
>
<Icon width={20} height={20} />
<p
className={`${
!label || !window.matchMedia('(min-width: 768)').matches
className={`${!label || !window.matchMedia('(min-width: 768)').matches
? 'sr-only sm:not-sr-only'
: ''
}`}
}`}
>
{label[0].toUpperCase() + label.slice(1)}
</p>
Expand All @@ -238,27 +253,43 @@ function MainContent({
teams,
setTeams,
setCurrentTeam,
apiUrlState,
billingUrlState,
}: {
selectedItem: MenuLabel
user: E2BUser
team: Team
teams: Team[]
setTeams: (teams: Team[]) => void
setCurrentTeam: (team: Team) => void
apiUrlState: [string, (value: string) => void]
billingUrlState: [string, (value: string) => void]
}) {
switch (selectedItem) {
case 'personal':
return <PersonalContent user={user} />
return <PersonalContent user={user} billingUrl={billingUrlState[0]} />
case 'keys':
return <KeysContent currentTeam={team} user={user} />
return (
<KeysContent
currentTeam={team}
user={user}
billingUrl={billingUrlState[0]}
/>
)
case 'sandboxes':
return <SandboxesContent team={team} />
return <SandboxesContent team={team} apiUrl={apiUrlState[0]} />
case 'templates':
return <TemplatesContent user={user} teamId={team.id} />
return (
<TemplatesContent
user={user}
teamId={team.id}
apiUrl={apiUrlState[0]}
/>
)
case 'usage':
return <UsageContent team={team} />
return <UsageContent team={team} billingUrl={billingUrlState[0]} />
case 'billing':
return <BillingContent team={team} />
return <BillingContent team={team} billingUrl={billingUrlState[0]} />
case 'team':
return (
<TeamContent
Expand All @@ -267,6 +298,13 @@ function MainContent({
teams={teams}
setTeams={setTeams}
setCurrentTeam={setCurrentTeam}
billingUrl={billingUrlState[0]}
/>
)
case 'developer':
return (
<DeveloperContent
apiUrlState={apiUrlState}
/>
)
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@



## SandboxException

```python
class SandboxException(Exception)
```

Base class for all sandbox errors.

Raised when a general sandbox exception occurs.


## TimeoutException

```python
class TimeoutException(SandboxException)
```

Raised when a timeout occurs.

The [unavailable] exception type is caused by sandbox timeout.

The [canceled] exception type is caused by exceeding request timeout.

The [deadline_exceeded] exception type is caused by exceeding the timeout for process, watch, etc.

The [unknown] exception type is sometimes caused by the sandbox timeout when the request is not processed correctly.


## InvalidArgumentException

```python
class InvalidArgumentException(SandboxException)
```

Raised when an invalid argument is provided.


## NotEnoughSpaceException

```python
class NotEnoughSpaceException(SandboxException)
```

Raised when there is not enough disk space.


## NotFoundException

```python
class NotFoundException(SandboxException)
```

Raised when a resource is not found.


## AuthenticationException

```python
class AuthenticationException(SandboxException)
```

Raised when authentication fails.


## TemplateException

```python
class TemplateException(SandboxException)
```

Exception raised when the template uses old envd version. It isn't compatible with the new SDK.


## RateLimitException

```python
class RateLimitException(SandboxException)
```

Raised when the API rate limit is exceeded.

Loading

0 comments on commit 4765dd5

Please sign in to comment.