From 0635898283292adcaf3858fc3d390a345f00a4ce Mon Sep 17 00:00:00 2001 From: Matt Casey Date: Mon, 21 Oct 2024 14:08:38 -0600 Subject: [PATCH] show op profile if you are not the author (#4862) * show op profile if you are not the author * fix types --- components/[pageId]/DocumentPage/DocumentPage.tsx | 1 + components/common/form/FormFieldAnswers.tsx | 4 +++- stories/FormFields/FormFields.stories.tsx | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/components/[pageId]/DocumentPage/DocumentPage.tsx b/components/[pageId]/DocumentPage/DocumentPage.tsx index 7773ec540f..a0da68b554 100644 --- a/components/[pageId]/DocumentPage/DocumentPage.tsx +++ b/components/[pageId]/DocumentPage/DocumentPage.tsx @@ -519,6 +519,7 @@ function DocumentPageComponent({ getFieldState={getFieldState} onSave={onSave} pageId={page.id} + isAuthor={proposalAuthors.includes(user?.id || '')} threads={threads} // This is required to reinstate the form field state after the proposal is published, necessary to show the correct project id key={proposal?.status === 'draft' ? 'draft' : 'published'} diff --git a/components/common/form/FormFieldAnswers.tsx b/components/common/form/FormFieldAnswers.tsx index 0c28b218c0..99bb57d146 100644 --- a/components/common/form/FormFieldAnswers.tsx +++ b/components/common/form/FormFieldAnswers.tsx @@ -51,6 +51,7 @@ type FormFieldAnswersProps = { values?: Record; pageId?: string; isDraft?: boolean; + isAuthor: boolean; threads?: Record; projectId?: string | null; proposalId: string; @@ -71,6 +72,7 @@ export function FormFieldAnswers({ onSave, formFields, disabled, + isAuthor, enableComments, getFieldState, control, @@ -233,7 +235,7 @@ export function FormFieldAnswers({ ) } description={formField.description as PageContent} - disabled={disabled} + disabled={disabled || (!isAuthor && formField.type === 'optimism_project_profile')} type={formField.type === 'short_text' ? 'text_multiline' : formField.type} label={formField.name} options={formField.options as SelectOptionType[]} diff --git a/stories/FormFields/FormFields.stories.tsx b/stories/FormFields/FormFields.stories.tsx index c8d36ee362..8402f0c69e 100644 --- a/stories/FormFields/FormFields.stories.tsx +++ b/stories/FormFields/FormFields.stories.tsx @@ -84,6 +84,7 @@ export function FormFieldsInputs() { {}} @@ -172,6 +173,7 @@ export function FormFieldsInputsDisplay() { {}}