Skip to content

Commit e286f80

Browse files
evavirsedamarc2332
andauthored
feat: add Connect to Address popup (#447)
* add setLinkedAddressDialog * add unlinking feature * minor fix * cleanup * cleanup * update menu * update menu * fix build * polish linked address * rename dialog * remove unnecessary dialog * udpate connect address dialog * fix conditional * fis sync of permissions * bring back manage popup * add util * update dependencies * fmt * last polishes * fix * rename component to NameDialogsController --------- Co-authored-by: marc2332 <mespinsanz@gmail.com>
1 parent 8089248 commit e286f80

File tree

10 files changed

+365
-16
lines changed

10 files changed

+365
-16
lines changed

dapp/src/app/(protected)/my-names/components/NamePanelTile.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Fragment } from 'react';
1111

1212
import { MenuButton } from '@/components/buttons/MenuButton';
1313
import { ContextMenuDropdown } from '@/components/ContextMenu';
14-
import { NameManageDialogs } from '@/components/dialogs/NameManageDialogs';
14+
import { NameDialogsController } from '@/components/dialogs/NameDialogsController';
1515
import { useNameRecord } from '@/hooks';
1616
import { useGetDefaultName } from '@/hooks/useGetDefaultName';
1717
import { useNameContextMenu } from '@/hooks/useNameContextMenu';
@@ -90,7 +90,7 @@ export function NamePanelTile({
9090
dropdownRef={dropdownRef}
9191
/>
9292

93-
<NameManageDialogs
93+
<NameDialogsController
9494
nft={registration}
9595
openDialogId={openDialogId}
9696
onClose={closeDialog}

dapp/src/components/dialogs/ConnectToAddressDialog.tsx

Lines changed: 320 additions & 0 deletions
Large diffs are not rendered by default.

dapp/src/components/dialogs/UpdateNameDialog.tsx renamed to dapp/src/components/dialogs/ManageNameDialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ import {
3535
isNameRecordExpired,
3636
} from '@/lib/utils/names';
3737

38-
type UpdateNameDialogProps = {
38+
type ManageNameDialogProps = {
3939
name: string;
4040
setOpen: (bool: boolean) => void;
4141
};
4242

43-
export function UpdateNameDialog({ name, setOpen }: UpdateNameDialogProps) {
43+
export function ManageNameDialog({ name, setOpen }: ManageNameDialogProps) {
4444
const iotaClient = useIotaClient();
4545
const queryClient = useQueryClient();
4646
const account = useCurrentAccount();

dapp/src/components/dialogs/NameManageDialogs.tsx renamed to dapp/src/components/dialogs/NameDialogsController.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,26 @@ import { Fragment } from 'react';
55

66
import { RegistrationNft } from '@/lib/interfaces';
77

8-
import { DeleteNameDialog, UpdateNameDialog } from '.';
8+
import { DeleteNameDialog } from '.';
9+
import { ConnectToAddressDialog } from './ConnectToAddressDialog';
910
import { CreateSubnameDialog } from './CreateSubnameDialog';
1011
import { NameDialogId } from './enums';
1112
import { GeneralInfoDialog } from './GeneralInfoDialog';
13+
import { ManageNameDialog } from './ManageNameDialog';
1214
import { PersonalizeAvatarDialog } from './PersonalizeAvatarDialog';
1315
import { RenewNameDialog } from './RenewNameDialog';
1416

15-
interface NameManageDialogsProps {
17+
interface NameDialogsControllerProps {
1618
nft: RegistrationNft;
1719
openDialogId: NameDialogId | null;
1820
onClose: () => void;
1921
}
2022

21-
export function NameManageDialogs({ nft, openDialogId, onClose }: NameManageDialogsProps) {
23+
export function NameDialogsController({ nft, openDialogId, onClose }: NameDialogsControllerProps) {
2224
return (
2325
<Fragment>
24-
{openDialogId === NameDialogId.Update ? (
25-
<UpdateNameDialog name={nft.name} setOpen={onClose} />
26+
{openDialogId === NameDialogId.Manage ? (
27+
<ManageNameDialog name={nft.name} setOpen={onClose} />
2628
) : null}
2729

2830
{openDialogId === NameDialogId.Delete ? (
@@ -44,6 +46,9 @@ export function NameManageDialogs({ nft, openDialogId, onClose }: NameManageDial
4446
{openDialogId === NameDialogId.GeneralInfo ? (
4547
<GeneralInfoDialog name={nft.name} setOpen={onClose} />
4648
) : null}
49+
{openDialogId === NameDialogId.ConnectToAddress ? (
50+
<ConnectToAddressDialog name={nft.name} setOpen={onClose} />
51+
) : null}
4752
</Fragment>
4853
);
4954
}

dapp/src/components/dialogs/enums.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
export enum NameDialogId {
5-
Update = 'update',
5+
Manage = 'manage',
66
Delete = 'delete',
77
CreateSubname = 'create-subname',
88
PersonalizeAvatar = 'personalize-avatar',
99
RenewName = 'renew-name',
1010
GeneralInfo = 'general-info',
11+
ConnectToAddress = 'connect-to-address',
1112
}

dapp/src/components/dialogs/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
export * from './PurchaseNameDialog';
5-
export * from './UpdateNameDialog';
65
export * from './DeleteNameDialog';

dapp/src/components/name-card/ExtendedNameCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { formatNameLabel } from '@/lib/utils/format/formatNames';
1212
import { getNameMenuOptions } from '@/lib/utils/getNameMenuOptions';
1313

1414
import { NameDialogId } from '../dialogs/enums';
15-
import { NameManageDialogs } from '../dialogs/NameManageDialogs';
15+
import { NameDialogsController } from '../dialogs/NameDialogsController';
1616
import { NameCard } from './NameCard';
1717
import { NameCardBody } from './NameCardBody';
1818
import { SubnameCountIndicator } from './NameCardIndicators';
@@ -52,7 +52,7 @@ export function ExtendedNameCard({
5252
</NameCardBody>
5353
</NameCard>
5454

55-
<NameManageDialogs nft={nft} openDialogId={openDialogId} onClose={closeDialog} />
55+
<NameDialogsController nft={nft} openDialogId={openDialogId} onClose={closeDialog} />
5656
</>
5757
);
5858
}

dapp/src/hooks/useUpdateNameTransaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export type NameUpdate =
2525
}
2626
| {
2727
type: 'set-target-address';
28-
address: string;
28+
address: string | undefined;
2929
isSubname: boolean;
3030
nftId: string;
3131
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) 2025 IOTA Stiftung
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import toast from 'react-hot-toast';
5+
6+
export async function copyToClipboard(text: string): Promise<boolean> {
7+
if (typeof navigator === 'undefined' || !navigator.clipboard) {
8+
return false;
9+
}
10+
11+
try {
12+
await navigator.clipboard.writeText(text);
13+
toast.success('Copied to clipboard!');
14+
return true;
15+
} catch (err) {
16+
toast.error('Failed to copy to clipboard. Please try again.');
17+
return false;
18+
}
19+
}

dapp/src/lib/utils/getNameMenuOptions.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) 2025 IOTA Stiftung
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { Add, Assets, Calendar, Info, Settings, Warning } from '@iota/apps-ui-icons';
4+
import { Add, Assets, Calendar, Info, Link, Settings, Warning } from '@iota/apps-ui-icons';
55

66
import { NameDialogId } from '@/components/dialogs/enums';
77
import { DropdownMenuOption } from '@/components/DropdownMenuOptions';
@@ -15,10 +15,15 @@ export function getNameMenuOptions(
1515
): MenuListItem[] {
1616
return [
1717
{
18-
onClick: () => onOpen(NameDialogId.Update),
18+
onClick: () => onOpen(NameDialogId.Manage),
1919
children: <DropdownMenuOption icon={<Settings />} label="Manage" />,
2020
hideBottomBorder: true,
2121
},
22+
{
23+
onClick: () => onOpen(NameDialogId.ConnectToAddress),
24+
children: <DropdownMenuOption icon={<Link />} label="Connect to Address" />,
25+
hideBottomBorder: true,
26+
},
2227
// {
2328
// onClick: () => {},
2429
// children: <DropdownMenuOption icon={<Pined />} label="Make name default" />,

0 commit comments

Comments
 (0)