-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fix related pubs bug #1017
Fix related pubs bug #1017
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { randomUUID } from "crypto"; | ||
|
||
import type { ProcessedPub } from "contracts"; | ||
import type { CommunitiesId, PubFieldsId, PubsId, PubTypesId, StagesId } from "db/public"; | ||
import type { CommunitiesId, PubsId, PubTypesId, StagesId } from "db/public"; | ||
import { CoreSchemaType } from "db/public"; | ||
import { expect } from "utils"; | ||
|
||
import type { FormElements, PubFieldElement } from "../../forms/types"; | ||
|
@@ -44,8 +45,10 @@ const RelatedPubValueElement = ({ | |
<p className="text-sm"> | ||
You are creating a Pub related to{" "} | ||
<span className="font-semibold">{getPubTitle(relatedPub)}</span> through the{" "} | ||
<span className="font-semibold">{fieldName}</span> pub field. Please enter a | ||
value for this relationship. | ||
<span className="font-semibold">{fieldName}</span> pub field. | ||
{element.schemaName !== CoreSchemaType.Null && ( | ||
<span>Please enter a value for this relationship.</span> | ||
)} | ||
Comment on lines
+49
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just noticed it was still saying to fill out a field if the schema was null (and then it wouldn't render an input to fill out) |
||
</p> | ||
<PubFieldFormElement | ||
label={label} | ||
|
@@ -269,12 +272,17 @@ export async function PubEditor(props: PubEditorProps) { | |
const currentStageId = pub?.stage?.id ?? ("stageId" in props ? props.stageId : undefined); | ||
const pubForForm = pub ?? { id: pubId, values: [], pubTypeId: form.pubTypeId }; | ||
|
||
// For the Context, we want both the pubs from the initial pub query (which is limited) | ||
// as well as the pubs related to this pub | ||
const relatedPubs = pub ? pub.values.flatMap((v) => (v.relatedPub ? [v.relatedPub] : [])) : []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL: you can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. very hot tip, the .filter typing is so annoying! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think they did fix this in a recent release, if you do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh no nvm, this only applies one level deep! they fixed the "simple" case in typescript 5.5 https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#inferred-type-predicates Example (change to typescript <5.5 to see error in the simple case) |
||
const pubsForContext = [...pubs, ...relatedPubs]; | ||
|
||
return ( | ||
<FormElementToggleProvider fieldSlugs={allSlugs}> | ||
<ContextEditorContextProvider | ||
pubId={pubId} | ||
pubTypeId={pubType.id} | ||
pubs={pubs} | ||
pubs={pubsForContext} | ||
pubTypes={pubTypes} | ||
> | ||
<PubEditorWrapper | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this originally came from #980 but it seems like just the
flex-1
is enough to keep the width. addingprose
changes a bunch of styles, including making<hr/>
s have huge marginsprose
is used for markdown, but I believe the various markdown places already haveprose
on them, i.e.StructuralElement
platform/core/app/components/FormBuilder/FormElement.tsx
Line 167 in 0711707