diff --git a/changelog.d/20240503_105638_boris_do_not_allow_removing_last_keyframe.md b/changelog.d/20240503_105638_boris_do_not_allow_removing_last_keyframe.md new file mode 100644 index 000000000000..3ff5dae47def --- /dev/null +++ b/changelog.d/20240503_105638_boris_do_not_allow_removing_last_keyframe.md @@ -0,0 +1,4 @@ +### Changed + +- Remove keyframe button is disabled when there is only one keyframe element + () diff --git a/cvat-ui/package.json b/cvat-ui/package.json index 408f19a9c6d7..418d188935c7 100644 --- a/cvat-ui/package.json +++ b/cvat-ui/package.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.63.8", + "version": "1.63.9", "description": "CVAT single-page application", "main": "src/index.tsx", "scripts": { diff --git a/cvat-ui/src/components/annotation-page/standard-workspace/objects-side-bar/object-item-buttons.tsx b/cvat-ui/src/components/annotation-page/standard-workspace/objects-side-bar/object-item-buttons.tsx index 3c72e0b8dc87..0716a54396c1 100644 --- a/cvat-ui/src/components/annotation-page/standard-workspace/objects-side-bar/object-item-buttons.tsx +++ b/cvat-ui/src/components/annotation-page/standard-workspace/objects-side-bar/object-item-buttons.tsx @@ -1,4 +1,5 @@ // Copyright (C) 2020-2022 Intel Corporation +// Copyright (C) 2024 CVAT.ai Corporation // // SPDX-License-Identifier: MIT @@ -26,7 +27,7 @@ import { interface Props { readonly: boolean; - parentID: number; + parentID: number | null; objectType: ObjectType; shapeType: ShapeType; occluded: boolean; @@ -227,9 +228,9 @@ function SwitchKeyframe(props: Props): JSX.Element { return ( {keyframe ? ( - + ) : ( - + )} ); diff --git a/cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/object-buttons.tsx b/cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/object-buttons.tsx index 0ed232caf2f1..3c426656e07d 100644 --- a/cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/object-buttons.tsx +++ b/cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/object-buttons.tsx @@ -1,10 +1,12 @@ // Copyright (C) 2020-2022 Intel Corporation +// Copyright (C) 2024 CVAT.ai Corporation // // SPDX-License-Identifier: MIT import React from 'react'; import { connect } from 'react-redux'; +import { ObjectState, Job } from 'cvat-core-wrapper'; import { EventScope } from 'cvat-logger'; import isAbleToChangeFrame from 'utils/is-able-to-change-frame'; import { ThunkDispatch } from 'utils/redux'; @@ -21,8 +23,8 @@ interface OwnProps { } interface StateToProps { - objectState: any; - jobInstance: any; + objectState: ObjectState; + jobInstance: Job; frameNumber: number; normalizedKeyMap: Record; outsideDisabled: boolean; @@ -60,7 +62,7 @@ function mapStateToProps(state: CombinedState, own: OwnProps): StateToProps { objectState, normalizedKeyMap, frameNumber, - jobInstance, + jobInstance: jobInstance as Job, outsideDisabled: typeof outsideDisabled === 'undefined' ? false : outsideDisabled, hiddenDisabled: typeof hiddenDisabled === 'undefined' ? false : hiddenDisabled, keyframeDisabled: typeof keyframeDisabled === 'undefined' ? false : keyframeDisabled, @@ -81,15 +83,15 @@ function mapDispatchToProps(dispatch: ThunkDispatch): DispatchToProps { class ItemButtonsWrapper extends React.PureComponent { private navigateFirstKeyframe = (): void => { const { objectState, frameNumber } = this.props; - const { first } = objectState.keyframes; - if (first !== frameNumber) { + const { first } = objectState.keyframes as NonNullable; + if (first !== null && first !== frameNumber) { this.changeFrame(first); } }; private navigatePrevKeyframe = (): void => { const { objectState, frameNumber } = this.props; - const { prev } = objectState.keyframes; + const { prev } = objectState.keyframes as NonNullable; if (prev !== null && prev !== frameNumber) { this.changeFrame(prev); } @@ -97,7 +99,7 @@ class ItemButtonsWrapper extends React.PureComponent { const { objectState, frameNumber } = this.props; - const { next } = objectState.keyframes; + const { next } = objectState.keyframes as NonNullable; if (next !== null && next !== frameNumber) { this.changeFrame(next); } @@ -105,8 +107,8 @@ class ItemButtonsWrapper extends React.PureComponent { const { objectState, frameNumber } = this.props; - const { last } = objectState.keyframes; - if (last !== frameNumber) { + const { last } = objectState.keyframes as NonNullable; + if (last !== null && last !== frameNumber) { this.changeFrame(last); } }; @@ -237,18 +239,23 @@ class ItemButtonsWrapper extends React.PureComponent