Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy cast links #537

Merged
merged 5 commits into from
Nov 7, 2024
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
1 change: 1 addition & 0 deletions apps/admin/src/components/CancelProposal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const CancelProposal = ({
color="secondary"
rules={[daoExists, isConnectedToDao, addressCanCancel]}
onClick={handleCancel}
style={{ paddingLeft: '1rem', paddingRight: '1rem' }}
// centerAlign
>
{isLoading ? <Loading size={20} /> : 'Cancel'}
Expand Down
7 changes: 6 additions & 1 deletion apps/admin/src/pages/DaoOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useCurrentDao, useDaoData } from '@daohaus/moloch-v3-hooks';
import { SingleColumnLayout } from '@daohaus/ui';
import { DaoOverview as DaoOverviewCard } from '@daohaus/moloch-v3-macro-ui';
import { Keychain } from '@daohaus/keychain-utils';
import { farcastleChain } from '@daohaus/utils';

export const DaoOverview = () => {
const { daoChain } = useCurrentDao();
Expand All @@ -10,7 +11,11 @@ export const DaoOverview = () => {
return (
<SingleColumnLayout>
{dao && (
<DaoOverviewCard daoChain={daoChain as keyof Keychain} daoId={dao.id} />
<DaoOverviewCard
daoChain={daoChain as keyof Keychain}
daoId={dao.id}
showFarcasterLink={farcastleChain(daoChain)}
/>
)}
</SingleColumnLayout>
);
Expand Down
26 changes: 23 additions & 3 deletions apps/admin/src/pages/Proposal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,33 @@
useDaoProposal,
} from '@daohaus/moloch-v3-hooks';
import {
FarcastleButton,
ProposalActions,
ProposalDetailsContainer,
ProposalHistory,
} from '@daohaus/moloch-v3-macro-ui';
import { BiColumnLayout, Card, ParLg, Loading, widthQuery } from '@daohaus/ui';
import {
BiColumnLayout,
Card,
ParLg,
Loading,
widthQuery,
Button,

Check warning on line 19 in apps/admin/src/pages/Proposal.tsx

View workflow job for this annotation

GitHub Actions / build

'Button' is defined but never used

Check warning on line 19 in apps/admin/src/pages/Proposal.tsx

View workflow job for this annotation

GitHub Actions / build

'Button' is defined but never used
} from '@daohaus/ui';
import {
DAO_METHOD_TO_PROPOSAL_TYPE,
farcastleChain,
getFarcastleFramemUrl,

Check warning on line 24 in apps/admin/src/pages/Proposal.tsx

View workflow job for this annotation

GitHub Actions / build

'getFarcastleFramemUrl' is defined but never used

Check warning on line 24 in apps/admin/src/pages/Proposal.tsx

View workflow job for this annotation

GitHub Actions / build

'getFarcastleFramemUrl' is defined but never used
getProposalTypeLabel,
PROPOSAL_TYPE_LABELS,
PROPOSAL_TYPE_WARNINGS,
ProposalTypeIds,
SENSITIVE_PROPOSAL_TYPES,
} from '@daohaus/utils';

import { CancelProposal } from '../components/CancelProposal';

import FarcasterLogo from '../assets/farcaster-logo.svg';

Check warning on line 33 in apps/admin/src/pages/Proposal.tsx

View workflow job for this annotation

GitHub Actions / build

'FarcasterLogo' is defined but never used

Check warning on line 33 in apps/admin/src/pages/Proposal.tsx

View workflow job for this annotation

GitHub Actions / build

'FarcasterLogo' is defined but never used

const LoadingContainer = styled.div`
margin-top: 5rem;
`;
Expand Down Expand Up @@ -84,7 +95,16 @@
)}`}
actions={
proposal && (
<CancelProposal proposal={proposal} onSuccess={() => refetch()} />
<>
<CancelProposal proposal={proposal} onSuccess={() => refetch()} />
{farcastleChain(daoChain) && (
<FarcastleButton
daoId={daoId}
daoChain={daoChain}
location={`proposals/${proposal.proposalId}`}
/>
)}
</>
)
}
left={
Expand Down
5 changes: 5 additions & 0 deletions libs/moloch-v3-macro-ui/src/assets/farcaster-logo-yellow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions libs/moloch-v3-macro-ui/src/assets/farcaster-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ type DaoOverviewProps = {
daoChain: ValidNetwork;
daoId: string;
graphApiKeys?: Keychain;
showFarcasterLink?: boolean;
};

export const DaoOverview = ({
daoChain,
daoId,
graphApiKeys,
showFarcasterLink,
}: DaoOverviewProps) => {
const { dao } = useDaoData({
daoChain,
Expand All @@ -34,7 +36,7 @@ export const DaoOverview = ({
{dao && (
<>
<OverviewCard>
<DaoProfile dao={dao} />
<DaoProfile dao={dao} showFarcasterLink={showFarcasterLink} />
<DataGrid>
<DataIndicator label="Members" data={dao.activeMemberCount} />
<DataIndicator label="Proposals" data={dao.proposalCount} />
Expand Down
13 changes: 11 additions & 2 deletions libs/moloch-v3-macro-ui/src/components/DaoOverview/DaoProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@ import {
daoProfileHasLinks,
missingDaoProfileData,
} from '../../utils/daoDataDisplayHelpers';
import { OverviewIconLinkList, OverviewLinkList, TagList } from '../Layout';
import {
FarcasterShareLink,
OverviewIconLinkList,
OverviewLinkList,
TagList,
} from '../Layout';

type DaoProfileProps = {
dao: MolochV3Dao;
showFarcasterLink?: boolean;
};

export const DaoProfile = ({ dao }: DaoProfileProps) => {
export const DaoProfile = ({ dao, showFarcasterLink }: DaoProfileProps) => {
const { daoChain, daoId } = useCurrentDao();

const missingProfile = useMemo(() => {
Expand Down Expand Up @@ -63,6 +69,9 @@ export const DaoProfile = ({ dao }: DaoProfileProps) => {
<OverviewIconLinkList links={dao.links} />
</>
)}
{showFarcasterLink && (
<FarcasterShareLink daoId={daoId} daoChain={daoChain} />
)}
<TagListContainer>
{dao.tags && <TagList tags={dao.tags} />}
</TagListContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ export const MetaCardHeader = styled.div`
margin-bottom: 3rem;
`;

export const MetaCardLinks = styled.div`
display: flex;
flex-wrap: wrap;
gap: 1rem;
`;

export const MetaContent = styled.div`
display: flex;
justify-content: flex-start;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Button } from '@daohaus/ui';
import { getFarcastleFramemUrl } from '@daohaus/utils';

