fix: fav feature review changes (#5304)
This commit is contained in:
parent
86a982e8ce
commit
fafa2c06c3
8 changed files with 112 additions and 32 deletions
|
|
@ -93,12 +93,12 @@ export const FavoriteFolder: React.FC<Props> = (props) => {
|
|||
const element = elementRef.current;
|
||||
|
||||
if (!element) return;
|
||||
const initialData = { type: "PARENT", id: favorite.id };
|
||||
const initialData = { type: "PARENT", id: favorite.id, is_folder: favorite.is_folder };
|
||||
|
||||
return combine(
|
||||
draggable({
|
||||
element,
|
||||
// getInitialData: () => initialData,
|
||||
getInitialData: () => initialData,
|
||||
onDragStart: () => setIsDragging(true),
|
||||
onDrop: (data) => {
|
||||
setIsDraggedOver(false);
|
||||
|
|
@ -109,7 +109,7 @@ export const FavoriteFolder: React.FC<Props> = (props) => {
|
|||
const edge = extractClosestEdge(destinationData) || undefined;
|
||||
const payload = {
|
||||
id: favorite.id,
|
||||
sequence: getDestinationStateSequence(favoriteMap, destinationData.id as string, edge),
|
||||
sequence: Math.round(getDestinationStateSequence(favoriteMap, destinationData.id as string, edge) || 0),
|
||||
};
|
||||
|
||||
handleOnDropFolder(payload);
|
||||
|
|
@ -127,7 +127,7 @@ export const FavoriteFolder: React.FC<Props> = (props) => {
|
|||
onDragEnter: (args) => {
|
||||
setIsDragging(true);
|
||||
setIsDraggedOver(true);
|
||||
setClosestEdge(extractClosestEdge(args.self.data));
|
||||
args.source.data.is_folder && setClosestEdge(extractClosestEdge(args.self.data));
|
||||
},
|
||||
onDragLeave: () => {
|
||||
setIsDragging(false);
|
||||
|
|
@ -142,7 +142,7 @@ export const FavoriteFolder: React.FC<Props> = (props) => {
|
|||
setIsDraggedOver(false);
|
||||
const sourceId = source?.data?.id as string | undefined;
|
||||
const destinationId = self?.data?.id as string | undefined;
|
||||
|
||||
if (source.data.is_folder) return;
|
||||
if (sourceId === destinationId) return;
|
||||
if (!sourceId || !destinationId) return;
|
||||
if (favoriteMap[sourceId].parent === destinationId) return;
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ export const FavoriteItem = observer(
|
|||
{getIcon()}
|
||||
|
||||
{!sidebarCollapsed && (
|
||||
<Link href={getLink()} className="text-sm leading-5 font-medium flex-1">
|
||||
<Link href={getLink()} className="text-sm leading-5 font-medium flex-1 truncate">
|
||||
{favorite.entity_data ? favorite.entity_data.name : favorite.name}
|
||||
</Link>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
||||
import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
||||
import { orderBy } from "lodash";
|
||||
import { orderBy, uniqBy } from "lodash";
|
||||
import { observer } from "mobx-react";
|
||||
import { useParams } from "next/navigation";
|
||||
import { ChevronRight, FolderPlus } from "lucide-react";
|
||||
|
|
@ -131,7 +131,7 @@ export const SidebarFavoritesMenu = observer(() => {
|
|||
)}
|
||||
>
|
||||
<span onClick={() => toggleFavoriteMenu(!isFavoriteMenuOpen)} className="flex-1 text-start">
|
||||
MY FAVORITES
|
||||
YOUR FAVORITES
|
||||
</span>
|
||||
<span className="flex gap-2 flex-shrink-0 opacity-0 pointer-events-none group-hover/workspace-button:opacity-100 group-hover/workspace-button:pointer-events-auto rounded p-0.5 ">
|
||||
<FolderPlus
|
||||
|
|
@ -168,7 +168,7 @@ export const SidebarFavoritesMenu = observer(() => {
|
|||
static
|
||||
>
|
||||
{createNewFolder && <NewFavoriteFolder setCreateNewFolder={setCreateNewFolder} actionType="create" />}
|
||||
{orderBy(Object.values(favoriteMap), "sequence", "desc")
|
||||
{uniqBy(orderBy(Object.values(favoriteMap), "sequence", "desc"), "id")
|
||||
.filter((fav) => !fav.parent)
|
||||
.map((fav, index) => (
|
||||
<Tooltip
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue