-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Implement object fields and settings new layout #7979
Conversation
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.
PR Summary
This pull request implements a new layout for object details settings, focusing on custom object renaming and synchronization between labels and API names. Here are the key changes:
- Added a new 'shouldSyncLabelAndName' field to object metadata, enabling label and API name synchronization
- Implemented auto-saving functionality in the 'Settings' tab of object details
- Created new components for object fields, indexes, and settings tabs
- Introduced a SyncObjectLabelAndNameToggle component for managing label and API name synchronization
- Updated validation schemas to support new fields and synchronization logic
- Removed the old SettingsObjectEdit component and related stories
The changes align with the requirements outlined in issue #5491, providing more flexibility in object renaming and API name management.
30 file(s) reviewed, 20 comment(s)
Edit PR Review Bot Settings | Greptile
@@ -26,4 +26,5 @@ export const objectMetadataItemSchema = z.object({ | |||
namePlural: camelCaseStringSchema, | |||
nameSingular: camelCaseStringSchema, | |||
updatedAt: z.string().datetime(), | |||
shouldSyncLabelAndName: z.boolean(), | |||
}) satisfies z.ZodType<ObjectMetadataItem>; |
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.
style: consider adding a default value for shouldSyncLabelAndName
}) satisfies z.ZodType<ObjectMetadataItem>; | |
shouldSyncLabelAndName: z.boolean().default(false), |
const StyledSettingsPageContainer = styled.div<{ | ||
width?: number; | ||
removeLeftPadding?: boolean; | ||
}>` |
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.
style: Consider using a more descriptive name for the removeLeftPadding
prop, such as noLeftPadding
or leftPaddingDisabled
const StyledSettingsPageContainer = styled.div<{ | |
width?: number; | |
removeLeftPadding?: boolean; | |
}>` | |
const StyledSettingsPageContainer = styled.div<{ | |
width?: number; | |
noLeftPadding?: boolean; | |
}>` |
& { | ||
${({ removeLeftPadding }) => removeLeftPadding && `padding-left: 0;`} | ||
} |
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.
style: Using &
selector here is unnecessary. Consider removing it for cleaner CSS
& { | |
${({ removeLeftPadding }) => removeLeftPadding && `padding-left: 0;`} | |
} | |
${({ removeLeftPadding }) => removeLeftPadding && `padding-left: 0;`} |
export const ObjectFields = ({ objectMetadataItem }: ObjectFieldsProps) => { | ||
const shouldDisplayAddFieldButton = !objectMetadataItem.isRemote; |
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.
style: Consider adding a comment explaining the isRemote property and its implications
export const ObjectFields = ({ objectMetadataItem }: ObjectFieldsProps) => { | |
const shouldDisplayAddFieldButton = !objectMetadataItem.isRemote; | |
// The isRemote property indicates whether the object is remote or local. If it is remote, the add field button should not be displayed. |
<SettingsObjectFieldTable | ||
objectMetadataItem={objectMetadataItem} | ||
mode="view" | ||
/> |
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.
logic: Ensure SettingsObjectFieldTable component is updated to handle auto-saving functionality
<SettingsObjectFieldTable | |
objectMetadataItem={objectMetadataItem} | |
mode="view" | |
/> | |
// Ensure that the SettingsObjectFieldTable component is updated to handle auto-saving functionality. |
const [updatedObjectSlug, setUpdatedObjectSlug] = useRecoilState( | ||
updatedObjectSlugState, | ||
); |
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.
style: Consider using a more descriptive name for this state, such as 'updatedObjectSlugState'
const [updatedObjectSlug, setUpdatedObjectSlug] = useRecoilState( | |
updatedObjectSlugState, | |
); | |
const [currentUpdatedObjectSlug, setCurrentUpdatedObjectSlug] = useRecoilState( | |
updatedObjectSlugState, | |
); |
activeObjectMetadataItem || | ||
(updatedActiveObjectMetadataItem as ObjectMetadataItem) |
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.
style: Type assertion might be unnecessary if types are properly inferred
activeObjectMetadataItem || | |
(updatedActiveObjectMetadataItem as ObjectMetadataItem) | |
// Remove type assertion if types are properly inferred | |
activeObjectMetadataItem || updatedActiveObjectMetadataItem |
const isAdvancedModeEnabled = useRecoilValue(isAdvancedModeEnabledState); | ||
|
||
const isUniqueIndexesEnabled = useIsFeatureEnabled( | ||
'IS_UNIQUE_INDEXES_ENABLED', | ||
); |
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.
style: Consider memoizing this value to prevent unnecessary re-renders
const isAdvancedModeEnabled = useRecoilValue(isAdvancedModeEnabledState); | |
const isUniqueIndexesEnabled = useIsFeatureEnabled( | |
'IS_UNIQUE_INDEXES_ENABLED', | |
); | |
const isAdvancedModeEnabled = useRecoilValue(isAdvancedModeEnabledState); | |
const isUniqueIndexesEnabled = useRecoilValue(useIsFeatureEnabled('IS_UNIQUE_INDEXES_ENABLED')); |
const renderActiveTabContent = () => { | ||
switch (activeTabId) { | ||
case 'fields': | ||
return <ObjectFields objectMetadataItem={objectMetadataItem} />; | ||
case 'settings': | ||
return <ObjectSettings objectMetadataItem={objectMetadataItem} />; | ||
case 'indexes': | ||
return <ObjectIndexes objectMetadataItem={objectMetadataItem} />; | ||
default: | ||
return <></>; | ||
} | ||
}; |
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.
style: Consider extracting this switch statement into a separate function or using a mapping object for better maintainability
const renderActiveTabContent = () => { | |
switch (activeTabId) { | |
case 'fields': | |
return <ObjectFields objectMetadataItem={objectMetadataItem} />; | |
case 'settings': | |
return <ObjectSettings objectMetadataItem={objectMetadataItem} />; | |
case 'indexes': | |
return <ObjectIndexes objectMetadataItem={objectMetadataItem} />; | |
default: | |
return <></>; | |
} | |
}; | |
const renderActiveTabContent = () => { | |
const tabContentMap = { | |
fields: <ObjectFields objectMetadataItem={objectMetadataItem} />, | |
settings: <ObjectSettings objectMetadataItem={objectMetadataItem} />, | |
indexes: <ObjectIndexes objectMetadataItem={objectMetadataItem} />, | |
}; | |
return tabContentMap[activeTabId] || <></>; | |
}; |
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.
logic: Entire file has been removed. Ensure the object editing functionality has been properly relocated or replaced elsewhere.
Hi @gitstart-twenty thanks for your work, we will wait for https://github.com/twentyhq/twenty/pull/7504/files to be merged before resuming the work here! |
ok, thank you @ijreilly |
c2e1667
to
6ba2970
Compare
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.
LGTM!
Btw, does not seem to be related to your change but the sort on the "isUnique" (the key icon in the table header) is broken
}, | ||
]} | ||
actionButton={ | ||
activeTabId === 'fields' && ( |
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.
activeTabId === 'fields' && ( | |
activeTabId === FIELDS_TAB_ID && ( |
FixesLayoutMargins should match those on other pages. The spacing between the title and the tab switcher should be 32px. CleanShot.2024-10-29.at.17.39.29.mp4Card designCurrentDesired
Advanced mode markSpacing should be 8px with content (-23px?) Title headerChange the description margin-top to 8px (instead of 12px) Fields HelperCurrentDesiredURLStore the tab in the URL with an |
Fixing ![image](https://github.com/user-attachments/assets/794968c2-1d13-49f2-9367-e93285a7d10f) Note - this page design be updated in the next release (#7979)
One last thing The title padding-top is 24px instead of 32px (like other pages) And I have no more advanced mode yellow border: I have a small unexpected horizontal scroll: CleanShot.2024-11-05.at.10.48.35.mp4Make description margin-top 4px instead of 8px: |
Log
|
Follow-up of #7979 Navigation between settings and fields tabs is now reflected in URL. <img width="1106" alt="Capture d’écran 2024-11-07 à 18 38 57" src="https://github.com/user-attachments/assets/24b153ef-9e68-4aa2-8e3a-6bf70834c5ad"> --------- Co-authored-by: gitstart-twenty <[email protected]> Co-authored-by: gitstart-twenty <[email protected]> Co-authored-by: Weiko <[email protected]> Co-authored-by: Charles Bochet <[email protected]>
Description
Settings
tab of object detailDemo\
https://www.loom.com/share/4198c0aa54b5450780a570ceee574838?sid=b4ef0a42-2d41-435f-9f5f-1b16816939f7
Refs
#TWNTY-5491