Skip to content

Commit

Permalink
fix(React): fixing format we propogate filters to graphql in
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe-lyons committed Mar 2, 2021
1 parent 83cd89a commit 28bb039
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
6 changes: 1 addition & 5 deletions datahub-web-react/src/Mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,7 @@ export const mocks = [
filters: [
{
field: 'platform',
value: 'kafka',
},
{
field: 'platform',
value: 'hdfs',
value: 'kafka,hdfs',
},
],
},
Expand Down
1 change: 0 additions & 1 deletion datahub-web-react/src/app/entity/dataset/DatasetEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export class DatasetEntity implements Entity<Dataset> {
renderProfile = (urn: string) => <Profile urn={urn} />;

renderPreview = (_: PreviewType, data: Dataset) => {
console.log(data);
return (
<Preview
urn={data.urn}
Expand Down
3 changes: 2 additions & 1 deletion datahub-web-react/src/app/search/EntitySearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { IconStyleType } from '../entity/Entity';
import { Message } from '../shared/Message';
import { useEntityRegistry } from '../useEntityRegistry';
import { SearchFilters } from './SearchFilters';
import { filtersToGraphqlParams } from './utils/filtersToGraphqlParams';

const styles = {
loading: { marginTop: '10%' },
Expand Down Expand Up @@ -44,7 +45,7 @@ export const EntitySearchResults = ({ type, query, page, filters, onChangeFilter
query,
start: (page - 1) * SearchCfg.RESULTS_PER_PAGE,
count: SearchCfg.RESULTS_PER_PAGE,
filters,
filters: filtersToGraphqlParams(filters),
},
},
});
Expand Down
10 changes: 10 additions & 0 deletions datahub-web-react/src/app/search/utils/filtersToGraphqlParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { FacetFilterInput } from '../../../types.generated';

export function filtersToGraphqlParams(filters: Array<FacetFilterInput>): Array<FacetFilterInput> {
return Object.entries(
filters.reduce((acc, filter) => {
acc[filter.field] = [...(acc[filter.field] || []), filter.value];
return acc;
}, {} as Record<string, string[]>),
).map(([field, values]) => ({ field, value: values.join(',') } as FacetFilterInput));
}

0 comments on commit 28bb039

Please sign in to comment.