import { MobileListView } from "../mobile/mobile-list-view"; import { MobileDetailView } from "../mobile/mobile-detail-view"; import { MobileEditView } from "../mobile/mobile-edit-view"; import { MobileFAB } from "../mobile/mobile-fab"; import { Icon } from "../../icon"; import type { ConfigProfile, CreateConfigProfileRequest } from "../../../api/config-profiles"; type MobileView = "list" | "detail" | "edit"; interface Props { profiles: ConfigProfile[]; selectedProfile: ConfigProfile | null; mobileView: MobileView; isCreating: boolean; formData: CreateConfigProfileRequest; saveStatus: "idle" | "saving" | "saved" | "error"; onViewChange: (view: MobileView) => void; onSelect: (profile: ConfigProfile) => void; onCreate: () => void; onDelete: (id: string) => void; onFormChange: (key: K, value: CreateConfigProfileRequest[K]) => void; onSubmit: () => void; getScopeLabel: (profile: ConfigProfile) => string; } export const ConfigProfilesMobileView = ({ profiles, selectedProfile, mobileView, isCreating, formData, saveStatus, onViewChange, onSelect, onCreate, onDelete, onFormChange, onSubmit, getScopeLabel, }: Props) => { if (mobileView === "list") { return (

Config Profiles

({ id: profile.id, title: profile.name, subtitle: profile.description || getScopeLabel(profile), }))} onItemClick={(id: string) => { const profile = profiles.find((p) => p.id === id); if (profile) { onSelect(profile); onViewChange("detail"); } }} onItemDelete={(id: string) => onDelete(id)} emptyMessage="No config profiles yet" /> { onCreate(); onViewChange("edit"); }} />
); } if (mobileView === "detail" && selectedProfile) { const fields = [ { label: "Name", value: selectedProfile.name }, { label: "Description", value: selectedProfile.description || "-" }, { label: "Scope", value: getScopeLabel(selectedProfile) }, { label: "Default", value: selectedProfile.is_default ? "Yes" : "No" }, { label: "Environment Variables", value: Object.keys(selectedProfile.env_vars).length > 0 ? Object.entries(selectedProfile.env_vars) .map(([k, v]) => `${k}=${v}`) .join(", ") : "-", }, { label: "Mounts", value: selectedProfile.mounts.length > 0 ? selectedProfile.mounts.map((m) => `${m.target} (${m.mode})`).join(", ") : "-", }, { label: "Includes", value: selectedProfile.includes.length > 0 ? `${selectedProfile.includes.length} profile(s)` : "-", }, ]; return ( onViewChange("list")} onEdit={() => { onSelect(selectedProfile); onViewChange("edit"); }} onDelete={() => onDelete(selectedProfile.id)} /> ); } if (mobileView === "edit") { return ( { onViewChange(isCreating ? "list" : "detail"); }} onSave={onSubmit} isSaving={saveStatus === "saving"} >
onFormChange("name", e.target.value)} placeholder="Profile name" required />