From 27cd4e0f51133d3ea2e9d3def5f81658741fda52 Mon Sep 17 00:00:00 2001 From: nikec <43032218+niikeec@users.noreply.github.com> Date: Fri, 23 Jun 2023 02:10:05 -0400 Subject: [PATCH] [ENG-741] Add explorer item cut style (#1006) Add cut style --- .../app/$libraryId/Explorer/View/GridView.tsx | 15 +++++++++++---- .../app/$libraryId/Explorer/View/ListView.tsx | 15 +++++++++++++-- interface/hooks/useExplorerStore.tsx | 8 ++++++++ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/interface/app/$libraryId/Explorer/View/GridView.tsx b/interface/app/$libraryId/Explorer/View/GridView.tsx index 9f395fe64..d633ff33a 100644 --- a/interface/app/$libraryId/Explorer/View/GridView.tsx +++ b/interface/app/$libraryId/Explorer/View/GridView.tsx @@ -3,7 +3,7 @@ import clsx from 'clsx'; import { memo } from 'react'; import { ExplorerItem, bytesToNumber, getItemFilePath, getItemLocation } from '@sd/client'; import GridList from '~/components/GridList'; -import { useExplorerStore } from '~/hooks'; +import { isCut, useExplorerStore } from '~/hooks'; import { ViewItem } from '.'; import FileThumb from '../File/Thumb'; import { useExplorerViewContext } from '../ViewContext'; @@ -13,9 +13,10 @@ interface GridViewItemProps { data: ExplorerItem; selected: boolean; index: number; + cut: boolean; } -const GridViewItem = memo(({ data, selected, index, ...props }: GridViewItemProps) => { +const GridViewItem = memo(({ data, selected, index, cut, ...props }: GridViewItemProps) => { const filePathData = getItemFilePath(data); const location = getItemLocation(data); const explorerStore = useExplorerStore(); @@ -30,7 +31,11 @@ const GridViewItem = memo(({ data, selected, index, ...props }: GridViewItemProp return (
- +
@@ -81,9 +86,11 @@ export default () => { ? explorerView.selected.includes(item.item.id) : explorerView.selected === item.item.id; + const cut = isCut(item.item.id); + return ( - + ); }} diff --git a/interface/app/$libraryId/Explorer/View/ListView.tsx b/interface/app/$libraryId/Explorer/View/ListView.tsx index ab6bff8e1..8b1a54f13 100644 --- a/interface/app/$libraryId/Explorer/View/ListView.tsx +++ b/interface/app/$libraryId/Explorer/View/ListView.tsx @@ -29,6 +29,7 @@ import { import { FilePathSearchOrderingKeys, getExplorerStore, + isCut, useExplorerStore, useScrolled } from '~/hooks'; @@ -43,6 +44,7 @@ interface ListViewItemProps { columnSizing: ColumnSizingState; paddingX: number; selected: boolean; + cut: boolean; } const ListViewItem = memo((props: ListViewItemProps) => { @@ -139,10 +141,16 @@ export default () => { const selected = selectedId === cell.row.original.item.id; + const cut = isCut(file.item.id); + return (
- +
{ accessorFn: (file) => getItemObject(file)?.pub_id } ], - [explorerView.selected] + [explorerView.selected, explorerStore.cutCopyState.sourcePathId] ); const table = useReactTable({ @@ -704,6 +712,8 @@ export default () => { const selectedNext = nextRow && isSelected(nextRow.original.item.id); + const cut = isCut(row.original.item.id); + return (
{ paddingX={paddingX} columnSizing={columnSizing} selected={selected} + cut={cut} />
diff --git a/interface/hooks/useExplorerStore.tsx b/interface/hooks/useExplorerStore.tsx index e0f246e29..2942f8373 100644 --- a/interface/hooks/useExplorerStore.tsx +++ b/interface/hooks/useExplorerStore.tsx @@ -78,3 +78,11 @@ export function useExplorerStore() { export function getExplorerStore() { return explorerStore; } + +export function isCut(id: number) { + return ( + explorerStore.cutCopyState.active && + explorerStore.cutCopyState.actionType === 'Cut' && + explorerStore.cutCopyState.sourcePathId === id + ); +}