Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/mandatory-fields-irritate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@aragon/app": patch
---

Allow resource links to be saved and rendered without custom link text.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import {
formatterUtils,
type IProposalAction,
type IProposalActionComponentProps,
Link,
NumberFormat,
} from '@aragon/gov-ui-kit';
import { formatUnits, type Hex, zeroAddress, zeroHash } from 'viem';
import type { IProposalActionData } from '@/modules/governance/components/createProposalForm';
import { useDao } from '@/shared/api/daoService';
import { ResourceLink } from '@/shared/components/resourceLink';
import {
type TranslationFunction,
useTranslations,
Expand Down Expand Up @@ -147,14 +147,12 @@ export const CapitalDistributorCreateCampaignActionDetails: React.FC<
>
<div className="flex flex-col gap-3">
{resources.map((link) => (
<Link
href={link.url}
<ResourceLink
isExternal={true}
key={link.url}
showUrl={true}
>
{link.name}
</Link>
name={link.name}
url={link.url}
/>
))}
</div>
</DefinitionList.Item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {
InputContainer,
type IProposalAction,
type IProposalActionComponentProps,
Link,
} from '@aragon/gov-ui-kit';
import type { IProposalActionData } from '@/modules/governance/components/createProposalForm';
import { NestedActionsList } from '@/modules/governance/components/nestedActionsList';
import { ResourceLink } from '@/shared/components/resourceLink';
import { SafeDocumentParser } from '@/shared/components/SafeDocumentParser';
import { useTranslations } from '@/shared/components/translationsProvider';
import type { ICoreActionCreateProposal } from '../types/coreActionCreateProposal';
Expand Down Expand Up @@ -103,14 +103,12 @@ export const CreateProposalActionDetails: React.FC<
>
<div className="flex flex-col gap-3">
{metadata.resources.map((resource) => (
<Link
href={resource.url}
<ResourceLink
isExternal={true}
key={resource.url}
showUrl={true}
>
{resource.name}
</Link>
name={resource.name}
url={resource.url}
/>
))}
</div>
</DefinitionList.Item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {
type IProposalAction,
type IProposalActionComponentProps,
type IProposalActionInputDataParameter,
Link,
} from '@aragon/gov-ui-kit';
import type { IProposalActionData } from '@/modules/governance/components/createProposalForm';
import { useDao } from '@/shared/api/daoService';
import { ResourceLink } from '@/shared/components/resourceLink';
import { useTranslations } from '@/shared/components/translationsProvider';
import { useDaoChain } from '@/shared/hooks/useDaoChain';
import { ipfsUtils } from '@/shared/utils/ipfsUtils';
Expand Down Expand Up @@ -103,14 +103,12 @@ export const GaugeRegistrarRegisterGaugeActionDetails: React.FC<
>
<div className="flex flex-col gap-3">
{links.map((link) => (
<Link
href={link.url}
<ResourceLink
isExternal={true}
key={link.url}
showUrl={true}
>
{link.name}
</Link>
name={link.name}
url={link.url}
/>
))}
</div>
</DefinitionList.Item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
DefinitionList,
type IProposalAction,
type IProposalActionComponentProps,
Link,
} from '@aragon/gov-ui-kit';
import type { IProposalActionData } from '@/modules/governance/components/createProposalForm';
import { useDao } from '@/shared/api/daoService';
import { ResourceLink } from '@/shared/components/resourceLink';
import { useTranslations } from '@/shared/components/translationsProvider';
import { useDaoChain } from '@/shared/hooks/useDaoChain';
import { ipfsUtils } from '@/shared/utils/ipfsUtils';
Expand Down Expand Up @@ -86,14 +86,12 @@ export const GaugeVoterCreateGaugeActionDetails: React.FC<
>
<div className="flex flex-col gap-3">
{links.map((link) => (
<Link
href={link.url}
<ResourceLink
isExternal={true}
key={link.url}
showUrl={true}
>
{link.name}
</Link>
name={link.name}
url={link.url}
/>
))}
</div>
</DefinitionList.Item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
DefinitionList,
type IProposalAction,
type IProposalActionComponentProps,
Link,
} from '@aragon/gov-ui-kit';
import type { IProposalActionData } from '@/modules/governance/components/createProposalForm';
import { useDao } from '@/shared/api/daoService';
import { ResourceLink } from '@/shared/components/resourceLink';
import { useTranslations } from '@/shared/components/translationsProvider';
import { useDaoChain } from '@/shared/hooks/useDaoChain';
import { ipfsUtils } from '@/shared/utils/ipfsUtils';
Expand Down Expand Up @@ -86,14 +86,12 @@ export const GaugeVoterUpdateGaugeMetadataActionDetails: React.FC<
>
<div className="flex flex-col gap-3">
{links.map((link) => (
<Link
href={link.url}
<ResourceLink
isExternal={true}
key={link.url}
showUrl={true}
>
{link.name}
</Link>
name={link.name}
url={link.url}
/>
))}
</div>
</DefinitionList.Item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
DateFormat,
DefinitionList,
formatterUtils,
Link,
} from '@aragon/gov-ui-kit';
import type { IFeaturedDelegates } from '@/shared/api/cmsService';
import {
Expand All @@ -16,6 +15,7 @@ import {
} from '@/shared/api/daoService';
import { Page } from '@/shared/components/page';
import { PluginSingleComponent } from '@/shared/components/pluginSingleComponent';
import { ResourceLink } from '@/shared/components/resourceLink';
import { useTranslations } from '@/shared/components/translationsProvider';
import { useAdminStatus } from '@/shared/hooks/useAdminStatus';
import { useDaoChain } from '@/shared/hooks/useDaoChain';
Expand Down Expand Up @@ -165,14 +165,12 @@ export const DaoDashboardPageClient: React.FC<IDaoDashboardPageClientProps> = (
)}
>
{dao.links.map(({ url, name }) => (
<Link
href={url}
<ResourceLink
isExternal={true}
key={url}
showUrl={true}
>
{name}
</Link>
name={name}
url={url}
/>
))}
</Page.AsideCard>
)}
Expand Down
12 changes: 5 additions & 7 deletions src/modules/finance/components/daoInfoAside/daoInfoAside.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
Collapsible,
DefinitionList,
IconType,
Link,
} from '@aragon/gov-ui-kit';
import { useFeatureFlags } from '@/shared/components/featureFlagsProvider';
import { ResourceLink } from '@/shared/components/resourceLink';
import { StatCard } from '@/shared/components/statCard';
import { useTranslations } from '@/shared/components/translationsProvider';
import { networkDefinitions } from '@/shared/constants/networkDefinitions';
Expand Down Expand Up @@ -86,14 +86,12 @@ export const DaoInfoAside: React.FC<IDaoInfoAsideProps> = (props) => {

<div className="flex flex-col gap-3">
{links.map((link) => (
<Link
href={link.url}
<ResourceLink
isExternal={true}
key={link.url}
showUrl={true}
>
{link.name}
</Link>
name={link.name}
url={link.url}
/>
))}
</div>
{resolvedOctavLink && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,20 @@ describe('<DaoProposalDetailsPageClient /> component', () => {
});
});

