Merge branch 'move-files' into disable-shared-collection-ops
This commit is contained in:
commit
c98d4792be
|
@ -7,13 +7,17 @@ export default function MoveIcon(props) {
|
||||||
height={props.height}
|
height={props.height}
|
||||||
viewBox={props.viewBox}
|
viewBox={props.viewBox}
|
||||||
width={props.width}>
|
width={props.width}>
|
||||||
<path d="M13.025 1l-2.847 2.828 6.176 6.176h-16.354v3.992h16.354l-6.176 6.176 2.847 2.828 10.975-11z" />
|
<path
|
||||||
|
d="M13.025 1l-2.847 2.828 6.176 6.176h-16.354v3.992h16.354l-6.176 6.176 2.847 2.828 10.975-11z"
|
||||||
|
strokeWidth="2"
|
||||||
|
stroke="black"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
MoveIcon.defaultProps = {
|
MoveIcon.defaultProps = {
|
||||||
height: 20,
|
height: 24,
|
||||||
width: 20,
|
width: 24,
|
||||||
viewBox: '0 0 24 24',
|
viewBox: '0 0 24 24',
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,6 +15,8 @@ import { SetCollectionNamerAttributes } from './CollectionNamer';
|
||||||
import CollectionOptions from './CollectionOptions';
|
import CollectionOptions from './CollectionOptions';
|
||||||
import OptionIcon, { OptionIconWrapper } from './OptionIcon';
|
import OptionIcon, { OptionIconWrapper } from './OptionIcon';
|
||||||
|
|
||||||
|
export const ALL_SECTION = 0;
|
||||||
|
|
||||||
interface CollectionProps {
|
interface CollectionProps {
|
||||||
collections: Collection[];
|
collections: Collection[];
|
||||||
selected?: number;
|
selected?: number;
|
||||||
|
@ -100,9 +102,9 @@ export default function Collections(props: CollectionProps) {
|
||||||
collectionRef.current.scrollLeft = 0;
|
collectionRef.current.scrollLeft = 0;
|
||||||
}, [collections]);
|
}, [collections]);
|
||||||
|
|
||||||
const clickHandler = (collection?: Collection) => () => {
|
const clickHandler = (collectionID?: number) => () => {
|
||||||
setSelectedCollectionID(collection?.id);
|
setSelectedCollectionID(collectionID);
|
||||||
setActiveCollection(collection?.id);
|
setActiveCollection(collectionID ?? ALL_SECTION);
|
||||||
};
|
};
|
||||||
|
|
||||||
const user: User = getData(LS_KEYS.USER);
|
const user: User = getData(LS_KEYS.USER);
|
||||||
|
@ -119,7 +121,7 @@ export default function Collections(props: CollectionProps) {
|
||||||
setDialogMessage: props.setDialogMessage,
|
setDialogMessage: props.setDialogMessage,
|
||||||
startLoadingBar: props.startLoadingBar,
|
startLoadingBar: props.startLoadingBar,
|
||||||
showCollectionShareModal: setCollectionShareModalView.bind(null, true),
|
showCollectionShareModal: setCollectionShareModalView.bind(null, true),
|
||||||
redirectToAll: setActiveCollection.bind(null, 0),
|
redirectToAll: setActiveCollection.bind(null, ALL_SECTION),
|
||||||
});
|
});
|
||||||
|
|
||||||
const scrollCollection = (direction: SCROLL_DIRECTION) => () => {
|
const scrollCollection = (direction: SCROLL_DIRECTION) => () => {
|
||||||
|
@ -171,7 +173,9 @@ export default function Collections(props: CollectionProps) {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Wrapper ref={collectionRef} onScroll={updateScrollObj}>
|
<Wrapper ref={collectionRef} onScroll={updateScrollObj}>
|
||||||
<Chip active={!selected} onClick={clickHandler()}>
|
<Chip
|
||||||
|
active={!selected}
|
||||||
|
onClick={clickHandler(ALL_SECTION)}>
|
||||||
All
|
All
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
|
@ -188,7 +192,7 @@ export default function Collections(props: CollectionProps) {
|
||||||
overlay={renderTooltip(item.id)}>
|
overlay={renderTooltip(item.id)}>
|
||||||
<Chip
|
<Chip
|
||||||
active={selected === item.id}
|
active={selected === item.id}
|
||||||
onClick={clickHandler(item)}>
|
onClick={clickHandler(item.id)}>
|
||||||
{item.name}
|
{item.name}
|
||||||
{item.type !== CollectionType.favorites &&
|
{item.type !== CollectionType.favorites &&
|
||||||
item.owner.id === user?.id ? (
|
item.owner.id === user?.id ? (
|
||||||
|
|
|
@ -384,18 +384,18 @@ export const addToCollection = async (
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export const moveToCollection = async (
|
export const moveToCollection = async (
|
||||||
oldCollectionID: number,
|
fromCollectionID: number,
|
||||||
newCollection: Collection,
|
toCollection: Collection,
|
||||||
files: File[]
|
files: File[]
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const token = getToken();
|
const token = getToken();
|
||||||
const fileKeysEncryptedWithNewCollection =
|
const fileKeysEncryptedWithNewCollection =
|
||||||
await encryptWithNewCollectionKey(newCollection, files);
|
await encryptWithNewCollectionKey(toCollection, files);
|
||||||
|
|
||||||
const requestBody: MoveToCollectionRequest = {
|
const requestBody: MoveToCollectionRequest = {
|
||||||
fromCollectionID: oldCollectionID,
|
fromCollectionID: fromCollectionID,
|
||||||
toCollectionID: newCollection.id,
|
toCollectionID: toCollection.id,
|
||||||
files: fileKeysEncryptedWithNewCollection,
|
files: fileKeysEncryptedWithNewCollection,
|
||||||
};
|
};
|
||||||
await HTTPService.post(
|
await HTTPService.post(
|
||||||
|
|
Loading…
Reference in a new issue