Skip to content

Commit

Permalink
Merge pull request #648 from ar-io/PE-7239-primary-names
Browse files Browse the repository at this point in the history
fix(PE-7239): make primary names owner only workflow
  • Loading branch information
atticusofsparta authored Jan 24, 2025
2 parents 5a2b57e + ec85d8a commit b648550
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 56 deletions.
114 changes: 59 additions & 55 deletions src/components/data-display/tables/DomainsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -418,65 +418,69 @@ const DomainsTable = ({
return (
<div className="flex justify-end w-full">
<span className="flex pr-3 w-fit gap-3">
<Tooltip
message={
!antHandlers?.includes('approvePrimaryName') ||
!antHandlers?.includes('removePrimaryNames')
? 'Update ANT to access Primary Names workflow'
: primaryNameData?.name === row.getValue('name')
? 'Remove Primary Name'
: 'Set Primary Name'
}
icon={
<button
disabled={
!antHandlers?.includes('approvePrimaryName') ||
!antHandlers?.includes('removePrimaryNames')
}
onClick={() => {
const targetName = row.getValue('name') as string;
if (primaryNameData?.name === targetName) {
// remove primary name payload
dispatchTransactionState({
type: 'setTransactionData',
payload: {
names: [targetName],
arioProcessId,
assetId: row.getValue('processId'),
functionName: 'removePrimaryNames',
},
});
} else {
dispatchTransactionState({
type: 'setTransactionData',
payload: {
name: targetName,
arioProcessId,
assetId: arioProcessId,
functionName: 'primaryNameRequest',
},
});
{row.getValue('role') === 'owner' ? (
<Tooltip
message={
!antHandlers?.includes('approvePrimaryName') ||
!antHandlers?.includes('removePrimaryNames')
? 'Update ANT to access Primary Names workflow'
: primaryNameData?.name === row.getValue('name')
? 'Remove Primary Name'
: 'Set Primary Name'
}
icon={
<button
disabled={
!antHandlers?.includes('approvePrimaryName') ||
!antHandlers?.includes('removePrimaryNames')
}
onClick={() => {
const targetName = row.getValue('name') as string;
if (primaryNameData?.name === targetName) {
// remove primary name payload
dispatchTransactionState({
type: 'setTransactionData',
payload: {
names: [targetName],
arioProcessId,
assetId: row.getValue('processId'),
functionName: 'removePrimaryNames',
},
});
} else {
dispatchTransactionState({
type: 'setTransactionData',
payload: {
name: targetName,
arioProcessId,
assetId: arioProcessId,
functionName: 'primaryNameRequest',
},
});
}

dispatchModalState({
type: 'setModalOpen',
payload: { showPrimaryNameModal: true },
});
}}
>
<Star
className={
(row.getValue('name') == primaryNameData?.name
? 'text-primary fill-primary'
: 'text-grey') +
`
dispatchModalState({
type: 'setModalOpen',
payload: { showPrimaryNameModal: true },
});
}}
>
<Star
className={
(row.getValue('name') == primaryNameData?.name
? 'text-primary fill-primary'
: 'text-grey') +
`
w-[18px]
`
}
/>
</button>
}
/>
}
/>
</button>
}
/>
) : (
<></>
)}
<ManageAssetButtons
id={lowerCaseDomain(row.getValue('name') as string)}
assetType="names"
Expand Down
6 changes: 5 additions & 1 deletion src/components/pages/ManageDomain/ManageDomain.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import TransactionSuccessCard from '@src/components/cards/TransactionSuccessCard/TransactionSuccessCard';
import { AntLogoIcon } from '@src/components/data-display/AntLogoIcon';
import DomainSettings from '@src/components/forms/DomainSettings/DomainSettings';
import useDomainInfo from '@src/hooks/useDomainInfo';
import { usePrimaryName } from '@src/hooks/usePrimaryName';
import { useGlobalState, useModalState, useWalletState } from '@src/state';
import { useTransactionState } from '@src/state/contexts/TransactionState';
Expand All @@ -19,9 +20,12 @@ function ManageDomain() {
useTransactionState();
const [, dispatchModalState] = useModalState();
const { data: primaryNameData } = usePrimaryName();
const { data: domainData } = useDomainInfo({ domain: name });
const [{ walletAddress }] = useWalletState();

const isOwner = walletAddress?.toString() === primaryNameData?.owner;
const isOwner = walletAddress
? walletAddress.toString() === domainData?.info?.Owner
: false;

const [logoId, setLogoId] = useState<string | undefined>();

Expand Down

0 comments on commit b648550

Please sign in to comment.