Skip to content

Commit

Permalink
Merge branch 'develop' into helm-nuclio-env
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev authored Mar 24, 2023
2 parents c787d12 + 777ea3b commit 353c827
Show file tree
Hide file tree
Showing 17 changed files with 177 additions and 73 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Nuclio function invocations when deployed via the Helm chart
(<https://github.com/opencv/cvat/issues/5626>)
- Downgrade NumPy used by HRNet because `np.int` is no longer available (<https://github.com/opencv/cvat/pull/5574>)
- Make empty previews responsive to page resize <https://github.com/opencv/cvat/pull/5925>

### Security
- TDB
Expand Down
2 changes: 1 addition & 1 deletion cvat-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-ui",
"version": "1.50.3",
"version": "1.50.4",
"description": "CVAT single-page application",
"main": "src/index.tsx",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion cvat-ui/src/actions/share-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const shareActions = {

export type ShareActions = ActionUnion<typeof shareActions>;

export function loadShareDataAsync(directory: string): ThunkAction {
export function loadShareDataAsync(directory: string): ThunkAction<Promise<ShareFileInfo[]>> {
return async (dispatch): Promise<ShareFileInfo[]> => {
try {
dispatch(shareActions.loadShareData());
Expand Down
26 changes: 26 additions & 0 deletions cvat-ui/src/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,29 @@ $box-shadow-base: 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 6px 16px 0 rgba(0, 0, 0,

$monospaced-fonts-stack: Consolas, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono,
Courier New, monospace;

.cvat-base-preview {
.ant-spin {
position: inherit;
}

font-size: $grid-unit-size * 15;
text-align: center;
height: 100%;
display: flex;
justify-content: center;
align-items: center;

svg {
width: 65%;
height: 65%;
}

.anticon {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
}
11 changes: 6 additions & 5 deletions cvat-ui/src/components/cloud-storages-page/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@

.cvat-cloud-storage-item-loading-preview,
.cvat-cloud-storage-item-empty-preview {
.ant-spin {
position: inherit;
}
@extend .cvat-base-preview;

font-size: $grid-unit-size * 15;
text-align: center;
height: $grid-unit-size * 24;

svg {
width: 40%;
height: 40%;
}
}

.cvat-cloud-storage-item-preview {
Expand Down
28 changes: 22 additions & 6 deletions cvat-ui/src/components/file-manager/file-manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { EventDataNode } from 'rc-tree/lib/interface';

import config from 'config';
import { CloudStorage } from 'reducers';
import CVATLoadingSpinner from 'components/common/loading-spinner';
import CloudStorageTab from './cloud-storages-tab';
import LocalFiles from './local-files';

Expand All @@ -38,8 +39,9 @@ interface State {
}

interface Props {
sharedStorageInitialized: boolean;
sharedStorageFetching: boolean;
treeData: (TreeNodeNormal & { mime_type: string })[];
share: any;
many: boolean;
onLoadData: (key: string) => Promise<any>;
onChangeActiveKey(key: string): void;
Expand All @@ -55,7 +57,6 @@ export class FileManager extends React.PureComponent<Props, State> {
public constructor(props: Props) {
super(props);
this.cloudStorageTabFormRef = React.createRef<FormInstance>();
const { onLoadData } = this.props;

this.state = {
files: {
Expand All @@ -69,8 +70,15 @@ export class FileManager extends React.PureComponent<Props, State> {
expandedKeys: [],
active: 'local',
};
}

public componentDidUpdate(): void {
const { active } = this.state;
const { onLoadData, sharedStorageInitialized, sharedStorageFetching } = this.props;

onLoadData('/');
if (active === 'share' && !sharedStorageInitialized && !sharedStorageFetching) {
onLoadData('/');
}
}

private handleUploadCloudStorageFiles = (cloudStorageFiles: string[]): void => {
Expand Down Expand Up @@ -156,12 +164,19 @@ export class FileManager extends React.PureComponent<Props, State> {
}

const { SHARE_MOUNT_GUIDE_URL } = config;
const { treeData, onUploadShareFiles, onLoadData } = this.props;
const {
treeData, sharedStorageInitialized, onUploadShareFiles, onLoadData,
} = this.props;
const { expandedKeys, files } = this.state;

return (
<Tabs.TabPane key='share' tab='Connected file share'>
{treeData[0].children && treeData[0].children.length ? (
{!sharedStorageInitialized && (
<div className='cvat-share-tree-initialization'>
<CVATLoadingSpinner />
</div>
)}
{sharedStorageInitialized && !!treeData[0].children?.length && (
<Tree
className='cvat-share-tree'
checkable
Expand Down Expand Up @@ -196,7 +211,8 @@ export class FileManager extends React.PureComponent<Props, State> {
}}
treeData={getTreeNodes(treeData)}
/>
) : (
)}
{sharedStorageInitialized && !treeData[0].children?.length && (
<div className='cvat-empty-share-tree'>
<Empty />
<Paragraph className='cvat-text-color'>
Expand Down
8 changes: 7 additions & 1 deletion cvat-ui/src/components/file-manager/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@

@import '../../base.scss';

.cvat-share-tree {
.cvat-share-tree-initialization {
height: 32 * $grid-unit-size;
}

.cvat-share-tree {
@extend .cvat-share-tree-initialization;
}

.cvat-empty-share-tree {
@extend .cvat-share-tree-initialization;

> .ant-typography {
margin-top: 10px;
}
Expand Down
10 changes: 4 additions & 6 deletions cvat-ui/src/components/jobs-page/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,11 @@

.cvat-job-item-loading-preview,
.cvat-job-item-empty-preview {
.ant-spin {
position: inherit;
}
@extend .cvat-base-preview;

font-size: $grid-unit-size * 15;
text-align: center;
height: $grid-unit-size * 24;
&:hover {
cursor: pointer;
}
}

.cvat-job-page-list-item-dimension {
Expand Down
10 changes: 5 additions & 5 deletions cvat-ui/src/components/models-page/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,19 @@

.cvat-model-item-loading-preview,
.cvat-model-item-empty-preview {
.ant-spin {
position: inherit;
}
@extend .cvat-base-preview;

font-size: 80px;
text-align: center;
height: $grid-unit-size * 18;

&:hover {
cursor: pointer;
}
}

.cvat-model-item-loading-preview {
padding-top: $grid-unit-size * 3;
}

.cvat-models-item-card-preview-wrapper {
display: flex;
justify-content: center;
Expand Down
12 changes: 7 additions & 5 deletions cvat-ui/src/components/projects-page/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@

.cvat-project-item-loading-preview,
.cvat-project-item-empty-preview {
.ant-spin {
position: inherit;
@extend .cvat-base-preview;

&:hover {
cursor: pointer;
}
}

font-size: $grid-unit-size * 15;
text-align: center;
height: $grid-unit-size * 24;
.cvat-project-item-loading-preview {
padding-top: $grid-unit-size * 3;
}

.cvat-projects-project-item-title {
Expand Down
5 changes: 1 addition & 4 deletions cvat-ui/src/components/task-page/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,10 @@

.cvat-task-item-loading-preview,
.cvat-task-item-empty-preview {
.ant-spin {
position: inherit;
}
@extend .cvat-base-preview;

height: $grid-unit-size * 18;
font-size: $grid-unit-size * 10;
text-align: center;
margin-bottom: $grid-unit-size * 3;
}

Expand Down
6 changes: 2 additions & 4 deletions cvat-ui/src/components/tasks-page/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,10 @@

.cvat-task-item-loading-preview,
.cvat-task-item-empty-preview {
.ant-spin {
position: inherit;
}
@extend .cvat-base-preview;

font-size: $grid-unit-size * 6;
text-align: center;
height: $grid-unit-size * 10;
}

.cvat-task-item-preview-wrapper {
Expand Down
79 changes: 52 additions & 27 deletions cvat-ui/src/containers/file-manager/file-manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,20 @@ interface OwnProps {
}

interface StateToProps {
treeData: (TreeNodeNormal & { mime_type: string })[];
share: any;
treeData: ShareItem;
sharedStorageInitialized: boolean;
sharedStorageFetching: boolean;
}

interface DispatchToProps {
getTreeData(key: string): Promise<ShareFileInfo[]>;
}

function mapStateToProps(state: CombinedState): StateToProps {
function convert(items: ShareItem[], path?: string): (TreeNodeNormal & { mime_type: string })[] {
return items.map(
(item): (TreeNodeNormal & { mime_type: string }) => {
const isLeaf = item.type !== 'DIR';
const key = `${path}${item.name}${isLeaf ? '' : '/'}`;
return {
key,
isLeaf,
title: item.name || 'root',
mime_type: item.mime_type,
children: convert(item.children, key),
};
},
);
}

const { root } = state.share;

return {
treeData: convert([root], ''),
share: state.share,
treeData: state.share.root,
sharedStorageInitialized: state.share.initialized,
sharedStorageFetching: state.share.fetching,
};
}

Expand All @@ -71,15 +55,54 @@ function mapDispatchToProps(dispatch: any): DispatchToProps {

type Props = StateToProps & DispatchToProps & OwnProps;

export class FileManagerContainer extends React.PureComponent<Props> {
interface State {
treeData: (TreeNodeNormal & {
mime_type: string;
})[];
prevRoot: ShareItem | null;
}

export class FileManagerContainer extends React.PureComponent<Props, State> {
private managerComponentRef: any;

public constructor(props: Props) {
super(props);

this.state = {
treeData: [],
prevRoot: null,
};

this.managerComponentRef = React.createRef();
}

static getDerivedStateFromProps(props: Props, state: State): State | null {
function convert(items: ShareItem[], path?: string): (TreeNodeNormal & { mime_type: string })[] {
return items.map(
(item): (TreeNodeNormal & { mime_type: string }) => {
const isLeaf = item.type !== 'DIR';
const key = `${path}${item.name}${isLeaf ? '' : '/'}`;
return {
key,
isLeaf,
title: item.name || 'root',
mime_type: item.mime_type,
children: convert(item.children, key),
};
},
);
}

if (state.prevRoot !== props.treeData) {
return {
prevRoot: props.treeData,
treeData: convert([props.treeData], ''),
};
}

return null;
}

private handleUploadShareFiles = (keys: string[]): Promise<void> => new Promise(() => {
const { onUploadShareFiles, getTreeData } = this.props;
const getItemTreeDataByPath = (data: any, partsPath: string[]): any => {
Expand All @@ -95,7 +118,7 @@ export class FileManagerContainer extends React.PureComponent<Props> {
type: string;
mime_type: string;
}[]> => {
const { treeData } = this.props;
const { treeData } = this.state;
let files: {
key: string;
type: string;
Expand Down Expand Up @@ -150,20 +173,22 @@ export class FileManagerContainer extends React.PureComponent<Props> {

public render(): JSX.Element {
const {
treeData,
share,
sharedStorageInitialized,
sharedStorageFetching,
getTreeData,
many,
onChangeActiveKey,
onUploadLocalFiles,
onUploadRemoteFiles,
onUploadCloudStorageFiles,
} = this.props;
const { treeData } = this.state;

return (
<FileManagerComponent
treeData={treeData}
share={share}
sharedStorageInitialized={sharedStorageInitialized}
sharedStorageFetching={sharedStorageFetching}
many={many}
onLoadData={getTreeData}
onUploadLocalFiles={onUploadLocalFiles}
Expand Down
Loading

0 comments on commit 353c827

Please sign in to comment.