Skip to content

Commit

Permalink
fix: change web map links (Greenstand#973)
Browse files Browse the repository at this point in the history
* fix: change web map links

* fix: correct .env domains

* feat: add shared object for the path type

* fix: domain on .env dev and test

Co-authored-by: Nick Charlton <[email protected]>
  • Loading branch information
henriquemoreiraa and nmcharlton authored Dec 31, 2022
1 parent a2b436e commit 6494e52
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REACT_APP_WEBMAP_DOMAIN=http://dev.treetracker.org
REACT_APP_WEBMAP_DOMAIN=https://beta-map.treetracker.org
REACT_APP_API_ROOT=https://dev-k8s.treetracker.org/api/admin
REACT_APP_EARNINGS_ROOT=https://dev-k8s.treetracker.org/earnings
REACT_APP_FIELD_DATA_ROOT=https://dev-k8s.treetracker.org/field-data
Expand Down
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REACT_APP_WEBMAP_DOMAIN=https://treetracker.org
REACT_APP_WEBMAP_DOMAIN=https://beta-map.treetracker.org
REACT_APP_API_ROOT=https://prod-k8s.treetracker.org/api/admin
REACT_APP_EARNINGS_ROOT=https://prod-k8s.treetracker.org/earnings
REACT_APP_GROWER_QUERY_API_ROOT=https://prod-k8s.treetracker.org/grower-account-query
Expand Down
2 changes: 1 addition & 1 deletion .env.staging
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REACT_APP_WEBMAP_DOMAIN=http://staging.treetracker.org
REACT_APP_WEBMAP_DOMAIN=https://beta-map.treetracker.org
REACT_APP_API_ROOT=https://prod-k8s.treetracker.org/api/admin
REACT_APP_EARNINGS_ROOT=https://prod-k8s.treetracker.org/earnings
REACT_APP_GROWER_QUERY_API_ROOT=https://prod-k8s.treetracker.org/grower-account-query
Expand Down
2 changes: 1 addition & 1 deletion .env.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REACT_APP_WEBMAP_DOMAIN=http://test.treetracker.org
REACT_APP_WEBMAP_DOMAIN=https://beta-map.treetracker.org
REACT_APP_API_ROOT=https://test-k8s.treetracker.org/api/admin
REACT_APP_EARNINGS_ROOT=https://test-k8s.treetracker.org/earnings
REACT_APP_GROWER_QUERY_API_ROOT=https://test-k8s.treetracker.org/grower-account-query
Expand Down
6 changes: 3 additions & 3 deletions src/components/CaptureDetailDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '@material-ui/core';
import Close from '@material-ui/icons/Close';
import OptimizedImage from './OptimizedImage';
import LinkToWebmap from './common/LinkToWebmap';
import LinkToWebmap, { pathType } from './common/LinkToWebmap';
import { verificationStates } from '../common/variables';
import { CaptureDetailContext } from '../context/CaptureDetailContext';
import CopyNotification from './common/CopyNotification';
Expand Down Expand Up @@ -162,7 +162,7 @@ function CaptureDetailDialog({ open, captureId, onClose, page }) {
<Box m={4}>
<Typography color="primary" variant="h6">
Capture{' '}
<LinkToWebmap value={capture.reference_id} type="tree" />
<LinkToWebmap value={capture} type={pathType.tree} />
<CopyButton
label="Capture ID"
value={capture.reference_id}
Expand Down Expand Up @@ -222,7 +222,7 @@ function CaptureDetailDialog({ open, captureId, onClose, page }) {
Open in new tab
</Link>
) : (
<LinkToWebmap value={item.value} type="user" />
<LinkToWebmap value={item.value} type={pathType.planter} />
)
) : item.value ? (
item.value
Expand Down
4 changes: 2 additions & 2 deletions src/components/Captures/CaptureTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '@material-ui/core';
import { GetApp } from '@material-ui/icons';
import { getDateTimeStringLocale } from '../../common/locale';
import LinkToWebmap from '../common/LinkToWebmap';
import LinkToWebmap, { pathType } from '../common/LinkToWebmap';
import { CapturesContext } from '../../context/CapturesContext';
import { SpeciesContext } from '../../context/SpeciesContext';
import { CaptureDetailProvider } from '../../context/CaptureDetailContext';
Expand Down Expand Up @@ -364,7 +364,7 @@ export const formatCell = (
return (
<LinkToWebmap
value={capture[attr]}
type={attr === 'reference_id' ? 'tree' : 'user'}
type={attr === 'reference_id' ? pathType.tree : pathType.planter}
/>
);
} else if (attr === 'species_id') {
Expand Down
8 changes: 6 additions & 2 deletions src/components/GrowerDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { MessagingContext } from 'context/MessagingContext';
import EditGrower from './EditGrower';
import GrowerOrganization from './GrowerOrganization';
import OptimizedImage from './OptimizedImage';
import LinkToWebmap from './common/LinkToWebmap';
import LinkToWebmap, { pathType } from './common/LinkToWebmap';
import { CopyButton } from './common/CopyButton';
import CopyNotification from './common/CopyNotification';
import FilterModel from '../models/Filter';
Expand Down Expand Up @@ -414,7 +414,11 @@ const GrowerDetail = ({ open, growerId, onClose }) => {
{grower.firstName} {grower.lastName}
</Typography>
<Typography variant="body2">
ID: <LinkToWebmap value={grower.id} type="user" />
ID:{' '}
<LinkToWebmap
value={grower.reference_id || grower.id}
type={pathType.planter}
/>
</Typography>
</Grid>
{process.env.REACT_APP_ENABLE_MESSAGING === 'true' &&
Expand Down
8 changes: 6 additions & 2 deletions src/components/Growers/Grower.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
CardContent,
} from '@material-ui/core';
import { Person } from '@material-ui/icons';
import LinkToWebmap from '../common/LinkToWebmap';
import LinkToWebmap, { pathType } from '../common/LinkToWebmap';
import OptimizedImage from '../OptimizedImage';
import GrowerOrganization from 'components/GrowerOrganization';
import { useStyle, GROWER_IMAGE_SIZE } from './Growers.styles.js';
Expand Down Expand Up @@ -52,7 +52,11 @@ export const Grower = ({ grower, growerClick }) => {
{grower.firstName} {grower.lastName}
</Typography>
<Typography>
ID: <LinkToWebmap value={grower.id} type="user" />
ID:{' '}
<LinkToWebmap
value={grower.reference_id || grower.id}
type={pathType.planter}
/>
</Typography>
<GrowerOrganization
organizationName={grower?.organization}
Expand Down
5 changes: 3 additions & 2 deletions src/components/Verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { VerifyContext } from 'context/VerifyContext';
import { SpeciesContext } from 'context/SpeciesContext';
import { TagsContext } from 'context/TagsContext';
import { CaptureDetailProvider } from 'context/CaptureDetailContext';
import { pathType } from './common/LinkToWebmap';

const log = require('loglevel').getLogger('components/Verify');
const EMPTY_ARRAY = new Array(16).fill();
Expand Down Expand Up @@ -288,14 +289,14 @@ const Verify = (props) => {
const handleCapturePinClick = (captureId) => (e) => {
e.stopPropagation();
log.debug('click on capture pin:', captureId);
const url = `${process.env.REACT_APP_WEBMAP_DOMAIN}/?treeid=${captureId}`;
const url = `${process.env.REACT_APP_WEBMAP_DOMAIN}/${pathType.tree}/${captureId}`;
window.open(url, '_blank').opener = null;
};

const handleGrowerMapClick = (growerId) => (e) => {
e.stopPropagation();
log.debug('click on grower:', growerId);
const url = `${process.env.REACT_APP_WEBMAP_DOMAIN}/?userid=${growerId}`;
const url = `${process.env.REACT_APP_WEBMAP_DOMAIN}/${pathType.planter}/${growerId}`;
window.open(url, '_blank').opener = null;
};

Expand Down
7 changes: 6 additions & 1 deletion src/components/common/LinkToWebmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ const useStyles = makeStyles((theme) => ({
},
}));

export const pathType = {
tree: 'trees',
planter: 'planters',
};

export default function LinkToWebmap(props) {
const { value, type } = props;
const classes = useStyles();
Expand All @@ -18,7 +23,7 @@ export default function LinkToWebmap(props) {
return (
<Link
onClick={(e) => e.stopPropagation()}
href={`${process.env.REACT_APP_WEBMAP_DOMAIN}/?${type}id=${id}`}
href={`${process.env.REACT_APP_WEBMAP_DOMAIN}/${type}/${id}`}
underline="always"
target="_blank"
>
Expand Down
6 changes: 3 additions & 3 deletions src/components/tests/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ const GROWERS = {
bulk_pack_file_name: null,
gender: 'female',
about: null,
reference_id: 105,
reference_id: 1,
devices: ['a', 'b', 'c'],
regions: null,
},
Expand All @@ -282,7 +282,7 @@ const GROWERS = {
bulk_pack_file_name: null,
gender: 'male',
about: null,
reference_id: 106,
reference_id: 2,
devices: ['d', 'e', 'f'],
regions: null,
},
Expand Down Expand Up @@ -310,7 +310,7 @@ const GROWERS = {
bulk_pack_file_name: null,
gender: null,
about: null,
reference_id: 107,
reference_id: 3,
devices: ['a'],
regions: null,
},
Expand Down

0 comments on commit 6494e52

Please sign in to comment.