Skip to content

Commit

Permalink
Merge pull request #78 from eea/develop
Browse files Browse the repository at this point in the history
Refactor using arcgis js sdk
  • Loading branch information
avoinea authored Jul 26, 2024
2 parents 72927f0 + 59fc638 commit c42f5b8
Show file tree
Hide file tree
Showing 74 changed files with 4,456 additions and 2,537 deletions.
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,35 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

### [5.0.0](https://github.com/eea/volto-eea-map/compare/4.1.0...5.0.0) - 25 July 2024

#### :house: Internal changes

- style: Automated code fix [eea-jenkins - [`aadf771`](https://github.com/eea/volto-eea-map/commit/aadf771b40e0a190c29de42d99466d2e6ef440e7)]
- style: Automated code fix [eea-jenkins - [`edfae3b`](https://github.com/eea/volto-eea-map/commit/edfae3b8ab4cdef23ae23ed7ea008043601dd783)]
- style: Automated code fix [eea-jenkins - [`fd6c49f`](https://github.com/eea/volto-eea-map/commit/fd6c49f6d0d5081a230f9b4427844eace0321361)]
- style: Automated code fix [eea-jenkins - [`5bcee12`](https://github.com/eea/volto-eea-map/commit/5bcee12ab667ad89096baae214ade24fa1c98fd1)]
- style: Automated code fix [eea-jenkins - [`9bf0079`](https://github.com/eea/volto-eea-map/commit/9bf0079694c16fa20c857f896e303850cf67da43)]
- style: Automated code fix [eea-jenkins - [`3d9adb6`](https://github.com/eea/volto-eea-map/commit/3d9adb6cee7ff1c45ae88d816e7f17de4bbaba37)]
- style: Automated code fix [eea-jenkins - [`f310427`](https://github.com/eea/volto-eea-map/commit/f3104279ad719b16a149a357c0eab2f8b7fd8ef7)]
- style: Automated code fix [eea-jenkins - [`fcf5adf`](https://github.com/eea/volto-eea-map/commit/fcf5adf32a73d388d97597dd9c88c3da362f90b8)]

#### :hammer_and_wrench: Others

- remove uneeded logo [Miu Razvan - [`759a07b`](https://github.com/eea/volto-eea-map/commit/759a07b587b8298d88800346a230fd55304aadf9)]
- fix bugs [Miu Razvan - [`ccccc8a`](https://github.com/eea/volto-eea-map/commit/ccccc8a1fac321d3968ffdc0843ff87138748476)]
- fix infinite rerenders [Miu Razvan - [`8dbb501`](https://github.com/eea/volto-eea-map/commit/8dbb5016741f2518668cfe1d40abe1484b53bfc3)]
- lint fix [Miu Razvan - [`56c2138`](https://github.com/eea/volto-eea-map/commit/56c2138099d7425e21a566cb13fee814acdaea68)]
- merge origin/develop into revamp branch [Miu Razvan - [`01ea06c`](https://github.com/eea/volto-eea-map/commit/01ea06ccad2b337a28f4e5847116a41bdda749e3)]
- fix zoom to layer extent [Miu Razvan - [`28bc084`](https://github.com/eea/volto-eea-map/commit/28bc08456fbaa66938e8d0bf5f25ceaff753fae3)]
- finalize eea-map refactoring [Miu Razvan - [`3c6abf9`](https://github.com/eea/volto-eea-map/commit/3c6abf998e3fdca55b1e81a0553749ee90bfbcd6)]
- update [Miu Razvan - [`65205bc`](https://github.com/eea/volto-eea-map/commit/65205bc494f1d3c1b381ed6f9af01ed022e87c75)]
- Update [Miu Razvan - [`13468a3`](https://github.com/eea/volto-eea-map/commit/13468a3c6738e612115535813e64b0a6af4c97d7)]
- wip [Miu Razvan - [`901fcc3`](https://github.com/eea/volto-eea-map/commit/901fcc318c618c0307a64081002ab4a048be70a7)]
- Update [Miu Razvan - [`d70dcf2`](https://github.com/eea/volto-eea-map/commit/d70dcf293b1395741ccbc524fa19145c829f72a9)]
- Update [Miu Razvan - [`a35b941`](https://github.com/eea/volto-eea-map/commit/a35b941700d985c6f3b53247cb60ecc103c4f339)]
- Widget component + other [Miu Razvan - [`291f5ad`](https://github.com/eea/volto-eea-map/commit/291f5ad97945cacb1bc4c6d12d177f232b907184)]
- update [Miu Razvan - [`b073166`](https://github.com/eea/volto-eea-map/commit/b073166de8be0b709e5b2ec397ba9d768c8c2fc8)]
### [4.1.0](https://github.com/eea/volto-eea-map/compare/4.0.0...4.1.0) - 7 June 2024

#### :hammer_and_wrench: Others
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pipeline {
environment {
GIT_NAME = "volto-eea-map"
NAMESPACE = "@eeacms"
SONARQUBE_TAGS = "volto.eea.europa.eu,forest.eea.europa.eu,climate-adapt.eea.europa.eu,biodiversity.europa.eu,demo-www.eea.europa.eu,www.eea.europa.eu-en,water.europa.eu-freshwater,water.europa.eu-marine"
SONARQUBE_TAGS = "volto.eea.europa.eu,forest.eea.europa.eu,climate-adapt.eea.europa.eu,biodiversity.europa.eu,demo-www.eea.europa.eu,www.eea.europa.eu-en,water.europa.eu-freshwater,water.europa.eu-marine,insitu.copernicus.eu"
DEPENDENCIES = "@eeacms/volto-embed"
BACKEND_PROFILES = "eea.kitkat:testing"
BACKEND_ADDONS = ""
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-eea-map",
"version": "4.1.0",
"version": "5.0.0",
"description": "@eeacms/volto-eea-map: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand All @@ -21,16 +21,19 @@
"@eeacms/volto-object-widget"
],
"dependencies": {
"@arcgis/core": "4.29.10",
"@eeacms/volto-embed": "*",
"@eeacms/volto-object-widget": "*",
"@plone/scripts": "*",
"esri-loader": "3.6.0",
"jsoneditor": "10.1.0",
"lodash": "4.17.21",
"razzle-plugin-scss": "4.2.18",
"react-color": "~2.19.3",
"react-querybuilder": "4.2.3"
"react-querybuilder": "6.5.5"
},
"devDependencies": {
"@babel/preset-env": "7.24.6",
"@cypress/code-coverage": "^3.10.0",
"@plone/scripts": "*",
"babel-plugin-transform-class-properties": "^6.24.1",
Expand Down
130 changes: 130 additions & 0 deletions src/Arcgis/Editor/Editor.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import { memo, useRef, useState, useMemo } from 'react';
import { isNil } from 'lodash';

import SidebarGroup from './SidebarGroup';

import _MapBuilder from '../Map/MapBuilder';

import {
StructureBaseLayerPanel,
StructureLayersPanel,
StructureWidgetsPanel,
SettingsGeneralPanel,
SettingsLayersPanel,
} from './Panels';

import EditorContext from './EditorContext';

import 'react-querybuilder/dist/query-builder.css';
import 'jsoneditor/dist/jsoneditor.min.css';

const MapBuilder = memo(_MapBuilder);

const panels = {
structure: [
{
title: 'Base layer',
Panel: StructureBaseLayerPanel,
},
{
title: 'Layers',
Panel: StructureLayersPanel,
},
{
title: 'Widgets',
Panel: StructureWidgetsPanel,
},
],
settings: [
{ title: 'General', Panel: SettingsGeneralPanel },
{ title: 'Layers', Panel: SettingsLayersPanel },
],
};

function useApi() {
const [data, setData] = useState({});
const [loading, setLoading] = useState({});
const [loaded, setLoaded] = useState({});
const [error, setError] = useState({});

const load = async (url, opts) => {
if (data[url]) return data[url];
let response, result;
setLoading((prev) => ({ ...prev, [url]: true }));
try {
response = await fetch(`${url}?f=json`, opts);
} catch {
response = { ok: false, statusText: 'Unexpected error' };
}
try {
result = await response.json();
} catch {
result = response.ok
? {
code: 500,
message: 'Unexpected error',
}
: {
code: response.status,
message: response.statusText,
};
}

if (!response.ok || (!isNil(result.code) && result.code !== 200)) {
setData((prev) => ({ ...prev, [url]: null }));
setError((prev) => ({ ...prev, [url]: result }));
setLoading((prev) => ({ ...prev, [url]: false }));
setLoaded((prev) => ({ ...prev, [url]: false }));
return;
}
setData((prev) => ({ ...prev, [url]: result }));
setError((prev) => ({ ...prev, [url]: null }));
setLoading((prev) => ({ ...prev, [url]: false }));
setLoaded((prev) => ({ ...prev, [url]: true }));
};

return { data, loading, loaded, error, load };
}

export default function Editor({ value, properties, onChangeValue }) {
const $map = useRef(null);
const [active, setActive] = useState({
sidebar: 'structure',
panel: panels.structure[0],
});
const servicesApi = useApi();
const layersApi = useApi();

const Panel = useMemo(() => active.panel.Panel, [active]);

return (
<EditorContext.Provider value={{ servicesApi, layersApi }}>
<div className="arcgis-map__editor">
<div className="arcgis-map__controls">
<div className="arcgis-map__sidebar">
{Object.keys(panels).map((panel) => (
<SidebarGroup
key={panel}
title={panel}
items={panels[panel]}
active={active}
setActive={setActive}
/>
))}
</div>
<div className="arcgis-map__panel">
<Panel
$map={$map}
value={value}
properties={properties}
onChangeValue={onChangeValue}
/>
</div>
</div>
<div className="arcgis-map__view">
<MapBuilder data={value} ref={$map} />
</div>
</div>
</EditorContext.Provider>
);
}
2 changes: 2 additions & 0 deletions src/Arcgis/Editor/EditorContext.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { createContext } from 'react';
export default createContext(null);
56 changes: 56 additions & 0 deletions src/Arcgis/Editor/Fold/Fold.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { useState } from 'react';
import cx from 'classnames';

import { Icon } from '@plone/volto/components';

import clearSVG from '@plone/volto/icons/clear.svg';
import upKeySVG from '@plone/volto/icons/up-key.svg';

export default function Fold({
children,
title,
icon,
foldable,
deletable,
onDelete,
}) {
const [fold, setFold] = useState(false);

const isfolded = foldable && fold;

return (
<div className={cx('fold', { fold__open: !isfolded, foldable })}>
<div
className="fold--top"
{...(foldable
? {
role: 'button',
tabIndex: 0,
onClick: () => setFold(!fold),
onKeyDown: () => {},
}
: {})}
>
<div className="fold--top__content">
{foldable && (
<Icon name={upKeySVG} className="fold--top__fold" size="16px" />
)}
{!!icon && <Icon name={icon} size="16px" />}
{!!title && <div className="fold--top__title">{title}</div>}
</div>
{deletable && (
<Icon
name={clearSVG}
className="fold--top__delete"
size="16px"
onClick={(e) => {
onDelete(e);
e.stopPropagation();
}}
/>
)}
</div>
{!isfolded && <div className="fold--content">{children}</div>}
</div>
);
}
8 changes: 8 additions & 0 deletions src/Arcgis/Editor/Panels/Panel.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function Panel({ header, content }) {
return (
<div className="panel">
{!!header && <div className="panel--header">{header}</div>}
{!!content && <div className="panel--content">{content}</div>}
</div>
);
}
Loading

0 comments on commit c42f5b8

Please sign in to comment.