Removed code duplications, added checks to CI (#5253)

main
Boris Sekachev 3 years ago committed by GitHub
parent aadfd8814e
commit e5d01359aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -286,7 +286,7 @@ jobs:
specs: ['actions_tasks', 'actions_tasks2', 'actions_tasks3',
'actions_objects', 'actions_objects2', 'actions_users',
'actions_projects_models', 'actions_organizations', 'canvas3d_functionality',
'canvas3d_functionality_2', 'issues_prs', 'issues_prs2']
'canvas3d_functionality_2', 'issues_prs', 'issues_prs2', 'masks', 'skeletons']
steps:
- uses: actions/checkout@v3
with:

@ -252,7 +252,7 @@ jobs:
specs: ['actions_tasks', 'actions_tasks2', 'actions_tasks3',
'actions_objects', 'actions_objects2', 'actions_users',
'actions_projects_models', 'actions_organizations', 'canvas3d_functionality',
'canvas3d_functionality_2', 'issues_prs', 'issues_prs2']
'canvas3d_functionality_2', 'issues_prs', 'issues_prs2', 'masks', 'skeletons']
steps:
- uses: actions/checkout@v3

@ -274,7 +274,7 @@ jobs:
specs: ['actions_tasks', 'actions_tasks2', 'actions_tasks3',
'actions_objects', 'actions_objects2', 'actions_users',
'actions_projects_models', 'actions_organizations', 'canvas3d_functionality',
'canvas3d_functionality_2', 'issues_prs', 'issues_prs2']
'canvas3d_functionality_2', 'issues_prs', 'issues_prs2', 'masks', 'skeletons']
steps:
- uses: actions/checkout@v3

