Skip to content
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

[FEATURE BRANCH] 902 E&A breakout #1154

Merged
merged 39 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7ffa351
Expose ExplorationAndAnalysis component, update date-fns for building…
sandrahoang686 Sep 10, 2024
7061c7f
Comment out analysis message for now
sandrahoang686 Sep 16, 2024
a6dfab5
Decouple datasets selector modal from E&A
sandrahoang686 Sep 16, 2024
ef45523
fix datepicker and abandom modal version
sandrahoang686 Sep 17, 2024
11eb134
clean some things up and uncomment things out
sandrahoang686 Sep 17, 2024
a31fc6d
Uncomment and comment out source of breakage for analysis-message-con…
sandrahoang686 Sep 17, 2024
bcbf657
add comment
sandrahoang686 Sep 17, 2024
ad732f7
Fix draw controls and analysis message
dzole0311 Oct 21, 2024
9f4e65c
Fix lint
dzole0311 Oct 22, 2024
9afeaaa
Fix unmount error
dzole0311 Oct 22, 2024
af34511
Clean up
dzole0311 Oct 23, 2024
39dfb20
Switch to non-ref object usage
dzole0311 Oct 24, 2024
df5da6c
Remove obsolete code and add a comment
dzole0311 Oct 25, 2024
1a6cff1
Make dataselectormodal exportable
hanbyul-here Oct 22, 2024
0c08048
Put onClick props directly
hanbyul-here Oct 23, 2024
db9e3c1
Consolidate onLinkClick and onClick into onClick
hanbyul-here Oct 24, 2024
103b3f6
Revert fix attempt
dzole0311 Oct 29, 2024
20ac2a9
Fix imports
dzole0311 Oct 29, 2024
165906e
Add missing import
dzole0311 Oct 29, 2024
6d6047e
Export useAtom, Remove any react router related components
hanbyul-here Oct 30, 2024
a538d20
Use a when opening a tab in a new window
hanbyul-here Oct 30, 2024
fb09159
Use linkproperties for sources (but is this necessary?)
hanbyul-here Oct 30, 2024
fb269d0
Flag the problem - 1
hanbyul-here Oct 30, 2024
3d89476
Edit date atom (workaround)
hanbyul-here Oct 30, 2024
acafa2e
Make a comment where it uses data faux module datasetLayers
hanbyul-here Oct 30, 2024
090c256
Put Try Catch block for drawcontrol function
hanbyul-here Oct 31, 2024
86c90c3
Add last array method
hanbyul-here Nov 1, 2024
529d6aa
Revert temporary work around
hanbyul-here Nov 1, 2024
6107a3c
Get rid of the line that is not necessary
hanbyul-here Nov 6, 2024
e130a6a
Resolved all conflicts
sandrahoang686 Nov 11, 2024
f23dac9
Fix import to fix buildlib error
sandrahoang686 Nov 11, 2024
de31403
Add is LinkExternal back that was removed from conflict resolution
sandrahoang686 Nov 11, 2024
4b59fd6
Remove onClick from linkProps, Remove linkProps req from card, Fix to…
sandrahoang686 Nov 11, 2024
8321a12
remove try/catch around area/point selection logic into useEffect
sandrahoang686 Nov 11, 2024
c502224
Fix to linter and ts error
sandrahoang686 Nov 11, 2024
0ec5744
fix lint error..
sandrahoang686 Nov 11, 2024
bee9d96
Fix lint error again.. ugh
sandrahoang686 Nov 11, 2024
1ab1a3f
add updated state to aoi use effect dep array
sandrahoang686 Nov 12, 2024
387401f
Various cleanup on EA breakout feature branch (#1251)
sandrahoang686 Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions app/scripts/components/common/card-sources.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
import styled from 'styled-components';
import { Link } from 'react-router-dom';
import { listReset } from '@devseed-ui/theme-provider';
import { TaxonomyItem } from '$types/veda';
import { LinkProperties, TaxonomyItem } from '$types/veda';
import { FilterActions } from '$components/common//catalog/utils';

const SourcesUl = styled.ul`
Expand All @@ -23,11 +22,12 @@ interface SourcesListProps {
sources?: TaxonomyItem[];
onSourceClick?: (v: string) => void;
rootPath?: string;
linkProperties?: LinkProperties;
}

export function CardSourcesList(props: SourcesListProps) {
const { sources, onSourceClick, rootPath } = props;

const { sources, onSourceClick, linkProperties, rootPath } = props;
const { LinkElement, pathAttributeKeyName } = linkProperties as { LinkElement: React.ElementType, pathAttributeKeyName: string };
if (!sources?.length) return null;

// No link rendering
Expand All @@ -50,19 +50,19 @@ export function CardSourcesList(props: SourcesListProps) {
<SourcesUl>
{sources.map((source) => (
<li key={source.id}>
<Link
to={`${rootPath}?${FilterActions.TAXONOMY}=${encodeURIComponent(
<LinkElement
{...{[pathAttributeKeyName]:`${rootPath}?${FilterActions.TAXONOMY}=${encodeURIComponent(
JSON.stringify({
Source: source.id
})
)}`}
)}`}}
onClick={(e) => {
e.preventDefault();
onSourceClick(source.id);
}}
>
{source.name}
</Link>
</LinkElement>
</li>
))}
</SourcesUl>
Expand Down
41 changes: 17 additions & 24 deletions app/scripts/components/common/card/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { lazy, MouseEventHandler, ComponentType } from 'react';
import React, { lazy, MouseEventHandler } from 'react';
import styled, { css } from 'styled-components';
import { format } from 'date-fns';
import format from 'date-fns/format';
import { CollecticonExpandTopRight } from '@devseed-ui/collecticons';
import {
glsp,
Expand All @@ -25,6 +25,7 @@ import HorizontalInfoCard, {
import { variableBaseType, variableGlsp } from '$styles/variable-utils';
import { ElementInteractive } from '$components/common/element-interactive';
import { Figure } from '$components/common/figure';
import { LinkProperties } from '$types/veda';

type CardType = 'classic' | 'cover' | 'featured' | 'horizontal-info';

Expand Down Expand Up @@ -230,12 +231,6 @@ export function ExternalLinkFlag() {
);
}

export interface LinkProperties {
LinkElement: string | ComponentType<any> | undefined;
pathAttributeKeyName: string;
onLinkClick?: MouseEventHandler;
}

export interface LinkWithPathProperties extends LinkProperties {
linkTo: string;
}
Expand All @@ -255,16 +250,17 @@ export interface CardComponentBaseProps {
footerContent?: JSX.Element;
hideExternalLinkBadge?: boolean;
onCardClickCapture?: MouseEventHandler;
onClick?: MouseEventHandler;
}

// @TODO: Consolidate these props when the instance adapts the new syntax
// @TODO: Created because GHG uses the card component directly and passes in "linkTo" prop. Consolidate these props when the instance adapts the new syntax
// Specifically: https://github.com/US-GHG-Center/veda-config-ghg/blob/develop/custom-pages/news-and-events/component.tsx#L108
export interface CardComponentPropsDeprecated extends CardComponentBaseProps {
linkTo: string;
onLinkClick?: MouseEventHandler;
}

export interface CardComponentProps extends CardComponentBaseProps {
linkProperties: LinkWithPathProperties;
linkProperties?: LinkWithPathProperties;
}

type CardComponentPropsType = CardComponentProps | CardComponentPropsDeprecated;
Expand All @@ -291,40 +287,37 @@ function CardComponent(props: CardComponentPropsType) {
parentTo,
footerContent,
hideExternalLinkBadge,
onCardClickCapture
onCardClickCapture,
onClick,
} = props;
// @TODO: This process is not necessary once all the instances adapt the linkProperties syntax
// Consolidate them to use LinkProperties only
let linkProperties: LinkWithPathProperties;
let linkProperties: LinkWithPathProperties | undefined;

if (hasLinkProperties(props)) {
// Handle new props with linkProperties
const { linkProperties: linkPropertiesProps } = props;
linkProperties = linkPropertiesProps;
} else {
const { linkTo, onLinkClick } = props;
linkProperties = {
const { linkTo } = props;
linkProperties = linkTo ? {
linkTo,
onLinkClick,
pathAttributeKeyName: 'to',
LinkElement: SmartLink
};
} : undefined;
}

const isExternalLink = /^https?:\/\//.test(linkProperties.linkTo);
const isExternalLink = linkProperties ? /^https?:\/\//.test(linkProperties.linkTo) : false;

return (
<ElementInteractive
linkProps={{
as: linkProperties.LinkElement,
[linkProperties.pathAttributeKeyName]: linkProperties.linkTo,
onLinkClick: linkProperties.onLinkClick
}}
{...(linkProperties ? {linkProps: {as: linkProperties.LinkElement, [linkProperties.pathAttributeKeyName]: linkProperties.linkTo}} : {})}
as={CardItem}
cardType={cardType}
className={className}
linkLabel={linkLabel ?? 'View more'}
onClickCapture={onCardClickCapture}
onClick={onClick}
>
{cardType !== 'horizontal-info' && (
<>
Expand All @@ -340,7 +333,7 @@ function CardComponent(props: CardComponentPropsType) {
parentTo &&
tagLabels.map((label) => (
<CardLabel
as={linkProperties.LinkElement}
as={linkProperties?.LinkElement}
to={parentTo}
key={label}
>
Expand Down
48 changes: 18 additions & 30 deletions app/scripts/components/common/catalog/catalog-card.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
import React from 'react';
import styled, { css } from 'styled-components';
import {
CollecticonPlus,
CollecticonTickSmall,
iconDataURI
} from '@devseed-ui/collecticons';
import { glsp, themeVal } from '@devseed-ui/theme-provider';

import { Card, LinkProperties } from '../card';
import { CardMeta, CardTopicsList } from '../card/styles';
import { DatasetClassification } from '../dataset-classification';
import { CardSourcesList } from '../card-sources';
import TextHighlight from '../text-highlight';
import React from "react";
import styled, { css } from "styled-components";
import { CollecticonPlus, CollecticonTickSmall, iconDataURI } from "@devseed-ui/collecticons";
import { glsp, themeVal } from "@devseed-ui/theme-provider";
import { Card } from "../card";
import { CardMeta, CardTopicsList } from "../card/styles";
import { DatasetClassification } from "../dataset-classification";
import { CardSourcesList } from "../card-sources";
import TextHighlight from "../text-highlight";
import { getDatasetDescription, getMediaProperty } from './utils';
import { DatasetData, DatasetLayer } from '$types/veda';
import { getDatasetPath } from '$utils/routes';
import {
TAXONOMY_SOURCE,
TAXONOMY_TOPICS,
getAllTaxonomyValues,
getTaxonomy
} from '$utils/veda-data/taxonomies';
import { Pill } from '$styles/pill';
import { LinkProperties } from '$types/veda';
import { DatasetData, DatasetLayer } from "$types/veda";
import { getDatasetPath } from "$utils/routes";
import { TAXONOMY_SOURCE, TAXONOMY_TOPICS, getAllTaxonomyValues, getTaxonomy } from "$utils/veda-data/taxonomies";
import { Pill } from "$styles/pill";

interface CatalogCardProps {
dataset: DatasetData;
Expand All @@ -31,7 +22,7 @@ interface CatalogCardProps {
selected?: boolean;
onDatasetClick?: () => void;
pathname?: string;
linkProperties: LinkProperties;
linkProperties?: LinkProperties;
}

const CardSelectable = styled(Card)<{
Expand Down Expand Up @@ -142,10 +133,11 @@ export const CatalogCard = (props: CatalogCardProps) => {
overline={
<CardMeta>
<DatasetClassification dataset={dataset} />
<CardSourcesList sources={sources} />
<CardSourcesList sources={sources} linkProperties={linkProperties} />
</CardMeta>
}
linkLabel='View dataset'
onClick={handleClick}
title={
<TextHighlight value={searchTerm} disabled={searchTerm.length < 3}>
{title}
Expand Down Expand Up @@ -179,11 +171,7 @@ export const CatalogCard = (props: CatalogCardProps) => {
) : null}
</>
}
linkProperties={{
...linkProperties,
linkTo: linkTo,
onLinkClick: handleClick
}}
{...(linkProperties ? {linkProperties: {...linkProperties, linkTo: linkTo}} : {})}
/>
);
};
3 changes: 1 addition & 2 deletions app/scripts/components/common/catalog/catalog-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import styled from 'styled-components';
import { glsp, themeVal } from '@devseed-ui/theme-provider';
import TextHighlight from '../text-highlight';
import { CollecticonDatasetLayers } from '../icons/dataset-layers';
import { LinkProperties } from '../card';
import { prepareDatasets } from './prepare-datasets';
import FiltersControl from './filters-control';
import { CatalogCard } from './catalog-card';
import CatalogTagsContainer from './catalog-tags';

import { FilterActions } from './utils';
import { LinkProperties } from '$types/veda';
import { DatasetData, DatasetDataWithEnhancedLayers } from '$types/veda';
import { CardList } from '$components/common/card/styles';
import EmptyHub from '$components/common/empty-hub';
Expand Down Expand Up @@ -264,7 +264,6 @@ function CatalogContent({
selectable={true}
selected={selectedIds.includes(datasetLayer.id)}
onDatasetClick={() => onCardSelect(datasetLayer.id, currentDataset)}
linkProperties={linkProperties}
pathname={pathname}
/>
</li>
Expand Down
3 changes: 1 addition & 2 deletions app/scripts/components/common/catalog/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react';
import styled from 'styled-components';
import { themeVal } from '@devseed-ui/theme-provider';
import { LinkProperties } from '../card';
import CatalogContent from './catalog-content';
import { DatasetData } from '$types/veda';
import { DatasetData, LinkProperties } from '$types/veda';
import {
useSlidingStickyHeaderProps
} from '$components/common/layout-root/useSlidingStickyHeaderProps';
Expand Down
12 changes: 10 additions & 2 deletions app/scripts/components/common/element-interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ const InteractiveLink = styled.a`
*/
export const ElementInteractive = React.forwardRef(
function ElementInteractiveFwd(props, ref) {
const { linkProps = {}, linkLabel = 'View', children, ...rest } = props;
const {
linkProps = {},
linkLabel = 'View',
children,
onClick,
...rest
} = props;
const [isStateOver, setStateOver] = useState(false);
const [isStateActive, setStateActive] = useState(false);
const [isStateFocus, setStateFocus] = useState(false);
Expand All @@ -92,6 +98,7 @@ export const ElementInteractive = React.forwardRef(
setStateOver(false);
setStateActive(false);
}, [])}
onClick={onClick}
>
{children}
<InteractiveLink
Expand All @@ -111,7 +118,8 @@ export const ElementInteractive = React.forwardRef(
ElementInteractive.propTypes = {
children: T.node.isRequired,
linkLabel: T.string.isRequired,
linkProps: T.object
linkProps: T.object,
onClick: T.func
};

/**
Expand Down
11 changes: 7 additions & 4 deletions app/scripts/components/common/featured-slider-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ function FeaturedSliderSection(props: FeaturedSliderSectionProps) {
return sortedFeaturedItems.map((d) => {
const date = new Date(d[dateProperty ?? '']);
const topics = getTaxonomy(d, TAXONOMY_TOPICS)?.values;

const linkProperties = {
pathAttributeKeyName: 'to',
LinkElement: SmartLink
};
return (
<ContinuumGridItem {...bag} key={d.id}>
<Card
Expand All @@ -112,9 +115,8 @@ function FeaturedSliderSection(props: FeaturedSliderSectionProps) {
cardType='featured'
linkLabel='View more'
linkProperties={{
linkTo: `${d.asLink?.url ?? getItemPath(d)}`,
pathAttributeKeyName: 'to',
LinkElement: SmartLink
...linkProperties,
linkTo: `${d.asLink?.url ?? getItemPath(d)}`
}}
title={d.name}
overline={
Expand All @@ -123,6 +125,7 @@ function FeaturedSliderSection(props: FeaturedSliderSectionProps) {
<DatasetClassification dataset={d} />
)}
<CardSourcesList
linkProperties={linkProperties}
sources={getTaxonomy(d, TAXONOMY_SOURCE)?.values}
/>
<VerticalDivider variation='light' />
Expand Down
Loading
Loading