|
1 | | -import { Box, Button, Chip, Grid, Typography, Tooltip } from "@mui/material"; |
| 1 | +import { Box, Button, Chip, Grid, Typography, Tooltip, Stack } from "@mui/material"; |
2 | 2 | import React, { useState } from "react"; |
3 | 3 | import { useSelector } from 'react-redux'; |
4 | 4 | import ReactMarkdown from 'react-markdown'; |
@@ -272,25 +272,68 @@ const GeneralInformation = ({ data, classes, showMetadataOnly = false }) => { |
272 | 272 | }; |
273 | 273 |
|
274 | 274 | // Render "Aligned To" chip |
275 | | - const renderAlignedTo = () => { |
| 275 | + const renderAlignedTo = (data) => { |
| 276 | + const images = Object.keys(data?.Images).length !== 0 ? data?.Images : data?.Examples; |
| 277 | + const templateIds = Object.keys(images); |
| 278 | + |
| 279 | + if (templateIds.length === 0) { |
| 280 | + return null; |
| 281 | + } |
| 282 | + |
| 283 | + const AllAlignedTo = () => { |
| 284 | + return ( |
| 285 | + <> |
| 286 | + { |
| 287 | + templateIds.map((templateId) => { |
| 288 | + return ( |
| 289 | + templateId !== currentTemplateId && <Chip |
| 290 | + icon={<LinkIcon />} |
| 291 | + label={templateId} |
| 292 | + sx={{ |
| 293 | + cursor: 'pointer', |
| 294 | + transition: 'background-color 0.2s ease-in-out', |
| 295 | + display: 'flex', |
| 296 | + alignItems: 'center', |
| 297 | + justifyContent: 'center', |
| 298 | + '&:hover': { |
| 299 | + backgroundColor: tabActiveColor |
| 300 | + } |
| 301 | + }} |
| 302 | + onClick={() => getInstanceByID(templateId, true, true, true)} |
| 303 | + /> |
| 304 | + ) |
| 305 | + }) |
| 306 | + } |
| 307 | + </> |
| 308 | + ) |
| 309 | + } |
276 | 310 | return currentTemplateId ? ( |
| 311 | + <> |
277 | 312 | <Chip |
278 | 313 | icon={<LinkIcon />} |
279 | 314 | label={currentTemplateName} |
280 | 315 | onClick={handleTemplateClick} |
281 | 316 | sx={{ |
282 | 317 | cursor: 'pointer', |
283 | 318 | transition: 'background-color 0.2s ease-in-out', |
| 319 | + backgroundColor: tabActiveColor, |
284 | 320 | '&:hover': { |
285 | 321 | backgroundColor: tabActiveColor |
286 | 322 | } |
287 | 323 | }} |
288 | 324 | /> |
| 325 | + <AllAlignedTo /> |
| 326 | + </> |
| 327 | + |
289 | 328 | ) : ( |
290 | | - <Chip |
| 329 | + <> |
| 330 | + <Chip |
291 | 331 | label={currentTemplateName} |
292 | 332 | sx={{ cursor: 'default' }} |
293 | 333 | /> |
| 334 | + <AllAlignedTo /> |
| 335 | + </> |
| 336 | + |
294 | 337 | ); |
295 | 338 | }; |
296 | 339 |
|
@@ -933,7 +976,9 @@ const GeneralInformation = ({ data, classes, showMetadataOnly = false }) => { |
933 | 976 | return ( |
934 | 977 | <Box key={key} display='flex' justifyContent='space-between' columnGap={1}> |
935 | 978 | <Typography sx={classes.heading}>{key}</Typography> |
936 | | - {renderAlignedTo()} |
| 979 | + <Stack direction='row' gap={1} alignItems='center' flexWrap='wrap'> |
| 980 | + {renderAlignedTo(data?.metadata)} |
| 981 | + </Stack> |
937 | 982 | </Box> |
938 | 983 | ); |
939 | 984 | } |
|
0 commit comments