Skip to content

Commit 13a8caa

Browse files
Refactor: Improve copy link functionality and naming conventions
Co-authored-by: yourton.ma <yourton.ma@gmail.com>
1 parent eda4888 commit 13a8caa

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

GLOSSARY_TERM_PERMANENT_LINK_IMPLEMENTATION.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,25 @@ Term Name [📋▼] [⭐ Follow]
6868

6969
## Technical Implementation
7070

71+
### Variable Naming Conventions
72+
73+
All variables use consistent, descriptive names aligned with UI text:
74+
75+
**Functions:**
76+
- `handleCopyUrlBasedOnFqn()` - Handles FQN URL copy
77+
- `handleCopyUrlBasedOnId()` - Handles ID URL copy
78+
79+
**State Variables:**
80+
- `showCopyUrlDropdown` - Controls dropdown menu visibility
81+
82+
**URL Variables:**
83+
- `fqnUrl` - FQN-based URL string
84+
- `idBasedUrl` - ID-based URL string
85+
86+
**Menu Item Keys:**
87+
- `copy-url-based-on-fqn` - FQN option identifier
88+
- `copy-url-based-on-id` - ID option identifier
89+
7190
### Key Features
7291

7392
1. **Backward Compatible**

openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityHeaderTitle/EntityHeaderTitle.component.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const EntityHeaderTitle = ({
6161
const { t } = useTranslation();
6262
const location = useCustomLocation();
6363
const [copyTooltip, setCopyTooltip] = useState<string>();
64-
const [showCopyDropdown, setShowCopyDropdown] = useState(false);
64+
const [showCopyUrlDropdown, setShowCopyUrlDropdown] = useState(false);
6565
const { onCopyToClipBoard } = useClipboard(window.location.href);
6666

6767
const handleShareButtonClick = async () => {
@@ -70,7 +70,7 @@ const EntityHeaderTitle = ({
7070
setTimeout(() => setCopyTooltip(''), 2000);
7171
};
7272

73-
const handleCopyFqnLink = async () => {
73+
const handleCopyUrlBasedOnFqn = async () => {
7474
if (!entityFqn) {
7575
return;
7676
}
@@ -83,23 +83,23 @@ const EntityHeaderTitle = ({
8383
} catch {
8484
showErrorToast(t('server.unexpected-error'));
8585
}
86-
setShowCopyDropdown(false);
86+
setShowCopyUrlDropdown(false);
8787
};
8888

89-
const handleCopyPermanentLink = async () => {
89+
const handleCopyUrlBasedOnId = async () => {
9090
if (!entityId) {
9191
return;
9292
}
9393

94-
const permanentUrl = `${window.location.origin}/glossary/${entityId}`;
94+
const idBasedUrl = `${window.location.origin}/glossary/${entityId}`;
9595

9696
try {
97-
await navigator.clipboard.writeText(permanentUrl);
97+
await navigator.clipboard.writeText(idBasedUrl);
9898
showSuccessToast(t('message.copied-to-clipboard'));
9999
} catch {
100100
showErrorToast(t('server.unexpected-error'));
101101
}
102-
setShowCopyDropdown(false);
102+
setShowCopyUrlDropdown(false);
103103
};
104104

105105
const isTourRoute = useMemo(
@@ -212,32 +212,32 @@ const EntityHeaderTitle = ({
212212
menu={{
213213
items: [
214214
{
215-
key: 'copy-fqn-link',
215+
key: 'copy-url-based-on-fqn',
216216
label: (
217217
<div className="d-flex items-center gap-2" style={{ fontSize: '12px' }}>
218218
<Icon component={LinkIcon} style={{ fontSize: '12px' }} />
219219
<span>{t('label.copy-fqn-link')}</span>
220220
</div>
221221
),
222-
onClick: handleCopyFqnLink,
222+
onClick: handleCopyUrlBasedOnFqn,
223223
},
224224
{
225-
key: 'copy-permanent-link',
225+
key: 'copy-url-based-on-id',
226226
label: (
227227
<div className="d-flex items-center gap-2" style={{ fontSize: '12px' }}>
228228
<Icon component={CopyIcon} style={{ fontSize: '12px' }} />
229229
<span>{t('label.copy-permanent-link')}</span>
230230
</div>
231231
),
232-
onClick: handleCopyPermanentLink,
232+
onClick: handleCopyUrlBasedOnId,
233233
},
234234
] as ItemType[],
235235
}}
236-
open={showCopyDropdown}
236+
open={showCopyUrlDropdown}
237237
overlayStyle={{ minWidth: '180px' }}
238238
placement="bottomRight"
239239
trigger={['click']}
240-
onOpenChange={setShowCopyDropdown}>
240+
onOpenChange={setShowCopyUrlDropdown}>
241241
<Tooltip
242242
placement="topRight"
243243
title={t('label.copy-link')}>

0 commit comments

Comments
 (0)