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:
parent
15f7a86c47
commit
b65fe208c0
@ -133,6 +133,10 @@ const ControlPrinter = ({ slicerIntegration = false }) => {
|
||||
)
|
||||
useDashboardObjectTools(currentObjectTools)
|
||||
|
||||
const objectInfoHyperlinkProps = slicerIntegration
|
||||
? { showHyperlink: false, objectPropertyProps: { showHyperlink: false } }
|
||||
: {}
|
||||
|
||||
const actions = {
|
||||
edit: () => {
|
||||
objectFormRef?.current.startEditing()
|
||||
@ -291,7 +295,10 @@ const ControlPrinter = ({ slicerIntegration = false }) => {
|
||||
edit: false,
|
||||
info: !slicerIntegration,
|
||||
control: !slicerIntegration,
|
||||
newPrinterProfile: !slicerIntegration
|
||||
newPrinterProfile: !slicerIntegration,
|
||||
list: !slicerIntegration,
|
||||
duplicate: !slicerIntegration,
|
||||
delete: !slicerIntegration
|
||||
}}
|
||||
objectData={objectFormState.objectData}
|
||||
/>
|
||||
@ -399,6 +406,7 @@ const ControlPrinter = ({ slicerIntegration = false }) => {
|
||||
}) => {
|
||||
return (
|
||||
<ObjectInfo
|
||||
{...objectInfoHyperlinkProps}
|
||||
loading={printerObjectLoading}
|
||||
column={sideBarVisible ? 1 : undefined}
|
||||
visibleProperties={{
|
||||
@ -429,9 +437,6 @@ const ControlPrinter = ({ slicerIntegration = false }) => {
|
||||
pendingSlicerUploads: false,
|
||||
name: !slicerIntegration
|
||||
}}
|
||||
objectPropertyProps={{
|
||||
showHyperlink: !slicerIntegration
|
||||
}}
|
||||
objectData={printerObjectData}
|
||||
type='printer'
|
||||
labelWidth='120px'
|
||||
@ -460,6 +465,7 @@ const ControlPrinter = ({ slicerIntegration = false }) => {
|
||||
currentSubJob={
|
||||
objectFormState.objectData?.currentSubJob
|
||||
}
|
||||
showHyperlink={!slicerIntegration}
|
||||
/>
|
||||
</Card>
|
||||
</InfoCollapse>
|
||||
@ -484,17 +490,14 @@ const ControlPrinter = ({ slicerIntegration = false }) => {
|
||||
}) => {
|
||||
return (
|
||||
<ObjectInfo
|
||||
{...objectInfoHyperlinkProps}
|
||||
loading={jobObjectLoading}
|
||||
column={sideBarVisible ? 1 : undefined}
|
||||
showHyperlink={!slicerIntegration}
|
||||
visibleProperties={{
|
||||
printers: false,
|
||||
createdAt: false,
|
||||
finishedAt: false
|
||||
}}
|
||||
objectPropertyProps={{
|
||||
showHyperlink: !slicerIntegration
|
||||
}}
|
||||
objectData={jobObjectData}
|
||||
type='job'
|
||||
/>
|
||||
@ -531,9 +534,9 @@ const ControlPrinter = ({ slicerIntegration = false }) => {
|
||||
}) => {
|
||||
return (
|
||||
<ObjectInfo
|
||||
{...objectInfoHyperlinkProps}
|
||||
loading={subJobObjectLoading}
|
||||
column={sideBarVisible ? 1 : undefined}
|
||||
showHyperlink={!slicerIntegration}
|
||||
visibleProperties={{
|
||||
printers: false,
|
||||
createdAt: false,
|
||||
@ -542,9 +545,6 @@ const ControlPrinter = ({ slicerIntegration = false }) => {
|
||||
job: false,
|
||||
printer: false
|
||||
}}
|
||||
objectPropertyProps={{
|
||||
showHyperlink: !slicerIntegration
|
||||
}}
|
||||
objectData={subJobObjectData}
|
||||
type='subJob'
|
||||
/>
|
||||
@ -602,9 +602,9 @@ const ControlPrinter = ({ slicerIntegration = false }) => {
|
||||
}) => {
|
||||
return (
|
||||
<ObjectInfo
|
||||
{...objectInfoHyperlinkProps}
|
||||
loading={filamentStockObjectLoading}
|
||||
column={sideBarVisible ? 1 : undefined}
|
||||
showHyperlink={!slicerIntegration}
|
||||
visibleProperties={{
|
||||
updatedAt: false,
|
||||
createdAt: false
|
||||
|
||||
@ -48,7 +48,7 @@ const ObjectInfo = ({
|
||||
items = items.filter((item) => item.required === required)
|
||||
}
|
||||
|
||||
if (showHyperlink) {
|
||||
if (showHyperlink !== undefined) {
|
||||
objectPropertyProps = { ...objectPropertyProps, showHyperlink }
|
||||
}
|
||||
// Filter items based on visibleProperties
|
||||
|
||||
@ -17,7 +17,7 @@ const toObject = (item) => {
|
||||
return item
|
||||
}
|
||||
|
||||
const PrinterQueue = ({ queue, currentSubJob }) => {
|
||||
const PrinterQueue = ({ queue, currentSubJob, showHyperlink = true }) => {
|
||||
const queueItems = Array.isArray(queue)
|
||||
? queue.map(toObject).filter(Boolean)
|
||||
: []
|
||||
@ -52,7 +52,13 @@ const PrinterQueue = ({ queue, currentSubJob }) => {
|
||||
className='printerQueue'
|
||||
size='small'
|
||||
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 = {
|
||||
queue: PropTypes.array,
|
||||
currentSubJob: PropTypes.oneOfType([PropTypes.object, PropTypes.string])
|
||||
currentSubJob: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
||||
showHyperlink: PropTypes.bool
|
||||
}
|
||||
|
||||
export default PrinterQueue
|
||||
|
||||
@ -9,6 +9,7 @@ import {
|
||||
useCallback,
|
||||
useMemo
|
||||
} from 'react'
|
||||
import { useLocation } from 'react-router-dom'
|
||||
import { AuthContext } from '../context/AuthContext'
|
||||
import { useActions } from '../context/ActionsContext'
|
||||
import InfoCircleIcon from '../../Icons/InfoCircleIcon'
|
||||
@ -32,6 +33,7 @@ const SpotlightTooltip = ({ query, type }) => {
|
||||
const [spotlightData, setSpotlightData] = useState(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [initialized, setInitialized] = useState(false)
|
||||
const isSlicerRoute = useLocation().pathname === '/slicer'
|
||||
|
||||
const { token, userProfile } = useContext(AuthContext)
|
||||
const { callAction } = useActions()
|
||||
@ -40,10 +42,10 @@ const SpotlightTooltip = ({ query, type }) => {
|
||||
|
||||
const model = getModelByName(type)
|
||||
const modelProperties = model.properties || []
|
||||
const rowActions = useMemo(
|
||||
() => model.actions?.filter((action) => action.row == true) || [],
|
||||
[model]
|
||||
)
|
||||
const rowActions = useMemo(() => {
|
||||
if (isSlicerRoute) return []
|
||||
return model.actions?.filter((action) => action.row == true) || []
|
||||
}, [isSlicerRoute, model])
|
||||
|
||||
const renderActions = useCallback(
|
||||
(objectData, actionsDisabled = false) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user