Fix workspace deletion broken (#14188)
Workspace deletion was broken because workspace schema deletion should be "CASCADE". Otherwise postgres will refuse to remove a schema with existing tables Also, user experience on delete was degraded because of redirect race condition: - we were redirecting to /welcome on deletion - also redirecting to /settings/profile as the system detects missingPermissionFlag I'm disabling permission check if the user is not logged in as it does not makes sense. I don't think this is a big issue but we will likely revisit this later if we face race condition between Permission checks redirect and PageChangeEffect. This could also be migrated fairly easily to PageChangeEffect where we make sure that we only redirect once
This commit is contained in:
+9
@@ -1,3 +1,4 @@
|
||||
import { useIsLogged } from '@/auth/hooks/useIsLogged';
|
||||
import { useHasPermissionFlag } from '@/settings/roles/hooks/useHasPermissionFlag';
|
||||
import { SettingsPath } from '@/types/SettingsPath';
|
||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
||||
@@ -20,11 +21,19 @@ export const SettingsProtectedRouteWrapper = ({
|
||||
settingsPermission,
|
||||
requiredFeatureFlag,
|
||||
}: SettingsProtectedRouteWrapperProps) => {
|
||||
const isLoggedIn = useIsLogged();
|
||||
const hasPermission = useHasPermissionFlag(settingsPermission);
|
||||
const requiredFeatureFlagEnabled = useIsFeatureEnabled(
|
||||
requiredFeatureFlag || null,
|
||||
);
|
||||
|
||||
if (!isLoggedIn) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO: this should be part of PageChangeEffect as otherwise we will have multiple sources of redirection that can:
|
||||
// - conflict (race conditions)
|
||||
// - degrade performance as we will redirect multiple times
|
||||
if ((requiredFeatureFlag && !requiredFeatureFlagEnabled) || !hasPermission) {
|
||||
return <Navigate to={getSettingsPath(SettingsPath.ProfilePage)} replace />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user