Skip to content

Commit

Permalink
UX updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mishushakov committed Dec 6, 2024
1 parent d13580e commit 0526a5d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 19 deletions.
8 changes: 4 additions & 4 deletions apps/web/src/app/(dashboard)/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Key,
LucideIcon,
PackageIcon,
PencilRuler,
Settings,
Users,
} from 'lucide-react'
Expand Down Expand Up @@ -46,6 +47,7 @@ const menuLabels = [
'usage',
'billing',
'team',
'developer',
] as const
type MenuLabel = (typeof menuLabels)[number]

Expand Down Expand Up @@ -189,9 +191,6 @@ const Sidebar = ({
currentTeam={currentTeam}
setCurrentTeam={setCurrentTeam}
setTeams={setTeams}
openDevSettings={() => {
setSelectedItem('developer')
}}
/>

<div className="flex flex-row justify-center space-x-4 md:space-x-0 md:space-y-2 md:flex-col">
Expand All @@ -216,6 +215,7 @@ const iconMap: { [key in MenuLabel]: LucideIcon } = {
team: Users,
templates: FileText,
sandboxes: PackageIcon,
developer: PencilRuler,
}

const MenuItem = ({
Expand Down Expand Up @@ -303,7 +303,7 @@ function MainContent({
billingUrl={billingUrlState[0]}
/>
)
case 'developer' as string:
case 'developer':
return (
<DeveloperContent
apiUrlState={apiUrlState}
Expand Down
11 changes: 1 addition & 10 deletions apps/web/src/components/Dashboard/AccountSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu'
import { ChevronRight, PencilRuler, PlusCircle } from 'lucide-react'
import { ChevronRight, PlusCircle } from 'lucide-react'
import { toast } from '../ui/use-toast'
import {
AlertDialog,
Expand All @@ -28,7 +28,6 @@ export const AccountSelector = ({
currentTeam,
setCurrentTeam,
setTeams,
openDevSettings,
}) => {
const [isDialogOpen, setIsDialogOpen] = useState(false)
const [teamName, setTeamName] = useState('')
Expand Down Expand Up @@ -93,14 +92,6 @@ export const AccountSelector = ({
<PlusCircle width={15} height={15} />
<span>Create Team</span>
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem
className="flex items-center space-x-1"
onClick={openDevSettings}
>
<PencilRuler width={15} height={15} />
<span>Developer</span>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>

Expand Down
44 changes: 39 additions & 5 deletions apps/web/src/components/Dashboard/Developer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import { Button } from '../Button'

const defaultAPIUrl = process.env.NEXT_PUBLIC_API_URL || ''
const defaultBillingUrl = process.env.NEXT_PUBLIC_BILLING_API_URL || ''

export const DeveloperContent = ({
apiUrlState,
billingUrlState,
Expand All @@ -12,12 +15,42 @@ export const DeveloperContent = ({
const [apiUrl, setApiUrl] = apiUrlState
const [billingUrl, setBillingUrl] = billingUrlState

function isUrl(url: string) {
try {
new URL(url)
return true
} catch (e) {
return false
}
}

return (
<div className="flex flex-col w-full">
<div className="flex flex-col h-full">
<h1 className="font-bold pb-10 text-xl">Developer settings</h1>
<h1 className="font-bold pb-10 text-xl">Dashboard settings</h1>

<span className="font-bold text-neutral-300 pb-2">API URL</span>
<span className="text-sm text-neutral-300 pb-4">
Customize E2B Cluster API URL.
</span>

{apiUrl !== defaultAPIUrl && (
<div
className="bg-white/5 border-l-4 border-orange-500/20 text-gray-300 p-4 mb-4 w-1/2"
role="alert"
>
<h4 className="font-medium pb-2">
Setting custom API URL in the E2B SDK & CLI
</h4>
<div className="text-sm text-gray-400">
In your environment variables, set E2B_DOMAIN variable to your
custom domain:
<br />
E2B_DOMAIN={isUrl(apiUrl) ? new URL(apiUrl).host : 'Invalid URL'}
</div>
</div>
)}

<div className="flex w-full items-center space-x-2 pb-4">
<input
type="text"
Expand All @@ -27,13 +60,16 @@ export const DeveloperContent = ({
/>
<Button
variant="desctructive"
onClick={() => setApiUrl(process.env.NEXT_PUBLIC_API_URL || '')}
onClick={() => setApiUrl(defaultAPIUrl)}
>
Reset to default
</Button>
</div>

<span className="font-bold text-neutral-300 pb-2">Billing URL</span>
<span className="text-sm text-neutral-300 pb-4">
Customize E2B Billing API URL.
</span>
<div className="flex w-full items-center space-x-2 pb-4">
<input
type="text"
Expand All @@ -43,9 +79,7 @@ export const DeveloperContent = ({
/>
<Button
variant="desctructive"
onClick={() =>
setBillingUrl(process.env.NEXT_PUBLIC_BILLING_API_URL || '')
}
onClick={() => setBillingUrl(defaultBillingUrl)}
>
Reset to default
</Button>
Expand Down

0 comments on commit 0526a5d

Please sign in to comment.