Skip to content

Commit

Permalink
Replace Datasets DatasetSelect component on groups page with ListReso…
Browse files Browse the repository at this point in the history
…urces [#870]

* conditionalize display of "List known update" in IndividualResource
  TooltipWrapper
* conditionalize display of "Most recent snapshot" in ResourceGroup
* conditionalize use of Showcase in ListResources based on length of
  showcaseCards prop
* conditionalize use of SortOptions in ListResources based on initial
  group lacking a lastUpdated field
* extend groups page with custom useDataFetch callback to hit
  charon/getAvailableResources endpoint
  • Loading branch information
genehack committed Jun 10, 2024
1 parent 62a1db4 commit 1fb7394
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,14 @@ export const IndividualResource = ({resource, isMobile}: IndividualResourceProps
)
}

const description = resource.lastUpdated ? `Last known update on ${resource.lastUpdated}` : "";

return (
<Container ref={ref}>

<FlexRow>

<TooltipWrapper description={`Last known update on ${resource.lastUpdated}`}>
<TooltipWrapper description={description}>
<ResourceLinkWrapper onShiftClick={() => setModalResource(resource)}>
<Name displayName={resource.displayName} href={resource.url} topOfColumn={topOfColumn}/>
</ResourceLinkWrapper>
Expand Down
2 changes: 1 addition & 1 deletion static-site/src/components/ListResources/ResourceGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const ResourceGroupHeader = ({group, isMobile, setCollapsed, collapsible, isColl
<TooltipWrapper description={`The most recently updated datasets in this group were last updated on ${group.lastUpdated}` +
'<br/>(however there may have been a more recent update since we indexed the data)'}>
<span>
{`Most recent snapshot: ${group.lastUpdated}`}
{group.lastUpdated !== "" && `Most recent snapshot: ${group.lastUpdated}`}
</span>
</TooltipWrapper>
)}
Expand Down
10 changes: 8 additions & 2 deletions static-site/src/components/ListResources/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,17 @@ function ListResources({
return (
<ListResourcesContainer>

<Showcase cards={showcaseCards} setSelectedFilterOptions={setSelectedFilterOptions}/>
{ showcaseCards.length > 0 && (
<Showcase cards={showcaseCards} setSelectedFilterOptions={setSelectedFilterOptions}/>
)}

<Filter options={availableFilterOptions} selectedFilterOptions={selectedFilterOptions} setSelectedFilterOptions={setSelectedFilterOptions}/>

<SortOptions sortMethod={sortMethod} changeSortMethod={changeSortMethod}/>
{ groups[0].lastUpdated !== "" && (
<SortOptions sortMethod={sortMethod} changeSortMethod={changeSortMethod}/>
) || (
<HugeSpacer/>
)}

<SetModalResourceContext.Provider value={setModalResource}>
<ScrollableAnchor id={LIST_ANCHOR}>
Expand Down
10 changes: 6 additions & 4 deletions static-site/src/pages/groups.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import { SmallSpacer, HugeSpacer, FlexCenter } from "../layouts/generalComponent
import * as splashStyles from "../components/splash/styles";
import { fetchAndParseJSON } from "../util/datasetsHelpers";
import DatasetSelect from "../components/Datasets/dataset-select";
import ListResources from "../components/ListResources/index";
import { GroupCards } from "../components/splash/groupCards";
import GenericPage from "../layouts/generic-page";
import { UserContext } from "../layouts/userDataWrapper";
import { DataFetchErrorParagraph } from "../components/splash/errorMessages";
import { groupsTitle, GroupsAbstract } from "../../data/SiteConfig";

const sourceId = "charon/groups";
const sourceUrl = "/charon/getAvailable?prefix=/groups/";
async function parseResourceListingCallback(response) {
const datasets = (await response.json()).datasets;

Expand Down Expand Up @@ -108,20 +109,21 @@ class GroupsPage extends React.Component {
<HugeSpacer />

<ListResources
sourceId={sourceId}
sourceUrl={sourceUrl}
resourceType="dataset"
versioned={false}
parseResourceListingCallback={parseResourceListingCallback}/>

<HugeSpacer />

<ScrollableAnchor id={'narratives'}>
<splashStyles.H2>Available Narratives</splashStyles.H2>
</ScrollableAnchor>

{this.state.dataLoaded && (
<DatasetSelect
datasets={this.state.narratives}
columns={datasetColumns({isNarrative: true})}
/>
columns={datasetColumns}/>
)}
{ this.state.errorFetchingData && <DataFetchErrorParagraph />}

Expand Down

0 comments on commit 1fb7394

Please sign in to comment.