// Copyright (C) 2021 Intel Corporation // // SPDX-License-Identifier: MIT import React from 'react'; import ObjectButtonsContainer from 'containers/annotation-page/standard-workspace/objects-side-bar/object-buttons'; import { ObjectType, ShapeType, ColorBy } from 'reducers/interfaces'; import ItemDetails, { attrValuesAreEqual } from './object-item-details'; import ItemBasics from './object-item-basics'; interface Props { normalizedKeyMap: Record; readonly: boolean; activated: boolean; objectType: ObjectType; shapeType: ShapeType; clientID: number; serverID: number | undefined; labelID: number; locked: boolean; attrValues: Record; color: string; colorBy: ColorBy; labels: any[]; attributes: any[]; collapsed: boolean; jobInstance: any; activate(): void; copy(): void; propagate(): void; createURL(): void; switchOrientation(): void; toBackground(): void; toForeground(): void; remove(): void; changeLabel(label: any): void; changeAttribute(attrID: number, value: string): void; changeColor(color: string): void; collapse(): void; resetCuboidPerspective(): void; } function objectItemsAreEqual(prevProps: Props, nextProps: Props): boolean { return ( nextProps.activated === prevProps.activated && nextProps.readonly === prevProps.readonly && nextProps.locked === prevProps.locked && nextProps.labelID === prevProps.labelID && nextProps.color === prevProps.color && nextProps.clientID === prevProps.clientID && nextProps.serverID === prevProps.serverID && nextProps.objectType === prevProps.objectType && nextProps.shapeType === prevProps.shapeType && nextProps.collapsed === prevProps.collapsed && nextProps.labels === prevProps.labels && nextProps.attributes === prevProps.attributes && nextProps.normalizedKeyMap === prevProps.normalizedKeyMap && nextProps.colorBy === prevProps.colorBy && attrValuesAreEqual(nextProps.attrValues, prevProps.attrValues) ); } function ObjectItemComponent(props: Props): JSX.Element { const { activated, readonly, objectType, shapeType, clientID, serverID, locked, attrValues, labelID, color, colorBy, attributes, labels, collapsed, normalizedKeyMap, activate, copy, propagate, createURL, switchOrientation, toBackground, toForeground, remove, changeLabel, changeAttribute, changeColor, collapse, resetCuboidPerspective, jobInstance, } = props; const type = objectType === ObjectType.TAG ? ObjectType.TAG.toUpperCase() : `${shapeType.toUpperCase()} ${objectType.toUpperCase()}`; const className = !activated ? 'cvat-objects-sidebar-state-item' : 'cvat-objects-sidebar-state-item cvat-objects-sidebar-state-active-item'; return (
{!!attributes.length && ( )}
); } export default React.memo(ObjectItemComponent, objectItemsAreEqual);