Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 70 additions & 2 deletions src/components/modals/ImageModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState, useMemo, useEffect } from 'react';
import { Download, Package, Monitor, Terminal, Zap, Star, Layers, Shield, FlaskConical, AppWindow, Box } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { Modal } from './Modal';
import { ErrorDisplay, ListItemSkeleton } from '../shared';
import { ErrorDisplay, ListItemSkeleton, ConfirmationDialog } from '../shared';
import type { BoardInfo, ImageInfo, ImageFilterType } from '../../types';
import { getImagesForBoard } from '../../hooks/useTauri';
import { useAsyncDataWhen } from '../../hooks/useAsyncData';
Expand Down Expand Up @@ -75,6 +75,9 @@ export function ImageModal({ isOpen, onClose, onSelect, board }: ImageModalProps
const { t } = useTranslation();
const [filterType, setFilterType] = useState<ImageFilterType>('all');
const [showSkeleton, setShowSkeleton] = useState(false);
// State for unstable image warning
const [pendingImage, setPendingImage] = useState<ImageInfo | null>(null);
const [showUnstableWarning, setShowUnstableWarning] = useState(false);

// Use hook for async data fetching
const { data: allImages, loading, error, reload } = useAsyncDataWhen<ImageInfo[]>(
Expand Down Expand Up @@ -109,6 +112,53 @@ export function ImageModal({ isOpen, onClose, onSelect, board }: ImageModalProps
};
}, [loading, imagesReady]);

// Reset warning state when modal is closed
useEffect(() => {
if (!isOpen) {
// eslint-disable-next-line react-hooks/set-state-in-effect -- Reset warning state when modal closes to prevent stale state from leaking into next session
setPendingImage(null);
setShowUnstableWarning(false);
}
}, [isOpen]);

/**
* Handle image click - show warning for unstable images before selecting
*/
function handleImageClick(image: ImageInfo) {
// Check if warning is needed
const isNightly = image.armbian_version.includes('trunk');
const isCommunityBoard = board?.has_community_support === true;

// No warning for custom images or stable images on supported boards
if (!isNightly && !isCommunityBoard) {
onSelect(image);
return;
}

// Show warning for nightly builds or community-supported boards
setPendingImage(image);
setShowUnstableWarning(true);
}

/**
* Confirm unstable image selection - proceed with pending image
*/
function handleUnstableWarningConfirm() {
if (pendingImage) {
onSelect(pendingImage);
setPendingImage(null);
}
setShowUnstableWarning(false);
}

/**
* Cancel unstable image selection - return to image list
*/
function handleUnstableWarningCancel() {
setPendingImage(null);
setShowUnstableWarning(false);
}

