Skip to content

Deprecated framework react-scripts #132

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

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all 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: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
REACT_APP_NEOFS=""
VITE_NEOFS=""
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ $(SITE_DIR):
docker run \
-v $$(pwd)/src:/usr/src/app/src \
-v $$(pwd)/public:/usr/src/app/public \
-v $$(pwd)/index.html:/usr/src/app/index.html \
-v $$(pwd)/vite.config.mjs:/usr/src/app/vite.config.mjs \
-v $$(pwd)/package.json:/usr/src/app/package.json \
-v $$(pwd)/.env:/usr/src/app/.env \
-v $$(pwd)/$(SITE_DIR):/usr/src/app/$(SITE_DIR) \
-e CURRENT_UID=$(CURRENT_UID) \
-w /usr/src/app node:14-alpine \
sh -c 'npm install && REACT_APP_VERSION=$(VERSION) npm run build && chown -R $$CURRENT_UID: $(SITE_DIR)'
-w /usr/src/app node:18-alpine \
sh -c 'npm install && VITE_VERSION=$(VERSION) npm run build && chown -R $$CURRENT_UID: $(SITE_DIR)'

start:
docker run \
-p $(PORT):3000 \
-v `pwd`:/usr/src/app \
-w /usr/src/app node:14-alpine \
-w /usr/src/app node:18-alpine \
sh -c 'npm install --silent && npm run build && npm install -g serve && serve -s $(SITE_DIR) -p 3000'

release: $(SITE_DIR)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Send.NeoFS is a simple example of integration with NeoFS network via HTTP protoc

- docker
- make
- node (`14+`)
- node (`18+`)

# Make instructions

Expand All @@ -29,14 +29,14 @@ Send.NeoFS is a simple example of integration with NeoFS network via HTTP protoc
* Get release directory with tar.gz using `make release`

Set variables in the `.env` file before executing the commands:
- `REACT_APP_NEOFS` - Path to SendFS
- `VITE_NEOFS` - Path to SendFS

# Send.NeoFS local up

- Start [neofs-dev-env](https://github.com/nspcc-dev/neofs-dev-env)
- Update `.env`
- Execute `npm install`
- Run local `npm start`
- Run local `npm run build`

# Deployment to production

Expand Down
26 changes: 26 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!doctype html>
<html lang="en">
<head>
<title>Send.NeoFS</title>
<meta charset='utf-8'>
<link rel="icon" href="/img/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="title" content="Send.NeoFS">
<meta name="description" content="HTTP-gate demo for distributed object storage">
<meta property="og:url" content="https://send.fs.neo.org">
<meta property="og:title" content="Send.NeoFS">
<meta property="og:description" content="HTTP-gate demo for distributed object storage">
<meta property="og:type" content="website">
<meta property="og:image" content="/img/cover.png">
<meta name="theme-color" content="#29363b" />
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self'; connect-src 'self' https://send.fs.neo.org; style-src 'unsafe-inline' 'self' https://fonts.googleapis.com; font-src https://fonts.gstatic.com; img-src 'self'; form-action 'self'; base-uri 'self';">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;800&display=swap" rel="stylesheet">
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
38 changes: 16 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,34 @@
"version": "0.6.4",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.4.0",
"@fortawesome/free-brands-svg-icons": "^6.4.0",
"@fortawesome/free-regular-svg-icons": "^6.4.0",
"@fortawesome/free-solid-svg-icons": "^6.4.0",
"@fortawesome/fontawesome-svg-core": "^6.7.2",
"@fortawesome/free-brands-svg-icons": "^6.7.2",
"@fortawesome/free-regular-svg-icons": "^6.7.2",
"@fortawesome/free-solid-svg-icons": "^6.7.2",
"@fortawesome/react-fontawesome": "^0.2.0",
"@types/react": "^18.2.41",
"@types/react-dom": "^18.2.17",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"bulma": "^0.9.4",
"react": "^17.0.2",
"copy-to-clipboard": "^3.3.3",
"react": "^19.0.0",
"react-bulma-components": "^4.1.0",
"react-copy-to-clipboard": "^5.1.0",
"react-dom": "^17.0.2",
"react-dom": "^19.0.0",
"react-router-dom": "^6.10.0"
},
"scripts": {
"start": "REACT_APP_VERSION=$(make version) GENERATE_SOURCEMAP=false react-scripts start",
"build": "GENERATE_SOURCEMAP=false BUILD_PATH='./send.fs.neo.org' react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
"dev": "VITE_VERSION=$(make version) vite",
"build": "vite build",
"preview": "vite preview"
},
"browserslist": [
">0.2%",
"not dead",
"not op_mini all"
],
"devDependencies": {
"dotenv": "^16.0.3",
"react-scripts": "^5.0.1",
"typescript": "^4.9.5"
"@vitejs/plugin-react": "^4.3.4",
"dotenv": "^16.4.7",
"typescript": "^5.7.3",
"vite": "^6.1.0"
}
}
28 changes: 0 additions & 28 deletions public/index.html

