From 9fe0033a8aad99daa11673c4d74250d8bcd06b58 Mon Sep 17 00:00:00 2001 From: michaelcanova Date: Fri, 31 Jul 2026 12:25:25 -0400 Subject: [PATCH] [Notebook] Removing Preprint creation --- app/layouts/PublishMenu.tsx | 41 +++---------- app/notebook/[orgSlug]/page.tsx | 15 +---- components/Notebook/NoteEditorLayout.tsx | 2 +- components/Notebook/NotebookHome.tsx | 9 +-- .../Notebook/NotebookPrimaryNavigation.tsx | 11 ---- components/Notebook/NotesMenu.tsx | 6 -- .../components/JournalSection.tsx | 56 ----------------- components/Notebook/PublishingForm/index.tsx | 61 ++++++------------- components/Notebook/PublishingForm/schema.ts | 1 - 9 files changed, 34 insertions(+), 168 deletions(-) delete mode 100644 components/Notebook/PublishingForm/components/JournalSection.tsx diff --git a/app/layouts/PublishMenu.tsx b/app/layouts/PublishMenu.tsx index a9358ee0d..5d7972534 100644 --- a/app/layouts/PublishMenu.tsx +++ b/app/layouts/PublishMenu.tsx @@ -34,27 +34,14 @@ const PUBLISH_MENU_SECTIONS = [ title: 'Funding Opportunity', description: 'Fund specific research you care about', icon: , - action: 'function', handler: 'handleOpenGrant', - requiresAuth: true, }, { id: 'request-funding', title: 'Proposal', description: 'Raise money for your research', icon: , - action: 'function', handler: 'handleFundResearch', - requiresAuth: true, - }, - { - id: 'submit-paper', - title: 'Preprint', - description: 'Publish your research as a preprint', - icon: , - action: 'navigate', - path: '/notebook?newResearch=true', - requiresAuth: true, }, ], }, @@ -115,24 +102,16 @@ export const PublishMenu: React.FC = ({ children, forceMinimiz }; const handleMenuItemClick = (item: (typeof PUBLISH_MENU_SECTIONS)[number]['items'][number]) => { - if (item.requiresAuth) { - executeAuthenticatedAction(() => { - if (item.action === 'navigate') { - router.push(item.path); - } else if (item.action === 'function') { - switch (item.handler) { - case 'handleFundResearch': - handleFundResearch(); - break; - case 'handleOpenGrant': - handleOpenGrant(); - break; - } - } - }); - } else if (item.action === 'navigate') { - router.push(item.path); - } + executeAuthenticatedAction(() => { + switch (item.handler) { + case 'handleFundResearch': + handleFundResearch(); + break; + case 'handleOpenGrant': + handleOpenGrant(); + break; + } + }); // Close mobile drawer after action if (smAndDown) { diff --git a/app/notebook/[orgSlug]/page.tsx b/app/notebook/[orgSlug]/page.tsx index 2d0842235..543b84934 100644 --- a/app/notebook/[orgSlug]/page.tsx +++ b/app/notebook/[orgSlug]/page.tsx @@ -5,7 +5,6 @@ import { useNotebookContext } from '@/contexts/NotebookContext'; import { useEffect } from 'react'; import { useSearchParams, useRouter } from 'next/navigation'; import proposalTemplate from '@/components/Editor/lib/data/proposalTemplate'; -import { getInitialContent, initialContent } from '@/components/Editor/lib/data/initialContent'; import grantTemplate from '@/components/Editor/lib/data/grantTemplate'; import { getDocumentTitle, @@ -31,7 +30,6 @@ export default function OrganizationPage() { const [{ isLoading: isUpdatingContent }, updateNoteContent] = useNoteContent(); const isNewFunding = searchParams.get('newFunding') === 'true'; - const isNewResearch = searchParams.get('newResearch') === 'true'; const isNewGrant = searchParams.get('newGrant') === 'true'; const grantSource = searchParams.get('grantSource'); const proposalSource = searchParams.get('proposalSource'); @@ -44,7 +42,7 @@ export default function OrganizationPage() { queryValue, documentType, }: { - template: typeof proposalTemplate | typeof initialContent | typeof grantTemplate; + template: typeof proposalTemplate | typeof grantTemplate; queryParam?: string; queryValue?: string; documentType?: string; @@ -78,14 +76,7 @@ export default function OrganizationPage() { useEffect(() => { if (!selectedOrg) return; - if (isNewResearch) { - createNoteWithContent(selectedOrg.slug, { - template: getInitialContent('research'), - queryParam: 'newResearch', - queryValue: 'true', - documentType: 'DISCUSSION', - }); - } else if (isNewFunding) { + if (isNewFunding) { // "Upload a document" is handled inline in OpenProposalModal; here we // only create from template/blank. if (proposalSource === 'blank') { @@ -106,7 +97,7 @@ export default function OrganizationPage() { documentType: 'GRANT', }); } - }, [selectedOrg, isNewResearch, isNewFunding, isNewGrant, grantSource, proposalSource]); // eslint-disable-line react-hooks/exhaustive-deps + }, [selectedOrg, isNewFunding, isNewGrant, grantSource, proposalSource]); // eslint-disable-line react-hooks/exhaustive-deps const handleStartFromTemplate = async () => { if (!selectedOrg) return; diff --git a/components/Notebook/NoteEditorLayout.tsx b/components/Notebook/NoteEditorLayout.tsx index 584390016..ae7bed53b 100644 --- a/components/Notebook/NoteEditorLayout.tsx +++ b/components/Notebook/NoteEditorLayout.tsx @@ -33,7 +33,7 @@ const NOTEBOOK_TOUR_FEATURE = 'notebook_tour'; // Query params the note-creation flows append when redirecting to the editor. // Their presence means the user just created this note (vs. opening an existing // one), which is the only moment we want to auto-launch the tour. -const NEW_NOTE_PARAMS = ['newResearch', 'newGrant', 'newFunding', 'template']; +const NEW_NOTE_PARAMS = ['newGrant', 'newFunding', 'template']; // Friendly label for the note's work type, shown at the top-left of the doc. function getWorkTypeLabel( diff --git a/components/Notebook/NotebookHome.tsx b/components/Notebook/NotebookHome.tsx index 06a73d651..b0854f11d 100644 --- a/components/Notebook/NotebookHome.tsx +++ b/components/Notebook/NotebookHome.tsx @@ -64,13 +64,6 @@ export function NotebookHome() { icon: , onClick: () => setIsProposalModalOpen(true), }, - { - id: 'preprint', - title: 'Preprint', - description: 'Publish your research as a preprint', - icon: , - onClick: () => router.push('/notebook?newResearch=true'), - }, ]; const hasNotes = notes?.some( @@ -117,7 +110,7 @@ export function NotebookHome() { ) : (
- No files yet. Create a funding opportunity, proposal, or preprint to get started. + No files yet. Create a funding opportunity or proposal to get started.
)} diff --git a/components/Notebook/NotebookPrimaryNavigation.tsx b/components/Notebook/NotebookPrimaryNavigation.tsx index 513163d07..8c08796da 100644 --- a/components/Notebook/NotebookPrimaryNavigation.tsx +++ b/components/Notebook/NotebookPrimaryNavigation.tsx @@ -18,11 +18,6 @@ export const NOTEBOOK_WORK_TYPES = [ label: 'Proposal', description: 'Create a research proposal and optionally raise funding.', }, - { - value: 'discussion', - label: 'Preprint', - description: 'Share research findings or a manuscript.', - }, ] as const; type NotebookWorkType = (typeof NOTEBOOK_WORK_TYPES)[number]['value']; @@ -36,7 +31,6 @@ const SectionHeading = ({ children }: { children: React.ReactNode }) => ( interface NotebookPrimaryNavigationProps { onNewFundingOpportunity: () => void; onNewProposal: () => void; - onNewPreprint: () => void; onInvitePeople: () => void; } @@ -52,7 +46,6 @@ interface NotebookPrimaryNavigationProps { export const NotebookPrimaryNavigation = ({ onNewFundingOpportunity, onNewProposal, - onNewPreprint, onInvitePeople, }: NotebookPrimaryNavigationProps) => { const { selectedOrg } = useOrganizationContext(); @@ -72,10 +65,6 @@ export const NotebookPrimaryNavigation = ({ icon: , onClick: onNewProposal, }, - discussion: { - icon: , - onClick: onNewPreprint, - }, }; return ( diff --git a/components/Notebook/NotesMenu.tsx b/components/Notebook/NotesMenu.tsx index 4641b423c..e0e7e604d 100644 --- a/components/Notebook/NotesMenu.tsx +++ b/components/Notebook/NotesMenu.tsx @@ -91,11 +91,6 @@ export function NotesMenu() { setIsProposalModalOpen(true); }; - const handleNewPreprint = () => { - setIsOpen(false); - router.push('/notebook?newResearch=true'); - }; - const handleInvitePeople = () => { setIsOpen(false); setIsSettingsModalOpen(true); @@ -105,7 +100,6 @@ export function NotesMenu() { ); diff --git a/components/Notebook/PublishingForm/components/JournalSection.tsx b/components/Notebook/PublishingForm/components/JournalSection.tsx deleted file mode 100644 index ce785bed1..000000000 --- a/components/Notebook/PublishingForm/components/JournalSection.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { useFormContext } from 'react-hook-form'; -import { BookOpen, Check } from 'lucide-react'; -import { Switch } from '@/components/ui/Switch'; -import { SectionHeader } from './SectionHeader'; - -export function JournalSection() { - const { watch, setValue } = useFormContext(); - const isJournalEnabled = watch('isJournalEnabled'); - - return ( -
- ResearchHub Journal -
-
-
-
-
- Price: - $1,000 USD -
-
- setValue('isJournalEnabled', checked)} - /> -
-
    -
  • - - - Accredited journal publication with low APCs - -
  • -
  • - - Rapid decision (21 days) -
  • -
  • - - 3x paid Peer Reviews -
  • -
-
-
-
- ); -} diff --git a/components/Notebook/PublishingForm/index.tsx b/components/Notebook/PublishingForm/index.tsx index a13199d19..2e0c769bf 100644 --- a/components/Notebook/PublishingForm/index.tsx +++ b/components/Notebook/PublishingForm/index.tsx @@ -7,7 +7,6 @@ import { FundingSection } from './components/FundingSection'; import { AuthorsSection } from './components/AuthorsSection'; import { ContactsSection } from './components/ContactsSection'; import { TopicsSection } from './components/TopicsSection'; -import { JournalSection } from './components/JournalSection'; import { GrantDescriptionSection } from './components/GrantDescriptionSection'; import { GrantOrganizationSection } from './components/GrantOrganizationSection'; import { GrantFundingAmountSection } from './components/GrantFundingAmountSection'; @@ -55,7 +54,6 @@ import { NOTEBOOK_WORK_TYPES } from '@/components/Notebook/NotebookPrimaryNaviga const FEATURE_FLAG_RESEARCH_COIN = false; const DEFAULT_FUNDRAISE_END_DAYS = '60'; -const FEATURE_FLAG_JOURNAL = false; const PUBLISH_LABEL: Record = { preregistration: 'Proposal', @@ -66,7 +64,6 @@ const PUBLISH_LABEL: Record = { interface PublishingFormProps { bountyAmount?: number | null; onBountyClick?: () => void; - defaultArticleType?: string; readOnly?: boolean; } @@ -74,15 +71,11 @@ const getButtonText = ({ isLoadingUpsert, isRedirecting, isLinkingNonprofit, - articleType, - isJournalEnabled, hasWorkId, }: { isLoadingUpsert: boolean; isRedirecting: boolean; isLinkingNonprofit: boolean; - articleType: string; - isJournalEnabled: boolean; hasWorkId: boolean; }) => { switch (true) { @@ -94,8 +87,6 @@ const getButtonText = ({ return 'Redirecting...'; case hasWorkId: return 'Publish'; - case Boolean(FEATURE_FLAG_JOURNAL && articleType === 'discussion' && isJournalEnabled): - return 'Pay & Publish'; default: return 'Publish'; } @@ -107,7 +98,6 @@ const FORM_DEFAULTS = { topics: [], rewardFunders: false, nftSupply: '1000', - isJournalEnabled: false, budget: '', coverImage: null, selectedNonprofit: null, @@ -267,28 +257,15 @@ const autoAddCurrentUser = ( } }; -interface ArticleTypeResult { - type: PublishingFormData['articleType']; - source: 'searchParam' | 'template' | 'default'; -} - const resolveArticleType = ( - params: { get(key: string): string | null } | null, - defaultArticleType?: string -): ArticleTypeResult | null => { - if (params?.get('newFunding') === 'true') - return { type: 'preregistration', source: 'searchParam' }; - if (params?.get('newResearch') === 'true') return { type: 'discussion', source: 'searchParam' }; - if (params?.get('newGrant') === 'true') return { type: 'grant', source: 'searchParam' }; + params: { get(key: string): string | null } | null +): PublishingFormData['articleType'] | null => { + if (params?.get('newFunding') === 'true') return 'preregistration'; + if (params?.get('newGrant') === 'true') return 'grant'; const template = params?.get('template'); - if (template === 'preregistration') return { type: 'preregistration', source: 'template' }; - if (template === 'grant') return { type: 'grant', source: 'template' }; - if (template) return { type: 'discussion', source: 'template' }; - - if (defaultArticleType) { - return { type: defaultArticleType as PublishingFormData['articleType'], source: 'default' }; - } + if (template === 'preregistration') return 'preregistration'; + if (template === 'grant') return 'grant'; return null; }; @@ -303,7 +280,6 @@ const getRedirectPath = (articleType: string, responseId: string, slug: string): export function PublishingForm({ bountyAmount, onBountyClick, - defaultArticleType, readOnly = false, }: Readonly) { const { currentNote: note, editor } = useNotebookContext(); @@ -343,7 +319,7 @@ export function PublishingForm({ const articleType = storedData?.articleType ?? (note.documentType ? mapDocumentTypeToArticleType(note.documentType) : null) ?? - resolveArticleType(searchParams, defaultArticleType)?.type; + resolveArticleType(searchParams); if (articleType) { methods.setValue('articleType', articleType); @@ -385,7 +361,6 @@ export function PublishingForm({ const { watch, clearErrors } = methods; const articleType = watch('articleType'); - const isJournalEnabled = watch('isJournalEnabled'); const selectedNonprofit = watch('selectedNonprofit'); const [{ isLoading: isLoadingUpsert }, upsertPost] = useUpsertPost(); @@ -394,6 +369,7 @@ export function PublishingForm({ const router = useRouter(); const isDeclined = note?.post?.grant?.status === 'DECLINED'; + const isPreprint = articleType === 'discussion'; const isPublishing = isLoadingUpsert || isRedirecting || isLinkingNonprofit || isUploadingImage; const canPublishRegisteredReport = articleType !== 'registered_report' || currentUser?.isModerator === true; @@ -409,6 +385,11 @@ export function PublishingForm({ const handlePublishClick = async () => { if (readOnly) return; + if (isPreprint) { + toast.error('Preprints can no longer be created in the notebook.'); + return; + } + if (!canPublishRegisteredReport) { toast.error('Only moderators can publish Registered Reports.'); return; @@ -438,7 +419,6 @@ export function PublishingForm({ if ( articleType !== 'preregistration' && - articleType !== 'discussion' && articleType !== 'grant' && articleType !== 'registered_report' ) { @@ -510,6 +490,11 @@ export function PublishingForm({ const handleConfirmPublish = async (editedTitle: string) => { if (readOnly || !note) return; + if (articleType === 'discussion') { + toast.error('Preprints can no longer be created in the notebook.'); + return; + } + try { setDocumentTitle(editor, editedTitle); @@ -751,7 +736,6 @@ export function PublishingForm({ onBountyClick={onBountyClick ?? (() => {})} /> )} - {FEATURE_FLAG_JOURNAL && articleType === 'discussion' && } )} @@ -762,12 +746,6 @@ export function PublishingForm({ {articleType === 'preregistration' && !methods.watch('workId') && ( )} - {FEATURE_FLAG_JOURNAL && articleType === 'discussion' && isJournalEnabled && ( -
- Payment due: - $1,000 USD -
- )} {articleType === 'registered_report' && !canPublishRegisteredReport && (

Only moderators can publish Registered Reports. @@ -780,6 +758,7 @@ export function PublishingForm({ disabled={ !articleType || readOnly || + isPreprint || isPublishing || isDeclined || showPrivateWarning || @@ -792,8 +771,6 @@ export function PublishingForm({ isLoadingUpsert: isLoadingUpsert || isUploadingImage, isRedirecting, isLinkingNonprofit, - articleType, - isJournalEnabled: isJournalEnabled ?? false, hasWorkId: Boolean(methods.watch('workId')), })} diff --git a/components/Notebook/PublishingForm/schema.ts b/components/Notebook/PublishingForm/schema.ts index 0d5962443..3bacdc33f 100644 --- a/components/Notebook/PublishingForm/schema.ts +++ b/components/Notebook/PublishingForm/schema.ts @@ -58,7 +58,6 @@ export const publishingFormSchema = z }) .nullable() .optional(), - isJournalEnabled: z.boolean().optional(), selectedNonprofit: z.any().nullable().optional(), selectedGrant: z.any().nullable().optional(), departmentLabName: z.string().optional(),