@ -8,8 +8,9 @@ import Icon from '@ant-design/icons';
import { Canvas } from 'cvat-canvas-wrapper';
import { BrushIcon } from 'icons';
import { ShapeType } from 'reducers';
import DrawShapePopoverContainer from 'containers/annotation-page/standard-workspace/controls-side-bar/draw-mask-popover';
import DrawShapePopoverContainer from 'containers/annotation-page/standard-workspace/controls-side-bar/draw-shape-popover';
import withVisibilityHandling from './handle-popover-visibility';
export interface Props {
@ -43,7 +44,7 @@ function DrawPointsControl(props: Props): JSX.Element {
{...dynamicPopoverProps}
overlayClassName='cvat-draw-shape-popover'
placement='right'
content={<DrawShapePopoverContainer />}
content={<DrawShapePopoverContainer shapeType={ShapeType.MASK} />}
>
<Icon {...dynamicIconProps} component={BrushIcon} />
</CustomPopover>

@ -1,61 +0,0 @@
// Copyright (C) 2022 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT
import React from 'react';
import { Row, Col } from 'antd/lib/grid';
import Button from 'antd/lib/button';
import Text from 'antd/lib/typography/Text';
import LabelSelector from 'components/label-selector/label-selector';
import CVATTooltip from 'components/common/cvat-tooltip';
interface Props {
labels: any[];
selectedLabelID: number;
repeatShapeShortcut: string;
onChangeLabel(value: string): void;
onDraw(labelID: number): void;
}
function DrawMaskPopover(props: Props): JSX.Element {
const {
labels, selectedLabelID, repeatShapeShortcut, onChangeLabel, onDraw,
} = props;
return (
<div className='cvat-draw-shape-popover-content'>
<Row justify='start'>
<Col>
<Text className='cvat-text-color' strong>
Draw new mask
</Text>
</Col>
</Row>
<Row justify='start'>
<Col>
<Text className='cvat-text-color'>Label</Text>
</Col>
</Row>
<Row justify='center'>
<Col span={24}>
<LabelSelector
style={{ width: '100%' }}
labels={labels}
value={selectedLabelID}
onChange={onChangeLabel}
/>
</Col>
</Row>
<Row justify='space-around'>
<Col span={24}>
<CVATTooltip title={`Press ${repeatShapeShortcut} to draw a mask again`}>
<Button onClick={() => onDraw(selectedLabelID)}>Draw a mask</Button>
</CVATTooltip>
</Col>
</Row>
</div>
);
}
export default React.memo(DrawMaskPopover);

@ -1,4 +1,5 @@
// Copyright (C) 2020-2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT
@ -14,7 +15,7 @@ import { DimensionType, ShapeType } from 'reducers';
import { clamp } from 'utils/math';
import LabelSelector from 'components/label-selector/label-selector';
import CVATTooltip from 'components/common/cvat-tooltip';
import { Label } from 'components/labels-editor/common';
import { Label } from 'cvat-core-wrapper';
interface Props {
shapeType: ShapeType;
@ -154,7 +155,7 @@ function DrawShapePopoverComponent(props: Props): JSX.Element {
<Button onClick={onDrawShape}>Shape</Button>
</CVATTooltip>
</Col>
{is2D && (
{is2D && shapeType !== ShapeType.MASK && (
<Col span={12}>
<CVATTooltip title={`Press ${repeatShapeShortcut} to draw again`}>
<Button onClick={onDrawTrack}>Track</Button>

@ -1,108 +0,0 @@
// Copyright (C) 2022 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT
import React from 'react';
import { connect } from 'react-redux';
import DrawMaskPopoverComponent from 'components/annotation-page/standard-workspace/controls-side-bar/draw-mask-popover';
import { rememberObject } from 'actions/annotation-actions';
import { CombinedState, ShapeType, ObjectType } from 'reducers';
import { Canvas } from 'cvat-canvas-wrapper';
interface DispatchToProps {
onDrawStart(
shapeType: ShapeType,
labelID: number,
objectType: ObjectType,
): void;
}
interface StateToProps {
normalizedKeyMap: Record<string, string>;
canvasInstance: Canvas;
labels: any[];
}
function mapDispatchToProps(dispatch: any): DispatchToProps {
return {
onDrawStart(
shapeType: ShapeType,
labelID: number,
objectType: ObjectType,
): void {
dispatch(
rememberObject({
activeObjectType: objectType,
activeShapeType: shapeType,
activeLabelID: labelID,
}),
);
},
};
}
function mapStateToProps(state: CombinedState): StateToProps {
const {
annotation: {
canvas: { instance: canvasInstance },
job: { labels },
},
shortcuts: { normalizedKeyMap },
} = state;
return {
canvasInstance: canvasInstance as Canvas,
normalizedKeyMap,
labels,
};
}
type Props = StateToProps & DispatchToProps;
interface State {
selectedLabelID: number;
}
class DrawShapePopoverContainer extends React.PureComponent<Props, State> {
constructor(props: Props) {
super(props);
const defaultLabelID = props.labels.length ? props.labels[0].id : null;
this.state = { selectedLabelID: defaultLabelID };
}
private onDraw = (): void => {
const { canvasInstance, onDrawStart } = this.props;
const { selectedLabelID } = this.state;
canvasInstance.cancel();
canvasInstance.draw({
enabled: true,
shapeType: ShapeType.MASK,
crosshair: false,
});
onDrawStart(ShapeType.MASK, selectedLabelID, ObjectType.SHAPE);
};
private onChangeLabel = (value: any): void => {
this.setState({ selectedLabelID: value.id });
};
public render(): JSX.Element {
const { selectedLabelID } = this.state;
const { normalizedKeyMap, labels } = this.props;
return (
<DrawMaskPopoverComponent
labels={labels}
selectedLabelID={selectedLabelID}
repeatShapeShortcut={normalizedKeyMap.SWITCH_DRAW_MODE}
onChangeLabel={this.onChangeLabel}
onDraw={this.onDraw}
/>
);
}
}
export default connect(mapStateToProps, mapDispatchToProps)(DrawShapePopoverContainer);

@ -12,7 +12,7 @@
},
"testFiles": [
"auth_page.js",
"skeletons_pipeline.js",
"skeletons/*.js",
"webhooks.js",
"masks/*.js",
"actions_tasks/**/*.js",

Loading…
Cancel
Save