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

Refactored and improved seeds #8695

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Refactored and improved seeds #8695

wants to merge 4 commits into from

Conversation

lucasbordeau
Copy link
Contributor

  • Added all field types on Company seeds
  • Added a new Seeder service to help with custom objects
  • Added RichTextFieldInput to edit a rich text field directly on the table.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR adds comprehensive seeding functionality and rich text field support across the application, including new demo data and field types for testing.

  • Added RichTextFieldInput with BlockNote editor integration for inline rich text editing in tables
  • Introduced new SeederService with support for custom objects, composite fields, and improved data seeding capabilities
  • Added 10 new demo field types to Company seeds (UUID, RichText, Array, Rating, etc.) with corresponding metadata and views
  • Added new seed data files for pets and survey results with 100 records each for testing
  • Fixed color naming consistency from 'grey' to 'gray' across multiple theme and UI files

51 file(s) reviewed, 36 comment(s)
Edit PR Review Bot Settings | Greptile

@@ -156,7 +156,7 @@ export const FieldInput = ({
onShiftTab={onShiftTab}
/>
) : isFieldRichText(fieldDefinition) ? (
<RichTextFieldInput />
<RichTextFieldInput onClickOutside={onClickOutside} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: RichTextFieldInput is missing onEnter, onEscape, onTab, and onShiftTab handlers that most other field types have

const persistField = usePersistField();

const persistRichTextField = (nextValue: PartialBlock[]) => {
if (!nextValue) persistField(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Missing return after setting null - could cause undefined behavior by continuing execution

Comment on lines +42 to +44
const draftValueParsed: PartialBlock[] = isNonEmptyString(draftValue)
? JSON.parse(draftValue)
: draftValue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: JSON.parse could throw if draftValue is malformed JSON - needs try/catch

fieldName: fieldName,
}),
);
const fieldRichTextValue = isFieldRichTextValue(fieldValue) ? fieldValue : '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Empty string fallback may not be appropriate for all rich text use cases - consider null or empty block array

fieldName,
);

const fieldValueParsed = parseJson<PartialBlock[]>(fieldValue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: parseJson could return undefined/null - need to handle this case explicitly to avoid runtime errors when using fieldValueParsed

Comment on lines +155 to +167
await this.seederService.seedCustomObjects(
dataSourceMetadata.id,
workspaceId,
PETS_METADATA_SEEDS,
PETS_DATA_SEEDS,
);

await this.seederService.seedCustomObjects(
dataSourceMetadata.id,
workspaceId,
SURVEY_RESULTS_METADATA_SEEDS,
SURVEY_RESULTS_DATA_SEEDS,
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: These sequential seeding operations could fail independently. Consider wrapping them in a transaction or adding error handling to ensure partial seeding doesn't leave the workspace in an inconsistent state.

Comment on lines +334 to +335
@WorkspaceIsNullable()
demoRichText: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: demoRichText should be typed as FieldRichTextValue or string[] instead of string to match the RichText field type

Comment on lines +463 to +464
@WorkspaceIsNullable()
demoRawJSON: JSON | null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: demoRawJSON should be typed as Record<string, unknown> | null instead of JSON | null for better type safety

Comment on lines +32 to +35
if (!isDefined(themeColor)) {
console.warn(`Tag color ${color} is not defined in the theme`);
return theme.tag.background.gray;
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider throwing an error instead of silently falling back to gray, since an undefined theme color likely indicates a bug that should be fixed

Comment on lines +133 to 135
) : (
<></>
)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Empty fragment is unnecessary here since the ternary could just return null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant