Skip to content

Commit

Permalink
feat: display folders even without the premium (#826)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsenta authored Jan 26, 2022
1 parent 86b38e1 commit 7726b12
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
10 changes: 2 additions & 8 deletions app/assets/javascripts/components/Tags/RootTagDropZone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const RootTagDropZone: React.FC<Props> = observer(
({ tagsState, featuresState }) => {
const premiumModal = usePremiumModal();
const isNativeFoldersEnabled = featuresState.enableNativeFoldersFeature;
const hasFolders = featuresState.hasFolders;

const [{ isOver, canDrop }, dropRef] = useDrop<DropItem, void, DropProps>(
() => ({
Expand All @@ -27,22 +26,17 @@ export const RootTagDropZone: React.FC<Props> = observer(
return true;
},
drop: (item) => {
if (!hasFolders) {
premiumModal.activate(TAG_FOLDERS_FEATURE_NAME);
return;
}

tagsState.assignParent(item.uuid, undefined);
},
collect: (monitor) => ({
isOver: !!monitor.isOver(),
canDrop: !!monitor.canDrop(),
}),
}),
[tagsState, hasFolders, premiumModal]
[tagsState, premiumModal]
);

if (!isNativeFoldersEnabled || !hasFolders) {
if (!isNativeFoldersEnabled) {
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/components/Tags/TagsListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const TagsListItem: FunctionComponent<Props> = observer(
isDragging: !!monitor.isDragging(),
}),
}),
[tag, hasFolders]
[tag, isNativeFoldersEnabled]
);

const [{ isOver, canDrop }, dropRef] = useDrop<DropItem, void, DropProps>(
Expand Down Expand Up @@ -160,7 +160,7 @@ export const TagsListItem: FunctionComponent<Props> = observer(
>
{!tag.errorDecrypting ? (
<div className="tag-info" title={title} ref={dropRef}>
{hasFolders && isNativeFoldersEnabled && hasAtLeastOneFolder && (
{isNativeFoldersEnabled && hasAtLeastOneFolder && (
<div
className={`tag-fold ${showChildren ? 'opened' : 'closed'}`}
onClick={hasChildren ? toggleChildren : undefined}
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/ui_models/app_state/tags_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class TagsState {
}

getChildren(tag: SNTag): SNTag[] {
if (!this.features.hasFolders) {
if (!this.features.enableNativeFoldersFeature) {
return [];
}

Expand Down Expand Up @@ -230,7 +230,7 @@ export class TagsState {
}

get rootTags(): SNTag[] {
if (!this.features.hasFolders) {
if (!this.features.enableNativeFoldersFeature) {
return this.tags;
}

Expand Down

0 comments on commit 7726b12

Please sign in to comment.