it('renders an empty-name proposal resource with the URL as link text', () => {
const resource = { name: '', url: 'https://empty-name.com' };
const proposal = generateProposal({ resources: [resource] });
useProposalSpy.mockReturnValue(
generateReactQueryResultSuccess({ data: proposal }),
);
render(createTestComponent());

const link = screen.getByRole('link', { name: resource.url });
expect(link).toBeInTheDocument();
expect(link.getAttribute('href')).toEqual(resource.url);
expect(screen.getAllByText(resource.url)).toHaveLength(1);
});

it('does not render the links section when proposal has no resources', () => {
const proposal = generateProposal({ resources: [] });
useProposalSpy.mockReturnValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
DefinitionList,
formatterUtils,
type IProposalActionsFooterDropdownItem,
Link,
ProposalActions,
ProposalActionTypeNoBasicView,
ProposalStatus,
Expand All @@ -25,6 +24,7 @@ import { AragonBackendServiceError } from '@/shared/api/aragonBackendService';
import { useDao } from '@/shared/api/daoService';
import { Page } from '@/shared/components/page';
import { PluginSingleComponent } from '@/shared/components/pluginSingleComponent';
import { ResourceLink } from '@/shared/components/resourceLink';
import { SafeDocumentParser } from '@/shared/components/SafeDocumentParser';
import { useTranslations } from '@/shared/components/translationsProvider';
import { useDaoChain } from '@/shared/hooks/useDaoChain';
Expand Down Expand Up @@ -419,14 +419,12 @@ export const DaoProposalDetailsPageClient: React.FC<
>
<div className="flex flex-col gap-4">
{resources.map((resource) => (
<Link
href={resource.url}
<ResourceLink
isExternal={true}
key={resource.name}
showUrl={true}
>
{resource.name}
</Link>
key={resource.url}
name={resource.name}
url={resource.url}
/>
))}
</div>
</Page.AsideCard>
Expand Down
11 changes: 5 additions & 6 deletions src/modules/settings/components/daoHierarchy/daoHierarchy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import type { IDao, ILinkedAccountSummary } from '@/shared/api/daoService';
import { DaoTypeTag } from '@/shared/components/daoTypeTag';
import { useFeatureFlags } from '@/shared/components/featureFlagsProvider';
import { ResourceLink } from '@/shared/components/resourceLink';
import { useTranslations } from '@/shared/components/translationsProvider';
import { networkDefinitions } from '@/shared/constants/networkDefinitions';
import { daoUtils } from '@/shared/utils/daoUtils';
Expand Down Expand Up @@ -128,14 +129,12 @@ const DaoInfo: React.FC<IDaoInfoProps> = ({ dao, permissionsHref }) => {
>
<div className="flex flex-col gap-3">
{dao.links.map((link) => (
<Link
href={link.url}
<ResourceLink
isExternal={true}
key={link.url}
showUrl={true}
>
{link.name}
</Link>
name={link.name}
url={link.url}
/>
))}
</div>
</DefinitionList.Item>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Link } from '@aragon/gov-ui-kit';
import type { IResource } from '@/shared/api/daoService';
import { ResourceLink } from '@/shared/components/resourceLink';

export interface IDaoPluginInfoMetadataProps {
/**
Expand All @@ -20,11 +20,13 @@ export const DaoPluginInfoMetadata: React.FC<IDaoPluginInfoMetadataProps> = (
return (
<div className="flex flex-col gap-y-6">
{description && <p className="text-neutral-500">{description}</p>}
{links?.map((resource: IResource, index: number) => (
<div className="flex flex-col gap-y-3" key={index}>
<Link href={resource.url} isExternal={true} showUrl={true}>
{resource.name}
</Link>
{links?.map((resource: IResource) => (
<div className="flex flex-col gap-y-3" key={resource.url}>
<ResourceLink
isExternal={true}
name={resource.name}
url={resource.url}
/>
</div>
))}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from '@aragon/gov-ui-kit';
import type { IDao } from '@/shared/api/daoService';
import { useFeatureFlags } from '@/shared/components/featureFlagsProvider';
import { ResourceLink } from '@/shared/components/resourceLink';
import { useTranslations } from '@/shared/components/translationsProvider';
import { networkDefinitions } from '@/shared/constants/networkDefinitions';
import { useDaoChain } from '@/shared/hooks/useDaoChain';
Expand Down Expand Up @@ -101,14 +102,12 @@ export const DaoSettingsInfo: React.FC<IDaoSettingsInfoProps> = (props) => {
>
<div className="flex flex-col gap-3">
{dao.links.map((link) => (
<Link
href={link.url}
<ResourceLink
isExternal={true}
key={link.url}
showUrl={true}
>
{link.name}
</Link>
name={link.name}
url={link.url}
/>
))}
</div>
</DefinitionList.Item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
type ICampaign,
} from '@/plugins/capitalDistributorPlugin/api/capitalDistributorService';
import type { ICapitalDistributorPlugin } from '@/plugins/capitalDistributorPlugin/types';
import { ResourceLink } from '@/shared/components/resourceLink';
import { useTranslations } from '@/shared/components/translationsProvider';
import { useFormField } from '@/shared/hooks/useFormField';
import type { ICapitalDistributorClaimDialogForm } from '../capitalDistributorClaimDialogDefinitions';
Expand Down Expand Up @@ -137,14 +138,12 @@ export const CapitalDistributorClaimDialogDetails: React.FC<
</Heading>
<div className="flex flex-col gap-4">
{resources.map((resource) => (
<Link
href={resource.url}
<ResourceLink
isExternal={true}
key={resource.url}
showUrl={true}
>
{resource.name}
</Link>
name={resource.name}
url={resource.url}
/>
))}
</div>
</Card>
Expand Down
Loading
Loading