This file was deleted.

6 changes: 3 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ function getCookie(name: string) {
export const App = () => {
const location: any = useLocation();
const [environment] = useState<Environment>({
version: process.env.REACT_APP_VERSION,
server: process.env.REACT_APP_NEOFS,
version: import.meta.env.VITE_VERSION,
server: import.meta.env.VITE_NEOFS,
});
const [user] = useState<User | null>(getCookie('X-Bearer') && getCookie('X-Attribute-Email') ? {
XBearer: getCookie('X-Bearer'),
Expand Down Expand Up @@ -166,7 +166,7 @@ export const App = () => {
<Navbar.Menu
className={menuActive ? 'is-active' : ''}
>
<Navbar.Container>
<Navbar.Container className="navbar-start">
<Link
to="/"
className="navbar-item"
Expand Down
74 changes: 33 additions & 41 deletions src/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import { Link } from "react-router-dom";
import { CopyToClipboard } from 'react-copy-to-clipboard';
import copy from 'copy-to-clipboard';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { UploadedObject } from './App.tsx';
import api from './api.ts';
Expand Down Expand Up @@ -238,22 +238,20 @@ const Home = ({
>
{uploadedObject.filename}
</a>
<CopyToClipboard
text={`${environment.server ? environment.server : document.location.origin}/gate/get/${uploadedObject.object_id}`}
onCopy={() => {
<div
onClick={() => {
copy(`${environment.server ? environment.server : document.location.origin}/gate/get/${uploadedObject.object_id}`);
setCopy(`name${index}`);
setTimeout(() => {
setCopy(false);
}, 700);
}}
>
<div>
<FontAwesomeIcon icon={['fas', 'copy']} />
{isCopied === `name${index}` && (
<div className="tooltip" style={{ top: '-125%', left: '-165%' }}>Copied!</div>
)}
</div>
</CopyToClipboard>
<FontAwesomeIcon icon={['fas', 'copy']} />
{isCopied === `name${index}` && (
<div className="tooltip" style={{ top: '-125%', left: '-165%' }}>Copied!</div>
)}
</div>
<div
onClick={() => onDownload(uploadedObject.object_id, uploadedObject.filename)}
style={{ lineHeight: 0 }}
Expand All @@ -270,61 +268,55 @@ const Home = ({
>
Metadata
</Link>
<CopyToClipboard
text={`${document.location.origin}/load/${uploadedObject.object_id}`}
onCopy={() => {
<div
onClick={() => {
copy(`${document.location.origin}/load/${uploadedObject.object_id}`);
setCopy(`link${index}`);
setTimeout(() => {
setCopy(false);
}, 700);
}}
>
<div>
<FontAwesomeIcon icon={['fas', 'copy']} />
{isCopied === `link${index}` && (
<div className="tooltip" style={{ top: '-125%', left: '-165%' }}>Copied!</div>
)}
</div>
</CopyToClipboard>
<FontAwesomeIcon icon={['fas', 'copy']} />
{isCopied === `link${index}` && (
<div className="tooltip" style={{ top: '-125%', left: '-165%' }}>Copied!</div>
)}
</div>
</Heading>
</div>
<Heading size={6} subtitle>
{`Container ID: ${uploadedObject.container_id}`}
<CopyToClipboard
text={uploadedObject.container_id}
onCopy={() => {
<div
onClick={() => {
copy(uploadedObject.container_id);
setCopy(`container_id${index}`);
setTimeout(() => {
setCopy(false);
}, 700);
}}
>
<div>
<FontAwesomeIcon icon={['fas', 'copy']} />
{isCopied === `container_id${index}` && (
<div className="tooltip" style={{ top: '-125%', left: '-165%' }}>Copied!</div>
)}
</div>
</CopyToClipboard>
<FontAwesomeIcon icon={['fas', 'copy']} />
{isCopied === `container_id${index}` && (
<div className="tooltip" style={{ top: '-125%', left: '-165%' }}>Copied!</div>
)}
</div>
</Heading>
<Heading size={6} subtitle>
{`Object ID: ${uploadedObject.object_id}`}
<CopyToClipboard
text={uploadedObject.object_id}
onCopy={() => {
<div
onClick={() => {
copy(uploadedObject.object_id);
setCopy(`object_id${index}`);
setTimeout(() => {
setCopy(false);
}, 700);
}}
>
<div>
<FontAwesomeIcon icon={['fas', 'copy']} />
{isCopied === `object_id${index}` && (
<div className="tooltip" style={{ top: '-125%', left: '-165%' }}>Copied!</div>
)}
</div>
</CopyToClipboard>
<FontAwesomeIcon icon={['fas', 'copy']} />
{isCopied === `object_id${index}` && (
<div className="tooltip" style={{ top: '-125%', left: '-165%' }}>Copied!</div>
)}
</div>
</Heading>
</Notification>
))}
Expand Down
22 changes: 10 additions & 12 deletions src/Load.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { CopyToClipboard } from 'react-copy-to-clipboard';
import copy from 'copy-to-clipboard';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
Button,
Expand Down Expand Up @@ -59,23 +59,21 @@ const Load = ({
<span>Download</span>
<FontAwesomeIcon icon={['fas', 'download']} style={{ marginLeft: 5, fontSize: 14 }} />
</Button>
<CopyToClipboard
text={`${environment.server ? environment.server : document.location.origin}/gate/get/${objectData.objectId}`}
onCopy={() => {
<Button
onClick={() => {
copy(`${environment.server ? environment.server : document.location.origin}/gate/get/${objectData.objectId}`);
setCopied(true);
setTimeout(() => {
setCopied(false);
}, 700);
}}
>
<Button>
<span>Copy link</span>
<FontAwesomeIcon icon={['fas', 'copy']} style={{ marginLeft: 5, fontSize: 14 }} />
{isCopied && (
<div className='tooltip'>Copied!</div>
)}
</Button>
</CopyToClipboard>
<span>Copy link</span>
<FontAwesomeIcon icon={['fas', 'copy']} style={{ marginLeft: 5, fontSize: 14 }} />
{isCopied && (
<div className='tooltip'>Copied!</div>
)}
</Button>
</Button.Group>
<Button.Group style={{ justifyContent: 'center' }}>
<a
Expand Down
3 changes: 2 additions & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const server = process.env.REACT_APP_NEOFS;
/// <reference types="vite/client" />
const server = import.meta.env.VITE_NEOFS;

type Methods = "GET" | "POST" | "HEAD";

Expand Down
13 changes: 0 additions & 13 deletions src/index.tsx

This file was deleted.

12 changes: 12 additions & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React, { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { App } from './App.tsx';
import { BrowserRouter } from "react-router-dom";

createRoot(document.getElementById('root') as HTMLElement).render(
<StrictMode>
<BrowserRouter future={{ v7_startTransition: true, v7_relativeSplatPath: true }}>
<App />
</BrowserRouter>
</StrictMode>,
)
13 changes: 13 additions & 0 deletions vite.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
plugins: [react()],
server: {
port: 3000,
},
build: {
sourcemap: false,
outDir: 'send.fs.neo.org',
},
});