未验证 提交 90ad0d1e 编写于 作者: K Kirill Lakhov 提交者: GitHub

Fixed export formats for empty project (#5899)

<!-- Raise an issue to propose your change
(https://github.com/opencv/cvat/issues).
It helps to avoid duplication of efforts from multiple independent
contributors.
Discuss your ideas with maintainers to be sure that changes will be
approved and merged.
Read the [Contribution
guide](https://opencv.github.io/cvat/docs/contributing/). -->

<!-- Provide a general summary of your changes in the Title above -->

### Motivation and context
<!-- Why is this change required? What problem does it solve? If it
fixes an open
issue, please link to the issue here. Describe your changes in detail,
add
screenshots. -->
- [x] Resolved #5381 
- [x] Fixed warining occured when opening export modal

![image](https://user-images.githubusercontent.com/50956430/226834232-10768b6a-622b-4352-9fd2-3b54dc8ef0d7.png)
- [x] Fixed ui issue

![image](https://user-images.githubusercontent.com/50956430/226834425-49ed3416-6166-44f9-abd9-b7f7e5557889.png)


### How has this been tested?
<!-- Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc. -->

### Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply.
If an item isn't applicable for some reason, then ~~explicitly
strikethrough~~ the whole
line. If you don't do that, GitHub will show incorrect progress for the
pull request.
If you're unsure about any of these, don't hesitate to ask. We're here
to help! -->
- [x] I submit my changes into the `develop` branch
- [ ] I have added a description of my changes into the
[CHANGELOG](https://github.com/opencv/cvat/blob/develop/CHANGELOG.md)
file
- ~~[ ] I have updated the documentation accordingly~~
- [ ] I have added tests to cover my changes
- [x] I have linked related issues (see [GitHub docs](

https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))
- [ ] I have increased versions of npm packages if it is necessary

([cvat-canvas](https://github.com/opencv/cvat/tree/develop/cvat-canvas#versioning),

[cvat-core](https://github.com/opencv/cvat/tree/develop/cvat-core#versioning),

[cvat-data](https://github.com/opencv/cvat/tree/develop/cvat-data#versioning)
and

[cvat-ui](https://github.com/opencv/cvat/tree/develop/cvat-ui#versioning))

### License

- [x] I submit _my code changes_ under the same [MIT License](
https://github.com/opencv/cvat/blob/develop/LICENSE) that covers the
project.
  Feel free to contact the maintainers if that's a concern.

---------
Co-authored-by: NBoris Sekachev <boris.sekachev@yandex.ru>
上级 e089a054
......@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Cloud storage content listing when the manifest name contains special characters
(<https://github.com/opencv/cvat/pull/5873>)
- Width and height in CVAT dataset format mask annotations (<https://github.com/opencv/cvat/pull/5905>)
- Empty list of export formats for a project without tasks (<https://github.com/opencv/cvat/pull/5899>)
### Security
- TDB
......
{
"name": "cvat-ui",
"version": "1.50.1",
"version": "1.50.2",
"description": "CVAT single-page application",
"main": "src/index.tsx",
"scripts": {
......
// Copyright (C) 2021-2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corporation
// Copyright (C) 2022-2023 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT
......@@ -18,7 +18,10 @@ import Space from 'antd/lib/space';
import TargetStorageField from 'components/storage/target-storage-field';
import { CombinedState, StorageLocation } from 'reducers';
import { exportActions, exportDatasetAsync } from 'actions/export-actions';
import { getCore, Storage, StorageData } from 'cvat-core-wrapper';
import {
Dumper,
getCore, Job, Project, Storage, StorageData, Task,
} from 'cvat-core-wrapper';
const core = getCore();
......@@ -56,15 +59,15 @@ function ExportDatasetModal(props: StateToProps): JSX.Element {
location: StorageLocation.LOCAL,
});
const [defaultStorageLocation, setDefaultStorageLocation] = useState(StorageLocation.LOCAL);
const [defaultStorageCloudId, setDefaultStorageCloudId] = useState<number | null>(null);
const [defaultStorageCloudId, setDefaultStorageCloudId] = useState<number>();
const [helpMessage, setHelpMessage] = useState('');
const dispatch = useDispatch();
useEffect(() => {
if (instance instanceof core.classes.Project) {
if (instance instanceof Project) {
setInstanceType(`project #${instance.id}`);
} else if (instance instanceof core.classes.Task || instance instanceof core.classes.Job) {
if (instance instanceof core.classes.Task) {
} else if (instance instanceof Task || instance instanceof Job) {
if (instance instanceof Task) {
setInstanceType(`task #${instance.id}`);
} else {
setInstanceType(`job #${instance.id}`);
......@@ -79,16 +82,16 @@ function ExportDatasetModal(props: StateToProps): JSX.Element {
useEffect(() => {
if (instance) {
if (instance instanceof core.classes.Project || instance instanceof core.classes.Task) {
if (instance instanceof Project || instance instanceof Task) {
setDefaultStorageLocation(instance.targetStorage?.location || StorageLocation.LOCAL);
setDefaultStorageCloudId(instance.targetStorage?.cloudStorageId || null);
setDefaultStorageCloudId(instance.targetStorage?.cloudStorageId);
} else {
core.tasks.get({ id: instance.taskId })
.then((response: any) => {
if (response.length) {
const [taskInstance] = response;
setDefaultStorageLocation(taskInstance.targetStorage?.location || StorageLocation.LOCAL);
setDefaultStorageCloudId(taskInstance.targetStorage?.cloudStorageId || null);
setDefaultStorageCloudId(taskInstance.targetStorage?.cloudStorageId);
}
})
.catch((error: Error) => {
......@@ -104,7 +107,6 @@ function ExportDatasetModal(props: StateToProps): JSX.Element {
}, [instance]);
useEffect(() => {
// eslint-disable-next-line prefer-template
setHelpMessage(`Export to ${(defaultStorageLocation) ? defaultStorageLocation.split('_')[0] : 'local'} ` +
`storage ${(defaultStorageCloudId) ? `№${defaultStorageCloudId}` : ''}`);
}, [defaultStorageLocation, defaultStorageCloudId]);
......@@ -129,7 +131,7 @@ function ExportDatasetModal(props: StateToProps): JSX.Element {
location: defaultStorageLocation,
cloudStorageId: defaultStorageCloudId,
}) : new Storage(targetStorage),
values.customName ? `${values.customName}.zip` : null,
values.customName ? `${values.customName}.zip` : undefined,
),
);
closeModal();
......@@ -168,10 +170,13 @@ function ExportDatasetModal(props: StateToProps): JSX.Element {
>
<Select virtual={false} placeholder='Select dataset format' className='cvat-modal-export-select'>
{dumpers
.sort((a: any, b: any) => a.name.localeCompare(b.name))
.filter((dumper: any): boolean => dumper.dimension === instance?.dimension)
.sort((a: Dumper, b: Dumper) => a.name.localeCompare(b.name))
.filter(
(dumper: Dumper): boolean => dumper.dimension === instance?.dimension ||
(instance instanceof Project && instance.dimension === null),
)
.map(
(dumper: any): JSX.Element => {
(dumper: Dumper): JSX.Element => {
const pending = (instance && current ? current : [])
.includes(dumper.name);
const disabled = !dumper.enabled || pending;
......@@ -192,7 +197,11 @@ function ExportDatasetModal(props: StateToProps): JSX.Element {
</Select>
</Form.Item>
<Space>
<Form.Item name='saveImages' className='cvat-modal-export-switch-use-default-storage'>
<Form.Item
className='cvat-modal-export-switch-use-default-storage'
name='saveImages'
valuePropName='checked'
>
<Switch className='cvat-modal-export-save-images' />
</Form.Item>
<Text strong>Save images</Text>
......@@ -206,7 +215,7 @@ function ExportDatasetModal(props: StateToProps): JSX.Element {
/>
</Form.Item>
<TargetStorageField
instanceId={instance?.id}
instanceId={instance ? instance.id : null}
switchDescription='Use default settings'
switchHelpMessage={helpMessage}
useDefaultStorage={useDefaultTargetStorage}
......@@ -224,9 +233,9 @@ function ExportDatasetModal(props: StateToProps): JSX.Element {
}
interface StateToProps {
dumpers: any;
instance: any;
current: any;
dumpers: Dumper[];
instance: Project | Task | Job | null;
current: string[];
}
function mapStateToProps(state: CombinedState): StateToProps {
......
......@@ -31,6 +31,7 @@
}
}
.cvat-switch-use-default-storage,
.cvat-modal-import-switch-use-default-storage,
.cvat-modal-import-switch-conv-mask-to-poly {
display: table-cell;
......
......@@ -54,7 +54,7 @@ export default function StorageWithSwitchField(props: Props): JSX.Element {
<Form.Item
name={switchName}
valuePropName='checked'
className='cvat-settings-switch'
className='cvat-settings-switch cvat-switch-use-default-storage'
>
<Switch
onChange={(value: boolean) => {
......
......@@ -22,6 +22,7 @@ import Issue from 'cvat-core/src/issue';
import Comment from 'cvat-core/src/comment';
import User from 'cvat-core/src/user';
import Organization from 'cvat-core/src/organization';
import { Dumper } from 'cvat-core/src/annotation-formats';
const cvat: any = _cvat;
......@@ -55,6 +56,7 @@ export {
ModelProviders,
ModelReturnType,
DimensionType,
Dumper,
};
export type {
......
// Copyright (C) 2023 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT
/// <reference types="cypress" />
const issueId = '5381';
const project = {
name: `Issue ${issueId}`,
label: 'Tree',
attrName: 'Kind',
attrVaue: 'Oak',
};
context('List of export formats for a project without tasks is not empty', () => {
before(() => {
cy.visit('auth/login');
cy.login();
cy.goToProjectsList();
cy.createProjects(project.name, project.label, project.attrName, project.attrVaue);
cy.goToProjectsList();
});
describe(`Testing issue "${issueId}"`, () => {
it('Export formats list is not empty for empty project', () => {
cy.projectActions(project.name);
cy.get('.cvat-project-actions-menu').contains('Export dataset').click();
cy.get('.cvat-modal-export-project').should('be.visible').find('.cvat-modal-export-select').click();
cy.get('.cvat-modal-export-option-item').should('have.length.above', 0);
});
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册