🐛 Fix trash path for sub folder deletion
This commit is contained in:
@@ -21,7 +21,6 @@ export default ({
|
|||||||
setParentId: (id: string) => void;
|
setParentId: (id: string) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [savedPath, setSavedPath] = useState<DriveItem[]>([]);
|
const [savedPath, setSavedPath] = useState<DriveItem[]>([]);
|
||||||
const { user } = useCurrentUser();
|
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const company = useRouterCompany();
|
const company = useRouterCompany();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -38,10 +37,10 @@ export default ({
|
|||||||
RouterServices.generateRouteFromState({
|
RouterServices.generateRouteFromState({
|
||||||
companyId: company,
|
companyId: company,
|
||||||
viewId,
|
viewId,
|
||||||
dirId
|
dirId,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
setParentId(dirId? dirId: viewId)
|
setParentId(dirId ? dirId : viewId);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -67,26 +66,28 @@ export const PathRender = ({
|
|||||||
inTrash: boolean;
|
inTrash: boolean;
|
||||||
onClick: (viewId: string, dirId: string) => void;
|
onClick: (viewId: string, dirId: string) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const pathLength = (path || []).reduce((acc, curr) => acc + curr.name.length, 0);
|
const parentIndex = path.findIndex(item => item.is_in_trash);
|
||||||
|
const pathToRender = parentIndex > -1 ? path.slice(parentIndex - 1) : path;
|
||||||
|
const pathLength = (pathToRender || []).reduce((acc, curr) => acc + curr.name.length, 0);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className="overflow-hidden whitespace-nowrap mr-2 pl-px inline-flex">
|
<nav className="overflow-hidden whitespace-nowrap mr-2 pl-px inline-flex">
|
||||||
{pathLength < 70 ? (
|
{pathLength < 70 ? (
|
||||||
(path || [])?.map((a, i) => (
|
(pathToRender || [])?.map((a, i) => (
|
||||||
<PathItem
|
<PathItem
|
||||||
key={a.id}
|
key={a.id}
|
||||||
item={a}
|
item={a}
|
||||||
first={i === 0}
|
first={i === 0}
|
||||||
last={i + 1 === path?.length}
|
last={i + 1 === pathToRender?.length}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<PathItem
|
<PathItem
|
||||||
key={path[path.length - 3]?.id}
|
key={pathToRender[pathToRender.length - 3]?.id}
|
||||||
item={{
|
item={{
|
||||||
...path[path?.length - 3],
|
...pathToRender[pathToRender?.length - 3],
|
||||||
name: '...',
|
name: '...',
|
||||||
}}
|
}}
|
||||||
first={true}
|
first={true}
|
||||||
@@ -94,15 +95,15 @@ export const PathRender = ({
|
|||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
/>
|
/>
|
||||||
<PathItem
|
<PathItem
|
||||||
key={path[path.length - 2]?.id}
|
key={pathToRender[pathToRender.length - 2]?.id}
|
||||||
item={path[path?.length - 2]}
|
item={pathToRender[pathToRender?.length - 2]}
|
||||||
first={false}
|
first={false}
|
||||||
last={false}
|
last={false}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
/>
|
/>
|
||||||
<PathItem
|
<PathItem
|
||||||
key={path[path.length - 1]?.id}
|
key={pathToRender[pathToRender.length - 1]?.id}
|
||||||
item={path[path?.length - 1]}
|
item={pathToRender[pathToRender?.length - 1]}
|
||||||
first={false}
|
first={false}
|
||||||
last={true}
|
last={true}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
@@ -136,7 +137,7 @@ const PathItem = ({
|
|||||||
const driveMenuItems = [
|
const driveMenuItems = [
|
||||||
{
|
{
|
||||||
type: 'menu',
|
type: 'menu',
|
||||||
text: Languages.t('components.side_menu.home',),
|
text: Languages.t('components.side_menu.home'),
|
||||||
onClick: () => onClick('root', ''),
|
onClick: () => onClick('root', ''),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -167,16 +168,18 @@ const PathItem = ({
|
|||||||
MenusManager.openMenu(driveMenuItems, { x: evt.clientX, y: evt.clientY }, 'center');
|
MenusManager.openMenu(driveMenuItems, { x: evt.clientX, y: evt.clientY }, 'center');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
onClick(viewId || '',item?.id || '');
|
onClick(viewId || '', item?.id || '');
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Title>
|
<Title>
|
||||||
{viewId?.includes('trash_') && first && Languages.t('components.header_path.my_trash')}
|
{viewId?.includes('trash_') && first && Languages.t('components.header_path.my_trash')}
|
||||||
{viewId === 'trash' && first && Languages.t('components.header_path.shared_trash')}
|
{viewId === 'trash' && first && Languages.t('components.header_path.shared_trash')}
|
||||||
{(viewId === 'trash' || viewId?.includes('trash_')) && !first && (cutFileName(item?.name) || '')}
|
{(viewId === 'trash' || viewId?.includes('trash_')) &&
|
||||||
{!viewId?.includes('trash') && (cutFileName(item?.name) || '')}
|
!first &&
|
||||||
</Title>
|
(cutFileName(item?.name) || '')}
|
||||||
|
{!viewId?.includes('trash') && (cutFileName(item?.name) || '')}
|
||||||
|
</Title>
|
||||||
</a>
|
</a>
|
||||||
{item?.access_info?.public?.level && item?.access_info?.public?.level !== 'none' && (
|
{item?.access_info?.public?.level && item?.access_info?.public?.level !== 'none' && (
|
||||||
<PublicIcon className="h-5 w-5 ml-2" />
|
<PublicIcon className="h-5 w-5 ml-2" />
|
||||||
|
|||||||
Reference in New Issue
Block a user