Skip to content

Commit e2e3bf4

Browse files
committed
refactor: Update ImageChipCell component and use it in TriggerDetails
1 parent 6766a23 commit e2e3bf4

File tree

4 files changed

+20
-23
lines changed

4 files changed

+20
-23
lines changed

src/Shared/Components/CICDHistory/TriggerOutput.tsx

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232
useAsync,
3333
not,
3434
ZERO_TIME_STRING,
35-
extractImage,
3635
useInterval,
3736
URLS,
3837
ServerError,
@@ -60,13 +59,13 @@ import { getTagDetails, getTriggerDetails, cancelCiTrigger, cancelPrePostCdTrigg
6059
import { DEFAULT_ENV, TIMEOUT_VALUE, WORKER_POD_BASE_URL } from './constants'
6160
import { GitTriggers } from '../../types'
6261
import warn from '../../../Assets/Icon/ic-warning.svg'
63-
import docker from '../../../Assets/Icon/ic-docker.svg'
6462
import { LogsRenderer } from './LogsRenderer'
6563
import DeploymentDetailSteps from './DeploymentDetailSteps'
6664
import { DeploymentHistoryDetailedView, DeploymentHistoryConfigList } from './DeploymentHistoryDiff'
6765
import { GitChanges, Scroller } from './History.components'
6866
import Artifacts from './Artifacts'
6967
import { statusColor as colorMap, EMPTY_STATE_STATUS, PULSATING_STATUS_MAP } from '../../constants'
68+
import { ImageChipCell } from '../ImageChipCell'
7069
import './cicdHistory.scss'
7170

7271
const Finished = React.memo(
@@ -88,10 +87,7 @@ const Finished = React.memo(
8887
{type === HistoryComponentType.CI && artifact && (
8988
<>
9089
<div className="dc__bullet" />
91-
<div className="dc__app-commit__hash">
92-
<img src={docker} alt="docker" className="commit-hash__icon grayscale" />
93-
{extractImage(artifact)}
94-
</div>
90+
<ImageChipCell imagePath={artifact} placement="top" />
9591
</>
9692
)}
9793
</div>
@@ -111,7 +107,7 @@ const WorkerStatus = React.memo(
111107
const getViewWorker = () =>
112108
showLink ? (
113109
<NavLink to={`${WORKER_POD_BASE_URL}/${workerPodName}/logs`} target="_blank" className="anchor">
114-
<div className="mr-10">View worker pod</div>
110+
<span className="mr-10 fs-13">View worker pod</span>
115111
</NavLink>
116112
) : null
117113

@@ -310,14 +306,7 @@ const StartDetails = ({
310306

311307
{type === HistoryComponentType.CD ? (
312308
// eslint-disable-next-line react/jsx-no-useless-fragment
313-
<>
314-
{artifact && (
315-
<div className="dc__app-commit__hash" data-testid="docker-image-hash">
316-
<img src={docker} alt="docker" className="commit-hash__icon grayscale" />
317-
{artifact.split(':')[1]}
318-
</div>
319-
)}
320-
</>
309+
<>{artifact && <ImageChipCell imagePath={artifact} placement="top" />}</>
321310
) : (
322311
Object.keys(gitTriggers ?? {}).length > 0 &&
323312
ciMaterials?.map((ciMaterial) => {

src/Shared/Components/CICDHistory/cicdHistory.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211

212212
&:hover {
213213
text-decoration: unset;
214-
background: var(--N100);
214+
background: var(--N50);
215215
}
216216

217217
&.active {

src/Shared/Components/ImageChipCell/ImageChipCell.component.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,20 @@
1515
*/
1616

1717
import Tippy from '@tippyjs/react'
18+
import { noop } from '@Common/Helper'
1819
import { ReactComponent as DockerIcon } from '../../../Assets/Icon/ic-docker.svg'
1920
import { ImageChipCellProps } from './types'
2021
import './imageChipCell.scss'
2122

22-
const ImageChipCell = ({ handleClick, imagePath, isExpanded, registryType }: ImageChipCellProps) => (
23+
const ImageChipCell = ({
24+
imagePath,
25+
registryType,
26+
handleClick = noop,
27+
isExpanded = false,
28+
placement = 'auto',
29+
}: ImageChipCellProps) => (
2330
<div className="cn-7 fs-14 lh-20 flexbox">
24-
<Tippy content={imagePath} className="default-tt" placement="auto" arrow={false}>
31+
<Tippy content={imagePath} className="default-tt" placement={placement} arrow={false}>
2532
<button
2633
type="button"
2734
className={`display-grid dc__align-items-center image-chip-cell__container ${isExpanded ? 'image-chip-cell__container--expanded' : ''} bcn-1 br-6 dc__transparent py-0 px-6 cursor max-w-100`}

src/Shared/Components/ImageChipCell/types.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
17-
import { SyntheticEvent } from 'react'
16+
import Tippy from '@tippyjs/react'
17+
import { ComponentProps, SyntheticEvent } from 'react'
1818
import { RegistryType } from '../../types'
1919

2020
export interface ImageChipCellProps {
21-
handleClick: (e: SyntheticEvent) => void
2221
imagePath: string
23-
isExpanded: boolean
24-
registryType: RegistryType
22+
isExpanded?: boolean
23+
handleClick?: (e: SyntheticEvent) => void
24+
registryType?: RegistryType
25+
placement?: ComponentProps<typeof Tippy>['placement']
2526
}

0 commit comments

Comments
 (0)