Skip to content

Commit

Permalink
undoing the img to div with backgorund to avoid cors issues detected …
Browse files Browse the repository at this point in the history
…in selenium test
  • Loading branch information
yyassi-heartex committed Dec 16, 2024
1 parent 9874aac commit 6f14092
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 77 deletions.
41 changes: 13 additions & 28 deletions web/libs/datamanager/src/components/CellViews/ImageCell.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getRoot } from "mobx-state-tree";
import { FF_LSDV_4711, FF_MEMORY_LEAK_FIX, isFF } from "../../utils/feature-flags";
import { FF_LSDV_4711, isFF } from "../../utils/feature-flags";
import { AnnotationPreview } from "../Common/AnnotationPreview/AnnotationPreview";

const imgDefaultProps = {};
Expand All @@ -12,7 +12,6 @@ export const ImageCell = (column) => {
value,
column: { alias },
} = column;
const isMemoryLeakFixEnabled = isFF(FF_MEMORY_LEAK_FIX);
const root = getRoot(original);

const renderImagePreview = original.total_annotations === 0 || !root.showPreviews;
Expand All @@ -21,32 +20,18 @@ export const ImageCell = (column) => {
if (!imgSrc) return null;

return renderImagePreview ? (
isMemoryLeakFixEnabled ? (
<div
data-testid="image-cell"
style={{
backgroundImage: `url(${imgSrc})`,
width: "100%",
height: "100%",
backgroundSize: "contain",
backgroundRepeat: "no-repeat",
backgroundPosition: "center",
}}
/>
) : (
<img
{...imgDefaultProps}
key={imgSrc}
src={imgSrc}
alt="Data"
style={{
maxHeight: "100%",
maxWidth: "100px",
objectFit: "contain",
borderRadius: 3,
}}
/>
)
<img
{...imgDefaultProps}
key={imgSrc}
src={imgSrc}
alt="Data"
style={{
maxHeight: "100%",
maxWidth: "100px",
objectFit: "contain",
borderRadius: 3,
}}
/>
) : (
<AnnotationPreview
task={original}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { inject, observer } from "mobx-react";
import React from "react";
import { taskToLSFormat } from "../../../sdk/lsf-utils";
import { cn } from "../../../utils/bem";
import { FF_LSDV_4711, FF_MEMORY_LEAK_FIX, isFF } from "../../../utils/feature-flags";
import { FF_LSDV_4711, isFF } from "../../../utils/feature-flags";
import { Spinner } from "../Spinner";
import "./AnnotationPreview.scss";

Expand Down Expand Up @@ -104,7 +104,6 @@ const injector = inject(({ store }) => {

export const AnnotationPreview = injector(
observer(({ labelingConfig, name, task, annotation, style, ...props }) => {
const isMemoryLeakFixEnabled = isFF(FF_MEMORY_LEAK_FIX);
const generator = React.useMemo(() => {
if (labelingConfig) return PreviewGenerator.getInstance(labelingConfig);
}, [labelingConfig]);
Expand All @@ -127,29 +126,14 @@ export const AnnotationPreview = injector(
}, [task, annotation, generator, preview]);

return preview ? (
isMemoryLeakFixEnabled ? (
<div
{...imgDefaultProps}
style={{
backgroundImage: `url(${preview[`$${name}`][variant]})`,
width: props.width,
height: props.height,
backgroundSize: "contain",
backgroundRepeat: "no-repeat",
backgroundPosition: "center",
...style,
}}
/>
) : (
<img
{...imgDefaultProps}
src={preview[`$${name}`][variant]}
alt=""
style={style}
width={props.width}
height={props.height}
/>
)
<img
{...imgDefaultProps}
src={preview[`$${name}`][variant]}
alt=""
style={style}
width={props.width}
height={props.height}
/>
) : (
<div className={cn("annotation-preview").toString()} width={props.width} height={props.height}>
<Spinner
Expand All @@ -162,30 +146,13 @@ export const AnnotationPreview = injector(
zIndex: 100,
}}
/>
{isMemoryLeakFixEnabled ? (
<div
data-testid="annotation-preview-image"
{...imgDefaultProps}
style={{
backgroundImage: `url(${props.fallbackImage})`,
width: props.width,
height: props.height,
backgroundSize: "contain",
backgroundRepeat: "no-repeat",
backgroundPosition: "center",
opacity: 0.5,
...style,
}}
/>
) : (
<img
src={props.fallbackImage}
style={{ ...(style ?? {}), opacity: 0.5 }}
alt=""
width={props.width}
height={props.height}
/>
)}
<img
src={props.fallbackImage}
style={{ ...(style ?? {}), opacity: 0.5 }}
alt=""
width={props.width}
height={props.height}
/>
</div>
);
}),
Expand Down

0 comments on commit 6f14092

Please sign in to comment.