Add schema name display in Settings Admin Workspace#15151
Conversation
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
This PR adds a schema name display feature to the Settings Admin Workspace panel. It introduces a new utility function getWorkspaceSchemaName that generates database schema names by prefixing "workspace_" to a base36-encoded workspace UUID. The main change adds this schema name as a new field in the workspace information display, providing administrators with visibility into the underlying database schema names associated with each workspace.
The implementation follows the existing pattern in the admin panel by adding a new entry to the workspaceInfoItems array, complete with an appropriate icon (IconId) and translatable label. This change integrates seamlessly with the existing workspace information display structure and maintains consistency with the current UI patterns.
Important Files Changed
Changed Files
| Filename | Score | Overview |
|---|---|---|
| packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceContent.tsx | 2/5 | Added schema name field to workspace info display with unsafe non-null assertion |
| packages/twenty-front/src/modules/settings/admin-panel/utils/get-workspace-schema-name.util.ts | 4/5 | New utility function to generate workspace schema names using base36 UUID encoding |
Confidence score: 2/5
- This PR requires careful review due to a critical null safety issue that could cause runtime errors
- Score lowered due to unsafe non-null assertion operator usage on
activeWorkspace?.id!which could throw if the workspace ID is undefined, and potential dependency on unvalidated external utility function - Pay close attention to SettingsAdminWorkspaceContent.tsx for the null assertion issue that needs proper error handling
Sequence Diagram
sequenceDiagram
participant User
participant SettingsAdminWorkspaceContent
participant getWorkspaceSchemaName
participant uuidToBase36
participant SettingsAdminTableCard
User->>SettingsAdminWorkspaceContent: "Views workspace admin panel"
SettingsAdminWorkspaceContent->>SettingsAdminWorkspaceContent: "Creates workspaceInfoItems array"
SettingsAdminWorkspaceContent->>getWorkspaceSchemaName: "getWorkspaceSchemaName(activeWorkspace.id)"
getWorkspaceSchemaName->>uuidToBase36: "uuidToBase36(workspaceId)"
uuidToBase36-->>getWorkspaceSchemaName: "Returns base36 encoded UUID"
getWorkspaceSchemaName-->>SettingsAdminWorkspaceContent: "Returns 'workspace_{base36_id}'"
SettingsAdminWorkspaceContent->>SettingsAdminTableCard: "Renders workspace info including schema name"
SettingsAdminTableCard-->>User: "Displays workspace information with schema name"
Context used:
- Context from
dashboard- Ensure that type assertions are safe and consider using type guards instead of direct assertions. (source)
2 files reviewed, 2 comments
| { | ||
| Icon: IconId, | ||
| label: t`Schema name`, | ||
| value: getWorkspaceSchemaName(activeWorkspace?.id!), |
There was a problem hiding this comment.
logic: Using non-null assertion (!) on activeWorkspace?.id could cause runtime error if workspace ID is undefined. Consider adding null check or default value.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceContent.tsx
Line: 172:172
Comment:
**logic:** Using non-null assertion (!) on activeWorkspace?.id could cause runtime error if workspace ID is undefined. Consider adding null check or default value.
How can I resolve this? If you propose a fix, please make it concise.| value: activeWorkspace?.id, | ||
| }, | ||
| { | ||
| Icon: IconId, |
There was a problem hiding this comment.
style: Same Icon (IconId) used for both ID and Schema name rows - consider using a different icon for schema name to improve visual distinction.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceContent.tsx
Line: 170:170
Comment:
**style:** Same Icon (IconId) used for both ID and Schema name rows - consider using a different icon for schema name to improve visual distinction.
How can I resolve this? If you propose a fix, please make it concise.| { | ||
| Icon: IconId, | ||
| label: t`Schema name`, | ||
| value: getWorkspaceSchemaName(activeWorkspace?.id!), |
There was a problem hiding this comment.
Potential bug: The component crashes if activeWorkspace is undefined because getWorkspaceSchemaName(activeWorkspace?.id!) is called before the null check, causing a TypeError.
-
Description: When an admin searches for a user with no workspaces, the
activeWorkspacevariable isundefined. TheSettingsAdminWorkspaceContentcomponent proceeds to defineworkspaceInfoItemsbefore its null check foractiveWorkspace. The linevalue: getWorkspaceSchemaName(activeWorkspace?.id!)uses a non-null assertion!on what becomes anundefinedvalue. Thisundefinedis passed togetWorkspaceSchemaNameand then touuidToBase36, which attempts to call.replace()on it. This results in aTypeError, causing a runtime crash in the admin panel. -
Suggested fix: Move the null check
if (!activeWorkspace) return null;to be before theworkspaceInfoItemsarray is defined. This will ensure the component exits early whenactiveWorkspaceis not available, preventing the crash.
severity: 0.65, confidence: 0.95
Did we get this right? 👍 / 👎 to inform future reviews.
|
🚀 Preview Environment Ready! Your preview environment is available at: http://bore.pub:24488 This environment will automatically shut down when the PR is closed or after 5 hours. |
|
Thanks @neo773 for your contribution! |

No description provided.