// Calculate available filters based on all images
const availableFilters = useMemo(() => {
if (!allImages) return { recommended: false, stable: false, nightly: false, apps: false, barebone: false };
Expand Down Expand Up @@ -181,7 +231,7 @@ export function ImageModal({ isOpen, onClose, onSelect, board }: ImageModalProps
<button
key={index}
className={`list-item ${image.promoted ? 'promoted' : ''}`}
onClick={() => onSelect(image)}
onClick={() => handleImageClick(image)}
>
{/* OS/App Icon */}
<div className="list-item-icon os-icon" style={{ backgroundColor: displayInfo?.color || DEFAULT_COLOR }}>
Expand Down Expand Up @@ -237,6 +287,24 @@ export function ImageModal({ isOpen, onClose, onSelect, board }: ImageModalProps
</div>
</>
)}

{/* Image status warning dialog */}
{showUnstableWarning && pendingImage && (
<ConfirmationDialog
isOpen={showUnstableWarning}
title={t('modal.imageStatusTitle')}
message={
board?.has_community_support === true
? t('modal.communityBoardMessage')
: t('modal.nightlyBuildMessage')
}
confirmText={t('common.confirm')}
cancelText={t('common.cancel')}
isDanger={false}
onCancel={handleUnstableWarningCancel}
onConfirm={handleUnstableWarningConfirm}
/>
)}
</Modal>
);
}
5 changes: 4 additions & 1 deletion src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"allImages": "Alle Images",
"insertDevice": "SD-Karte oder USB-Stick einstecken",
"refreshDevices": "Geräte aktualisieren",
"loading": "Wird geladen..."
"loading": "Wird geladen...",
"imageStatusTitle": "Image-Status-Warnung",
"nightlyBuildMessage": "Nightly-Builds sind automatische Entwicklungsversionen, die ungetestete Funktionen und Fehler enthalten können. Sie werden nicht für den Produktionsempfohlen.",
"communityBoardMessage": "Dieses Board wird von der Community gewartet. Images möglicherweise nicht starten oder korrekt funktionieren. Begrenzter Support ist verfügbar. Verwenden Sie wenn möglich offizielle Builds."
},
"device": {
"system": "System",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"allImages": "All Images",
"insertDevice": "Insert an SD card or USB drive",
"refreshDevices": "Refresh Devices",
"loading": "Loading..."
"loading": "Loading...",
"imageStatusTitle": "Image Status Warning",
"nightlyBuildMessage": "Nightly builds are automated development versions that may contain untested features and bugs. They are not recommended for production use.",
"communityBoardMessage": "This board is maintained by the community. Images may not boot or work correctly. Limited support is available. Use official builds when possible."
},
"device": {
"system": "System",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"allImages": "Todas las imágenes",
"insertDevice": "Inserte una tarjeta SD o unidad USB",
"refreshDevices": "Actualizar dispositivos",
"loading": "Cargando..."
"loading": "Cargando...",
"imageStatusTitle": "Advertencia de estado de imagen",
"nightlyBuildMessage": "Las versiones Nightly son versiones de desarrollo automatizadas que pueden contener funciones sin probar y errores. No se recomiendan para uso en producción.",
"communityBoardMessage": "Esta placa es mantenida por la comunidad. Las imágenes pueden no iniciarse o funcionar correctamente. Soporte limitado disponible. Use versiones oficiales cuando sea posible."
},
"device": {
"system": "Sistema",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"allImages": "Toutes les images",
"insertDevice": "Insérez une carte SD ou une clé USB",
"refreshDevices": "Actualiser les périphériques",
"loading": "Chargement..."
"loading": "Chargement...",
"imageStatusTitle": "Avertissement de statut d'image",
"nightlyBuildMessage": "Les versions Nightly sont des versions de développement automatisées qui peuvent contenir des fonctionnalités non testées et des bugs. Elles ne sont pas recommandées pour une utilisation en production.",
"communityBoardMessage": "Cette carte est maintenue par la communauté. Les images peuvent ne pas démarrer ou fonctionner correctement. Support limité disponible. Utilisez les versions officielles lorsque possible."
},
"device": {
"system": "Système",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/hr.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"allImages": "Sve slike",
"insertDevice": "Umetnite SD karticu ili USB uređaj",
"refreshDevices": "Osvježi uređaje",
"loading": "Učitavanje..."
"loading": "Učitavanje...",
"imageStatusTitle": "Upozorenje o statusu slike",
"nightlyBuildMessage": "Nightly izgradnje su automatske razvojne verzije koje mogu sadržavati neispitane značajke i greške. Nisu preporučene za proizvodnju.",
"communityBoardMessage": "Ovu ploču održava zajednica. Slike možda neće pokrenuti se ili ispravno raditi. Ograničena podrška je dostupna. Koristite službene izgradnje kada je moguće."
},
"device": {
"system": "Sustav",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"allImages": "Tutte le Immagini",
"insertDevice": "Inserisci una scheda SD o una chiavetta USB",
"refreshDevices": "Aggiorna Dispositivi",
"loading": "Caricamento..."
"loading": "Caricamento...",
"imageStatusTitle": "Avviso sullo stato dell'immagine",
"nightlyBuildMessage": "Le build Nightly sono versioni di sviluppo automatiche che possono contenere funzionalità non testate e bug. Non sono consigliate per l'uso in produzione.",
"communityBoardMessage": "Questa scheda è mantenuta dalla community. Le immagini potrebbero non avviarsi o funzionare correttamente. Supporto limitato disponibile. Usa le build ufficiali quando possibile."
},
"device": {
"system": "Sistema",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"allImages": "すべてのイメージ",
"insertDevice": "SDカードまたはUSBドライブを挿入してください",
"refreshDevices": "デバイスを更新",
"loading": "読み込み中..."
"loading": "読み込み中...",
"imageStatusTitle": "画像ステータス警告",
"nightlyBuildMessage": "Nightlyビルドは自動開発バージョンであり、テストされていない機能やバグが含まれている可能性があります。本番環境での使用は推奨されません。",
"communityBoardMessage": "このボードはコミュニティによって維持されています。イメージが起動しない、または正しく動作しない可能性があります。サポートは限定的です。可能な場合は公式ビルドを使用してください。"
},
"device": {
"system": "システム",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"allImages": "모든 이미지",
"insertDevice": "SD 카드 또는 USB 드라이브를 삽입하세요",
"refreshDevices": "장치 새로고침",
"loading": "로드 중..."
"loading": "로드 중...",
"imageStatusTitle": "이미지 상태 경고",
"nightlyBuildMessage": "Nightly 빌드는 테스트되지 않은 기능과 버그가 포함될 수 있는 자동 개발 버전입니다. 프로덕션 사용에는 권장되지 않습니다.",
"communityBoardMessage": "이 보드는 커뮤니티에서 유지 관리됩니다. 이미지가 부팅되지 않거나 제대로 작동하지 않을 수 있습니다. 지원이 제한되어 있습니다. 가능하면 공식 빌드를 사용하세요."
},
"device": {
"system": "시스템",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"allImages": "Alle images",
"insertDevice": "Plaats een SD-kaart of USB-stick",
"refreshDevices": "Apparaten vernieuwen",
"loading": "Laden..."
"loading": "Laden...",
"imageStatusTitle": "Image Status Waarschuwing",
"nightlyBuildMessage": "Nightly-builds zijn automatische ontwikkelingsversies die ongeteste functies en bugs kunnen bevatten. Ze worden niet aanbevolen voor productiegebruik.",
"communityBoardMessage": "Dit board wordt door de community onderhouden. Images mogelijk niet correct opstarten of werken. Beperkte ondersteuning beschikbaar. Gebruik indien mogelijk officiële builds."
},
"device": {
"system": "Systeem",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"allImages": "Wszystkie obrazy",
"insertDevice": "Włóż kartę SD lub pendrive USB",
"refreshDevices": "Odśwież urządzenia",
"loading": "Ładowanie..."
"loading": "Ładowanie...",
"imageStatusTitle": "Ostrzeżenie o statusie obrazu",
"nightlyBuildMessage": "Wersje Nightly to automatyczne wersje programistyczne, które mogą zawierać nieprzetestowane funkcje i błędy. Nie są zalecane do użytku produkcyjnego.",
"communityBoardMessage": "Ta płyta jest utrzymywana przez społeczność. Obrazy może nie udać się uruchomić lub działać poprawnie. Ograniczone wsparcie jest dostępne. Używaj oficjalnych kompilacji, gdy to możliwe."
},
"device": {
"system": "System",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"allImages": "Todas as imagens",
"insertDevice": "Insira um cartão SD ou pendrive USB",
"refreshDevices": "Atualizar dispositivos",
"loading": "Carregando..."
"loading": "Carregando...",
"imageStatusTitle": "Aviso de estado da imagem",
"nightlyBuildMessage": "Versões Nightly são versões de desenvolvimento automáticas que podem conter recursos não testados e bugs. Não são recomendadas para uso em produção.",
"communityBoardMessage": "Esta placa é mantida pela comunidade. As imagens podem não inicializar ou funcionar corretamente. Suporte limitado disponível. Use compilações oficiais quando possível."
},
"device": {
"system": "Sistema",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"allImages": "Todas as imagens",
"insertDevice": "Insira um cartão SD ou pendrive USB",
"refreshDevices": "Atualizar dispositivos",
"loading": "A carregar..."
"loading": "A carregar...",
"imageStatusTitle": "Aviso de estado da imagem",
"nightlyBuildMessage": "As versões Nightly são versões de desenvolvimento automáticas que podem conter funcionalidades não testadas e erros. Não são recomendadas para uso em produção.",
"communityBoardMessage": "Esta placa é mantida pela comunidade. As imagens podem não iniciar ou funcionar corretamente. Suporte limitado disponível. Use versões oficiais quando possível."
},
"device": {
"system": "Sistema",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"allImages": "Все образы",
"insertDevice": "Вставьте SD-карту или USB-накопитель",
"refreshDevices": "Обновить устройства",
"loading": "Загрузка..."
"loading": "Загрузка...",
"imageStatusTitle": "Предупреждение о статусе образа",
"nightlyBuildMessage": "Сборки Nightly — это автоматические версии для разработки, которые могут содержать непроверенные функции и ошибки. Они не рекомендуются для производственного использования.",
"communityBoardMessage": "Эта плата поддерживается сообществом. Образы могут не загрузиться или работать неправильно. Доступна ограниченная поддержка. По возможности используйте официальные сборки."
},
"device": {
"system": "Системный",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/sl.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"allImages": "Vse slike",
"insertDevice": "Vstavite SD kartico ali USB pogon",
"refreshDevices": "Osveži naprave",
"loading": "Nalaganje..."
"loading": "Nalaganje...",
"imageStatusTitle": "Opozorilo o stanu slike",
"nightlyBuildMessage": "Različice Nightly so samodejne razvojne različice, ki lahko vsebujejo nepreizkušene funkcije in napake. Niso priporočene za proizvodnjo.",
"communityBoardMessage": "To ploščo vzdržuje skupnost. Slike morda ne bodo zagnale ali delovale pravilno. Na voljo je omejena podpora. Ko je mogoče, uporabite uradne različice."
},
"device": {
"system": "Sistemska",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"minimal": "Minimal",
"allImages": "Alla images",
"insertDevice": "Sätt i ett SD-kort eller USB-minne",
"refreshDevices": "Uppdatera enheter"
"refreshDevices": "Uppdatera enheter",
"imageStatusTitle": "Varning om avbildningsstatus",
"nightlyBuildMessage": "Nightly-versioner är automatiska utvecklingsversioner som kan innehålla otestade funktioner och buggar. De rekommenderas inte för användning i produktion.",
"communityBoardMessage": "Detta kort underhålls av gemenskapen. Images kanske inte startar eller fungerar korrekt. Begränsad support finns tillgänglig. Använd officiella versioner när det är möjligt."
},
"device": {
"system": "System",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"allImages": "Tüm İmajlar",
"insertDevice": "Bir SD kart veya USB sürücü takın",
"refreshDevices": "Cihazları Yenile",
"loading": "Yükleniyor..."
"loading": "Yükleniyor...",
"imageStatusTitle": "İmaj Durumu Uyarısı",
"nightlyBuildMessage": "Nightly yapımları, test edilmemiş özellikler ve hatalar içerebilen otomatik geliştirme sürümleridir. Üretim kullanımı için önerilmez.",
"communityBoardMessage": "Bu kart topluluk tarafından sürdürülüyor. İmajlar önyüklemez veya düzgün çalışmayabilir. Sınırlı destek mevcut. Mümkün olduğunda resmi yapımları kullanın."
},
"device": {
"system": "Sistem",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"allImages": "Усі образи",
"insertDevice": "Вставте SD-картку або USB-накопичувач",
"refreshDevices": "Оновити пристрої",
"loading": "Завантаження..."
"loading": "Завантаження...",
"imageStatusTitle": "Попередження про статус образу",
"nightlyBuildMessage": "Збірки Nightly — це автоматичні версії для розробки, які можуть містити неперевірені функції та помилки. Вони не рекомендуються для виробничого використання.",
"communityBoardMessage": "Ця плата підтримується спільнотою. Образи можуть не завантажитись або працювати неправильно. Обмежена підтримка доступна. Використовуйте офіційні збірки, коли це можливо."
},
"device": {
"system": "Системний",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"allImages": "所有镜像",
"insertDevice": "请插入SD卡或U盘",
"refreshDevices": "刷新设备",
"loading": "加载中..."
"loading": "加载中...",
"imageStatusTitle": "镜像状态警告",
"nightlyBuildMessage": "每日构建版本是自动开发版本,可能包含未经测试的功能和错误。不建议在生产环境中使用。",
"communityBoardMessage": "此开发板由社区维护。镜像可能无法启动或正常工作。支持有限。请尽可能使用官方构建。"
},
"device": {
"system": "系统",
Expand Down