Add "Scan a packet" to the editor's Plants mode #120
@@ -13,6 +13,7 @@ import { PlantPicker } from '@/editor/PlantPicker'
|
||||
import { Palette } from '@/editor/Palette'
|
||||
import { SeedTray } from '@/editor/SeedTray'
|
||||
import { RecentPlants } from '@/editor/RecentPlants'
|
||||
import { ScanPacketModal } from '@/components/plants/ScanPacketModal'
|
||||
|
|
||||
import { ClearBedModal } from '@/editor/ClearBedModal'
|
||||
import { EditorHint } from '@/editor/EditorHint'
|
||||
import { SeasonBanner, SeasonPicker } from '@/editor/SeasonPicker'
|
||||
@@ -108,6 +109,7 @@ export function GardenEditorPage() {
|
||||
const [picker, setPicker] = useState<'place' | 'change' | null>(null)
|
||||
const [sharing, setSharing] = useState(false)
|
||||
const [clearing, setClearing] = useState(false)
|
||||
const [scanning, setScanning] = useState(false)
|
||||
const nudgeTimer = useRef<number | null>(null)
|
||||
const nudgeFire = useRef<(() => void) | null>(null)
|
||||
|
||||
@@ -632,6 +634,8 @@ export function GardenEditorPage() {
|
||||
onClear={() => setClearing(true)}
|
||||
onFill={fillBed}
|
||||
filling={fillObject.isPending}
|
||||
canScan={!!capabilities.data?.vision}
|
||||
|
gitea-actions
commented
⚪ capabilities.data?.vision read inline at three sites; hoist to a single canScan local for consistency maintainability · flagged by 1 model
🪰 Gadfly · advisory ⚪ **capabilities.data?.vision read inline at three sites; hoist to a single canScan local for consistency**
_maintainability · flagged by 1 model_
- `web/src/pages/GardenEditorPage.tsx:735-743` — The mobile pre-focus hint inlines a second copy of the "📷 Scan packet" button JSX instead of reusing the one already factored into `PlantPlacementTools` (lines 819-823). The PR's stated premise is dedup via `PlantPlacementTools`, and it holds for the two focused-bed sites, but this third site duplicates the label, `variant="ghost"`, the `text-xs` ghost-button styling, and `onClick={() => setScanning(true)}` (the `ml-auto` class differs here vs. th…
<sub>🪰 Gadfly · advisory</sub>
|
||||
onScan={() => setScanning(true)}
|
||||
/>
|
||||
) : (
|
||||
<span className="text-xs text-muted">Not plantable</span>
|
||||
@@ -706,6 +710,8 @@ export function GardenEditorPage() {
|
||||
onClear={() => setClearing(true)}
|
||||
onFill={fillBed}
|
||||
filling={fillObject.isPending}
|
||||
canScan={!!capabilities.data?.vision}
|
||||
onScan={() => setScanning(true)}
|
||||
/>
|
||||
<Button variant="ghost" className="ml-auto px-2 py-1 text-xs" onClick={exitFocus}>
|
||||
Done planting
|
||||
@@ -724,7 +730,18 @@ export function GardenEditorPage() {
|
||||
</div>
|
||||
)
|
||||
) : (
|
||||
<p className="px-1 text-xs text-muted">Tap a bed, then “🌱 Plant here” to start planting.</p>
|
||||
<div className="flex items-center gap-2">
|
||||
<p className="px-1 text-xs text-muted">Tap a bed, then “🌱 Plant here” to start planting.</p>
|
||||
{capabilities.data?.vision && (
|
||||
|
gitea-actions
commented
🟡 Mobile pre-focus hint duplicates the "📷 Scan packet" button JSX instead of sharing it with PlantPlacementTools maintainability · flagged by 1 model
🪰 Gadfly · advisory 🟡 **Mobile pre-focus hint duplicates the "📷 Scan packet" button JSX instead of sharing it with PlantPlacementTools**
_maintainability · flagged by 1 model_
- `web/src/pages/GardenEditorPage.tsx:735-743` — The mobile pre-focus hint inlines a second copy of the "📷 Scan packet" button JSX instead of reusing the one already factored into `PlantPlacementTools` (lines 819-823). The PR's stated premise is dedup via `PlantPlacementTools`, and it holds for the two focused-bed sites, but this third site duplicates the label, `variant="ghost"`, the `text-xs` ghost-button styling, and `onClick={() => setScanning(true)}` (the `ml-auto` class differs here vs. th…
<sub>🪰 Gadfly · advisory</sub>
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="ml-auto px-2 py-1 text-xs"
|
||||
onClick={() => setScanning(true)}
|
||||
>
|
||||
📷 Scan packet
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
@@ -741,6 +758,8 @@ export function GardenEditorPage() {
|
||||
|
||||
{sharing && <ShareGardenModal garden={g} onClose={() => setSharing(false)} />}
|
||||
|
||||
{scanning && <ScanPacketModal unit={garden.unitPref} onClose={() => setScanning(false)} />}
|
||||
|
||||
{clearing && focusedObject && (
|
||||
<ClearBedModal
|
||||
objectId={focusedObject.id}
|
||||
@@ -768,6 +787,8 @@ function PlantPlacementTools({
|
||||
onClear,
|
||||
onFill,
|
||||
filling,
|
||||
canScan,
|
||||
onScan,
|
||||
}: {
|
||||
recentPlants: Plant[]
|
||||
trayPlants: Plant[]
|
||||
@@ -780,6 +801,10 @@ function PlantPlacementTools({
|
||||
onClear: () => void
|
||||
onFill: (layout: FillLayout) => void
|
||||
filling: boolean
|
||||
// Scanning a packet adds a variety to the catalog mid-planting; only offered
|
||||
// where a vision model is configured.
|
||||
canScan: boolean
|
||||
onScan: () => void
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
@@ -791,6 +816,11 @@ function PlantPlacementTools({
|
||||
onRemove={onRemove}
|
||||
onOpenPicker={onOpenPicker}
|
||||
/>
|
||||
{canScan && (
|
||||
<Button variant="ghost" className="px-2 py-1 text-xs" onClick={onScan}>
|
||||
📷 Scan packet
|
||||
</Button>
|
||||
)}
|
||||
{armedPlant && <FillControl onFill={onFill} busy={filling} />}
|
||||
{armedPlant && (
|
||||
<Button variant="ghost" className="px-2 py-1 text-xs" onClick={onDisarm}>
|
||||
|
||||
Reference in New Issue
Block a user
⚪ ScanPacketModal (a @/components/ import) placed mid-@/editor import block*
maintainability · flagged by 1 model
web/src/pages/GardenEditorPage.tsx:735-743— The mobile pre-focus hint inlines a second copy of the "📷 Scan packet" button JSX instead of reusing the one already factored intoPlantPlacementTools(lines 819-823). The PR's stated premise is dedup viaPlantPlacementTools, and it holds for the two focused-bed sites, but this third site duplicates the label,variant="ghost", thetext-xsghost-button styling, andonClick={() => setScanning(true)}(theml-autoclass differs here vs. th…🪰 Gadfly · advisory