-
Notifications
You must be signed in to change notification settings - Fork 0
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
useResourceSearchParams
and export AvailableFacets component
#78
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1acc0dc
simplify search param hooks
ChristopherChudzicki 80305f9
export AvailableFacets
ChristopherChudzicki b956622
enzyme drives me nuts
ChristopherChudzicki 24bc27f
remove generated client
ChristopherChudzicki baafa59
do not use index as key
ChristopherChudzicki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
import { Config } from "@jest/types"; | ||
import { Config } from "@jest/types" | ||
|
||
const common = { | ||
testEnvironment: "jsdom", | ||
transform: { | ||
transform: { | ||
"^.+\\.(t)sx?$": "@swc/jest", | ||
}, | ||
setupFilesAfterEnv: ["<rootDir>src/test_setup.ts"], | ||
testMatch: ["<rootDir>/src/**/*.(spec|test).ts?(x)"], | ||
}; | ||
testMatch: ["<rootDir>/src/**/*.(spec|test).ts?(x)"], | ||
} | ||
|
||
const config: Config.InitialOptions = { | ||
projects: [ | ||
{ | ||
displayName: "history-v4", | ||
displayName: "history-v4", | ||
moduleNameMapper: { | ||
history$: "history-v4", | ||
}, | ||
...common, | ||
}, | ||
{ | ||
displayName: "history-v5", | ||
displayName: "history-v5", | ||
moduleNameMapper: { | ||
history$: "history", | ||
}, | ||
...common, | ||
}, | ||
], | ||
}; | ||
} | ||
|
||
export default config; | ||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ import { LEVELS, DEPARTMENTS } from "../constants" | |
|
||
export type BucketWithLabel = Bucket & { label: string } | ||
|
||
interface Props { | ||
interface FacetDisplayProps { | ||
facetMap: FacetManifest | ||
facetOptions: (group: string) => Aggregation | null | ||
activeFacets: Facets | ||
|
@@ -47,8 +47,53 @@ const resultsWithLabels = ( | |
return newResults | ||
} | ||
|
||
const AvailableFacets: React.FC<Omit<FacetDisplayProps, "clearAllFilters">> = ({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In MIT Open, we do not want (2). Since (1) is simple, it can be implemented easily in MIT Open. But (3) is worth exporting on its own. |
||
facetMap, | ||
facetOptions, | ||
activeFacets, | ||
onFacetChange | ||
}) => { | ||
return ( | ||
<> | ||
{facetMap.map(facetSetting => | ||
facetSetting.useFilterableFacet ? ( | ||
<FilterableFacet | ||
key={facetSetting.name} | ||
results={resultsWithLabels( | ||
facetOptions(facetSetting.name) || [], | ||
facetSetting.labelFunction | ||
)} | ||
name={facetSetting.name} | ||
title={facetSetting.title} | ||
selected={activeFacets[facetSetting.name] || []} | ||
onUpdate={e => | ||
onFacetChange(e.target.name, e.target.value, e.target.checked) | ||
} | ||
expandedOnLoad={facetSetting.expandedOnLoad} | ||
/> | ||
) : ( | ||
<Facet | ||
key={facetSetting.name} | ||
title={facetSetting.title} | ||
name={facetSetting.name} | ||
results={resultsWithLabels( | ||
facetOptions(facetSetting.name) || [], | ||
facetSetting.labelFunction | ||
)} | ||
onUpdate={e => | ||
onFacetChange(e.target.name, e.target.value, e.target.checked) | ||
} | ||
selected={activeFacets[facetSetting.name] || []} | ||
expandedOnLoad={facetSetting.expandedOnLoad} | ||
/> | ||
) | ||
)} | ||
</> | ||
) | ||
} | ||
|
||
const FacetDisplay = React.memo( | ||
function FacetDisplay(props: Props) { | ||
function FacetDisplay(props: FacetDisplayProps) { | ||
const { | ||
facetMap, | ||
facetOptions, | ||
|
@@ -83,39 +128,12 @@ const FacetDisplay = React.memo( | |
)) | ||
)} | ||
</div> | ||
{facetMap.map((facetSetting, key) => | ||
facetSetting.useFilterableFacet ? ( | ||
<FilterableFacet | ||
key={key} | ||
results={resultsWithLabels( | ||
facetOptions(facetSetting.name) || [], | ||
facetSetting.labelFunction | ||
)} | ||
name={facetSetting.name} | ||
title={facetSetting.title} | ||
selected={activeFacets[facetSetting.name] || []} | ||
onUpdate={e => | ||
onFacetChange(e.target.name, e.target.value, e.target.checked) | ||
} | ||
expandedOnLoad={facetSetting.expandedOnLoad} | ||
/> | ||
) : ( | ||
<Facet | ||
key={key} | ||
title={facetSetting.title} | ||
name={facetSetting.name} | ||
results={resultsWithLabels( | ||
facetOptions(facetSetting.name) || [], | ||
facetSetting.labelFunction | ||
)} | ||
onUpdate={e => | ||
onFacetChange(e.target.name, e.target.value, e.target.checked) | ||
} | ||
selected={activeFacets[facetSetting.name] || []} | ||
expandedOnLoad={facetSetting.expandedOnLoad} | ||
/> | ||
) | ||
)} | ||
<AvailableFacets | ||
facetMap={facetMap} | ||
facetOptions={facetOptions} | ||
activeFacets={activeFacets} | ||
onFacetChange={onFacetChange} | ||
/> | ||
</> | ||
) | ||
}, | ||
|
@@ -130,3 +148,4 @@ const FacetDisplay = React.memo( | |
) | ||
|
||
export default FacetDisplay | ||
export { AvailableFacets } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Originally, I was not going to introduce the
@mitodl/open-api-axios
client in this PR. However, the client previously committed in this repo was missing the newresource_type: Video
which caused some type errors in MIT Open, so I went ahead and replaced the client in this PR.