Skip to content

Commit

Permalink
Fix [Model Endpoints] Selected element doesn't highlighted (#3064)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariana-furyk authored Jan 29, 2025
1 parent b42d70f commit f4e6f27
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 40 deletions.
71 changes: 34 additions & 37 deletions src/elements/ArtifactsTableRow/ArtifactsTableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ import ActionsMenu from '../../common/ActionsMenu/ActionsMenu'
import TableCell from '../TableCell/TableCell'

import { ACTIONS_MENU } from '../../types'
import {
DETAILS_OVERVIEW_TAB,
MODEL_ENDPOINTS_TAB
} from '../../constants'
import { DETAILS_OVERVIEW_TAB, MODEL_ENDPOINTS_TAB } from '../../constants'
import { getArtifactIdentifier } from '../../utils/getUniqueIdentifier'

const ArtifactsTableRow = ({
Expand All @@ -40,7 +37,7 @@ const ArtifactsTableRow = ({
mainRowItemsCount = 1,
rowItem,
selectedItem,
tab = '',
tab = ''
}) => {
const parent = useRef()
const params = useParams()
Expand All @@ -49,45 +46,45 @@ const ArtifactsTableRow = ({
'table-row',
'table-body-row',
'parent-row',
(selectedItem?.db_key || selectedItem?.spec?.model) &&
(selectedItem?.db_key || selectedItem?.spec?.model_name) &&
getArtifactIdentifier(selectedItem, true) === rowItem.data.ui.identifierUnique &&
'table-row_active'
)

return (
<tr className={rowClassNames} ref={parent}>
<>
{rowItem.content.map((value, index) => {
const cellClassNames = classnames(
!isEmpty(selectedItem) && index >= mainRowItemsCount && 'table-body__cell_hidden'
)
<>
{rowItem.content.map((value, index) => {
const cellClassNames = classnames(
!isEmpty(selectedItem) && index >= mainRowItemsCount && 'table-body__cell_hidden'
)

return (
!value.hidden && (
<TableCell
className={cellClassNames}
data={value}
firstCell={index === 0 && params.pageTab !== MODEL_ENDPOINTS_TAB}
item={rowItem.data}
key={value.id}
link={value.getLink?.(params.tab ?? DETAILS_OVERVIEW_TAB)}
onClick={value.handleClick}
selectItem={handleSelectItem}
selectedItem={selectedItem}
/>
)
)
})}
{!hideActionsMenu && (
<td className="table-body__cell table-cell-icon">
<ActionsMenu
dataItem={rowItem.data}
withQuickActions={tab !== MODEL_ENDPOINTS_TAB}
menu={actionsMenu}
return (
!value.hidden && (
<TableCell
className={cellClassNames}
data={value}
firstCell={index === 0 && params.pageTab !== MODEL_ENDPOINTS_TAB}
item={rowItem.data}
key={value.id}
link={value.getLink?.(params.tab ?? DETAILS_OVERVIEW_TAB)}
onClick={value.handleClick}
selectItem={handleSelectItem}
selectedItem={selectedItem}
/>
</td>
)}
</>
)
)
})}
{!hideActionsMenu && (
<td className="table-body__cell table-cell-icon">
<ActionsMenu
dataItem={rowItem.data}
withQuickActions={tab !== MODEL_ENDPOINTS_TAB}
menu={actionsMenu}
/>
</td>
)}
</>
</tr>
)
}
Expand All @@ -99,7 +96,7 @@ ArtifactsTableRow.propTypes = {
rowIndex: PropTypes.number.isRequired,
rowItem: PropTypes.shape({}).isRequired,
selectedItem: PropTypes.shape({}).isRequired,
tab: PropTypes.string,
tab: PropTypes.string
}

export default React.memo(ArtifactsTableRow)
6 changes: 3 additions & 3 deletions src/utils/getUniqueIdentifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export const getArtifactIdentifier = (artifact, unique) => {

if (artifact?.db_key || artifact?.spec?.db_key) {
identifier = artifact?.db_key || artifact?.spec?.db_key
} else if (artifact?.spec?.model) {
identifier = `${artifact?.spec?.model}.${artifact?.spec?.function_uri}`
} else if (artifact?.spec?.model_name) {
identifier = `${artifact?.spec?.model_name}.${artifact?.spec?.function_uri}`
}

if (unique) {
Expand Down Expand Up @@ -80,7 +80,7 @@ export const getWorkflowJobIdentifier = (job, unique) => {
}

if (unique) {
jobId = job.customData.run_uid ? job.customData.run_uid : job.customData?.functionHash ?? ''
jobId = job.customData.run_uid ? job.customData.run_uid : (job.customData?.functionHash ?? '')
}

if (jobId) identifier += `.${jobId}`
Expand Down

0 comments on commit f4e6f27

Please sign in to comment.