import FarcasterLogo from '../../assets/farcaster-logo.svg';

export const FarcastleButton = ({
daoId,
daoChain,
location,
}: {
daoId: string;
daoChain: string;
location?: string;
}) => {
return (
<Button
color="secondary"
href={getFarcastleFramemUrl({
daoId,
daoChain,
location,
})}
style={{ gap: '.5rem' }}
>
<img src={FarcasterLogo} alt="farcaster" width="22px" /> Cast
</Button>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {

import {
charLimit,
farcastleChain,
formatLongDateFromSeconds,
ZERO_ADDRESS,
} from '@daohaus/utils';
Expand All @@ -19,6 +20,7 @@ import { MolochV3Dao } from '@daohaus/moloch-v3-data';
import {
DaoProfileAvatar,
MetaCardHeader,
MetaCardLinks,
MetaContent,
SettingsContainer,
WarningContainer,
Expand All @@ -28,6 +30,7 @@ import { useDaoMember } from '@daohaus/moloch-v3-hooks';
import { ButtonRouterLink, SettingsLinkList, TagList } from '../Layout';
import { daoProfileHasLinks } from '../../utils/daoDataDisplayHelpers';
import { useMemo } from 'react';
import { FarcastleButton } from './FarcastleButton';

type MetadataSettingsProps = {
dao: MolochV3Dao;
Expand Down Expand Up @@ -57,14 +60,19 @@ export const MetadataSettings = ({
<SettingsContainer>
<MetaCardHeader>
<H3>Metadata</H3>
{includeLinks && enableActions && (
<ButtonRouterLink
color="secondary"
to={`/molochv3/${daoChain}/${dao.id}/settings/update`}
>
Update Metadata
</ButtonRouterLink>
)}
<MetaCardLinks>
{includeLinks && enableActions && (
<ButtonRouterLink
color="secondary"
to={`/molochv3/${daoChain}/${dao.id}/settings/update`}
>
Update Metadata
</ButtonRouterLink>
)}
{farcastleChain(daoChain) && (
<FarcastleButton daoId={dao.id} daoChain={daoChain} />
)}
</MetaCardLinks>
</MetaCardHeader>
<MetaContent>
<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './ContractSettings';
export * from './DaoSettings';
export * from './FarcastleButton';
export * from './GovernanceSettings';
export * from './MetadataSettings';
export * from './ShamanSettings';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {

import { DaoProfileLink } from '@daohaus/moloch-v3-data';
import { DataMd, Link, ParMd } from '@daohaus/ui';
import { charLimit } from '@daohaus/utils';
import { charLimit, getFarcastleFramemUrl } from '@daohaus/utils';
import FarcasterLogo from '../../assets/farcaster-logo-yellow.svg';

export const isPredefinedSettingsLink = (link: DaoProfileLink) => {
return (
Expand Down Expand Up @@ -40,6 +41,19 @@ const IconLinkContainer = styled.div`
margin: 1.5rem 0;
`;

const FarcasterLinkContainer = styled.div`
display: flex;
gap: 1.5rem;
margin: 1.5rem 0;
padding-left: 0.5rem;
`;

const FarcasterLinkContents = styled.div`
display: flex;
align-items: center;
gap: 0.5rem;
`;

const MetadataLinkIcons: { [key: string]: React.ReactNode } = {
Github: <RiGithubFill size={'2.5rem'} />,
Discord: <RiDiscordFill size={'2.5rem'} />,
Expand Down Expand Up @@ -117,3 +131,26 @@ export const OverviewLinkList = ({ links }: LinkListsProps) => {
</LinkContainer>
);
};

export const FarcasterShareLink = ({
daoId,
daoChain,
location,
}: {
daoId?: string;
daoChain?: string;
location?: string;
}) => {
if (!daoId || !daoChain) return null;
const url = getFarcastleFramemUrl({ daoId, daoChain, location });
return (
<FarcasterLinkContainer>
<Link showExternalIcon={false} href={url}>
<FarcasterLinkContents>
<img src={FarcasterLogo} alt="farcaster" width="22px" />
<DataMd>Cast Farcastle Frame</DataMd>
</FarcasterLinkContents>
</Link>
</FarcasterLinkContainer>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import { ProposalActionConfig } from '../ProposalActionData';

import ReactMarkdown from 'react-markdown';
import { FarcasterShareLink } from '../Layout';

Check warning on line 33 in libs/moloch-v3-macro-ui/src/components/ProposalDetails/ProposalDetails.tsx

View workflow job for this annotation

GitHub Actions / build

'FarcasterShareLink' is defined but never used

Check warning on line 33 in libs/moloch-v3-macro-ui/src/components/ProposalDetails/ProposalDetails.tsx

View workflow job for this annotation

GitHub Actions / build

'FarcasterShareLink' is defined but never used

const Spacer = styled.div`
margin-bottom: 2rem;
Expand Down
16 changes: 16 additions & 0 deletions libs/utils/src/utils/farcastle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const farcastleChain = (daoChain?: string) => daoChain !== '0xaa36a7';

export const getFarcastleFramemUrl = ({
daoChain,
daoId,
location,
}: {
daoChain: string;
daoId: string;
location?: string;
}): string | undefined => {
if (daoChain === '0xaa36a7') return;
const baseUrl = `https://warpcast.com/~/compose?text=&embeds[]=https://frames.farcastle.net/molochv3/${daoChain}/${daoId}`;

return location ? `${baseUrl}/${location}` : baseUrl;
};
1 change: 1 addition & 0 deletions libs/utils/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from './cache';
export * from './dates';
export * from './gas';
export * from './general';
export * from './farcastle';
export * from './formatting';
export * from './gnosis';
export * from './typeguards';
Expand Down
Loading