Skip to content

Commit

Permalink
Make applied filters persist when navigating to catalog directories (#…
Browse files Browse the repository at this point in the history
…25746)

## Summary & Motivation
As titled

## How I Tested These Changes
I clicked on a folder link and saw the filters persist to the new page

## Changelog
[ui] Filters in the asset catalog now persist when navigating
subdirectories.
  • Loading branch information
salazarm authored Nov 5, 2024
1 parent 69cec63 commit 367d240
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,25 @@ export function filterAssetDefinition(
return true;
}

const KEYS: Record<keyof AssetFilterType, '1'> = {
groups: '1',
kinds: '1',
changedInBranch: '1',
owners: '1',
tags: '1',
codeLocations: '1',
selectAllFilters: '1',
};
export function getAssetFilterStateQueryString() {
const params = new URLSearchParams(location.search);
return Object.keys(KEYS).reduce((soFar, key) => {
if (params.get(key)) {
return soFar + `&${key}=${params.get(key)}`;
}
return soFar;
}, '');
}

function lowerCaseOwner(owner: AssetOwner) {
if (owner.__typename === 'TeamAssetOwner') {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Box, Caption, Checkbox, Colors, Icon, Skeleton} from '@dagster-io/ui-components';
import * as React from 'react';
import {Link} from 'react-router-dom';
import {getAssetFilterStateQueryString} from 'shared/assets/useAssetDefinitionFilterState.oss';
import styled from 'styled-components';

import {RepoAddress} from './types';
Expand Down Expand Up @@ -67,13 +68,18 @@ export const VirtualizedAssetRow = (props: AssetRowProps) => {
} = props;

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

if (type === 'folder') {
// Forward filters
linkUrl += getAssetFilterStateQueryString();
}

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

1 comment on commit 367d240

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-26l8bqwio-elementl.vercel.app

Built with commit 367d240.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.