mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-21 03:18:47 +00:00
refactor: add icon support for deployments and services in UI components
This commit is contained in:
@@ -14,10 +14,11 @@ import {
|
|||||||
import type { inferRouterOutputs } from "@trpc/server";
|
import type { inferRouterOutputs } from "@trpc/server";
|
||||||
import {
|
import {
|
||||||
ArrowUpDown,
|
ArrowUpDown,
|
||||||
Boxes,
|
|
||||||
ChevronLeft,
|
ChevronLeft,
|
||||||
ChevronRight,
|
ChevronRight,
|
||||||
|
CircuitBoard,
|
||||||
ExternalLink,
|
ExternalLink,
|
||||||
|
GlobeIcon,
|
||||||
Loader2,
|
Loader2,
|
||||||
Rocket,
|
Rocket,
|
||||||
Server,
|
Server,
|
||||||
@@ -71,6 +72,7 @@ function getServiceInfo(d: DeploymentRow) {
|
|||||||
return {
|
return {
|
||||||
type: "Application" as const,
|
type: "Application" as const,
|
||||||
name: app.name,
|
name: app.name,
|
||||||
|
icon: app.icon,
|
||||||
projectId: app.environment.project.projectId,
|
projectId: app.environment.project.projectId,
|
||||||
environmentId: app.environment.environmentId,
|
environmentId: app.environment.environmentId,
|
||||||
projectName: app.environment.project.name,
|
projectName: app.environment.project.name,
|
||||||
@@ -83,6 +85,7 @@ function getServiceInfo(d: DeploymentRow) {
|
|||||||
return {
|
return {
|
||||||
type: "Compose" as const,
|
type: "Compose" as const,
|
||||||
name: comp.name,
|
name: comp.name,
|
||||||
|
icon: comp.icon,
|
||||||
projectId: comp.environment.project.projectId,
|
projectId: comp.environment.project.projectId,
|
||||||
environmentId: comp.environment.environmentId,
|
environmentId: comp.environment.environmentId,
|
||||||
projectName: comp.environment.project.name,
|
projectName: comp.environment.project.name,
|
||||||
@@ -175,10 +178,16 @@ export function ShowDeploymentsTable() {
|
|||||||
if (!info) return <span className="text-muted-foreground">—</span>;
|
if (!info) return <span className="text-muted-foreground">—</span>;
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
{info.type === "Application" ? (
|
{info.icon ? (
|
||||||
<Rocket className="size-4 text-muted-foreground shrink-0" />
|
<img
|
||||||
|
src={info.icon}
|
||||||
|
alt={info.name}
|
||||||
|
className="size-4 object-contain shrink-0"
|
||||||
|
/>
|
||||||
|
) : info.type === "Application" ? (
|
||||||
|
<GlobeIcon className="size-4 text-muted-foreground shrink-0" />
|
||||||
) : (
|
) : (
|
||||||
<Boxes className="size-4 text-muted-foreground shrink-0" />
|
<CircuitBoard className="size-4 text-muted-foreground shrink-0" />
|
||||||
)}
|
)}
|
||||||
<div className="flex flex-col min-w-0">
|
<div className="flex flex-col min-w-0">
|
||||||
<span className="font-medium truncate">{info.name}</span>
|
<span className="font-medium truncate">{info.name}</span>
|
||||||
|
|||||||
@@ -45,10 +45,12 @@ type ServiceItem = {
|
|||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
type: ServiceType;
|
type: ServiceType;
|
||||||
|
icon: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
type NamedService = {
|
type NamedService = {
|
||||||
name: string;
|
name: string;
|
||||||
|
icon?: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
type EnvironmentServiceCollections = {
|
type EnvironmentServiceCollections = {
|
||||||
@@ -116,8 +118,20 @@ const getStringQueryParam = (value: string | string[] | undefined) =>
|
|||||||
const includesSearch = (value: string | null | undefined, search: string) =>
|
const includesSearch = (value: string | null | undefined, search: string) =>
|
||||||
value?.toLowerCase().includes(search.toLowerCase()) ?? false;
|
value?.toLowerCase().includes(search.toLowerCase()) ?? false;
|
||||||
|
|
||||||
const getServiceIcon = (type: ServiceType, className = "size-4") => {
|
const getServiceIcon = (
|
||||||
const Icon = SERVICE_ICONS[type];
|
service: Pick<ServiceItem, "type" | "icon">,
|
||||||
|
className = "size-4",
|
||||||
|
) => {
|
||||||
|
if (service.icon) {
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
src={service.icon}
|
||||||
|
alt=""
|
||||||
|
className={`${className} object-contain shrink-0`}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const Icon = SERVICE_ICONS[service.type];
|
||||||
return <Icon className={className} />;
|
return <Icon className={className} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -127,7 +141,7 @@ const countEnvironmentServices = (environment: ServiceCollections): number =>
|
|||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
|
|
||||||
const mapServices = <T extends { name: string }>(
|
const mapServices = <T extends NamedService>(
|
||||||
items: readonly T[],
|
items: readonly T[],
|
||||||
getId: (item: T) => string,
|
getId: (item: T) => string,
|
||||||
type: ServiceType,
|
type: ServiceType,
|
||||||
@@ -136,6 +150,7 @@ const mapServices = <T extends { name: string }>(
|
|||||||
id: getId(item),
|
id: getId(item),
|
||||||
name: item.name,
|
name: item.name,
|
||||||
type,
|
type,
|
||||||
|
icon: item.icon ?? null,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const extractServicesFromEnvironment = (
|
const extractServicesFromEnvironment = (
|
||||||
@@ -550,7 +565,7 @@ export const AdvanceBreadcrumb = () => {
|
|||||||
aria-expanded={serviceOpen}
|
aria-expanded={serviceOpen}
|
||||||
className="h-auto px-2 py-1.5 hover:bg-accent gap-2"
|
className="h-auto px-2 py-1.5 hover:bg-accent gap-2"
|
||||||
>
|
>
|
||||||
{getServiceIcon(currentService.type)}
|
{getServiceIcon(currentService)}
|
||||||
<span className="font-medium max-w-[50px] md:max-w-[150px] truncate">
|
<span className="font-medium max-w-[50px] md:max-w-[150px] truncate">
|
||||||
{currentService.name}
|
{currentService.name}
|
||||||
</span>
|
</span>
|
||||||
@@ -589,7 +604,7 @@ export const AdvanceBreadcrumb = () => {
|
|||||||
>
|
>
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<div className="flex items-center justify-center size-8 rounded-md bg-muted">
|
<div className="flex items-center justify-center size-8 rounded-md bg-muted">
|
||||||
{getServiceIcon(service.type)}
|
{getServiceIcon(service)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<span className="font-medium">
|
<span className="font-medium">
|
||||||
|
|||||||
@@ -802,7 +802,7 @@ export const findAllDeploymentsByComposeId = async (composeId: string) => {
|
|||||||
|
|
||||||
const centralizedDeploymentsWith = {
|
const centralizedDeploymentsWith = {
|
||||||
application: {
|
application: {
|
||||||
columns: { applicationId: true, name: true, appName: true },
|
columns: { applicationId: true, name: true, appName: true, icon: true },
|
||||||
with: {
|
with: {
|
||||||
environment: {
|
environment: {
|
||||||
columns: { environmentId: true, name: true },
|
columns: { environmentId: true, name: true },
|
||||||
@@ -821,7 +821,7 @@ const centralizedDeploymentsWith = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
compose: {
|
compose: {
|
||||||
columns: { composeId: true, name: true, appName: true },
|
columns: { composeId: true, name: true, appName: true, icon: true },
|
||||||
with: {
|
with: {
|
||||||
environment: {
|
environment: {
|
||||||
columns: { environmentId: true, name: true },
|
columns: { environmentId: true, name: true },
|
||||||
|
|||||||
Reference in New Issue
Block a user