Skip to content

Commit

Permalink
Fix [Models] Wrong preview presentation Part 1 - fixed bugs with clic…
Browse files Browse the repository at this point in the history
…k on name (#2109)
  • Loading branch information
mariana-furyk authored and ilan7empest committed Dec 14, 2023
1 parent 9234542 commit 0404693
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/elements/ArtifactsExtraData/ArtifactsExtraData.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ illegal under applicable law, and the grant of the foregoing license
under the Apache 2.0 license is conditioned upon your compliance with
such restriction.
*/
import React, { useEffect, useState, useCallback } from 'react'
import React, { useEffect, useState, useCallback, useMemo } from 'react'
import classnames from 'classnames'
import { useParams } from 'react-router-dom'
import PropTypes from 'prop-types'

import { TextTooltipTemplate, Tooltip } from 'igz-controls/components'
Expand All @@ -31,9 +30,7 @@ import { generateArtifactIndexes } from '../../components/Details/details.util'
import './artifactsExtraData.scss'

const ArtifactsExtraData = ({ artifact }) => {
const [extraData, setExtraData] = useState([])
const [artifactsIndexes, setArtifactsIndexes] = useState([])
const params = useParams()

const showArtifactPreview = useCallback(
index => {
Expand All @@ -42,17 +39,15 @@ const ArtifactsExtraData = ({ artifact }) => {
[artifactsIndexes, setArtifactsIndexes]
)

useEffect(() => {
if (artifact.extra_data && extraData.length === 0) {
setExtraData(generateExtraDataContent(artifact.extra_data, showArtifactPreview))
}
}, [artifact, extraData.length, params.projectName, showArtifactPreview])
const extraData = useMemo(() => {
return generateExtraDataContent(artifact.extra_data, showArtifactPreview)
}, [artifact.extra_data, showArtifactPreview])

useEffect(() => {
return () => {
setExtraData([])
setArtifactsIndexes([])
}
}, [])
}, [artifact])

return (
<div className="artifact-extra-data">
Expand Down

0 comments on commit 0404693

Please sign in to comment.