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

AOI code cleanup #1248

Draft
wants to merge 40 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
2341e1b
Expose ExplorationAndAnalysis component, update date-fns for building…
sandrahoang686 Sep 10, 2024
b5e5ff9
Comment out analysis message for now
sandrahoang686 Sep 16, 2024
606acc9
Decouple datasets selector modal from E&A
sandrahoang686 Sep 16, 2024
ecf0989
fix datepicker and abandom modal version
sandrahoang686 Sep 17, 2024
97112dd
clean some things up and uncomment things out
sandrahoang686 Sep 17, 2024
3aed77b
Uncomment and comment out source of breakage for analysis-message-con…
sandrahoang686 Sep 17, 2024
c949b35
add comment
sandrahoang686 Sep 17, 2024
c85eba0
Merge branch 'main' into 902-ea-breakout
dzole0311 Oct 17, 2024
8ee8253
Fix draw controls and analysis message
dzole0311 Oct 21, 2024
d7f5070
Fix lint
dzole0311 Oct 22, 2024
8bf1abf
Fix unmount error
dzole0311 Oct 22, 2024
b2eee6d
Make dataselectormodal exportable
hanbyul-here Oct 22, 2024
f5ff42c
Clean up
dzole0311 Oct 23, 2024
c4ca598
Put onClick props directly
hanbyul-here Oct 23, 2024
ae793f7
Switch to non-ref object usage
dzole0311 Oct 24, 2024
f7a4284
Consolidate onLinkClick and onClick into onClick
hanbyul-here Oct 24, 2024
ce6bd1c
lint
hanbyul-here Oct 24, 2024
588fd8b
Remove obsolete code and add a comment
dzole0311 Oct 25, 2024
2ae4c21
Make Data selector modal work (#1213)
hanbyul-here Oct 28, 2024
1f52025
Merge branch '902-ea-breakout' into 1155-fix-map-controls
dzole0311 Oct 29, 2024
c6aadaf
Revert fix attempt
dzole0311 Oct 29, 2024
772b19b
Fix map controls and resolve Analyses Message issue (#1205)
dzole0311 Oct 29, 2024
4848c88
Fix imports
dzole0311 Oct 29, 2024
195e3f3
Add missing import
dzole0311 Oct 29, 2024
ef4a30c
[REFACTOR] Import fixes needed for the Next.js instance (#1222)
dzole0311 Oct 29, 2024
7e4cf7e
Export useAtom, Remove any react router related components
hanbyul-here Oct 30, 2024
4f69a4a
Use a when opening a tab in a new window
hanbyul-here Oct 30, 2024
e01d03e
Use linkproperties for sources (but is this necessary?)
hanbyul-here Oct 30, 2024
4a0318f
Flag the problem - 1
hanbyul-here Oct 30, 2024
0fc1b2b
Edit date atom (workaround)
hanbyul-here Oct 30, 2024
889bd47
Make a comment where it uses data faux module datasetLayers
hanbyul-here Oct 30, 2024
bafb20e
Put Try Catch block for drawcontrol function
hanbyul-here Oct 31, 2024
ed269c6
Add last array method
hanbyul-here Nov 1, 2024
dc0408a
Revert temporary work around
hanbyul-here Nov 1, 2024
f5bb96c
Get rid of the line that is not necessary
hanbyul-here Nov 6, 2024
7771378
Various fixes for E&A (#1229)
sandrahoang686 Nov 6, 2024
2c61865
Remove unused files
AliceR Nov 6, 2024
ffff3c6
Clean up effect dependencies
AliceR Nov 6, 2024
ea2634c
Increase consistency between atoms and use-aois
AliceR Nov 6, 2024
17361f3
Console logging while debugging, please revert
AliceR Nov 6, 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
63 changes: 0 additions & 63 deletions app/scripts/components/common/aoi/types.d.ts

This file was deleted.

134 changes: 0 additions & 134 deletions app/scripts/components/common/aoi/use-aoi-controls.ts

This file was deleted.

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
20 changes: 7 additions & 13 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 @@ -16,6 +16,7 @@ import HorizontalInfoCard, { HorizontalCardStyles } from './horizontal-info-card
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 @@ -219,12 +220,6 @@ export function ExternalLinkFlag() {
);
}

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

export interface LinkWithPathProperties extends LinkProperties {
linkTo: string;
isLinkExternal?: boolean;
Expand All @@ -250,7 +245,7 @@ export interface CardComponentBaseProps {
// 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;
onClick?: MouseEventHandler;
isLinkExternal?: boolean;
}
export interface CardComponentProps extends CardComponentBaseProps {
Expand Down Expand Up @@ -289,24 +284,23 @@ function CardComponent(props: CardComponentPropsType) {
const { linkProperties: linkPropertiesProps } = props;
linkProperties = linkPropertiesProps;
} else {
const { linkTo, onLinkClick, isLinkExternal } = props;
const { linkTo, onClick, isLinkExternal } = props;
linkProperties = {
linkTo,
onLinkClick,
onClick,
pathAttributeKeyName: 'to',
LinkElement: SmartLink,
isLinkExternal
};
}

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

return (
<ElementInteractive
linkProps={{
as: linkProperties.LinkElement,
[linkProperties.pathAttributeKeyName]: linkProperties.linkTo,
onLinkClick: linkProperties.onLinkClick,
onClick: linkProperties.onClick,
isLinkExternal: isExternalLink
}}
as={CardItem}
Expand Down
8 changes: 4 additions & 4 deletions app/scripts/components/common/catalog/catalog-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ 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 { 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 { 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";
Expand Down Expand Up @@ -121,7 +121,7 @@ export const CatalogCard = (props: CatalogCardProps) => {
overline={
<CardMeta>
<DatasetClassification dataset={dataset} />
<CardSourcesList sources={sources} />
<CardSourcesList sources={sources} linkProperties={linkProperties} />
</CardMeta>
}
linkLabel='View dataset'
Expand Down Expand Up @@ -155,7 +155,7 @@ export const CatalogCard = (props: CatalogCardProps) => {
) : null}
</>
}
linkProperties={{...linkProperties, linkTo: linkTo, onLinkClick: handleClick}}
linkProperties={{...linkProperties, linkTo: linkTo, onClick: handleClick}}
/>
);
};
2 changes: 1 addition & 1 deletion 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
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
Loading