GeezerVison is showing github.com — refactor: one derivation over the query channel says whether the buil… · u8array/ZPLab@7ad1739
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/components/Output/RendererSelect.tsx +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,7 +2,7 @@ import { useId } from "react"; | 2 | 2 | import { useT } from "../../hooks/useT"; | 3 | 3 | import { formatTemplate } from "../../lib/formatTemplate"; | 4 | 4 | import { previewProviderChoices, previewProviderLabel } from "../../lib/previewProviderLabel"; | 5 | | -import { selectEffectivePreviewProvider, useLabelStore } from "../../store/labelStore"; | | 5 | +import { selectEffectivePreviewProvider, selectReadsPrinter, useLabelStore } from "../../store/labelStore"; | 6 | 6 | import type { PreviewProvider } from "../../store/slices/uiSlice"; | 7 | 7 | import { sectionHeadingCls } from "../ui/formStyles"; | 8 | 8 | import { Select } from "../ui/Select"; | @@ -14,8 +14,9 @@ export function RendererSelect() { | 14 | 14 | const chosen = useLabelStore((s) => s.previewProvider); | 15 | 15 | const effective = useLabelStore(selectEffectivePreviewProvider); | 16 | 16 | const labelaryAvailable = useLabelStore((s) => s.thirdParty.labelary); | | 17 | + const readsPrinter = useLabelStore(selectReadsPrinter); | 17 | 18 | const setProvider = useLabelStore((s) => s.setPreviewProvider); | 18 | | - const choices = previewProviderChoices(t, { thirdParty: { labelary: labelaryAvailable } }); | | 19 | + const choices = previewProviderChoices(t, { labelary: labelaryAvailable, printer: readsPrinter }); | 19 | 20 | return ( | 20 | 21 | <div className="flex flex-col gap-1"> | 21 | 22 | <label htmlFor={id} className={sectionHeadingCls}> | |
Collapse file Copy file name to clipboardExpand all lines: src/components/Output/ZPLOutput.tsx +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { useRef } from 'react'; | 2 | 2 | import { CheckIcon, ClipboardDocumentIcon, ChevronDownIcon, ChevronUpIcon, EyeIcon, PrinterIcon } from '@heroicons/react/16/solid'; | 3 | | -import { useLabelStore, selectEffectivePreviewProvider, selectPreviewLocksEditor } from '../../store/labelStore'; | | 3 | +import { useLabelStore, selectEffectivePreviewProvider, selectPreviewLocksEditor, selectReadsPrinter } from '../../store/labelStore'; | 4 | 4 | import { useZplOutputView } from '../../hooks/useZplOutputView'; | 5 | 5 | import { useCopyToClipboard } from '../../hooks/useCopyToClipboard'; | 6 | 6 | import { finishZplExport } from '../../lib/exportZpl'; | 7 | 7 | import { useT } from '../../hooks/useT'; | 8 | 8 | import { useLabelaryConsent } from '../../hooks/useLabelaryConsent'; | 9 | 9 | import { ZplSourceEditor } from './ZplSourceEditor'; | 10 | 10 | import { Tooltip } from '../ui/Tooltip'; | 11 | | -import { isDesktopShell } from '../../lib/platform'; | 12 | 11 | import { PrinterChip } from './PrinterChip'; | 13 | 12 | import { PaginationControl } from './PaginationControl'; | 14 | 13 | import { sectionHeadingCls } from '../ui/formStyles'; | @@ -27,6 +26,7 @@ export function ZPLOutput({ collapsed, onCollapse, onExpand, onResizeMouseDown } | 27 | 26 | const t = useT(); | 28 | 27 | const effectiveProvider = useLabelStore(selectEffectivePreviewProvider); | 29 | 28 | const previewActive = useLabelStore(selectPreviewLocksEditor); | | 29 | + const readsPrinter = useLabelStore(selectReadsPrinter); | 30 | 30 | const enterPreviewMode = useLabelStore((s) => s.enterPreviewMode); | 31 | 31 | const exitPreviewMode = useLabelStore((s) => s.exitPreviewMode); | 32 | 32 | const { gate, notice: consentNotice } = useLabelaryConsent(); | @@ -80,7 +80,7 @@ export function ZPLOutput({ collapsed, onCollapse, onExpand, onResizeMouseDown } | 80 | 80 | </div> | 81 | 81 | <PaginationControl /> | 82 | 82 | <div className="col-start-3 justify-self-end flex items-center gap-3"> | 83 | | - {isDesktopShell && <PrinterChip />} | | 83 | + {readsPrinter && <PrinterChip />} | 84 | 84 | {previewAvailable && ( | 85 | 85 | <Tooltip content={t.output.previewHeading}> | 86 | 86 | <button | |
Collapse file Copy file name to clipboardExpand all lines: src/components/Output/ZebraWayPanel.tsx +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -5,7 +5,7 @@ import { Select } from "../ui/Select"; | 5 | 5 | import { primaryButtonCls } from "../ui/formStyles"; | 6 | 6 | import { sendViaBrowserPrint, sendViaNetwork } from "../../lib/zebraPrint"; | 7 | 7 | import { isDesktopShell } from "../../lib/platform"; | 8 | | -import { needsRawChannel, resolveQueryTarget, type PrintTransport } from "../../lib/printTarget"; | | 8 | +import { needsRawChannel, readsPrinter, resolveQueryTarget, type PrintTransport } from "../../lib/printTarget"; | 9 | 9 | import { queryButtonText, queryOffer } from "../../lib/printWayText"; | 10 | 10 | import { QueryHints } from "./QueryHints"; | 11 | 11 | import type { DocumentQueryFacts } from "../../lib/outputChoice"; | @@ -204,7 +204,7 @@ export function ZebraWayPanel({ zpl, way, devices, query }: { zpl: () => string; | 204 | 204 | // Every way reaches the same device, so every way may ask it, and a way that cannot be questioned | 205 | 205 | // itself falls back to the configured address. | 206 | 206 | const addressCheck = (sending: boolean) => { | 207 | | - if (!isDesktopShell) return null; | | 207 | + if (!readsPrinter(printTarget, isDesktopShell, way)) return null; | 208 | 208 | const resolved = resolveQueryTarget(printTarget, way); | 209 | 209 | if ("failure" in resolved) return null; | 210 | 210 | return ( | |
Collapse file Copy file name to clipboardExpand all lines: src/components/PrinterSettings/PreviewSettingsTab.tsx +5-4Lines changed: 5 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { useState, useEffect } from "react"; | 2 | 2 | import { useT } from "../../hooks/useT"; | 3 | | -import { useLabelStore, selectEffectivePreviewProvider } from "../../store/labelStore"; | | 3 | +import { useLabelStore, selectEffectivePreviewProvider, selectReadsPrinter } from "../../store/labelStore"; | 4 | 4 | import { isDesktopShell } from "../../lib/platform"; | 5 | 5 | import { isDefaultHost } from "../../lib/labelary"; | 6 | 6 | import { labelCls, inputCls, buttonCls, sectionHeadingCls } from "../ui/formStyles"; | @@ -18,7 +18,8 @@ export function PreviewSettingsTab() { | 18 | 18 | const provider = useLabelStore(selectEffectivePreviewProvider); | 19 | 19 | const setProvider = useLabelStore((s) => s.setPreviewProvider); | 20 | 20 | const labelaryAvailable = useLabelStore((s) => s.thirdParty.labelary); | 21 | | - const locked = Object.fromEntries(previewProviderChoices(t, { thirdParty: { labelary: labelaryAvailable } }).map((c) => [c.provider, c.disabled])); | | 21 | + const readsPrinter = useLabelStore(selectReadsPrinter); | | 22 | + const locked = Object.fromEntries(previewProviderChoices(t, { labelary: labelaryAvailable, printer: readsPrinter }).map((c) => [c.provider, c.disabled])); | 22 | 23 | const labelaryConsent = useLabelStore((s) => s.labelaryNoticeAcknowledged); | 23 | 24 | const acknowledgeLabelaryNotice = useLabelStore((s) => s.acknowledgeLabelaryNotice); | 24 | 25 | const revokeLabelaryNotice = useLabelStore((s) => s.revokeLabelaryNotice); | @@ -92,7 +93,7 @@ export function PreviewSettingsTab() { | 92 | 93 | current={chosen} | 93 | 94 | onSelect={setProvider} | 94 | 95 | label={loc.providerPrinter} | 95 | | - hint={isDesktopShell ? loc.providerPrinterHint : loc.providerPrinterDesktopOnly} | | 96 | + hint={readsPrinter ? loc.providerPrinterHint : loc.providerPrinterDesktopOnly} | 96 | 97 | disabled={locked.printer} | 97 | 98 | /> | 98 | 99 | <RadioOption | @@ -110,7 +111,7 @@ export function PreviewSettingsTab() { | 110 | 111 | )} | 111 | 112 | </section> | 112 | 113 |
| 113 | | - {provider === "printer" && isDesktopShell && ( | | 114 | + {provider === "printer" && ( | 114 | 115 | <section className="flex items-center gap-3"> | 115 | 116 | <span className="text-[10px] text-muted">{loc.printerTargetHint}</span> | 116 | 117 | <button type="button" className={buttonCls} onClick={() => setPrinterSettingsTab("printTarget")}> | |
Collapse file Copy file name to clipboardExpand all lines: src/components/PrinterSettings/PrintTargetTab.tsx +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import type { SgdSetting } from "@zplab/core/lib/sgd"; | 2 | 2 | import { useReplyRead } from "../../hooks/useReplyRead"; | 3 | 3 | import { useT } from "../../hooks/useT"; | 4 | | -import { useLabelStore } from "../../store/labelStore"; | | 4 | +import { useLabelStore, selectReadsPrinter } from "../../store/labelStore"; | 5 | 5 | import { isDesktopShell } from "../../lib/platform"; | 6 | 6 | import { effectiveTransport, offeredTransports, type PrintTransport } from "../../lib/printTarget"; | 7 | 7 | import { wayHint, wayLabel } from "../../lib/printWayText"; | @@ -33,6 +33,7 @@ export function PrintTargetTab() { | 33 | 33 | const setPrintTarget = useLabelStore((s) => s.setPrintTarget); | 34 | 34 | const readPrinterSettings = useLabelStore((s) => s.readPrinterSettings); | 35 | 35 | const reading = useLabelStore((s) => s.printerReading) !== undefined; | | 36 | + const readsPrinter = useLabelStore(selectReadsPrinter); | 36 | 37 | const settings = useReplyRead<SgdSetting[]>(); | 37 | 38 | const usb = useUsbPrinters(isDesktopShell); | 38 | 39 | const local = useLocalPrinters(isDesktopShell); | @@ -88,7 +89,7 @@ export function PrintTargetTab() { | 88 | 89 | <span className="text-[10px] text-muted max-w-md">{loc.addressHint}</span> | 89 | 90 | </section> | 90 | 91 |
| 91 | | - {isDesktopShell && ( | | 92 | + {readsPrinter && ( | 92 | 93 | <button type="button" className={`${buttonCls} self-start`} disabled={reading} onClick={openSettings}> | 93 | 94 | {t.printerSettings.printerStatus.adoptFromPrinter} | 94 | 95 | </button> | |
Collapse file Copy file name to clipboardExpand all lines: src/components/PrinterSettings/PrinterSettingsModal.tsx +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -7,7 +7,7 @@ import { useT } from "../../hooks/useT"; | 7 | 7 | import { generateSetupScript, setupFormatBlocks, setupScriptLines, type SetupScriptField } from "../../lib/zplSetupScript"; | 8 | 8 | import type { SETUP_UPLOAD_FIELDS } from "@zplab/core/types/PrinterProfile"; | 9 | 9 | import type { Translations } from "../../locales"; | 10 | | -import { useLabelStore, selectEditorFrozen, selectHasPerLabelOverrides } from "../../store/labelStore"; | | 10 | +import { useLabelStore, selectEditorFrozen, selectHasPerLabelOverrides, selectReadsPrinter } from "../../store/labelStore"; | 11 | 11 | import { isDesktopShell } from "../../lib/platform"; | 12 | 12 | import type { PrinterSettingsTab } from "../../store/slices/uiSlice"; | 13 | 13 | import { TAB_GATES, type TabGateCtx } from "./tabVisibility"; | @@ -167,6 +167,7 @@ export function PrinterSettingsModal() { | 167 | 167 | resetPerLabelConfig(); | 168 | 168 | }; | 169 | 169 | const hasPerLabelOverrides = useLabelStore(selectHasPerLabelOverrides); | | 170 | + const readsPrinter = useLabelStore(selectReadsPrinter); | 170 | 171 | const mcpSidecarAvailable = useLabelStore((s) => s.mcpSidecarAvailable); | 171 | 172 | const gateCtx: TabGateCtx = { mcpSidecarAvailable, isDesktop: isDesktopShell }; | 172 | 173 | const openOutput = useLabelStore((s) => s.openOutput); | @@ -271,7 +272,7 @@ export function PrinterSettingsModal() { | 271 | 272 | /> | 272 | 273 | ))} | 273 | 274 | </nav> | 274 | | - {activeTopTab === 'objects' && isDesktopShell && <PrinterStorageUsage />} | | 275 | + {activeTopTab === 'objects' && readsPrinter && <PrinterStorageUsage />} | 275 | 276 | {activeTopTab === 'perLabel' && hasPerLabelOverrides && ( | 276 | 277 | <div className="px-3 pb-3"> | 277 | 278 | <ResetPerLabelButton | |
Collapse file Copy file name to clipboardExpand all lines: src/components/PrinterSettings/PrinterStorage.tsx +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,15 +3,14 @@ import { InformationCircleIcon } from "@heroicons/react/16/solid"; | 3 | 3 | import { hostObjectPath, type HostObject } from "@zplab/core/lib/hostDirectory"; | 4 | 4 | import { isWritableDevice } from "@zplab/core/lib/storagePath"; | 5 | 5 | import { deleteKnowledge, driveUsage, listedObject, originState, type DeleteKnowledge, type OriginState, type StoredObjectKind, type StoredObjectOrigin } from "@zplab/core/lib/storedObjectOrigins"; | 6 | | -import { isDesktopShell } from "../../lib/platform"; | 7 | 6 | import { usePrinterListing } from "../../hooks/usePrinterListing"; | 8 | 7 | import { useReplyRead } from "../../hooks/useReplyRead"; | 9 | 8 | import { useT } from "../../hooks/useT"; | 10 | 9 | import type { Translations } from "../../locales"; | 11 | 10 | import { formatTemplate } from "../../lib/formatTemplate"; | 12 | 11 | import type { PrinterObjectsState } from "../../store/slices/printerObjectsSlice"; | 13 | 12 | import { driveUsageText, failureText, kilobytes, readingText } from "../../lib/printerStatusText"; | 14 | | -import { selectPrinterObjects, useLabelStore } from "../../store/labelStore"; | | 13 | +import { selectPrinterObjects, selectReadsPrinter, useLabelStore } from "../../store/labelStore"; | 15 | 14 | import { ConfirmDialog } from "../ui/ConfirmDialog"; | 16 | 15 | import { MemoryBar } from "../ui/MemoryBar"; | 17 | 16 | import { Tooltip } from "../ui/Tooltip"; | @@ -21,17 +20,18 @@ import { useStoredObjectHover } from "../../hooks/useStoredObjectHover"; | 21 | 20 |
| 22 | 21 | export function StoredObjectsHeading() { | 23 | 22 | const loc = useT().printerSettings.objects; | | 23 | + const readsPrinter = useLabelStore(selectReadsPrinter); | 24 | 24 | return ( | 25 | 25 | <div className="flex items-baseline justify-between gap-2"> | 26 | 26 | <div className="flex items-center gap-1.5"> | 27 | 27 | <h3 className={sectionHeadingCls}>{loc.listHeading}</h3> | 28 | | - <Tooltip content={isDesktopShell ? `${loc.listHint} ${loc.listHintPrinter}` : loc.listHint}> | | 28 | + <Tooltip content={readsPrinter ? `${loc.listHint} ${loc.listHintPrinter}` : loc.listHint}> | 29 | 29 | <InformationCircleIcon className="w-3 h-3 text-muted/60 cursor-help shrink-0" /> | 30 | 30 | </Tooltip> | 31 | 31 | </div> | 32 | 32 | <span className="flex items-center gap-1"> | 33 | 33 | <span className={zplCommandTagCls}>~DY</span> | 34 | | - {isDesktopShell && <span className={zplCommandTagCls}>^HW</span>} | | 34 | + {readsPrinter && <span className={zplCommandTagCls}>^HW</span>} | 35 | 35 | </span> | 36 | 36 | </div> | 37 | 37 | ); | |
Collapse file Copy file name to clipboardExpand all lines: src/components/PrinterSettings/StoredFontsTab.tsx +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,8 +9,7 @@ import { listsStoredFont } from "@zplab/core/lib/storedObjects"; | 9 | 9 | import { storedObjectOrigins } from "@zplab/core/lib/storedObjectOrigins"; | 10 | 10 | import { storageKey, storageRefMatchesPath } from "@zplab/core/lib/storagePath"; | 11 | 11 | import { useCachedFonts } from "../../hooks/useCachedFonts"; | 12 | | -import { useLabelStore, selectEditorFrozen } from "../../store/labelStore"; | 13 | | -import { isDesktopShell } from "../../lib/platform"; | | 12 | +import { useLabelStore, selectEditorFrozen, selectReadsPrinter } from "../../store/labelStore"; | 14 | 13 | import { PrinterObjectActions, PrinterOriginMark, PrinterStorageBar, StoredObjectsHeading } from "./PrinterStorage"; | 15 | 14 | import { buttonCls, disabledCls } from "../ui/formStyles"; | 16 | 15 | import { ConfirmDialog } from "../ui/ConfirmDialog"; | @@ -41,6 +40,7 @@ export function StoredFontsTab() { | 41 | 40 | const loc = t.printerSettings.fonts; | 42 | 41 | const { setHoveredKey } = useStoredObjectHover(); | 43 | 42 | const frozen = useLabelStore(selectEditorFrozen); | | 43 | + const readsPrinter = useLabelStore(selectReadsPrinter); | 44 | 44 |
| 45 | 45 | // A cache row is named by its printer path, so profile and cache rows share one identity rule. | 46 | 46 | const cachedPaths = fonts.map(cachedFontPath).filter((path) => listsStoredFont(path, setupFonts)); | @@ -95,7 +95,7 @@ export function StoredFontsTab() { | 95 | 95 | </span> | 96 | 96 | )} | 97 | 97 | </div> | 98 | | - {isDesktopShell && <PrinterStorageBar />} | | 98 | + {readsPrinter && <PrinterStorageBar />} | 99 | 99 | {rows.length === 0 ? ( | 100 | 100 | <p className="text-xs text-muted/70">{loc.noFonts}</p> | 101 | 101 | ) : ( | |
Collapse file Copy file name to clipboardExpand all lines: src/components/PrinterSettings/StoredGraphicsTab.tsx +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -6,7 +6,7 @@ import { useStoredObjectHover } from "../../hooks/useStoredObjectHover"; | 6 | 6 | import { usePrinterListing } from "../../hooks/usePrinterListing"; | 7 | 7 | import { useT } from "../../hooks/useT"; | 8 | 8 | import { useUpload } from "../../hooks/useUpload"; | 9 | | -import { useLabelStore, useFileDeletability, forgetHistoryUsing, selectEditorFrozen, type DeleteBlock } from "../../store/labelStore"; | | 9 | +import { useLabelStore, useFileDeletability, forgetHistoryUsing, selectEditorFrozen, selectReadsPrinter, type DeleteBlock } from "../../store/labelStore"; | 10 | 10 | import { encodeGraphicFile } from "@zplab/core/lib/imageToZpl"; | 11 | 11 | import { sanitizeStorageName, uploadedGraphicPath } from "@zplab/core/lib/storagePath"; | 12 | 12 | import { setupEntryHoldsOther, withSetupEntry, withoutSetupEntry } from "@zplab/core/lib/setupEntries"; | @@ -18,7 +18,6 @@ import { storedObjectOrigins } from "@zplab/core/lib/storedObjectOrigins"; | 18 | 18 | import { removeImage } from "@zplab/core/lib/imageCache"; | 19 | 19 | import { imageUsage } from "@zplab/core/lib/imageUsage"; | 20 | 20 | import type { SetupGraphic } from "@zplab/core/types/PrinterProfile"; | 21 | | -import { isDesktopShell } from "../../lib/platform"; | 22 | 21 | import { PrinterObjectActions, PrinterOriginMark, PrinterStorageBar, StoredObjectsHeading } from "./PrinterStorage"; | 23 | 22 |
| 24 | 23 | export function StoredGraphicsTab() { | @@ -52,6 +51,7 @@ export function StoredGraphicsTab() { | 52 | 51 |
| 53 | 52 | // Frozen, the open pages are not what a source session will apply, so no control may act on them. | 54 | 53 | const frozen = useLabelStore(selectEditorFrozen); | | 54 | + const readsPrinter = useLabelStore(selectReadsPrinter); | 55 | 55 | const usage = imageUsage(pages); | 56 | 56 | const deletability = useFileDeletability(); | 57 | 57 | const cached = useCachedImages(); | @@ -116,7 +116,7 @@ export function StoredGraphicsTab() { | 116 | 116 | </span> | 117 | 117 | )} | 118 | 118 | </div> | 119 | | - {isDesktopShell && <PrinterStorageBar />} | | 119 | + {readsPrinter && <PrinterStorageBar />} | 120 | 120 | {origins.length === 0 ? ( | 121 | 121 | <p className="text-xs text-muted/70">{loc.noGraphics}</p> | 122 | 122 | ) : ( | |
Collapse file Copy file name to clipboardExpand all lines: src/lib/previewProviderLabel.ts +3-5Lines changed: 3 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import type { Translations } from "../locales"; | 2 | | -import type { LabelState } from "../store/labelStore"; | 3 | 2 | import type { PreviewProvider } from "../store/slices/uiSlice"; | 4 | | -import { isDesktopShell } from "./platform"; | 5 | 3 |
| 6 | 4 | /** The one wording per renderer, so every place names it the same. */ | 7 | 5 | export function previewProviderLabel(t: Translations, provider: PreviewProvider): string { | @@ -18,11 +16,11 @@ export interface PreviewProviderChoice { | 18 | 16 | } | 19 | 17 |
| 20 | 18 | /** The renderers as one choice list, so every place locks the same ones. */ | 21 | | -export function previewProviderChoices(t: Translations, s: Pick<LabelState, "thirdParty">): PreviewProviderChoice[] { | | 19 | +export function previewProviderChoices(t: Translations, offered: { labelary: boolean; printer: boolean }): PreviewProviderChoice[] { | 22 | 20 | const loc = t.printerSettings.preview; | 23 | 21 | return [ | 24 | | - { provider: "labelary", label: loc.providerLabelary, disabled: !s.thirdParty.labelary }, | 25 | | - { provider: "printer", label: loc.providerPrinter, disabled: !isDesktopShell, ...(isDesktopShell ? {} : { reason: loc.providerPrinterDesktopOnly }) }, | | 22 | + { provider: "labelary", label: loc.providerLabelary, disabled: !offered.labelary }, | | 23 | + { provider: "printer", label: loc.providerPrinter, disabled: !offered.printer, ...(offered.printer ? {} : { reason: loc.providerPrinterDesktopOnly }) }, | 26 | 24 | { provider: "none", label: loc.providerNone, disabled: false }, | 27 | 25 | ]; | 28 | 26 | } |
|