feat: display folders even without the premium (#826)

This commit is contained in:
Laurent Senta
2022-01-26 09:21:24 +01:00
committed by GitHub
parent 86b38e1041
commit 7726b1249c
3 changed files with 6 additions and 12 deletions

View File

@@ -18,7 +18,6 @@ export const RootTagDropZone: React.FC<Props> = observer(
({ tagsState, featuresState }) => { ({ tagsState, featuresState }) => {
const premiumModal = usePremiumModal(); const premiumModal = usePremiumModal();
const isNativeFoldersEnabled = featuresState.enableNativeFoldersFeature; const isNativeFoldersEnabled = featuresState.enableNativeFoldersFeature;
const hasFolders = featuresState.hasFolders;
const [{ isOver, canDrop }, dropRef] = useDrop<DropItem, void, DropProps>( const [{ isOver, canDrop }, dropRef] = useDrop<DropItem, void, DropProps>(
() => ({ () => ({
@@ -27,11 +26,6 @@ export const RootTagDropZone: React.FC<Props> = observer(
return true; return true;
}, },
drop: (item) => { drop: (item) => {
if (!hasFolders) {
premiumModal.activate(TAG_FOLDERS_FEATURE_NAME);
return;
}
tagsState.assignParent(item.uuid, undefined); tagsState.assignParent(item.uuid, undefined);
}, },
collect: (monitor) => ({ collect: (monitor) => ({
@@ -39,10 +33,10 @@ export const RootTagDropZone: React.FC<Props> = observer(
canDrop: !!monitor.canDrop(), canDrop: !!monitor.canDrop(),
}), }),
}), }),
[tagsState, hasFolders, premiumModal] [tagsState, premiumModal]
); );
if (!isNativeFoldersEnabled || !hasFolders) { if (!isNativeFoldersEnabled) {
return null; return null;
} }

View File

@@ -120,7 +120,7 @@ export const TagsListItem: FunctionComponent<Props> = observer(
isDragging: !!monitor.isDragging(), isDragging: !!monitor.isDragging(),
}), }),
}), }),
[tag, hasFolders] [tag, isNativeFoldersEnabled]
); );
const [{ isOver, canDrop }, dropRef] = useDrop<DropItem, void, DropProps>( const [{ isOver, canDrop }, dropRef] = useDrop<DropItem, void, DropProps>(
@@ -160,7 +160,7 @@ export const TagsListItem: FunctionComponent<Props> = observer(
> >
{!tag.errorDecrypting ? ( {!tag.errorDecrypting ? (
<div className="tag-info" title={title} ref={dropRef}> <div className="tag-info" title={title} ref={dropRef}>
{hasFolders && isNativeFoldersEnabled && hasAtLeastOneFolder && ( {isNativeFoldersEnabled && hasAtLeastOneFolder && (
<div <div
className={`tag-fold ${showChildren ? 'opened' : 'closed'}`} className={`tag-fold ${showChildren ? 'opened' : 'closed'}`}
onClick={hasChildren ? toggleChildren : undefined} onClick={hasChildren ? toggleChildren : undefined}

View File

@@ -172,7 +172,7 @@ export class TagsState {
} }
getChildren(tag: SNTag): SNTag[] { getChildren(tag: SNTag): SNTag[] {
if (!this.features.hasFolders) { if (!this.features.enableNativeFoldersFeature) {
return []; return [];
} }
@@ -230,7 +230,7 @@ export class TagsState {
} }
get rootTags(): SNTag[] { get rootTags(): SNTag[] {
if (!this.features.hasFolders) { if (!this.features.enableNativeFoldersFeature) {
return this.tags; return this.tags;
} }