fix: Default View Font Color and Reordering (#7940)

This PR fixes issue #6114 
I removed the separate check for default item and add it into the
draggable list.
This commit is contained in:
Ngan Phan
2024-10-23 06:44:17 -07:00
committed by GitHub
parent 5b6487979c
commit 45b3992784

View File

@ -60,8 +60,6 @@ export const ViewPickerListContent = () => {
const { getIcon } = useIcons(); const { getIcon } = useIcons();
const indexView = viewsOnCurrentObject.find((view) => view.key === 'INDEX');
const handleDragEnd = useCallback( const handleDragEnd = useCallback(
(result: DropResult) => { (result: DropResult) => {
if (!result.destination) return; if (!result.destination) return;
@ -81,33 +79,29 @@ export const ViewPickerListContent = () => {
return ( return (
<> <>
<DropdownMenuItemsContainer> <DropdownMenuItemsContainer>
{indexView && (
<MenuItemDraggable
key={indexView.id}
iconButtons={[
{
Icon: IconLock,
},
].filter(isDefined)}
isIconDisplayedOnHoverOnly={false}
onClick={() => handleViewSelect(indexView.id)}
LeftIcon={getIcon(indexView.icon)}
text={indexView.name}
accent="placeholder"
isDragDisabled
/>
)}
<DraggableList <DraggableList
onDragEnd={handleDragEnd} onDragEnd={handleDragEnd}
draggableItems={viewsOnCurrentObject draggableItems={viewsOnCurrentObject.map((view, index) => (
.filter((view) => indexView?.id !== view.id)
.map((view, index) => (
<DraggableItem <DraggableItem
key={view.id} key={view.id}
draggableId={view.id} draggableId={view.id}
index={index} index={index}
isDragDisabled={viewsOnCurrentObject.length === 1} isDragDisabled={viewsOnCurrentObject.length === 1}
itemComponent={ itemComponent={
view.key === 'INDEX' ? (
<MenuItemDraggable
key={view.id}
iconButtons={[
{
Icon: IconLock,
},
].filter(isDefined)}
isIconDisplayedOnHoverOnly={false}
onClick={() => handleViewSelect(view.id)}
LeftIcon={getIcon(view.icon)}
text={view.name}
/>
) : (
<MenuItemDraggable <MenuItemDraggable
key={view.id} key={view.id}
iconButtons={[ iconButtons={[
@ -117,13 +111,12 @@ export const ViewPickerListContent = () => {
handleEditViewButtonClick(event, view.id), handleEditViewButtonClick(event, view.id),
}, },
].filter(isDefined)} ].filter(isDefined)}
isIconDisplayedOnHoverOnly={ isIconDisplayedOnHoverOnly={true}
indexView?.id === view.id ? false : true
}
onClick={() => handleViewSelect(view.id)} onClick={() => handleViewSelect(view.id)}
LeftIcon={getIcon(view.icon)} LeftIcon={getIcon(view.icon)}
text={view.name} text={view.name}
/> />
)
} }
/> />
))} ))}