Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ import { ProposalVoteForm } from '../../components/governance/ProposalVoteForm';
import App from '../../App';
import { svPartyId } from '../mocks/constants';
import { Wrapper } from '../helpers';
import {
PROPOSAL_LINK_LABEL,
SUPPORTING_URL_LABEL,
VOTE_PROPOSAL_CONTRACT_ID_LABEL,
} from '../../utils/constants';
import { getProposalLink } from '../../utils/governance';

const voteRequest = {
contractId: 'abc123' as ContractId<VoteRequest>,
Expand Down Expand Up @@ -165,6 +171,10 @@ describe('Proposal Details Content', () => {
const action = screen.getByTestId('proposal-details-action-value');
expect(action.textContent).toMatch(/Offboard Member/);

expect(screen.getByTestId('proposal-details-contractid-label').textContent).toBe(
VOTE_PROPOSAL_CONTRACT_ID_LABEL
);

const offboardSection = screen.getByTestId('proposal-details-offboard-member-section');
expect(offboardSection).toBeInTheDocument();

Expand All @@ -177,9 +187,17 @@ describe('Proposal Details Content', () => {
const summary = screen.getByTestId('proposal-details-summary-value');
expect(summary.textContent).toMatch(/Summary of the proposal/);

expect(screen.getByTestId('proposal-details-url-label').textContent).toBe(SUPPORTING_URL_LABEL);

const url = screen.getByTestId('proposal-details-url');
expect(url.textContent).toMatch(/https:\/\/example.com/);

expect(screen.getByTestId('proposal-details-proposal-link-label').textContent).toBe(
PROPOSAL_LINK_LABEL
);
const proposalLink = screen.getByTestId('proposal-details-proposal-link-link');
expect(proposalLink).toHaveAttribute('href', getProposalLink(voteRequest.contractId));

const votingInformationSection = screen.getByTestId('proposal-details-voting-information');
expect(votingInformationSection).toBeInTheDocument();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Review Proposal Component', () => {
expect(screen.getByTestId('action-title').textContent).toBe('Action');
expect(screen.getByTestId('action-field').textContent).toBe(actionName);

expect(screen.getByTestId('url-title').textContent).toBe('URL');
expect(screen.getByTestId('url-title').textContent).toBe('Supporting URL');
expect(screen.getByTestId('url-field').textContent).toBe(url);

expect(screen.getByTestId('summary-title').textContent).toBe('Summary');
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('Review Proposal Component', () => {
expect(screen.getByTestId('action-title').textContent).toBe('Action');
expect(screen.getByTestId('action-field').textContent).toBe(actionName);

expect(screen.getByTestId('url-title').textContent).toBe('URL');
expect(screen.getByTestId('url-title').textContent).toBe('Supporting URL');
expect(screen.getByTestId('url-field').textContent).toBe(url);

expect(screen.getByTestId('summary-title').textContent).toBe('Summary');
Expand Down Expand Up @@ -136,7 +136,7 @@ describe('Review Proposal Component', () => {
expect(screen.getByTestId('action-title').textContent).toBe('Action');
expect(screen.getByTestId('action-field').textContent).toBe(actionName);

expect(screen.getByTestId('url-title').textContent).toBe('URL');
expect(screen.getByTestId('url-title').textContent).toBe('Supporting URL');
expect(screen.getByTestId('url-field').textContent).toBe(url);

expect(screen.getByTestId('summary-title').textContent).toBe('Summary');
Expand Down Expand Up @@ -180,7 +180,7 @@ describe('Review Proposal Component', () => {
expect(screen.getByTestId('action-title').textContent).toBe('Action');
expect(screen.getByTestId('action-field').textContent).toBe(actionName);

expect(screen.getByTestId('url-title').textContent).toBe('URL');
expect(screen.getByTestId('url-title').textContent).toBe('Supporting URL');
expect(screen.getByTestId('url-field').textContent).toBe(url);

expect(screen.getByTestId('summary-title').textContent).toBe('Summary');
Expand Down Expand Up @@ -230,7 +230,7 @@ describe('Review Proposal Component', () => {
expect(screen.getByTestId('action-title').textContent).toBe('Action');
expect(screen.getByTestId('action-field').textContent).toBe(actionName);

expect(screen.getByTestId('url-title').textContent).toBe('URL');
expect(screen.getByTestId('url-title').textContent).toBe('Supporting URL');
expect(screen.getByTestId('url-field').textContent).toBe(url);

expect(screen.getByTestId('summary-title').textContent).toBe('Summary');
Expand Down Expand Up @@ -296,7 +296,7 @@ describe('Review Proposal Component', () => {
expect(screen.getByTestId('action-title').textContent).toBe('Action');
expect(screen.getByTestId('action-field').textContent).toBe(actionName);

expect(screen.getByTestId('url-title').textContent).toBe('URL');
expect(screen.getByTestId('url-title').textContent).toBe('Supporting URL');
expect(screen.getByTestId('url-field').textContent).toBe(url);

expect(screen.getByTestId('summary-title').textContent).toBe('Summary');
Expand Down Expand Up @@ -368,7 +368,7 @@ describe('Review Proposal Component', () => {
expect(screen.getByTestId('action-title').textContent).toBe('Action');
expect(screen.getByTestId('action-field').textContent).toBe(actionName);

expect(screen.getByTestId('url-title').textContent).toBe('URL');
expect(screen.getByTestId('url-title').textContent).toBe('Supporting URL');
expect(screen.getByTestId('url-field').textContent).toBe(url);

expect(screen.getByTestId('summary-title').textContent).toBe('Summary');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useState } from 'react';
import { useDsoInfos } from '../../contexts/SvContext';
import { useAppForm } from '../../hooks/form';
import { useProposalMutation } from '../../hooks/useProposalMutation';
import { THRESHOLD_DEADLINE_SUBTITLE } from '../../utils/constants';
import { SUPPORTING_URL_LABEL, THRESHOLD_DEADLINE_SUBTITLE } from '../../utils/constants';
import { createProposalActions, getInitialExpiration } from '../../utils/governance';
import type { CommonProposalFormData } from '../../utils/types';
import { EffectiveDateField } from '../form-components/EffectiveDateField';
Expand Down Expand Up @@ -227,7 +227,7 @@ export const CreateUnallocatedUnclaimedActivityRecordForm: React.FC = _ => {
>
{field => (
<field.TextField
title="SUPPORTING URL"
title={SUPPORTING_URL_LABEL}
id="create-unallocated-unclaimed-activity-record-url"
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { dateTimeFormatISO } from '@canton-network/splice-common-frontend-utils';
import { useAppForm } from '../../hooks/form';
import { useStore } from '@tanstack/react-form';
import { THRESHOLD_DEADLINE_SUBTITLE } from '../../utils/constants';
import { SUPPORTING_URL_LABEL, THRESHOLD_DEADLINE_SUBTITLE } from '../../utils/constants';
import { CommonProposalFormData } from '../../utils/types';
import { ContractId } from '@daml/types';
import { FeaturedAppRight } from '@daml.js/splice-amulet/lib/Splice/Amulet';
Expand Down Expand Up @@ -344,7 +344,7 @@ export const GrantRevokeFeaturedAppForm: React.FC<GrantRevokeFeaturedAppFormProp
onChange: ({ value }) => validateUrl(value),
}}
>
{field => <field.TextField title="SUPPORTING URL" id={`${testIdPrefix}-url`} />}
{field => <field.TextField title={SUPPORTING_URL_LABEL} id={`${testIdPrefix}-url`} />}
</form.AppField>
</>
)}
Expand Down
4 changes: 2 additions & 2 deletions apps/sv/frontend/src/components/forms/OffboardSvForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { EffectiveDateField } from '../form-components/EffectiveDateField';
import { ProposalSummary } from '../governance/ProposalSummary';
import { ProposalSubmissionError } from '../form-components/ProposalSubmissionError';
import { useProposalMutation } from '../../hooks/useProposalMutation';
import { THRESHOLD_DEADLINE_SUBTITLE } from '../../utils/constants';
import { SUPPORTING_URL_LABEL, THRESHOLD_DEADLINE_SUBTITLE } from '../../utils/constants';

interface ExtraFormFields {
sv: string;
Expand Down Expand Up @@ -175,7 +175,7 @@ export const OffboardSvForm: React.FC = _ => {
onChange: ({ value }) => validateUrl(value),
}}
>
{field => <field.TextField title="SUPPORTING URL" id="offboard-sv-url" />}
{field => <field.TextField title={SUPPORTING_URL_LABEL} id="offboard-sv-url" />}
</form.AppField>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ActionRequiringConfirmation,
AmuletRules_ActionRequiringConfirmation,
} from '@daml.js/splice-dso-governance/lib/Splice/DsoRules';
import { THRESHOLD_DEADLINE_SUBTITLE } from '../../utils/constants';
import { SUPPORTING_URL_LABEL, THRESHOLD_DEADLINE_SUBTITLE } from '../../utils/constants';
import {
buildAmuletRulesPendingConfigFields,
configFormDataToConfigChanges,
Expand Down Expand Up @@ -288,7 +288,9 @@ export const SetAmuletConfigRulesForm: () => JSX.Element = () => {
onChange: ({ value }) => validateUrl(value),
}}
>
{field => <field.TextField title="SUPPORTING URL" id="set-amulet-config-rules-url" />}
{field => (
<field.TextField title={SUPPORTING_URL_LABEL} id="set-amulet-config-rules-url" />
)}
</form.AppField>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { useAppForm } from '../../hooks/form';
import { useProposalMutation } from '../../hooks/useProposalMutation';
import { buildDsoConfigChanges } from '../../utils/buildDsoConfigChanges';
import { buildDsoRulesConfigFromChanges } from '../../utils/buildDsoRulesConfigFromChanges';
import { THRESHOLD_DEADLINE_SUBTITLE } from '../../utils/constants';
import { SUPPORTING_URL_LABEL, THRESHOLD_DEADLINE_SUBTITLE } from '../../utils/constants';
import {
buildPendingConfigFields,
configFormDataToConfigChanges,
Expand Down Expand Up @@ -304,7 +304,9 @@ export const SetDsoConfigRulesForm: () => JSX.Element = () => {
onChange: ({ value }) => validateUrl(value),
}}
>
{field => <field.TextField title="SUPPORTING URL" id="set-dso-config-rules-url" />}
{field => (
<field.TextField title={SUPPORTING_URL_LABEL} id="set-dso-config-rules-url" />
)}
</form.AppField>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
validateUrl,
validateWeight,
} from './formValidators';
import { THRESHOLD_DEADLINE_SUBTITLE } from '../../utils/constants';
import { SUPPORTING_URL_LABEL, THRESHOLD_DEADLINE_SUBTITLE } from '../../utils/constants';
import {
createProposalActions,
formatBasisPoints,
Expand Down Expand Up @@ -220,7 +220,9 @@ export const UpdateSvRewardWeightForm: React.FC = _ => {
onChange: ({ value }) => validateUrl(value),
}}
>
{field => <field.TextField title="SUPPORTING URL" id="update-sv-reward-weight-url" />}
{field => (
<field.TextField title={SUPPORTING_URL_LABEL} id="update-sv-reward-weight-url" />
)}
</form.AppField>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { East } from '@mui/icons-material';
import { Alert, Box, Stack, Typography } from '@mui/material';
import { Link as RouterLink } from 'react-router';
import { CopyableIdentifier, MemberIdentifier, PageSectionHeader } from '../../components/beta';
import { VOTE_PROPOSAL_CONTRACT_ID_LABEL } from '../../utils/constants';
import React from 'react';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
Expand Down Expand Up @@ -134,7 +135,7 @@ const ActionCard = (props: ActionCardProps) => {
</Box>
<Box sx={{ flexShrink: 1, minWidth: 0, maxWidth: 300 }}>
<ActionCardSegment
title="CONTRACT ID"
title={VOTE_PROPOSAL_CONTRACT_ID_LABEL}
content={
<CopyableIdentifier
value={contractId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ import { CreateUnallocatedUnclaimedActivityRecordSection } from './proposal-deta
import { CopyableIdentifier, CopyableUrl, MemberIdentifier, VoteStats } from '../beta';
import { useQuery } from '@tanstack/react-query';
import { useSvAdminClient } from '../../contexts/SvAdminServiceContext';
import { DEFAULT_APP_ACTIVITY_WEIGHT } from '../../utils/constants';
import {
DEFAULT_APP_ACTIVITY_WEIGHT,
PROPOSAL_LINK_LABEL,
SUPPORTING_URL_LABEL,
VOTE_PROPOSAL_CONTRACT_ID_LABEL,
VOTE_REASON_SUMMARY_LABEL,
VOTE_REASON_URL_LABEL,
} from '../../utils/constants';
import { getProposalLink } from '../../utils/governance';

dayjs.extend(relativeTime);

Expand Down Expand Up @@ -203,7 +211,7 @@ export const ProposalDetailsContent: React.FC<ProposalDetailsContentProps> = pro
/>

<DetailItem
label="Vote Proposal Contract ID"
label={VOTE_PROPOSAL_CONTRACT_ID_LABEL}
value={
<CopyableIdentifier
value={contractId}
Expand Down Expand Up @@ -302,7 +310,7 @@ export const ProposalDetailsContent: React.FC<ProposalDetailsContentProps> = pro
/>

<DetailItem
label="URL"
label={SUPPORTING_URL_LABEL}
value={
<CopyableUrl
url={proposalDetails.url}
Expand All @@ -312,6 +320,18 @@ export const ProposalDetailsContent: React.FC<ProposalDetailsContentProps> = pro
}
labelId="proposal-details-url-label"
/>

<DetailItem
label={PROPOSAL_LINK_LABEL}
value={
<CopyableUrl
url={getProposalLink(contractId)}
size="large"
data-testid="proposal-details-proposal-link"
/>
}
labelId="proposal-details-proposal-link-label"
/>
</VoteSection>

<VoteSection title="Voting Information" data-testid="proposal-details-voting-information">
Expand Down Expand Up @@ -529,11 +549,23 @@ const VoteItem: React.FC<VoteItemProps> = ({
/>
</Box>
{comment && (
<Typography fontSize={16} color="text.secondary">
{comment}
</Typography>
<Box>
<Typography variant="caption" color="text.secondary" display="block" mb={1}>
{VOTE_REASON_SUMMARY_LABEL}
</Typography>
<Typography fontSize={16} color="text.secondary">
{comment}
</Typography>
</Box>
)}
{url && (
<Box>
<Typography variant="caption" color="text.secondary" display="block" mb={1}>
{VOTE_REASON_URL_LABEL}
</Typography>
<CopyableUrl url={url} size="small" data-testid="proposal-details-vote-url" />
</Box>
)}
{url && <CopyableUrl url={url} size="small" data-testid="proposal-details-vote-url" />}
</Box>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 4 }}>
<VoteStats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const ProposalListingSection: React.FC<ProposalListingSectionProps> = pro
<TableHead>
<TableRow sx={{ display: 'grid', gridTemplateColumns: gridTemplate }}>
<TableCell>ACTION</TableCell>
<TableCell>VOTE PROPOSAL CONTRACT ID</TableCell>
<TableCell>Vote Proposal Contract ID</TableCell>
{showThresholdDeadline && <TableCell>THRESHOLD DEADLINE</TableCell>}
<TableCell>EFFECTIVE AT</TableCell>
{showStatus && <TableCell>STATUS</TableCell>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import { Box, Typography } from '@mui/material';
import { THRESHOLD_DEADLINE_SUBTITLE } from '../../utils/constants';
import { SUPPORTING_URL_LABEL, THRESHOLD_DEADLINE_SUBTITLE } from '../../utils/constants';
import type { ConfigChange } from '../../utils/types';
import { scrollContainerSx, scrollableIdentifierFieldSx } from '../beta/identifierStyles';
import { ConfigValuesChanges } from './ConfigValuesChanges';
Expand Down Expand Up @@ -71,7 +71,7 @@ export const ProposalSummary: React.FC<ProposalSummaryProps> = props => {
<Box>
<ProposalField id="action" title="Action" value={actionName} />

<ProposalField id="url" title="URL" value={url} />
<ProposalField id="url" title={SUPPORTING_URL_LABEL} value={url} />

<ProposalField id="summary" title="Summary" value={summary} />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ContractId } from '@daml/types';
import { VoteRequest } from '@daml.js/splice-dso-governance/lib/Splice/DsoRules';
import { ProposalVote } from '../../utils/types';
import { Alert, Box, Button, Stack, TextField, Typography } from '@mui/material';
import { VOTE_REASON_SUMMARY_LABEL, VOTE_REASON_URL_LABEL } from '../../utils/constants';
interface CastVoteArgs {
accepted: boolean;
url: string;
Expand Down Expand Up @@ -109,7 +110,7 @@ export const ProposalVoteForm: React.FC<ProposalVoteFormProps> = props => {
fontSize={18}
lineHeight={1}
>
Reason
{VOTE_REASON_SUMMARY_LABEL}
</Typography>
<TextField
variant="filled"
Expand Down Expand Up @@ -161,7 +162,7 @@ export const ProposalVoteForm: React.FC<ProposalVoteFormProps> = props => {
fontSize={18}
lineHeight={1}
>
Vote Reason URL
{VOTE_REASON_URL_LABEL}
</Typography>
<TextField
variant="filled"
Expand Down
6 changes: 6 additions & 0 deletions apps/sv/frontend/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ export const DEFAULT_PROPOSAL_SUMMARY_MAX_LENGTH = 1024;
export const THRESHOLD_DEADLINE_SUBTITLE =
'Proposal remains open only if ⅔ of nodes place a vote before this date-time';
export const DEFAULT_APP_ACTIVITY_WEIGHT = '1.0';

export const SUPPORTING_URL_LABEL = 'Supporting URL';
export const PROPOSAL_LINK_LABEL = 'Proposal Link';
export const VOTE_REASON_URL_LABEL = 'Vote Reason URL';
export const VOTE_REASON_SUMMARY_LABEL = 'Vote Reason Summary';
export const VOTE_PROPOSAL_CONTRACT_ID_LABEL = 'Vote Proposal Contract ID';
5 changes: 5 additions & 0 deletions apps/sv/frontend/src/utils/governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,8 @@ export function buildAmuletRulesPendingConfigFields(
}));
});
}

export function getProposalLink(contractId: string): string {
const origin = typeof window !== 'undefined' ? window.location.origin : '';
return `${origin}/governance/proposals/${contractId}`;
}
Loading