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

[Major] (v2.0.0) Change bundler to Vite #172

Merged
merged 4 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ lerna-debug.log
.DS_Store
/data
/.idea
.vscode
*.sparql
2 changes: 1 addition & 1 deletion deploy/frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ RUN yarn run build

EXPOSE 4000

CMD serve -s build -l 4000
CMD serve -s dist -l 4000
38 changes: 38 additions & 0 deletions frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {
root: true,
env: {
browser: true,
},
globals: {
process: true,
},
settings: {
react: {
version: 'detect',
},
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
},
plugins: ['react', '@typescript-eslint', 'jsx-a11y', 'react-hooks'],
rules: {
'react/prop-types': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
},
overrides: [
{
files: ['*.js', '*.jsx'],
extends: ['plugin:@typescript-eslint/disable-type-checked'],
},
],
};
1 change: 1 addition & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# production
/build
/dist

# misc
.DS_Store
Expand Down
22 changes: 14 additions & 8 deletions frontend/public/index.html → frontend/index.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

<title>Archipelago</title>

<meta name="theme-color" content="#000000" />
<meta
name="description"
content="SemApps admin interface"
content="Archipelago"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />

<link rel="apple-touch-icon" href="/logo192.png" />
<link rel="manifest" href="/manifest.json" />
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.8.0/dist/leaflet.css" crossorigin="" />
<link rel="stylesheet" href="https://unpkg.com/leaflet-defaulticon-compatibility@0.1.1/dist/leaflet-defaulticon-compatibility.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.5.3/dist/MarkerCluster.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.5.3/dist/MarkerCluster.Default.css" />
<link rel="stylesheet" href="https://unpkg.com/react-mde@11.5.0/lib/styles/css/react-mde-all.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/fullcalendar@5.7.2/main.min.css" />
<title>Archipelago</title>

<meta name="apple-mobile-web-app-title" content="Archipelago">
<meta name="application-name" content="Archipelago">
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
35 changes: 24 additions & 11 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "archipelago-frontend",
"version": "1.0.0",
"type": "module",
"dependencies": {
"@fullcalendar/core": "^5.7.2",
"@mui/material": "^5.15.11",
"@mui/styles": "^5.15.11",
"@mui/material": "^5.15.14",
"@mui/styles": "^5.15.14",
"@mui/x-tree-view": "6.0.0-beta.0",
"@semapps/auth-provider": "0.6.0",
"@semapps/date-components": "0.6.0",
Expand All @@ -15,16 +16,26 @@
"@semapps/list-components": "0.6.0",
"@semapps/markdown-components": "0.6.0",
"@semapps/semantic-data-provider": "0.6.0",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"@vitejs/plugin-react": "^4.2.1",
"date-fns": "~2.8.1",
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"leaflet": "^1.9.4",
"leaflet-defaulticon-compatibility": "^0.1.2",
"leaflet.markercluster": "^1.5.3",
"mui-tree-select": "^1.0.0-beta.11",
"ra-language-french": "^4.16.12",
"react": "^18.1.0",
"react-admin": "^4.16.12",
"react-admin": "^4.16.14",
"react-dom": "^18.1.0",
"react-scripts": "5.0.1"
"typescript": "^5.4.3",
"vite": "^5.2.7",
"vite-plugin-checker": "^0.6.4"
},
"devDependencies": {
"@testing-library/jest-dom": "^4.2.4",
Expand All @@ -34,23 +45,25 @@
"yalc": "1.0.0-pre.53"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"lint": "eslint './src/**/*.{js,jsx,ts,tsx}'",
"analyze": "source-map-explorer 'build/static/js/*.js'",
"link-semapps-packages": "yalc link @semapps/activitypub-components @semapps/auth-provider @semapps/date-components @semapps/field-components @semapps/geo-components @semapps/input-components @semapps/list-components @semapps/markdown-components @semapps/semantic-data-provider",
"unlink-semapps-packages": "yalc remove --all && rm -rf node_modules/@semapps && yarn install --force"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not op_mini all"
],
"engines": {
"node": ">=18"
},
"prettier": {
"singleQuote": true,
"trailingComma": "all",
"printWidth": 120
}
}
File renamed without changes.
9 changes: 5 additions & 4 deletions frontend/src/HomePage.js → frontend/src/HomePage.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import React from 'react';
import { useShowController, ShowContextProvider } from 'react-admin';
import PageShow from './resources/Page/PageShow';
import config from './config/config';

