Skip to content

Commit

Permalink
Remove excess
Browse files Browse the repository at this point in the history
  • Loading branch information
Marishka17 committed Oct 8, 2021
1 parent ceb0654 commit 9a55eb8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 33 deletions.
18 changes: 8 additions & 10 deletions cvat-ui/src/components/cloud-storages-page/cloud-storage-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ import Status from './cloud-storage-status';
import Preview from './cloud-storage-preview';

interface Props {
cloudStorageInstance: CloudStorage;
cloudStorage: CloudStorage;
}

export default function CloudStorageItemComponent(props: Props): JSX.Element {
const history = useHistory();
const dispatch = useDispatch();

// cloudStorageInstance: {storage, preview}
const { cloudStorageInstance } = props;
const { cloudStorage } = props;
const {
id,
displayName,
Expand All @@ -40,10 +39,9 @@ export default function CloudStorageItemComponent(props: Props): JSX.Element {
createdDate,
updatedDate,
description,
} = cloudStorageInstance.storage;
// const { preview } = cloudStorageInstance;
} = cloudStorage;
const deletes = useSelector((state: CombinedState) => state.cloudStorages.activities.deletes);
const deleted = cloudStorageInstance.storage.id in deletes ? deletes[cloudStorageInstance.storage.id] : false;
const deleted = cloudStorage.id in deletes ? deletes[cloudStorage.id] : false;

const style: React.CSSProperties = {};

Expand All @@ -62,21 +60,21 @@ export default function CloudStorageItemComponent(props: Props): JSX.Element {
content: `You are going to remove the cloudstorage "${displayName}". Continue?`,
className: 'cvat-delete-cloud-storage-modal',
onOk: () => {
dispatch(deleteCloudStorageAsync(cloudStorageInstance.storage));
dispatch(deleteCloudStorageAsync(cloudStorage));
},
okButtonProps: {
type: 'primary',
danger: true,
},
okText: 'Delete',
});
}, [cloudStorageInstance.storage.id]);
}, [cloudStorage.id]);

return (
<Card
cover={(
<>
<Preview cloudStorage={cloudStorageInstance.storage} />
<Preview cloudStorage={cloudStorage} />
{description ? (
<CVATTooltip overlay={description}>
<QuestionCircleOutlined className='cvat-cloud-storage-description-icon' />
Expand Down Expand Up @@ -111,7 +109,7 @@ export default function CloudStorageItemComponent(props: Props): JSX.Element {
<Text type='secondary'>Last updated </Text>
<Text type='secondary'>{moment(updatedDate).fromNow()}</Text>
</Paragraph>
<Status cloudStorage={cloudStorageInstance.storage} />
<Status cloudStorage={cloudStorage} />
<Dropdown
overlay={(
<Menu className='cvat-project-actions-menu'>
Expand Down
18 changes: 5 additions & 13 deletions cvat-ui/src/components/cloud-storages-page/cloud-storages-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import CloudStorageItemComponent from './cloud-storage-item';

interface Props {
storages: CloudStorage[];
// previews: string[];
totalCount: number;
page: number;
onChangePage(page: number): void;
Expand All @@ -25,17 +24,10 @@ export default function StoragesList(props: Props): JSX.Element {
const groupedStorages = storages.reduce(
(acc: CloudStorage[][], storage: CloudStorage, index: number): CloudStorage[][] => {
if (index && index % 4) {
acc[acc.length - 1].push({
storage,
// preview: previews[index],
});
acc[acc.length - 1].push(storage);
} else {
acc.push([{
storage,
// preview: previews[index],
}]);
acc.push([storage]);
}

return acc;
},
[],
Expand All @@ -47,10 +39,10 @@ export default function StoragesList(props: Props): JSX.Element {
<Col span={24} className='cvat-cloud-storages-list'>
{groupedStorages.map(
(instances: CloudStorage[]): JSX.Element => (
<Row key={instances[0].storage.id} gutter={[8, 8]}>
<Row key={instances[0].id} gutter={[8, 8]}>
{instances.map((instance: CloudStorage) => (
<Col span={6} key={instance.storage.id}>
<CloudStorageItemComponent cloudStorageInstance={instance} />
<Col span={6} key={instance.id}>
<CloudStorageItemComponent cloudStorage={instance} />
</Col>
))}
</Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ export default function StoragesPageComponent(): JSX.Element {
const totalCount = useSelector((state: CombinedState) => state.cloudStorages.count);
const isFetching = useSelector((state: CombinedState) => state.cloudStorages.fetching);
const current = useSelector((state: CombinedState) => state.cloudStorages.current);
// .map((cloudStrage: CloudStorage) => cloudStrage.instance);
// const previews = useSelector((state: CombinedState) => state.cloudStorages.current)
// .map((cloudStrage: CloudStorage) => cloudStrage.preview as string);
const query = useSelector((state: CombinedState) => state.cloudStorages.gettingQuery);
const onSearch = useCallback(
(_query: CloudStoragesQuery) => {
Expand Down Expand Up @@ -96,7 +93,6 @@ export default function StoragesPageComponent(): JSX.Element {
totalCount={totalCount}
page={query.page}
storages={current}
// previews={previews}
onChangePage={onChangePage}
/>
) : (
Expand Down
6 changes: 0 additions & 6 deletions cvat-ui/src/reducers/cloud-storages-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@ export default (
case CloudStorageActionTypes.GET_CLOUD_STORAGE_SUCCESS: {
const { count, query, array } = action.payload;

// const combined = action.payload.array.map(
// (cloudStorage: any, index: number): CloudStorage => ({
// instance: cloudStorage,
// preview: action.payload.previews[index],
// }),
// );
return {
...state,
initialized: true,
Expand Down

0 comments on commit 9a55eb8

Please sign in to comment.