diff --git a/src/components/admin/devices/admin-devices-overview.tsx b/src/components/admin/devices/admin-devices-overview.tsx index 3a3d0cb..74732b7 100644 --- a/src/components/admin/devices/admin-devices-overview.tsx +++ b/src/components/admin/devices/admin-devices-overview.tsx @@ -3129,7 +3129,7 @@ export function DeviceDetails({ device }: DeviceDetailsProps) { const hasRemoteAccess = remoteAccessEntries.length > 0 const summaryChips = useMemo(() => { - const chips: Array<{ key: string; label: string; value: string; icon: ReactNode; tone?: "warning" | "muted" }> = [] + const chips: Array<{ key: string; label: string; value: string; icon: ReactNode; tone?: "warning" | "muted"; onClick?: () => void }> = [] const osName = osNameDisplay || "Sistema desconhecido" const osVersionRaw = device?.osVersion ?? windowsVersionLabel ?? "" const osVersion = formatOsVersionDisplay(osNameDisplay, osVersionRaw) @@ -3259,6 +3259,7 @@ export function DeviceDetails({ device }: DeviceDetailsProps) { const [togglingActive, setTogglingActive] = useState(false) const [isResettingAgent, setIsResettingAgent] = useState(false) const [showAllWindowsSoftware, setShowAllWindowsSoftware] = useState(false) + const [isUsbModalOpen, setIsUsbModalOpen] = useState(false) const jsonText = useMemo(() => { const payload = { id: device?.id, @@ -3927,10 +3928,40 @@ export function DeviceDetails({ device }: DeviceDetailsProps) { {/* ping integrado na badge de status */}
{summaryChips.map((chip) => ( - + setIsUsbModalOpen(true) : undefined} + /> ))}
+ {/* Modal de Controle USB */} + + + + + + Controle de USB - {device.displayName ?? device.hostname} + + + Gerencie as politicas de acesso a dispositivos USB de armazenamento + + + + + +

Controles do dispositivo

@@ -5257,16 +5288,6 @@ export function DeviceDetails({ device }: DeviceDetailsProps) { ) : null} - - {canManageRemoteAccess && device?.osName?.toLowerCase().includes("windows") ? ( - - ) : null}
{windowsCpuDetails.length > 0 ? ( @@ -6196,7 +6217,7 @@ function DetailLine({ label, value, classNameValue, layout = "spread" }: DetailL ) } -function InfoChip({ label, value, icon, tone = "default" }: { label: string; value: string; icon?: ReactNode; tone?: "default" | "warning" | "muted" }) { +function InfoChip({ label, value, icon, tone = "default", onClick }: { label: string; value: string; icon?: ReactNode; tone?: "default" | "warning" | "muted"; onClick?: () => void }) { const toneClasses = tone === "warning" ? "border-amber-200 bg-amber-50 text-amber-700" @@ -6204,8 +6225,16 @@ function InfoChip({ label, value, icon, tone = "default" }: { label: string; val ? "border-slate-200 bg-slate-50 text-neutral-600" : "border-slate-200 bg-white text-neutral-800" + const clickableClasses = onClick ? "cursor-pointer hover:ring-2 hover:ring-blue-200 transition-all" : "" + return ( -
+
{ if (e.key === "Enter" || e.key === " ") onClick() } : undefined} + > {icon ? {icon} : null}

{label}

diff --git a/src/components/admin/devices/usb-policy-control.tsx b/src/components/admin/devices/usb-policy-control.tsx index 4ee4739..d01ba50 100644 --- a/src/components/admin/devices/usb-policy-control.tsx +++ b/src/components/admin/devices/usb-policy-control.tsx @@ -99,6 +99,7 @@ interface UsbPolicyControlProps { actorName?: string actorId?: string disabled?: boolean + variant?: "card" | "inline" } export function UsbPolicyControl({ @@ -108,6 +109,7 @@ export function UsbPolicyControl({ actorName, actorId, disabled = false, + variant = "card", }: UsbPolicyControlProps) { const [selectedPolicy, setSelectedPolicy] = useState("ALLOW") const [isApplying, setIsApplying] = useState(false) @@ -135,7 +137,7 @@ export function UsbPolicyControl({ const handleApplyPolicy = async () => { if (selectedPolicy === usbPolicy?.policy) { - toast.info("A política selecionada já está aplicada.") + toast.info("A politica selecionada ja esta aplicada.") return } @@ -148,10 +150,10 @@ export function UsbPolicyControl({ actorEmail, actorName, }) - toast.success("Política USB enviada para aplicação.") + toast.success("Politica USB enviada para aplicacao.") } catch (error) { - console.error("[usb-policy] Falha ao aplicar política", error) - toast.error("Falha ao aplicar política USB. Tente novamente.") + console.error("[usb-policy] Falha ao aplicar politica", error) + toast.error("Falha ao aplicar politica USB. Tente novamente.") } finally { setIsApplying(false) } @@ -164,22 +166,10 @@ export function UsbPolicyControl({ }) } - return ( - - -
-
- - Controle USB -
- {usbPolicy?.status && getStatusBadge(usbPolicy.status)} -
- - Gerencie o acesso a dispositivos de armazenamento USB neste dispositivo. - -
- -
+ const content = ( +
+
+
@@ -188,120 +178,144 @@ export function UsbPolicyControl({

{currentConfig.description}

+ {usbPolicy?.status && getStatusBadge(usbPolicy.status)} +
- {usbPolicy?.error && ( -
-

Erro na aplicação

-

{usbPolicy.error}

-
- )} - -
-
- - -
- - - - - - - {selectedPolicy === usbPolicy?.policy - ? "A política já está aplicada" - : `Aplicar política "${getPolicyConfig(selectedPolicy).label}"`} - - - + {usbPolicy?.error && ( +
+

Erro na aplicacao

+

{usbPolicy.error}

+ )} -
- + + + {selectedPolicy === usbPolicy?.policy + ? "A politica ja esta aplicada" + : `Aplicar politica "${getPolicyConfig(selectedPolicy).label}"`} + + + +
- {usbPolicy?.reportedAt && ( -

- Último relato do agente: {formatEventDate(usbPolicy.reportedAt)} -

+
+ + + {showHistory && policyEvents && ( +
+ {policyEvents.length === 0 ? ( +

+ Nenhuma alteracao registrada +

+ ) : ( + policyEvents.map((event: UsbPolicyEvent) => ( +
+
+
+ + {getPolicyConfig(event.oldPolicy).label} + + -> + + {getPolicyConfig(event.newPolicy).label} + + {getStatusBadge(event.status)} +
+

+ {event.actorName ?? event.actorEmail ?? "Sistema"} - {formatEventDate(event.createdAt)} +

+ {event.error && ( +

{event.error}

+ )} +
+
+ )) + )} +
)} +
+ + {usbPolicy?.reportedAt && ( +

+ Ultimo relato do agente: {formatEventDate(usbPolicy.reportedAt)} +

+ )} +
+ ) + + if (variant === "inline") { + return content + } + + return ( + + +
+
+ + Controle USB +
+
+ + Gerencie o acesso a dispositivos de armazenamento USB neste dispositivo. + +
+ + {content}
)