const HomePage = () => {
const config = {
id: process.env.REACT_APP_MIDDLEWARE_URL + 'pages/accueil',
const showConfig = {
id: config.middlewareUrl + 'pages/accueil',
resource: 'Page'
};

return (
<ShowContextProvider value={useShowController(config)}>
<PageShow {...config} />
<ShowContextProvider value={useShowController(showConfig)}>
<PageShow {...showConfig} />
</ShowContextProvider>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ function generateFilterTree(broader, label, allItems, routeTree, parentId) {
maxWidth: "140px"
}}>{route["pair:label"]}
</div>}
nodeId={route["id"]}
key={route["id"]}
nodeId={route["id"]}
key={route["id"]}
selected={true} >
{generateFilterTree(broader, label, allItems, [], route["id"])}
</CustomTreeItem>
Expand All @@ -58,7 +58,7 @@ function generateFilterTree(broader, label, allItems, routeTree, parentId) {

const CustomContent = React.forwardRef(function CustomContent(props, ref) {
const { filterValues } = useListFilterContext();

const {
classes,
className,
Expand Down Expand Up @@ -89,7 +89,7 @@ const CustomContent = React.forwardRef(function CustomContent(props, ref) {
handleExpansion(event);
};

const handleSelectionClick = (event, b) => {
const handleSelectionClick = (event) => {
handleSelection(event);
};

Expand Down Expand Up @@ -143,7 +143,7 @@ function CustomTreeItem(props) {
return <TreeItem ContentComponent={CustomContent} {...props} />;
}

const ReferenceFilterTree = ({ reference, source, broader, label, limit, sort, filter, icon, predicate, title }) => {
const ReferenceFilterTree = ({ reference, source, broader, label, sort, filter, title }) => {
const { data } = useGetList(reference, { pagination:{page: 1, perPage: Infinity} , sort, filter});
const { filterValues, setFilters } = useListFilterContext();
const [ selected, setSelected ] = useState();
Expand Down Expand Up @@ -205,4 +205,4 @@ const ReferenceFilterTree = ({ reference, source, broader, label, limit, sort, f
)
};

export default ReferenceFilterTree;
export default ReferenceFilterTree;
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react';
import { extractContext, LocationInput as SemAppsLocationInput } from '@semapps/geo-components';
import config from '../../config/config';

const LocationInput = props => (
<SemAppsLocationInput
mapboxConfig={{
access_token: process.env.REACT_APP_MAPBOX_ACCESS_TOKEN,
access_token: config.mapboxAccessToken,
types: ['place', 'address'],
country: ['fr', 'be', 'ch']
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ const useHideInputStyles = makeStyles({
display: 'none'
}
});

const ReificationArrayInput = props => {
const { reificationClass, children, ...otherProps } = props;
const hideInputStyles = useHideInputStyles();

return (
<ArrayInput {...otherProps}>
<SimpleFormIterator inline>
{props.children}
{children}
<TextInput className={hideInputStyles.root} source="type" defaultValue={reificationClass} />
</SimpleFormIterator>
</ArrayInput>
);
};
export default ReificationArrayInput;

export default ReificationArrayInput;
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable jsx-a11y/no-static-element-interactions */
/* eslint-disable jsx-a11y/click-events-have-key-events */
/* eslint-disable no-redeclare */
import React, { useEffect, useState } from "react";
import TreeSelect, { DefaultOption, getDefaultOptionProps } from "mui-tree-select";
import { getTreeData,Node } from "./TreeItemUtils";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable jsx-a11y/no-static-element-interactions */
/* eslint-disable jsx-a11y/click-events-have-key-events */
/* eslint-disable no-redeclare */
import React, { useEffect, useState } from "react";
import TreeSelect, { DefaultOption, getDefaultOptionProps } from "mui-tree-select";
import { getTreeData, Node } from "./TreeItemUtils";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable jsx-a11y/no-static-element-interactions */
/* eslint-disable jsx-a11y/click-events-have-key-events */
/* eslint-disable no-redeclare */
import React from "react";
import { TreeItem } from '@mui/x-tree-view';

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const Hero = ({ children, image, defaultImage }) => {
};

Hero.defaultProps = {
defaultImage: process.env.PUBLIC_URL + '/logo512.png'
defaultImage: '/logo512.png'
};

export default Hero;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Box } from '@mui/material';
import makeStyles from '@mui/styles/makeStyles';
import LargeLabel from './LargeLabel';

const useStyles = makeStyles(theme => ({
const useStyles = makeStyles(() => ({
divider: {
paddingTop: 5,
paddingBottom: 20,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import SubdirectoryArrowRightIcon from '@mui/icons-material/SubdirectoryArrowRig
import { buildTreeData, generateTreeItem } from '../input/TreeComponent/TreeItemUtils';


const TreeList =({source, label, reference , defaultExpanded = true}) => {
const TreeList =({source, label, defaultExpanded = true}) => {
const redirect = useRedirect()
const createPath = useCreatePath();
const { data, isLoading } = useListContext();
Expand All @@ -28,4 +28,4 @@ const TreeList =({source, label, reference , defaultExpanded = true}) => {
)
}

export default TreeList;
export default TreeList;
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
const config = {
// Middleware API url (ex: https://<host>:<port>/). Should contain a trailing slash.
middlewareUrl: process.env.MIDDLEWARE_URL,

// Mapbox Access Token used for addresses completion
mapboxAccessToken: process.env.MAPBOX_ACCESS_TOKEN,

// Displays import tab when creating resource if it is listed here
importableResources: [
"Event",
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/config/dataProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import ontologies from './ontologies.json';
import dataServers from './dataServers';
import resources from '../resources';
import { withLifecycleCallbacks } from 'react-admin';
import config from './config';

const baseDataProvider = semanticDataProvider({
dataServers,
resources: Object.fromEntries(Object.entries(resources).map(([k, v]) => [k, v.dataModel])),
ontologies,
jsonContext: [
'https://www.w3.org/ns/activitystreams',
process.env.REACT_APP_MIDDLEWARE_URL + '.well-known/context.jsonld'
config.middlewareUrl + '.well-known/context.jsonld'
]
});

Expand Down
6 changes: 4 additions & 2 deletions frontend/src/config/dataServers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import config from "./config";

const dataServers = {
default: {
baseUrl: process.env.REACT_APP_MIDDLEWARE_URL,
baseUrl: config.middlewareUrl,
authServer: true,
default: true,
uploadsContainer: '/files'
Expand Down Expand Up @@ -30,4 +32,4 @@ const dataServers = {
// }
};

export default dataServers;
export default dataServers;
4 changes: 3 additions & 1 deletion frontend/src/index.js → frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ import { createRoot } from 'react-dom/client';
import './index.css';
import App from './App';

const root = createRoot(document.getElementById('root'));
const root = createRoot(
document.getElementById('root') as HTMLElement
);
root.render(<App />);
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const AppBar = props => {
<div className={classes.presContainer}>
<div className={classes.logoContainer}>
<Zoom in={true} timeout={2000}>
<img className={classes.logo} src={process.env.PUBLIC_URL + '/logo192.png'} alt="logo" />
<img className={classes.logo} src={'/logo192.png'} alt="logo" />
</Zoom>
</div>
<Typography className={classes.title} variant="h6" noWrap>
Expand Down
File renamed without changes.
Loading