Skip to content

Commit

Permalink
Fix navigating to folders in asset catalog (#22764)
Browse files Browse the repository at this point in the history
## Summary & Motivation

#22589 broke the behavior for
navigating to folders within the asset catalog. Previously on an
`AssetNotFoundError` we would assume the path was a folder and render
the asset catalog with that path set, after that PR we would instead
always redirect to the root of the catalog. After this PR we instead
redirect to the catalog at that current path

## How I Tested These Changes

tests locally with app proxy
  • Loading branch information
salazarm authored and alangenfeld committed Jun 28, 2024
1 parent 7c297a4 commit 939cb25
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ export const AssetView = ({

if (definitionQueryResult.data?.assetOrError.__typename === 'AssetNotFoundError') {
// Redirect to the asset catalog
return <Redirect to="/assets" />;
return <Redirect to={`/assets/${currentPath.join('/')}?view=folder`} />;
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import {AssetGlobalLineageLink, AssetPageHeader} from './AssetPageHeader';
import {AssetView} from './AssetView';
import {AssetsCatalogTable} from './AssetsCatalogTable';
import {assetDetailsPathForKey} from './assetDetailsPathForKey';
import {AssetKey} from './types';
import {AssetKey, AssetViewParams} from './types';
import {useTrackPageView} from '../app/analytics';
import {displayNameForAssetKey} from '../asset-graph/Utils';
import {useDocumentTitle} from '../hooks/useDocumentTitle';
import {useQueryPersistedState} from '../hooks/useQueryPersistedState';
import {usePageLoadTrace} from '../performance';
import {ReloadAllButton} from '../workspace/ReloadAllButton';

Expand All @@ -28,6 +29,7 @@ export const AssetsOverviewRoot = ({
useTrackPageView();

const params = useParams();
const [searchParams] = useQueryPersistedState<AssetViewParams>({});
const history = useHistory();

const currentPathStr = (params as any)['0'];
Expand All @@ -51,7 +53,7 @@ export const AssetsOverviewRoot = ({
currentPath && currentPath.length === 0 ? 'AssetsOverviewRoot' : 'AssetCatalogAssetView',
);

if (currentPath.length === 0) {
if (currentPath.length === 0 || searchParams.view === 'folder') {
return (
<Box flex={{direction: 'column'}} style={{height: '100%', overflow: 'hidden'}}>
<AssetPageHeader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ export const VirtualizedAssetRow = (props: AssetRowProps) => {
} = props;

const liveData = useLiveDataOrLatestMaterializationDebounced(path, type);
const linkUrl = assetDetailsPathForKey({path});
const linkUrl = assetDetailsPathForKey(
{path},
{
view: type === 'folder' ? 'folder' : undefined,
},
);

const onChange = (e: React.FormEvent<HTMLInputElement>) => {
if (onToggleChecked && e.target instanceof HTMLInputElement) {
Expand Down

0 comments on commit 939cb25

Please sign in to comment.