Skip to content

Commit 081ac89

Browse files
fix: remove divider for tree view actions + add tooltip for shared item (#545)
1 parent abbbd25 commit 081ac89

File tree

7 files changed

+67
-30
lines changed

7 files changed

+67
-30
lines changed

src/components/FileManager/FileManager.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -878,18 +878,22 @@ export const DialFileManagerView: FC = () => {
878878
});
879879
}
880880
}
881+
if (!items.length) {
882+
return elements;
883+
}
881884

882-
if (elements.length > 0) {
883-
return [
884-
...items,
885-
{
886-
key: 'divider',
887-
type: DropdownItemType.Divider,
888-
},
889-
...elements,
890-
];
885+
if (!elements.length) {
886+
return items;
891887
}
892-
return items;
888+
889+
return [
890+
...items,
891+
{
892+
key: 'divider',
893+
type: DropdownItemType.Divider,
894+
},
895+
...elements,
896+
];
893897
},
894898
[
895899
treeOptions?.actionLabels,

src/components/FileManager/components/FileManagerItemIcon/FileManagerItemIcon.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface DialFileManagerItemIconProps
1717
shared?: boolean;
1818
loading?: boolean;
1919
sharedIndicatorClassName?: string;
20+
sharedIndicatorTooltip?: ReactNode;
2021
}
2122

