From e0a5cb5f184af064b60f76624367045156aa1ab6 Mon Sep 17 00:00:00 2001 From: johnnyd-eth Date: Wed, 11 Sep 2024 15:35:48 +1000 Subject: [PATCH] feat: v4 archive projects --- src/locales/messages.pot | 9 + .../ArchiveProjectSettingsPage.tsx | 167 ++++++++++++++++++ .../ProjectDetailsSettingsPage.tsx | 15 +- .../ProjectSettingsContent.tsx | 19 +- .../ProjectSettingsDashboard.tsx | 32 ++-- 5 files changed, 207 insertions(+), 35 deletions(-) create mode 100644 src/packages/v4/views/V4ProjectSettings/ArchiveProjectSettingsPage.tsx diff --git a/src/locales/messages.pot b/src/locales/messages.pot index 7abc7cc37a..91a9ce5d62 100644 --- a/src/locales/messages.pot +++ b/src/locales/messages.pot @@ -227,6 +227,9 @@ msgstr "" msgid "Error downloading participants, try again." msgstr "" +msgid "Edit next ruleset" +msgstr "" + msgid "Set a future date & time to start your project's first cycle." msgstr "" @@ -1427,6 +1430,9 @@ msgstr "" msgid "What do we value?" msgstr "" +msgid "Ruleset configuration" +msgstr "" + msgid "Add a brief one-sentence summary of your project." msgstr "" @@ -3815,6 +3821,9 @@ msgstr "" msgid "DeFi" msgstr "" +msgid "Make changes to your ruleset settings and rules" +msgstr "" + msgid "While enabled, this project will use the custom behavior defined in the contract above when somebody redeems from this project. Exercise caution." msgstr "" diff --git a/src/packages/v4/views/V4ProjectSettings/ArchiveProjectSettingsPage.tsx b/src/packages/v4/views/V4ProjectSettings/ArchiveProjectSettingsPage.tsx new file mode 100644 index 0000000000..4757ec3611 --- /dev/null +++ b/src/packages/v4/views/V4ProjectSettings/ArchiveProjectSettingsPage.tsx @@ -0,0 +1,167 @@ +import { Trans } from '@lingui/macro' +import { Button, Statistic } from 'antd' +import { Callout } from 'components/Callout/Callout' +import { useJBProjectMetadataContext } from 'juice-sdk-react' +import { uploadProjectMetadata } from 'lib/api/ipfs' +import { useEditProjectDetailsTx } from 'packages/v4/hooks/useEditProjectDetailsTx' +import { useCallback, useState } from 'react' +import { emitErrorNotification, emitInfoNotification } from 'utils/notifications' + +export function ArchiveProjectSettingsPage() { + const [loading, setLoading] = useState(false) + + const editV4ProjectDetailsTx = useEditProjectDetailsTx() + const { metadata } = useJBProjectMetadataContext() + + const projectMetadata = metadata.data + + const setArchived = useCallback(async (archived: boolean) => { + if (!projectMetadata) return + + setLoading(true) + + const uploadedMetadata = await uploadProjectMetadata({ + ...projectMetadata, + archived, + }) + + if (!uploadedMetadata.Hash) { + setLoading(false) + return + } + + editV4ProjectDetailsTx( + uploadedMetadata.Hash as `0x${string}`, { + onTransactionPending: () => null, + onTransactionConfirmed: () => { + setLoading(false) + emitInfoNotification('Project archived', { + description: 'Your project has been archived.', + }) + + // v4Todo: part of v2, not sure if necessary + // if (projectId) { + // await revalidateProject({ + // pv: PV_V4, + // projectId: String(projectId), + // }) + // } + }, + onTransactionError: (error: unknown) => { + console.error(error) + setLoading(false) + emitErrorNotification(`Error launching ruleset: ${error}`) + }, + } + ) + }, [ + editV4ProjectDetailsTx, + projectMetadata, + ]) + + if (projectMetadata?.archived) { + return ( +
+ Project state} + valueRender={() => Archived} + /> + +
+

+ Unarchiving your project has the following effects: +

+ +
    +
  • + Your project will appear as 'active'. +
  • +
  • + + Your project can receive payments through the juicebox.money + app. + +
  • +
+
+ +

+ + Allow a few days for your project to appear in the "active" projects + list on the Projects page. + +

+
+ +
+
+ ) + } + + return ( +
+ Project state} + valueRender={() => Active} + /> + +
+

+ Archiving your project has the following effects: +

+ +
    +
  • + Your project will appear as 'archived'. +
  • +
  • + + Your project can't receive payments through the juicebox.money + app. + +
  • +
  • + + Unless payments to this project are paused in your cycle's + rules, your project can still receive payments directly through + the Juicebox protocol contracts. + +
  • +
+
+ +
+

+ + Allow a few days for your project to appear in the "archived" + projects list on the Projects page. + +

+ + + You can unarchive your project at any time. + +
+ +
+ +
+
+ ) +} diff --git a/src/packages/v4/views/V4ProjectSettings/ProjectDetailsSettingsPage/ProjectDetailsSettingsPage.tsx b/src/packages/v4/views/V4ProjectSettings/ProjectDetailsSettingsPage/ProjectDetailsSettingsPage.tsx index 2a81156d71..cd23f05410 100644 --- a/src/packages/v4/views/V4ProjectSettings/ProjectDetailsSettingsPage/ProjectDetailsSettingsPage.tsx +++ b/src/packages/v4/views/V4ProjectSettings/ProjectDetailsSettingsPage/ProjectDetailsSettingsPage.tsx @@ -1,18 +1,17 @@ import { useForm } from 'antd/lib/form/Form' import { ProjectDetailsForm, ProjectDetailsFormFields } from 'components/Project/ProjectSettings/ProjectDetailsForm' import { PROJECT_PAY_CHARACTER_LIMIT } from 'constants/numbers' -import { ProjectMetadataContext } from 'contexts/ProjectMetadataContext' +import { useJBProjectMetadataContext } from 'juice-sdk-react' import { uploadProjectMetadata } from 'lib/api/ipfs' import { useEditProjectDetailsTx } from 'packages/v4/hooks/useEditProjectDetailsTx' -import { useCallback, useContext, useEffect, useState } from 'react' +import { useCallback, useEffect, useState } from 'react' import { withoutHttps } from 'utils/http' import { emitErrorNotification, emitInfoNotification } from 'utils/notifications' export function ProjectDetailsSettingsPage() { - const { projectMetadata, refetchProjectMetadata } = useContext( - ProjectMetadataContext, - ) + const { metadata } = useJBProjectMetadataContext() + const projectMetadata = metadata.data const [loadingSaveChanges, setLoadingSaveChanges] = useState() const [projectForm] = useForm() @@ -63,7 +62,6 @@ export function ProjectDetailsSettingsPage() { // projectId: String(projectId), // }) // } - refetchProjectMetadata() }, onTransactionError: (error: unknown) => { console.error(error) @@ -75,7 +73,6 @@ export function ProjectDetailsSettingsPage() { }, [ editProjectDetailsTx, projectForm, - refetchProjectMetadata, projectMetadata, ]) @@ -90,8 +87,7 @@ export function ProjectDetailsSettingsPage() { coverImageUri: projectMetadata?.coverImageUri ?? '', description: projectMetadata?.description ?? '', projectTagline: projectMetadata?.projectTagline ?? '', - projectRequiredOFACCheck: - projectMetadata?.projectRequiredOFACCheck ?? false, + projectRequiredOFACCheck: false, // OFAC not supported in V4 yet twitter: projectMetadata?.twitter ?? '', discord, telegram, @@ -107,7 +103,6 @@ export function ProjectDetailsSettingsPage() { projectMetadata?.coverImageUri, projectMetadata?.description, projectMetadata?.projectTagline, - projectMetadata?.projectRequiredOFACCheck, projectMetadata?.twitter, projectMetadata?.discord, projectMetadata?.telegram, diff --git a/src/packages/v4/views/V4ProjectSettings/ProjectSettingsContent.tsx b/src/packages/v4/views/V4ProjectSettings/ProjectSettingsContent.tsx index d49acdaf0a..c9ff01032d 100644 --- a/src/packages/v4/views/V4ProjectSettings/ProjectSettingsContent.tsx +++ b/src/packages/v4/views/V4ProjectSettings/ProjectSettingsContent.tsx @@ -5,6 +5,7 @@ import { Button, Layout } from 'antd' import Link from 'next/link' import { useMemo } from 'react' import { twJoin } from 'tailwind-merge' +import { ArchiveProjectSettingsPage } from './ArchiveProjectSettingsPage' import { CreateErc20TokenSettingsPage } from './CreateErc20TokenSettingsPage' import { EditCyclePage } from './EditCyclePage/EditCyclePage' import { useSettingsPagePath } from './hooks/useSettingsPagePath' @@ -16,14 +17,14 @@ const SettingsPageComponents: { [k in SettingsPageKey]: () => JSX.Element | null } = { general: ProjectDetailsSettingsPage, - handle: () => null, //ProjectHandleSettingsPage, + // handle: () => null, //ProjectHandleSettingsPage, cycle: EditCyclePage, // nfts: () => null, //EditNftsPage, payouts: () => null, //PayoutsSettingsPage, - reservedtokens: () => null, //ReservedTokensSettingsPage, - transferownership: () => null, //TransferOwnershipSettingsPage, - archiveproject: () => null, //ArchiveProjectSettingsPage, - heldfees: () => null, //ProcessHeldFeesPage, + // reservedtokens: () => null, //ReservedTokensSettingsPage, + // transferownership: () => null, //TransferOwnershipSettingsPage, + archiveproject: ArchiveProjectSettingsPage, + // heldfees: () => null, //ProcessHeldFeesPage, createerc20: CreateErc20TokenSettingsPage, } @@ -33,14 +34,14 @@ const V4SettingsPageKeyTitleMap = ( [k in SettingsPageKey]: string } => ({ general: t`General`, - handle: t`Project handle`, + // handle: t`Project handle`, cycle: t`Cycle configuration`, payouts: t`Payouts`, - reservedtokens: t`Reserved token recipients`, + // reservedtokens: t`Reserved token recipients`, // nfts: hasExistingNfts ? t`Edit NFT collection` : t`Launch New NFT Collection`, - transferownership: t`Transfer ownership`, + // transferownership: t`Transfer ownership`, archiveproject: t`Archive project`, - heldfees: t`Process held fees`, + // heldfees: t`Process held fees`, createerc20: t`Create ERC-20 token`, }) diff --git a/src/packages/v4/views/V4ProjectSettings/ProjectSettingsDashboard.tsx b/src/packages/v4/views/V4ProjectSettings/ProjectSettingsDashboard.tsx index da2c5c8d41..67382b8867 100644 --- a/src/packages/v4/views/V4ProjectSettings/ProjectSettingsDashboard.tsx +++ b/src/packages/v4/views/V4ProjectSettings/ProjectSettingsDashboard.tsx @@ -14,14 +14,14 @@ import { useSettingsPagePath } from './hooks/useSettingsPagePath' export type SettingsPageKey = | 'general' - | 'handle' + // | 'handle' -> commenting out not necessary for v4 | 'cycle' // | 'nfts' | 'payouts' - | 'reservedtokens' - | 'transferownership' + // | 'reservedtokens' + // | 'transferownership' | 'archiveproject' - | 'heldfees' + // | 'heldfees' | 'createerc20' function SettingsCard({ children }: { children: React.ReactNode }) { @@ -146,6 +146,11 @@ export function ProjectSettingsDashboard() { Basic details +
  • + + Archive + +
  • {/*
  • Project handle @@ -155,13 +160,13 @@ export function ProjectSettingsDashboard() { Cycle configuration} + title={Ruleset configuration} subtitle={ - Make changes to your cycle settings and rules + Make changes to your ruleset settings and rules } > - Edit next cycle + Edit next ruleset
  • )} -
  • + {/*
  • Process held fees -
  • + */} - Manage} subtitle={Manage your project's state and ownership} > @@ -193,13 +198,8 @@ export function ProjectSettingsDashboard() { Transfer ownership -
  • - - Archive - -
  • -
    + */}