-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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]: Redirect to NOT_FOUND
page when landing on unactive
Object model
#10461
base: main
Are you sure you want to change the base?
Conversation
Welcome!
Hello there, congrats on your first PR! We're excited to have you contributing to this project. |
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
Added a check in RecordIndexPage to prevent access to disabled object views, redirecting users to NotFound page when attempting to access inactive objects.
- Reordered conditions in
/packages/twenty-front/src/pages/object-record/RecordIndexPage.tsx
to checkobjectMetadataItem?.isActive
after ensuringobjectMetadataItem
is defined to prevent potential undefined behavior - Added navigation to NotFound page when
isActive
is false, addressing issue I shouldn't be redirected to Companies when I've disabled Companies object #10064 where users could access disabled company views - Consider adding a loading state between the undefined check and active check to prevent flash of content
💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!
1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
if (!objectMetadataItem?.isActive) { | ||
navigateApp(AppPath.NotFound); | ||
} |
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: Missing return statement after navigation - component will continue executing
if (!objectMetadataItem?.isActive) { | |
navigateApp(AppPath.NotFound); | |
} | |
if (!objectMetadataItem?.isActive) { | |
navigateApp(AppPath.NotFound); | |
return null; | |
} |
NOT_FOUND
page when landing on unactive
Object model
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.
Hello @Paribesh01, thanks for your contribution. You got the main idea !
Left a request regarding some implementation detail
Note: That would be overkill but when entering settings from the company record table page and deactivating the companies, by leaving settings it will redirect to companies page which will redirect to 404. Not a huge plus value here as object model activation and deactivation is IMO not recurrent nor critical
@@ -17,6 +20,11 @@ export const RecordIndexPage = () => { | |||
'main-context-store', | |||
); | |||
|
|||
if (!objectMetadataItem?.isActive) { |
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.
Remark: Combining optional chaining and bang operator is IMO not very readable.
Here this block will entered if objectMetadataItem
is undefined
and if isActive
is falsy
Also this bypass below if
block that will now never occurs anymore ( changing component behavior )
if (!objectMetadataItem.isActive) {
navigateApp(AppPath.NotFound);
return null;
}
if (
// First assertion is `never`
isUndefined(objectMetadataItem) ||
// Nitpick: might wanna use isUndefined and isEmptyString instead 🤔
// Should determine if we want a redirection here
!isNonEmptyString(contextStoreCurrentViewId)
) {
return null;
}
@prastoin rather then redirecting to 404 page we can so message like "This company has been deactivated" in the page. |
Yep asked product about the expect behavior here in the related issue #10064 (comment) |
fix: #10064