fix showing/hidding of collection in different context
This commit is contained in:
parent
b44bfe8a8e
commit
4e2c9ca59a
|
@ -5,8 +5,7 @@ import CollectionOptions from 'components/Collections/CollectionOptions';
|
||||||
import { SetCollectionNamerAttributes } from 'components/Collections/CollectionNamer';
|
import { SetCollectionNamerAttributes } from 'components/Collections/CollectionNamer';
|
||||||
import { SpaceBetweenFlex } from 'components/Container';
|
import { SpaceBetweenFlex } from 'components/Container';
|
||||||
import { CollectionInfoBarWrapper } from './styledComponents';
|
import { CollectionInfoBarWrapper } from './styledComponents';
|
||||||
import { isSystemCollection } from 'utils/collection';
|
import { isOptionsHavingCollection } from 'utils/collection';
|
||||||
import { TRASH_SECTION } from 'constants/collection';
|
|
||||||
|
|
||||||
interface Iprops {
|
interface Iprops {
|
||||||
activeCollection: Collection;
|
activeCollection: Collection;
|
||||||
|
@ -32,13 +31,13 @@ export default function CollectionInfoWithOptions({
|
||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { name, type, fileCount, id } = collectionSummary;
|
const { name, type, fileCount } = collectionSummary;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CollectionInfoBarWrapper>
|
<CollectionInfoBarWrapper>
|
||||||
<SpaceBetweenFlex>
|
<SpaceBetweenFlex>
|
||||||
<CollectionInfo name={name} fileCount={fileCount} />
|
<CollectionInfo name={name} fileCount={fileCount} />
|
||||||
{(!isSystemCollection(type) || id === TRASH_SECTION) && (
|
{isOptionsHavingCollection(type) && (
|
||||||
<CollectionOptions {...props} />
|
<CollectionOptions {...props} />
|
||||||
)}
|
)}
|
||||||
</SpaceBetweenFlex>
|
</SpaceBetweenFlex>
|
||||||
|
|
|
@ -15,6 +15,7 @@ import useWindowSize from 'hooks/useWindowSize';
|
||||||
import LinkButton from 'components/pages/gallery/LinkButton';
|
import LinkButton from 'components/pages/gallery/LinkButton';
|
||||||
import { SpaceBetweenFlex } from 'components/Container';
|
import { SpaceBetweenFlex } from 'components/Container';
|
||||||
import { sortCollectionSummaries } from 'services/collectionService';
|
import { sortCollectionSummaries } from 'services/collectionService';
|
||||||
|
import { shouldBeShownOnCollectionBar } from 'utils/collection';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
activeCollection?: number;
|
activeCollection?: number;
|
||||||
|
@ -34,8 +35,8 @@ export default function CollectionListBar(props: IProps) {
|
||||||
const sortedCollectionSummary = useMemo(
|
const sortedCollectionSummary = useMemo(
|
||||||
() =>
|
() =>
|
||||||
sortCollectionSummaries(
|
sortCollectionSummaries(
|
||||||
[...collectionSummaries.values()].filter(
|
[...collectionSummaries.values()].filter((c) =>
|
||||||
(c) => c.fileCount > 0
|
shouldBeShownOnCollectionBar(c.type)
|
||||||
),
|
),
|
||||||
COLLECTION_SORT_BY.UPDATION_TIME_DESCENDING
|
COLLECTION_SORT_BY.UPDATION_TIME_DESCENDING
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { useContext, useEffect, useMemo } from 'react';
|
import React, { useContext, useEffect, useMemo } from 'react';
|
||||||
import { Collection, CollectionSummaries } from 'types/collection';
|
import { Collection, CollectionSummaries } from 'types/collection';
|
||||||
import DialogTitleWithCloseButton from 'components/DialogBox/TitleWithCloseButton';
|
import DialogTitleWithCloseButton from 'components/DialogBox/TitleWithCloseButton';
|
||||||
import { isSystemCollection } from 'utils/collection';
|
import { isUploadAllowedCollection } from 'utils/collection';
|
||||||
import { AppContext } from 'pages/_app';
|
import { AppContext } from 'pages/_app';
|
||||||
import { AllCollectionDialog } from 'components/Collections/AllCollections/dialog';
|
import { AllCollectionDialog } from 'components/Collections/AllCollections/dialog';
|
||||||
import { DialogContent } from '@mui/material';
|
import { DialogContent } from '@mui/material';
|
||||||
|
@ -35,7 +35,8 @@ function CollectionSelector({
|
||||||
...collectionSummaries.values(),
|
...collectionSummaries.values(),
|
||||||
]?.filter(
|
]?.filter(
|
||||||
({ type, id }) =>
|
({ type, id }) =>
|
||||||
id !== attributes?.fromCollection && !isSystemCollection(type)
|
id !== attributes?.fromCollection &&
|
||||||
|
!isUploadAllowedCollection(type)
|
||||||
);
|
);
|
||||||
return personalCollectionsOtherThanFrom;
|
return personalCollectionsOtherThanFrom;
|
||||||
}, [collectionSummaries, attributes]);
|
}, [collectionSummaries, attributes]);
|
||||||
|
|
|
@ -37,5 +37,21 @@ export const SYSTEM_COLLECTION_TYPES = new Set([
|
||||||
CollectionType.all,
|
CollectionType.all,
|
||||||
CollectionType.archive,
|
CollectionType.archive,
|
||||||
CollectionType.trash,
|
CollectionType.trash,
|
||||||
CollectionType.shared,
|
]);
|
||||||
|
|
||||||
|
export const UPLOAD_ALLOWED_COLLECTION_TYPES = new Set([
|
||||||
|
CollectionType.album,
|
||||||
|
CollectionType.folder,
|
||||||
|
CollectionType.favorites,
|
||||||
|
]);
|
||||||
|
|
||||||
|
export const OPTIONS_HAVING_COLLECTION_TYPES = new Set([
|
||||||
|
CollectionType.folder,
|
||||||
|
CollectionType.album,
|
||||||
|
CollectionType.trash,
|
||||||
|
]);
|
||||||
|
|
||||||
|
export const HIDE_FROM_COLLECTION_BAR_TYPES = new Set([
|
||||||
|
CollectionType.trash,
|
||||||
|
CollectionType.archive,
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -19,7 +19,13 @@ import {
|
||||||
CollectionMagicMetadataProps,
|
CollectionMagicMetadataProps,
|
||||||
CollectionSummaries,
|
CollectionSummaries,
|
||||||
} from 'types/collection';
|
} from 'types/collection';
|
||||||
import { CollectionType, SYSTEM_COLLECTION_TYPES } from 'constants/collection';
|
import {
|
||||||
|
CollectionType,
|
||||||
|
HIDE_FROM_COLLECTION_BAR_TYPES,
|
||||||
|
OPTIONS_HAVING_COLLECTION_TYPES,
|
||||||
|
SYSTEM_COLLECTION_TYPES,
|
||||||
|
UPLOAD_ALLOWED_COLLECTION_TYPES,
|
||||||
|
} from 'constants/collection';
|
||||||
import { getAlbumSiteHost } from 'constants/pages';
|
import { getAlbumSiteHost } from 'constants/pages';
|
||||||
import { getUnixTimeInMicroSecondsWithDelta } from 'utils/time';
|
import { getUnixTimeInMicroSecondsWithDelta } from 'utils/time';
|
||||||
import {
|
import {
|
||||||
|
@ -202,6 +208,18 @@ export const hasNonEmptyCollections = (
|
||||||
return collectionSummaries?.size <= 3;
|
return collectionSummaries?.size <= 3;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const isUploadAllowedCollection = (type: CollectionType) => {
|
||||||
|
return UPLOAD_ALLOWED_COLLECTION_TYPES.has(type);
|
||||||
|
};
|
||||||
|
|
||||||
export const isSystemCollection = (type: CollectionType) => {
|
export const isSystemCollection = (type: CollectionType) => {
|
||||||
return SYSTEM_COLLECTION_TYPES.has(type);
|
return SYSTEM_COLLECTION_TYPES.has(type);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const isOptionsHavingCollection = (type: CollectionType) => {
|
||||||
|
return OPTIONS_HAVING_COLLECTION_TYPES.has(type);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const shouldBeShownOnCollectionBar = (type: CollectionType) => {
|
||||||
|
return !HIDE_FROM_COLLECTION_BAR_TYPES.has(type);
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue