Enhance ControlPrinter and ObjectInfo Components for Slicer Integration

- Updated ControlPrinter to conditionally manage hyperlink visibility based on slicer integration, improving user experience.
- Refactored ObjectInfo to handle hyperlink display logic more flexibly, ensuring consistent behavior across components.
- Modified PrinterQueue to accept a showHyperlink prop, allowing for better control over hyperlink rendering in queue items.
- Enhanced SpotlightTooltip to prevent action rendering on slicer routes, optimizing performance and user interaction.
This commit is contained in:
Tom Butcher 2026-11-08 23:40:40 +00:00
parent 15f7a86c47
commit b65fe208c0
4 changed files with 30 additions and 21 deletions

View File

@ -133,6 +133,10 @@ const ControlPrinter = ({ slicerIntegration = false }) => {
) )
useDashboardObjectTools(currentObjectTools) useDashboardObjectTools(currentObjectTools)
const objectInfoHyperlinkProps = slicerIntegration
? { showHyperlink: false, objectPropertyProps: { showHyperlink: false } }
: {}
const actions = { const actions = {
edit: () => { edit: () => {
objectFormRef?.current.startEditing() objectFormRef?.current.startEditing()
@ -291,7 +295,10 @@ const ControlPrinter = ({ slicerIntegration = false }) => {
edit: false, edit: false,
info: !slicerIntegration, info: !slicerIntegration,
control: !slicerIntegration, control: !slicerIntegration,
newPrinterProfile: !slicerIntegration newPrinterProfile: !slicerIntegration,
list: !slicerIntegration,
duplicate: !slicerIntegration,
delete: !slicerIntegration
}} }}
objectData={objectFormState.objectData} objectData={objectFormState.objectData}
/> />
@ -399,6 +406,7 @@ const ControlPrinter = ({ slicerIntegration = false }) => {
}) => { }) => {
return ( return (
<ObjectInfo <ObjectInfo
{...objectInfoHyperlinkProps}
loading={printerObjectLoading} loading={printerObjectLoading}
column={sideBarVisible ? 1 : undefined} column={sideBarVisible ? 1 : undefined}
visibleProperties={{ visibleProperties={{
@ -429,9 +437,6 @@ const ControlPrinter = ({ slicerIntegration = false }) => {
pendingSlicerUploads: false, pendingSlicerUploads: false,
name: !slicerIntegration name: !slicerIntegration
}} }}
objectPropertyProps={{
showHyperlink: !slicerIntegration
}}
objectData={printerObjectData} objectData={printerObjectData}
type='printer' type='printer'
labelWidth='120px' labelWidth='120px'
@ -460,6 +465,7 @@ const ControlPrinter = ({ slicerIntegration = false }) => {
currentSubJob={ currentSubJob={
objectFormState.objectData?.currentSubJob objectFormState.objectData?.currentSubJob
} }
showHyperlink={!slicerIntegration}
/> />
</Card> </Card>
</InfoCollapse> </InfoCollapse>
@ -484,17 +490,14 @@ const ControlPrinter = ({ slicerIntegration = false }) => {
}) => { }) => {
return ( return (
<ObjectInfo <ObjectInfo
{...objectInfoHyperlinkProps}
loading={jobObjectLoading} loading={jobObjectLoading}
column={sideBarVisible ? 1 : undefined} column={sideBarVisible ? 1 : undefined}
showHyperlink={!slicerIntegration}
visibleProperties={{ visibleProperties={{
printers: false, printers: false,
createdAt: false, createdAt: false,
finishedAt: false finishedAt: false
}} }}
objectPropertyProps={{
showHyperlink: !slicerIntegration
}}
objectData={jobObjectData} objectData={jobObjectData}
type='job' type='job'
/> />
@ -531,9 +534,9 @@ const ControlPrinter = ({ slicerIntegration = false }) => {
}) => { }) => {
return ( return (
<ObjectInfo <ObjectInfo
{...objectInfoHyperlinkProps}
loading={subJobObjectLoading} loading={subJobObjectLoading}
column={sideBarVisible ? 1 : undefined} column={sideBarVisible ? 1 : undefined}
showHyperlink={!slicerIntegration}
visibleProperties={{ visibleProperties={{
printers: false, printers: false,
createdAt: false, createdAt: false,
@ -542,9 +545,6 @@ const ControlPrinter = ({ slicerIntegration = false }) => {
job: false, job: false,
printer: false printer: false
}} }}
objectPropertyProps={{
showHyperlink: !slicerIntegration
}}
objectData={subJobObjectData} objectData={subJobObjectData}
type='subJob' type='subJob'
/> />
@ -602,9 +602,9 @@ const ControlPrinter = ({ slicerIntegration = false }) => {
}) => { }) => {
return ( return (
<ObjectInfo <ObjectInfo
{...objectInfoHyperlinkProps}
loading={filamentStockObjectLoading} loading={filamentStockObjectLoading}
column={sideBarVisible ? 1 : undefined} column={sideBarVisible ? 1 : undefined}
showHyperlink={!slicerIntegration}
visibleProperties={{ visibleProperties={{
updatedAt: false, updatedAt: false,
createdAt: false createdAt: false

View File

@ -48,7 +48,7 @@ const ObjectInfo = ({
items = items.filter((item) => item.required === required) items = items.filter((item) => item.required === required)
} }
if (showHyperlink) { if (showHyperlink !== undefined) {
objectPropertyProps = { ...objectPropertyProps, showHyperlink } objectPropertyProps = { ...objectPropertyProps, showHyperlink }
} }
// Filter items based on visibleProperties // Filter items based on visibleProperties

View File

@ -17,7 +17,7 @@ const toObject = (item) => {
return item return item
} }
const PrinterQueue = ({ queue, currentSubJob }) => { const PrinterQueue = ({ queue, currentSubJob, showHyperlink = true }) => {
const queueItems = Array.isArray(queue) const queueItems = Array.isArray(queue)
? queue.map(toObject).filter(Boolean) ? queue.map(toObject).filter(Boolean)
: [] : []
@ -52,7 +52,13 @@ const PrinterQueue = ({ queue, currentSubJob }) => {
className='printerQueue' className='printerQueue'
size='small' size='small'
items={items.map((item) => ({ items={items.map((item) => ({
title: <ObjectDisplay object={item} objectType='subJob' showHyperlink /> title: (
<ObjectDisplay
object={item}
objectType='subJob'
showHyperlink={showHyperlink}
/>
)
}))} }))}
/> />
) )
@ -60,7 +66,8 @@ const PrinterQueue = ({ queue, currentSubJob }) => {
PrinterQueue.propTypes = { PrinterQueue.propTypes = {
queue: PropTypes.array, queue: PropTypes.array,
currentSubJob: PropTypes.oneOfType([PropTypes.object, PropTypes.string]) currentSubJob: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
showHyperlink: PropTypes.bool
} }
export default PrinterQueue export default PrinterQueue

View File

@ -9,6 +9,7 @@ import {
useCallback, useCallback,
useMemo useMemo
} from 'react' } from 'react'
import { useLocation } from 'react-router-dom'
import { AuthContext } from '../context/AuthContext' import { AuthContext } from '../context/AuthContext'
import { useActions } from '../context/ActionsContext' import { useActions } from '../context/ActionsContext'
import InfoCircleIcon from '../../Icons/InfoCircleIcon' import InfoCircleIcon from '../../Icons/InfoCircleIcon'
@ -32,6 +33,7 @@ const SpotlightTooltip = ({ query, type }) => {
const [spotlightData, setSpotlightData] = useState(null) const [spotlightData, setSpotlightData] = useState(null)
const [loading, setLoading] = useState(true) const [loading, setLoading] = useState(true)
const [initialized, setInitialized] = useState(false) const [initialized, setInitialized] = useState(false)
const isSlicerRoute = useLocation().pathname === '/slicer'
const { token, userProfile } = useContext(AuthContext) const { token, userProfile } = useContext(AuthContext)
const { callAction } = useActions() const { callAction } = useActions()
@ -40,10 +42,10 @@ const SpotlightTooltip = ({ query, type }) => {
const model = getModelByName(type) const model = getModelByName(type)
const modelProperties = model.properties || [] const modelProperties = model.properties || []
const rowActions = useMemo( const rowActions = useMemo(() => {
() => model.actions?.filter((action) => action.row == true) || [], if (isSlicerRoute) return []
[model] return model.actions?.filter((action) => action.row == true) || []
) }, [isSlicerRoute, model])
const renderActions = useCallback( const renderActions = useCallback(
(objectData, actionsDisabled = false) => { (objectData, actionsDisabled = false) => {