2223
/**
@@ -55,21 +56,26 @@ export interface DialFileManagerItemIconProps
5556
* @param {string} [props.label] - Accessible label for screen readers.
5657
* @param {ReactNode} [props.indicator] - Optional indicator to display over the icon.
5758
* @param {string} [props.sharedIndicatorClassName] - Optional CSS class for the shared indicator.
59+
* @param [sharedIndicatorTooltip] - Custom tooltip content for the shared indicator; defaults to "Shared"
5860
*/
5961
export const DialFileManagerItemIcon: FC<DialFileManagerItemIconProps> = ({
6062
name,
6163
type,
6264
shared = false,
6365
loading = false,
6466
sharedIndicatorClassName,
67+
sharedIndicatorTooltip,
6568
...restProps
6669
}) => {
6770
const wrapIcon = (icon: ReactNode) => (
6871
<span className="inline-flex relative text-secondary" role="img">
6972
{icon}
7073
{shared && (
7174
<span className="absolute -bottom-0.5 -left-0.5">
72-
<DialSharedEntityIndicator className={sharedIndicatorClassName} />
75+
<DialSharedEntityIndicator
76+
className={sharedIndicatorClassName}
77+
sharedIndicatorTooltip={sharedIndicatorTooltip}
78+
/>
7379
</span>
7480
)}
7581
</span>
@@ -89,7 +95,10 @@ export const DialFileManagerItemIcon: FC<DialFileManagerItemIconProps> = ({
8995
className="text-secondary"
9096
indicator={
9197
shared ? (
92-
<DialSharedEntityIndicator className={sharedIndicatorClassName} />
98+
<DialSharedEntityIndicator
99+
className={sharedIndicatorClassName}
100+
sharedIndicatorTooltip={sharedIndicatorTooltip}
101+
/>
93102
) : null
94103
}
95104
label="File type icon"

src/components/FileManager/components/FileManagerItemName/FileManagerItemName.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface DialFileManagerItemNameProps
1818
loading?: boolean;
1919
shared?: boolean;
2020
details?: ReactNode;
21+
sharedIndicatorTooltip?: ReactNode;
2122
validate?: (value: string) => string | null;
2223
onSave?: (value: string) => void;
2324
onCancel?: () => void;
@@ -69,6 +70,7 @@ export const DialFileManagerItemName: FC<DialFileManagerItemNameProps> = ({
6970
onCancel,
7071
inputContainerClassName,
7172
sharedIndicatorClassName,
73+
sharedIndicatorTooltip,
7274
...restProps
7375
}) => {
7476
const { value, invalid, invalidMessage, onChange, inputRef } =
@@ -116,6 +118,7 @@ export const DialFileManagerItemName: FC<DialFileManagerItemNameProps> = ({
116118
onChange={onChange}
117119
iconSize={iconSize}
118120
inputContainerClassName={inputContainerClassName}
121+
sharedIndicatorTooltip={sharedIndicatorTooltip}
119122
sharedIndicatorClassName={sharedIndicatorClassName}
120123
/>
121124
);

src/components/FileManager/components/FileManagerItemNameInput/FileManagerItemNameInput.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface DialFileManagerItemNameInputProps {
2525
inputRef?: Ref<HTMLInputElement>;
2626
onChange?: (value?: string) => void;
2727
sharedIndicatorClassName?: string;
28+
sharedIndicatorTooltip?: ReactNode;
2829
}
2930

3031
/**
@@ -94,6 +95,7 @@ export const DialFileManagerItemNameInput: FC<
9495
inputRef,
9596
onChange,
9697
sharedIndicatorClassName,
98+
sharedIndicatorTooltip,
9799
}) => {
98100
const getInputIconAfter = () => {
99101
if (!inputInvalid) return null;
@@ -124,6 +126,7 @@ export const DialFileManagerItemNameInput: FC<
124126
loading={loading}
125127
shared={shared}
126128
sharedIndicatorClassName={sharedIndicatorClassName}
129+
sharedIndicatorTooltip={sharedIndicatorTooltip}
127130
/>
128131
<DialInput
129132
containerClassName={mergeClasses(

src/components/FileName/FileName.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface DialFileNameProps {
1313
iconSize?: number;
1414
details?: ReactNode;
1515
sharedIndicatorClassName?: string;
16+
sharedIndicatorTooltip?: ReactNode;
1617
}
1718

1819
/**
@@ -40,6 +41,7 @@ export interface DialFileNameProps {
4041
* @param iconSize - Icon size in px. Default: BASE_ICON_SIZE.
4142
* @param details - Optional metadata block displayed under the file name (e.g., size, modified date).
4243
* @param sharedIndicatorClassName - Additional CSS classes for the shared indicator.
44+
* @param sharedIndicatorTooltip - Custom tooltip content for the shared indicator; defaults to "Shared"
4345
*/
4446
export const DialFileName: FC<DialFileNameProps> = ({
4547
name,
@@ -48,6 +50,7 @@ export const DialFileName: FC<DialFileNameProps> = ({
4850
iconSize = BASE_ICON_SIZE,
4951
details,
5052
sharedIndicatorClassName,
53+
sharedIndicatorTooltip,
5154
}) => {
5255
const extension = name.includes('.') ? name.split('.').pop() : undefined;
5356

@@ -59,7 +62,10 @@ export const DialFileName: FC<DialFileNameProps> = ({
5962
className="text-secondary"
6063
indicator={
6164
shared ? (
62-
<DialSharedEntityIndicator className={sharedIndicatorClassName} />
65+
<DialSharedEntityIndicator
66+
className={sharedIndicatorClassName}
67+
sharedIndicatorTooltip={sharedIndicatorTooltip}
68+
/>
6369
) : null
6470
}
6571
label="File type icon"

src/components/FolderName/FolderName.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { mergeClasses } from '@/utils/merge-classes';
2-
import type { FC } from 'react';
2+
import type { FC, ReactNode } from 'react';
33
import { DialSharedEntityIndicator } from '@/components/SharedEntityIndicator/SharedEntityIndicator';
44
import { DialEllipsisTooltip } from '@/components/EllipsisTooltip/EllipsisTooltip';
55
import { DialIcon } from '@/components/Icon/Icon';
@@ -14,6 +14,7 @@ export interface DialFolderNameProps {
1414
iconSize?: number;
1515
className?: string;
1616
sharedIndicatorClassName?: string;
17+
sharedIndicatorTooltip?: ReactNode;
1718
}
1819

1920
/**
@@ -31,6 +32,7 @@ export interface DialFolderNameProps {
3132
* @param loading - If true, shows loading state. Default: false.
3233
* @param iconSize - Icon size in px. Default: BASE_ICON_SIZE.
3334
* @param sharedIndicatorClassName - Additional CSS classes for the shared indicator
35+
* @param sharedIndicatorTooltip - Custom tooltip content for the shared indicator; defaults to "Shared"
3436
*/
3537
export const DialFolderName: FC<DialFolderNameProps> = ({
3638
name,
@@ -39,6 +41,7 @@ export const DialFolderName: FC<DialFolderNameProps> = ({
3941
loading = false,
4042
iconSize = BASE_ICON_SIZE,
4143
sharedIndicatorClassName,
44+
sharedIndicatorTooltip,
4245
}) => {
4346
const getIcon = () => {
4447
if (loading) {
@@ -58,7 +61,10 @@ export const DialFolderName: FC<DialFolderNameProps> = ({
5861
{getIcon()}
5962
{shared && (
6063
<span className="absolute z-50 -bottom-0.5 -left-0.5">
61-
<DialSharedEntityIndicator className={sharedIndicatorClassName} />
64+
<DialSharedEntityIndicator
65+
className={sharedIndicatorClassName}
66+
sharedIndicatorTooltip={sharedIndicatorTooltip}
67+
/>
6268
</span>
6369
)}
6470
</span>

src/components/SharedEntityIndicator/SharedEntityIndicator.tsx

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import { DialIcon } from '@/components/Icon/Icon';
44

55
import { mergeClasses } from '@/utils/merge-classes';
66
import { IconArrowUpRight } from '@tabler/icons-react';
7+
import { DialTooltip } from '../Tooltip/Tooltip';
78

89
export interface DialSharedEntityIndicatorProps {
910
label?: ReactNode;
1011
size?: number;
1112
stroke?: number;
1213
className?: string;
1314
containerClassName?: string;
15+
sharedIndicatorTooltip?: ReactNode;
1416
}
1517

1618
/**
@@ -29,6 +31,7 @@ export interface DialSharedEntityIndicatorProps {
2931
* @param [className] - Additional Tailwind classes applied to the icon
3032
* @param [containerClassName] - Additional Tailwind classes appended to the container
3133
* @param [stroke=1.5] - Stroke width for the icon
34+
* @param [sharedIndicatorTooltip] - Custom tooltip content, defaults to "Shared"
3235
*
3336
*/
3437
export const DialSharedEntityIndicator: FC<DialSharedEntityIndicatorProps> = ({
@@ -37,22 +40,25 @@ export const DialSharedEntityIndicator: FC<DialSharedEntityIndicatorProps> = ({
3740
className,
3841
containerClassName,
3942
stroke = 1.5,
43+
sharedIndicatorTooltip,
4044
}) => {
4145
return (
42-
<DialIcon
43-
className={mergeClasses(
44-
'text-accent-primary flex bg-layer-3',
45-
containerClassName,
46-
)}
47-
icon={
48-
<IconArrowUpRight
49-
size={size}
50-
stroke={stroke}
51-
aria-label={typeof label === 'string' ? label : undefined}
52-
className={className}
53-
role="img"
54-
/>
55-
}
56-
/>
46+
<DialTooltip tooltip={sharedIndicatorTooltip || 'Shared'}>
47+
<DialIcon
48+
className={mergeClasses(
49+
'text-accent-primary flex bg-layer-3',
50+
containerClassName,
51+
)}
52+
icon={
53+
<IconArrowUpRight
54+
size={size}
55+
stroke={stroke}
56+
aria-label={typeof label === 'string' ? label : undefined}
57+
className={className}
58+
role="img"
59+
/>
60+
}
61+
/>
62+
</DialTooltip>
5763
);
5864
};

0 commit comments

Comments
 (0)